in reply to Matching for the second,fourth, and fifth word in a text

Assuming your printer records contain a blank line and you can read the whole file in at once then you could loop aroung a //g; as in:
local undef $/; open(FILE,"<printfile"); my $_ = <FILE>; # slurp close (FILE); print "printer '$1' $2 - $3\n" while (/^printer\s+(\w+)\s+\w+\s+(\w+)\ +.\s+(\w+)/msg); __OUTPUT__ 'llp' idle - enabled 'ps' idle - enabled

Dingus


Enter any 47-digit prime number to continue.

Replies are listed 'Best First'.
Re^2: Matching for the second,fourth, and fifth word in a text
by Aristotle (Chancellor) on Dec 11, 2002 at 13:53 UTC
    local undef $/;
    Thatīll first clear $/, then localize it. Legal syntax, but not probably what you meant.
    $ perl -wle'$_ = "x"; { local undef $_ } print' Use of uninitialized value in print at -e line 1. $ perl -wle'$_ = "x"; { undef local $_ } print' x

    Makeshifts last the longest.