Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: using sed buffers

by ww (Archbishop)
on May 02, 2012 at 21:37 UTC ( [id://968553]=note: print w/replies, xml ) Need Help??


in reply to using sed buffers

Don't use sed; use a regex, re which, see perlrequick, perlretut and the regex section of our Tutorials.

Also, please use code tags (<c>...</c) around code, as directed around the text-entry box you used.

Update: Reading Markup in the Monastery will also help resolve your display issues.

However, a hint: perl regexen use $1, $2, etc for the buffers you seem to be seeking.

Replies are listed 'Best First'.
Re^2: using sed buffers
by JavaFan (Canon) on May 02, 2012 at 22:39 UTC
    I think his intention is to write it in Perl. After all, he's asking "this is what I do in sed, how do I translate it to perl".
Re^2: using sed buffers
by floobit (Initiate) on May 02, 2012 at 21:41 UTC
    Thanks, I'll look those up. Is sed generally discouraged in perl?

      Actually, the point is that sed isn't a Perl function.

      What's discouraged (much of the time) is shelling out to a (legacy) OS-function because doing so is often more costly than using the Perl equivalent/variant.
        What's discouraged (much of the time)
        Only by some people
        is often more costly than using the Perl equivalent/variant.
        So what? In many cases, it doesn't matter.

        Note also he's using sed to strip off some of the output of ps. I'm sure someone made a module somewhere that mimics all the flavours of ps, but I rather spend a few microseconds forking and execing a 'ps', then I go hunting down said module, download and install it, and learn how it works.

        There can be all kinds of reasons one does something in Perl instead of shelling out. But being considered "discouraged" by some doesn't strike me as an important reason.

        But that may be just me.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2025-07-18 07:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.