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

Re: Counting strings not counting correctly.

by johngg (Canon)
on May 11, 2017 at 10:09 UTC ( [id://1190051]=note: print w/replies, xml ) Need Help??


in reply to Counting strings not counting correctly.

my $emd = `date --date '-30 min' +'%H'`; chop ($emd); $emd = "/tmp/pathtomyfiles/$emd.txt";

Probably better to avoid shelling out to /bin/date and use the core POSIX::strftime instead. Also, chomp would be better than chop in your original code.

johngg@shiraz:~/perl/utils > perl -Mstrict -Mwarnings -MPOSIX=strftime + -E ' my $emd = strftime q{/tmp/pathtomyfiles/%H.txt}, localtime( time() - 1800 ); say $emd;' /tmp/pathtomyfiles/10.txt

I hope this is of interest.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-29 05:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found