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

Re: Removing leading whitespace from a file?

by Juerd (Abbot)
on Jul 09, 2002 at 05:44 UTC ( [id://180419]=note: print w/replies, xml ) Need Help??


in reply to Removing leading whitespace from a file?

An alternative:

use Tie::File; tie @file, 'Tie::File', 'test.txt'; s/^\s+// for @file;
Not the most efficient solution, but I'd prefer it to setting $^I, if it were in a larger program.

The easiest solution was already mentioned:

perl -i -pe's/^\s+//' test.txt

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2025-06-16 23:02 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.