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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
?????

 



zoomer003
Novice

Jun 8, 2010, 1:30 PM

Post #1 of 5 (1177 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: $?";


FishMonger
Veteran / Moderator

Jun 8, 2010, 3:53 PM

Post #2 of 5 (1172 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.


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

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



zoomer003
Novice

Jun 9, 2010, 8:04 AM

Post #3 of 5 (1159 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)


zoomer003
Novice

Jun 9, 2010, 8:25 AM

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

Perfect. I got it Thanks alot!


FishMonger
Veteran / Moderator

Jun 9, 2010, 8:35 AM

Post #5 of 5 (1155 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.
http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.37/lib/Spreadsheet/WriteExcel.pm

 
 


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

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