Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Faster replacement of sed commands..

by pvaldes (Chaplain)
on Aug 20, 2014 at 23:23 UTC ( #1098176=note: print w/replies, xml ) Need Help??


in reply to Faster replacement of sed commands..

unrelated with the topic, but perhaps useful to make your script a little faster:

you could want to put the whole "/data/admin/scsripts/SapcmedadpebM/xdecoder/decodedir" thing in a var. The purpose of this is to avoid typing mistakes and to write shorter sentences easier to debug. Something like: (untested).

my $path = "/very/long/path/here"; # or maybe: opendir(my $path, "/very/long/path/here"); move($abc1,"$path/compleat/"); foreach my $file (<$path/MHSAPC/*csv>){chomp; ... ## read also about +glob

You probably don't need to use the touch line here, just open the file. Open avoids you later the need for an one-liner inside a perl script, (bad style to me, you are opening two perl processes and the second is not necessary)

`perl -i -pe 's/[^[:ascii:]]//g; tr/\015//d' $abc1`; ## to avoid

avoid `find -mmin ...`, use stat instead:

$mmtime = (stat($file))[9]; if ($mmtime > 600){do something ....} ; ## note that these are seconds, 10 min = 600 sec
if ($abc1 eq "") { next; }

No need to spend four lines for this, probably:

next if ($abc1 eq "");

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2019-10-17 17:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?