Hi Dr. Ruud,
On Wed, 14 Nov 2012 10:33:28 +0100
"Dr.Ruud" <[email protected]> wrote:
> On 2012-11-13 13:12, Shlomi Fish wrote:
>
> > while (my $line = <>)
> > {
> > chomp($line);
> > if (my ($dev_num) = $line =~ /\AdisplayDevNum=(.*)\z/)
>
> In Perl5, '\z' is not needed here, because '.' matches non-newlines.
> (also the chomp is not needed here, looks like cargo cult to me)
>
You are right that the \z is not needed. It does not hurt though. However, if
you omit the chomp and include the \z, then the code will fail. I know what
chomp does, and it is a good idea to always include it, unless you are
interested in keeping the \n (cargo cult or not).
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
My Public Domain Photos - http://www.flickr.com/photos/shlomif/
Do one thing every day that scares you.
— Eleanor Roosevelt
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/