e.g.: to print a list of lines beginning with 'my' from a directory of perl scripts:
while (<*>){
open IN, "$_";
@matches = grep {/^my/} <IN>;
close IN;
}
print @matches
HTH
From: "Hawley, Eric" <[EMAIL PROTECTED]>
To: "'Peter Guzis'" <[EMAIL PROTECTED]>, "Perl-Win32 \(E-mail\)" <[EMAIL PROTECTED]>
Subject: RE: question about grep
Date: Thu, 13 Feb 2003 13:49:20 -0500
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
_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs