From: Mike S. <m...@pe...> - 2004-05-13 17:08:51
|
Dennis Gregorovic wrote on 5/13/2004, 7:41 AM: > In this line: > > @text = <TEXT>; > > it is assuming that $/ is set to "\n", which would result in @text > containing an entry for each line in the config file. Ah, ok, now I understand. However, tinkering with $/ without limiting its scope is considered bad style. "perldoc perlvar" shows: But the following code is quite bad: open my $fh, "foo" or die $!; undef $/; # enable slurp mode my $content = <$fh>; close $fh; since some other module, may want to read data from some file in the default "line mode", so if the code we have just presented has been executed, the global value of $/ is now changed for any other code running inside the same Perl interpreter. Usually when a variable is localized you want to make sure that this change affects the shortest scope possible. So unless you are already inside some short "{}" block, you should create one yourself. For example: my $content = ''; open my $fh, "foo" or die $!; { local $/; $content = <$fh>; } close $fh; So, regarding Log4perl: unless anyone has any strong opinion about this, I'd rather leave it as it is for now. -- -- Mike Mike Schilli m...@pe... |