Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 scrutinizing the Monastery: (7)
As of 2015-07-04 11:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (59 votes), past polls