in reply to Monks to the rescue
As for your question 3, I'm not quite sure about your intention, but I think the best way to start is by using a regex match and capture:my $date =`/bin/date +'%m%d%y'`; chomp $date; my $LOG = "log.$date"; # another way to do that is to use perl internals instead of a sub-she +ll: { my ($d,$m,$y)=(localtime)[3..5]; my $perldate = sprintf "%02d%02d%02d", $m+1, $d, $y-100; die "This should never happen: $perldate != $date" if $perldate ne $date; }
(BTW, when using date strings in file names, I like to arrange them as "%y%m%d", so they sort nicely.)while (<HANDLE>) { next unless ( /FREEZING media id (.*)/ ); print "I am FREEZING $1\n"; }
update: Forgot to mention: when using a regex match in the while loop as shown above, you don't need to open a pipeline that runs the data through a separate "grep" process -- perl does the grep for you, by ignoring the lines that don't match the regex.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Monks to the rescue
by mrbbq (Sexton) on Jan 28, 2005 at 18:19 UTC |