Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Matching for the second,fourth, and fifth word in a text

by dingus (Friar)
on Dec 10, 2002 at 20:17 UTC ( [id://218891]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://218891]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-25 05:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found