in reply to How do I remove newline character from a number got from unix command
Don't have a Linux system up but presume chomp would do it:
$year=`date +%Y`; chomp $year; printf "$year";
I see choroba was faster on the post than I was, and also gave a more complete answer.
Okay, fine, I'll give in. Everyone is mentioning localtime, but my old eyes don't see the commensurate adjustment warning:
# Humanize the time my $nowsse = time; my ($nowsec,$nowmin,$nowhou,$nowdom,$nowmon,$nowyea,$nowdow,$nowdo +y,$nowdst) = localtime($nowsse); $nowyea += 1900; $nowmon++;
With some further explanations of my TLAs:
Some additional thoughts:
The original question was specifically about the newline on the OS response, so that's what my post covered. It was irresponsible of me to not mention, as so many other Monks have, the particular function you appeared to be attempting to perform was available via both native and module functionality.
But the other Monks did cover that, rather thoroughly. I love Perlmonks. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I remove newline character from a number got from unix command
by tousifp (Novice) on Sep 04, 2013 at 12:20 UTC | |
by Happy-the-monk (Canon) on Sep 04, 2013 at 13:05 UTC | |
by tousifp (Novice) on Sep 04, 2013 at 15:51 UTC |