RE: Chomp method



-----Original Message-----
From: Randal L. Schwartz [mailto:merlyn@xxxxxxxxxxxxxx]

For example, almost no amount of experimentation will stumble across
how chomp actually removes $/, not just "\n".


But that's exactly why you need to try it and see. The more a document
spends on the arcane details of a function (which perldoc does), the more
likely a beginner would get lost in those details and find some other source
of reference.

Instead of the perldoc chomp example of:

while (<>) {
chomp; # avoid \n on last field
@array = split(/:/);
# ...
}

(I consider myself an intermediate Perl programmer, and the above is still a
useless example to me. It never really shows you what chomp does).

How about:

$ll = "A full line here.\n" ;
chomp ( $ll ) ;

# Now $ll = "A full line here." ;

Sure this doesn't cover everything but for a beginner it's an example you
can put your arms around.

-r

Russell J. Foster
R. J. Foster and Associates
rjf@xxxxxxxxxxxxxx



.



Relevant Pages