I'm gonna de-lurk for this one.
If you look at Peter's example, you will note that grep applies a block-or-something 
to a list and returns a list.
You are applying it to the file name, not the contents.  Perl grep doesn't read files.
If this wasn't the win32 perl list, I would just advise that you really want the 
shell's grep 
[ like $lines = `grep "^Status" $project_file` to get the Status line(s) from one file 
]

Strictly within perl, you would need to open the file and snarf in its contents  to 
grep.
Maybe it would look like this (off the cuff, if errors, please point them out, to add 
value for readers):

 open (IFILE, "<$project_file" ) or die "useful message here:$!";
 @lines = grep /^Status/, <IFILE>;
 close (IFILE);
 #  At this point, @lines has all the lines from $project_file that start with Status.
 #  If these files are HUGE, it might be better to roll your own match loop with while 
(<IFILE>) {...}

HTH,
Joe Dial


-----Original Message-----
From: Hawley, Eric [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, February 13, 2003 1:49 PM
To: 'Peter Guzis'; Perl-Win32 (E-mail)
Subject: RE: question about grep


I tried what you did suggested and it only pulled out the word Status, here
is the code below;

#location contains the path for the report to be stored
$report_location = $location;
$report_location =~ s/\//\\/;
$report_location = "$report_location" . "\\Reports";
unless( -e $report_location) ){
  mkdir( $report_location ) or die "died creating Report Directory";
}
  
#open Report HTML file
open( FILE, "> $report_location\\$year_$month_$date_Report.htm" ) or die
"Dead creating Report";
#print intial html to report file
print FILE
"<html>\n<head>\n<title>$year_$month_$date_report</title>\n</head>\n<body>\n
";
  
#file paths include paths to the files, that Status should be greped from
#ex) C:\\Test.htm
foreach $project_file ( @file_paths ){
  #grep Status line from $project_file 
  @status_line = grep /^Status/, $project_file;
}
print FILE "</body>\n</html>\n";
close(FILE);


Hope this can point to any failures.

Thanks
Eric
----------------------------------------------------------------------------
----------------------------------------------

-----Original Message-----
From: Peter Guzis [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 1:33 PM
To: Perl-Win32 (E-mail)
Subject: RE: question about grep


@matches = grep /^Status/, @data;

If this doesn't do it you might consider posting some sample data.

Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: [EMAIL PROTECTED]
www.encad.com 

-----Original Message-----
From: Hawley, Eric [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 10:23 AM
To: Perl-Win32 (E-mail)
Subject: question about grep


I got a question concerning grep.  I would like to use it to pull out all
full lines of text, that starts with the word "Status", from a list of
files.  I am not really too experienced with using Metacharacters and
Metasymbols and do not know how to go about doing this with grep.  Can
someone help me out with this?

Thanks in advanced
Eric
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to