in reply to Re: Style Question: Throwaway Objects
in thread Style Question: Throwaway Objects
or, as I'd prefer,my $book; { my $parser = Spreadsheet::ParseExcel->new() $book = $parser->Parse($filename); }
logically followed bymy $book = do { my $parser = Spreadsheet::ParseExcel->new() $parser->Parse($filename); };
which is (and here's the important step) obviously equivalent to my $book = do { Spreadsheet::ParseExcel->new() }->Parse($filename); which is trivially equivalent to my $book = Spreadsheet::ParseExcel->new()->Parse($filename); Tightly scoping with a block instead is generally better practice. The garbage collector will clean up after you without any extra effort on your side anyway.my $book = do { my $parser = Spreadsheet::ParseExcel->new() $parser }->Parse($filename);
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Style Question: Throwaway Objects
by dws (Chancellor) on Dec 09, 2002 at 02:44 UTC | |
by Aristotle (Chancellor) on Dec 09, 2002 at 09:06 UTC |