Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How do I remove newline character from a number got from unix command

by space_monk (Chaplain)
on Sep 04, 2013 at 12:34 UTC ( #1052324=note: print w/ replies, xml ) Need Help??


in reply to How do I remove newline character from a number got from unix command

The newline is attached because you're executing an OS command to do the work. Try using something more operating system agnostic - e.g.

use POSIX qw(strftime); my $date = strftime "%Y", localtime; print $date;
or...
use DateTime qw(); DateTime->now->strftime('%Y');
If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)


Comment on Re: How do I remove newline character from a number got from unix command
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2014-12-29 00:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (183 votes), past polls