in reply to Re: Sed to perl conversion-- flipping lines in a file
in thread Sed to perl conversion-- flipping lines in a file

kvale,
While this is a perfectly good solution, it may be an issue if the file in question is very large. In that case, instead of slurping the whole thing into memory it might be better to use a perl implementation of tac. If you need to manipulate the lines at all in addition to reversing them, you could always have a look at File::ReadBackwards

For any other conversions of sed, there is always the s2p utility that ships with the core.

Cheers - L~R

  • Comment on Re: Re: Sed to perl conversion-- flipping lines in a file

Replies are listed 'Best First'.
Re: Re: Re: Sed to perl conversion-- flipping lines in a file
by NovMonk (Chaplain) on Feb 18, 2004 at 17:50 UTC
    Actually, I need it to swap lines Only if it matches a given pattern, like the sed example. I have some other lines Around the ones in the example which need to stay where they are. Where can I read more about s2p? I'm using perl on a network where they Think they've gotten rid of it-- everything I've tried so far works and compiles (when I get all the bugs fixed in my code) but I might not have everything. Thanks
        Thanks.

        I read the online documentation. I'm wondering now if I even Have s2p on my network-- I get an error message when I try to run it on my little sed script. I can't download it myself (and remain employed, which is kind of the whole point...)

        Would I get flamed too badly if asked posted a request to convert a sed script of mine and post it where I can compare the two? I'm new here and don't want to tick any one off unecessarily. Or is there a site devoted to sed to perl issues? I didn't find anything useful on a google, but that may be a function of my own ignorance and not lack of resources.

        Thanks