Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: upto match please, my one-lina!!

by japhy (Canon)
on Jun 09, 2006 at 01:33 UTC ( [id://554403]=note: print w/replies, xml ) Need Help??


in reply to upto match please, my one-lina!!

perl -ne 'BEGIN { $pat = qr/.../; $size = (N-1) } @_ = ($_, @_[0 .. ($ +#_ > $size ? $size : $#_)]); print reverse @_ if /$pat/'

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: upto match please, my one-lina!!
by Firefly258 (Beadle) on Jun 09, 2006 at 02:01 UTC
    Jeff, Thanks for pointing $# out .. didnt realize that one. Errm, i dont see the point to the code .. seems like a long way around
    perl -ne 'print if /(?-xism:.{3})/'
      Huh? I presented code that prints N lines before a matching line.

      Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
      How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-26 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found