
davorg
Thaumaturge
/ Moderator
Sep 5, 2006, 7:55 AM
Post #3 of 4
(1509 views)
|
|
Re: [perl1006] $var .= $_; what it mean?
[In reply to]
|
Can't Post
|
|
KevinR has given you the literal translation of the code. But what he hasn't told you is the "real" meaning of that code - which is that the person who wrote it really didn't know what they were doing. What you're trying to do here is to read in the contents of a file into a scalar variable. The person who wrote this knows that the default behaviour of the file input operator is to return a single row when called in scalar context. But he didn't know how to get round that either by a) calling it in list context: Or by changing its default "line at a time" behaviour:
$var = do { local $/; <IN>; } I'd be very loathe to trust any Perl code written by the person who wrote that snippet. -- Dave Cross, Perl Hacker, Trainer and Writer http://www.dave.org.uk/ Get more help at Perl Monks
|