Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

perl.exe not functioning?

by fmogavero (Monk)
on Feb 20, 2003 at 14:05 UTC ( [id://237083]=perlquestion: print w/replies, xml ) Need Help??

fmogavero has asked for the wisdom of the Perl Monks concerning the following question:

I am trying perl -pi.bb -e 's/\n\n/\n/g' filname and this has worked before but it is not working now. I have tried many different varitations of the one-off as well. The only difference that I can see now is my workstation is Windows 2000 Professional. One other thing is that if I do not include a file extension for the -i switch, I get a message that says it cannot do an inline edit without a backup type specified. I have read all of the "Remove ^M from a document" nodes. Has anybody had similar problems like this? fmogavero

Replies are listed 'Best First'.
Re: perl.exe not functioning?
by xmath (Hermit) on Feb 20, 2003 at 14:22 UTC
    perl -p walks over each individual line of each input file, so the match /\n\n/ will obviously never be true (a single line can't contain two newlines)

    If the files are not too large, you can ofcourse slurp them entirely into memory and then do the substitution: perl -0777 -pi.bb -e 's/\n\n/\n/g' filename (that's a zero, not an o)

    otherwise you'll need a bit smarter script, like: perl -pi.bb -e '$p&&s/^\n//;$p=/^\n/'

    BTW, if you just want to filter out blank lines, you can do: perl -pi.bb -e 's/^\n//' (which is like doing perl -0777 -pi.bb -e 's/\n+/\n/g' except more efficient)

Re: perl.exe not functioning?
by PodMaster (Abbot) on Feb 21, 2003 at 01:15 UTC
    Try perl -e 'warn 1' and then see `perldoc perlrun'.

    update: if it wasn't obvious to anyone, the windows shells have different quoting rules. `perldoc perlrun' explains these.


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
    ** The Third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-16 20:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found