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.
or...use POSIX qw(strftime); my $date = strftime "%Y", localtime; print $date;
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! :-)
|
---|
In Section
Seekers of Perl Wisdom