rvosa has asked for the wisdom of the Perl Monks concerning the following question:
So, I have a hash %opts, that contains a file path under the -file key. I open the file, create a reference to the handle, assign that to $opts{-handle} and send the whole %opts hash to the $parser->from_handle method. Then, over in the from_handle method, the following happens:open(FH, $opts{-file}); $opts{-handle} = \*FH; $parser->from_handle(%opts);
Okay, so in the "while" loop I was hoping $_ would contain the contents of $opts{-file}, one line at a time. Instead, it contains "GLOB(0x18660a8)". I've read perldata and perlref but I'm not quite sure what is expected of me. I tried *FH{IO} and desparate permutations with or without slashes in front of *FH, but they don't give me what I want.sub from_handle { my $self = shift; my %opts = @_; while (<$opts{-handle}>) { #... and here we're supposed to read from FH } }
|
|---|