nhainer (6) [Avatar] Offline
#1
In the middle of page 11, should the 'l' command line parameter be deleted from the following perl command:

Should:

perl -wl -e 'print 22/7;'

Be:

perl -w -e 'print 22/7;'
tmaher (37) [Avatar] Offline
#2
Re: Another Mistake On Page 11?
> In the middle of page 11, should the 'l' command line
> parameter be deleted from the following perl
> command:
>
> Should:
>
> perl -wl -e 'print 22/7;'
>
> Be:
>
> perl -w -e 'print 22/7;'

No, because that will prevent the carriage return (provided by the -l)
from appearing after the result of the division is printed.

-Tim
nhainer (6) [Avatar] Offline
#3
Re: Another Mistake On Page 11?
I see.

How about these two on page 13:

perl -w -e 'while (<>smilie { print; }' myfile and perl -wl -e 'while (<>smilie { print; }' myfile

behave differently as expected.

perl -wnl -e 'print;' myfile and perl -wn -e 'print;' myfile behave the same. Why doesn't the -l make a difference?
tmaher (37) [Avatar] Offline
#4
Re: Another Mistake On Page 11?
> I see.
>
> How about these two on page 13:
>
> perl -w -e 'while (<>smilie { print; }' myfile and perl
> -wl -e 'while (<>smilie { print; }' myfile
>
> behave differently as expected.

-l doesn't remove newlines from input read by <> (see footnote on p. 339), so when it adds an additional newliine to each line for
printing, double spacing is the result.

> perl -wnl -e 'print;' myfile and perl -wn -e 'print;'
> myfile behave the same. Why doesn't the -l make a
> difference?

-l automatically strips newlines from input read by the -n option, and later
replaces those newlines when the lines are printed. In this simple case,
that produces the same result as not stripping the newlines first, so they're
still there at printing time.

Please don't worry too much about what -l does. The Minimal Perl
approach is designed to insulate you from these concerns, by teaching you
techniques that automatically produce the correct results.

-Tim
nhainer (6) [Avatar] Offline
#5
Re: Another Mistake On Page 11?
OK I will leave "-l" alone. Though my questions have demonstrated to me that the breath and width of perl is large and also how the minimal perl applies.

Thanks for responding.