Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Inline change to the file passed by Glob

by poj (Abbot)
on Aug 23, 2017 at 06:52 UTC ( [id://1197852]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Inline change to the file passed by Glob
in thread Inline change to the file passed by Glob

#!/usr/bin/perl use strict; my $csv_add = 'add.csv'; my $csv_flex = 'flex.csv'; print " csv_add : $csv_add csv_flex : $csv_flex\n"; for my $filename ($csv_add,$csv_flex){ if (-e $filename){ rm_spaces($filename); } else { warn "$filename not found"; } } # remove spaces,tabs,newlines,formfeeds,cr # and /I/0 and /T/0 sub rm_spaces { my $filename = shift; my $bakfile = $filename.'.bak'; rename ($filename,$bakfile) or die "Could not rename $filename to $bakfile"; open my $fh_in, '<',$bakfile or die "Could not open $bakfile"; open my $fh_out,'>',$filename or die "Could not open $filename"; while (<$fh_in>) { s/\s+|\/[IT]\/0//g; print $fh_out "$_\n"; } close $fh_in; close $fh_out; unlink $bakfile; }
poj

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 21:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found