CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:



Jun 8, 2010, 1:30 PM

Post #1 of 5 (2947 views)
????? Can't Post

hey guys how would you write this command in perl script

C:\GPS\grep.exe FTS, EVKCONFIGFILE.txt -> GPRS.xls

little background, grep.exe is a program that searches EVKCONFIGFILE.txt for FTS, and paste everysingle line that has FTS, in GPRS.xls

i have tried this method

@grep = ('C:\GPS\grep.exe', 'FTS,', 'EVKCONFIGFILE.txt', '->', 'GPRS.xls');
system(@grep) == 0 or die "system @grepfailed: $?";

Veteran / Moderator

Jun 8, 2010, 3:53 PM

Post #2 of 5 (2942 views)
Re: [zoomer003] ????? [In reply to] Can't Post

There are several ways to accomplish this task. This is the most likely method I'd use, which doesn't rely on a system call.

open my $fh, '<', 'EVKCONFIGFILE.txt' 
or die "failed to open 'EVKCONFIGFILE.txt' $!";

my @fts = grep(/FTS/, <$fh>);
print @fts;


Jun 9, 2010, 8:04 AM

Post #3 of 5 (2929 views)
Re: [FishMonger] ????? [In reply to] Can't Post

hey thank you .. but just a little problem the method you gave me is printing the output on the cmd screen but i want it to print it in Excel worksheet .. how would i do that
Attachments: cmd screen.JPG (244 KB)


Jun 9, 2010, 8:25 AM

Post #4 of 5 (2927 views)
Re: [FishMonger] ????? [In reply to] Can't Post

Perfect. I got it Thanks alot!

Veteran / Moderator

Jun 9, 2010, 8:35 AM

Post #5 of 5 (2925 views)
Re: [zoomer003] ????? [In reply to] Can't Post

First, you should understand that you were not creating an Excel file. You were creating a plain text file which you happen to view in Excel.

If you want a plain text file then either use command line input/output redirection to send the output to a file or open another filehandle in the script and send the output to that filehandle instead of STDOUT.

If you want to create a true Excel binary file, then you need to use the Spreadsheet::WriteExcel module.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives