Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Removing white space from the file

by Monk::Thomas (Friar)
on Aug 12, 2015 at 07:59 UTC ( [id://1138281]=note: print w/replies, xml ) Need Help??


in reply to Removing white space from the file

$fh =~ s/\s//g;

You can not apply a substitution to a file handle. (Well you can, but it does not modify the actual file content.)

Another problem is:

open(my $fh, ">> uuu.txt")

...which would open the file for appending, but NOT for reading.

You did not specify whether you want an in-place edit of the file or whether you just want to convert the content for further processing. (For an in-place edit I would actually prefer to use something like 'sed -i~ s/[0-9 ]//g uuu.txt' instead of perl, because I get a backup copy of the original file for free.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found