in reply to Monks to the rescue

When you use a back-ticked command line to assign a string to a perl variable, the string includes the final line-feed character that was printed at the end by the shell command. So if you plan to use the string as a file name in an open statement, you need to "chomp" it:
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; }
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:
while (<HANDLE>) { next unless ( /FREEZING media id (.*)/ ); print "I am FREEZING $1\n"; }
(BTW, when using date strings in file names, I like to arrange them as "%y%m%d", so they sort nicely.)

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
    Thanks! That was a big help! I am doing the "your the man" dance around my cubicle as I type. Thanks again.