Okay, so here's the whole code. This sub is the one calling the parser:
sub parse { my $self = shift; my @opts = @_; my %opts; if ( ! @opts || scalar @opts % 2 ) { $self->COMPLAIN("bad number of arguments."); return; } else { %opts = @opts; if ( ! $opts{-format} || ! grep(ucfirst($opts{-format}), @pars +ers) ) { $self->COMPLAIN("no valid format specified."); return; } if ( $opts{-file} && ( ! -T $opts{-file} || ! -r $opts{-file} +) ) { $self->COMPLAIN("file not found, not a text file, or not r +eadable"); return; } elsif ( ! $opts{-file} && ! $opts{-string} ) { $self->COMPLAIN("no data source specified."); return; } my $lib = ref $self; $lib .= '::' . ucfirst($opts{-format}); eval "require $lib"; my $parser = new $lib; if ( $opts{-file} && $parser->can('from_handle') ) { open(FH, $opts{-file}); $opts{-handle} = \*FH; return $parser->from_handle(%opts); } if ( $opts{-string} && $parser->can('from_string') ) { return $parser->from_string(%opts); } $self->COMPLAIN("the parser can't handle the data source speci +fied"); return; } }
The call is 9 physical lines from the bottom. And here's the one who gets called:
sub from_handle { my $self = shift; my %opts = @_; my $taxa = new Phylo::Taxa; my $version = $self->VERSION; while (<$opts{-handle}>) { if ( $_ ) { my $taxon = new Phylo::Taxa::Taxon; my $date = localtime; my $description = qq{Read from $opts{-file} using Phylo ve +rsion $version on $date}; $taxon->name($_); $taxon->desc($description); $taxa->insert($taxon); } } return $taxa; }
And in the second block $_ == GLOB(0xa0bb570).

In reply to Re^4: Passing a file handle to a sub. I still don't get it. by rvosa
in thread Passing a file handle to a sub. I still don't get it. by rvosa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.