RE: Chomp method
- From: rjf@xxxxxxxxxxxxxx (Russ Foster)
- Date: Thu, 27 Apr 2006 10:41:40 -0500
-----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
.
- References:
- Re: Chomp method
- From: Randal L. Schwartz
- Re: Chomp method
- Prev by Date: Re: problam in RE
- Next by Date: Re: Chomp method
- Previous by thread: RE: Chomp method
- Next by thread: Re: Chomp method
- Index(es):
Relevant Pages
|
|