Front page | perl.beginners |
Postings from July 2011
Re: s/// and \n question
Thread Previous
|
Thread Next
From:
JPH
Date:
July 22, 2011 11:41
Subject:
Re: s/// and \n question
Message ID:
20110722184057.30897.qmail@lists-nntp.develooper.com
Are you familiar with chomp( $str ) ? Often you will want to use chomp to get rid of trailing newlines on your input lines.
On 07/21/2011 11:11 PM, Mike McClain wrote:
> Given the following snippet of code could someone explain to me
> why the linefeed gets included in $num?
>
> mike@/deb40a:~/perl> perl -e'
> $str = "asdfggfh 987321qwertyyy\n";
> ($num = $str) =~ s/^.*?(\d+).*$/$1/;
> print $num;
> ' | hd
> 00000000 39 38 37 33 32 31 0a |987321.|
> 00000007
>
> Thanks,
> Mike
Thread Previous
|
Thread Next