in reply to Inline::Files bug?

One arg open is documented. From the manual page:
               If EXPR is omitted, the scalar variable of the
               same name as the FILEHANDLE contains the filename.
               (Note that lexical variables--those declared with
               "my"--will not work for this purpose; so if you're
               using "my", specify EXPR in your call to open.)
Always consult the manual first, it's likely to be documented! ;-)

Abigail

Replies are listed 'Best First'.
Re: Re: Inline::Files bug?
by BrowserUk (Patriarch) on Aug 01, 2002 at 12:18 UTC

    Well, that (half) explains that bit. Thanks.

    Problem is, in the sample (pod) code,

    • $CACHE is used, but never given any value.
    • In this particular use of open, its not clear what value I would give the scalar variable of the same name?
    • It appears as if, in the case of Inline::Files, that it is the name of the scalar variable of the same name as the filehandle that is being used - which seems (to me) to be a little redundant?

    I freely admit to still being a newbie to this stuff, but to implicitly use the name of an undeclared, uninitialised global variable, with the same name as a supplied filehandle, to supply the name of the virtual file to open.....(phew)...seems...erm...a little confusing?

      Of course $CACHE is given a value, even if grepping for CACHE didn't reveal it.

      I don't know Inline::Files myself, but one minute browsing of the module and I found:

      my (%symbols, $source); foreach my $vfile (vf_load($file, $SOVFM_pat)) { my $symbol = vf_marker($vfile); $symbol =~ s/^__|__\n//g; push @{$symbols{$symbol}}, $vfile; } foreach my $symbol (keys %symbols) { no strict 'refs'; my $fq_symbol = "${package}::${symbol}"; @$fq_symbol = @{$symbols{$symbol}}; $$fq_symbol = $symbols{$symbol}[0]; my $impl = tie *$fq_symbol, $class, $fq_symbol, -w $file; tie %$fq_symbol, $class."::Data", $impl; }
      I think I can guess what that does.

      Abigail

        Ok, I admit it. No matter how much I look at that code, even my guesses at its function read like mental line-noise. :)

        Then again, I've spent several days (trying) to work out how some (most) of your regex code works (this has been a permenant resident in my editor for two weeks now>). I guess I'm gonna need rather more than my current 8-weeks association with Perl to achieve that level of understanding.

        I'm afraid my feelings re: this implicit use of the name of a filehandle to give a value to an autoloaded, global variable of the same name, is that it is at best, unintuative, and at worst, wholey redundant.

        Maybe if I had experienced Perl 4 (or earlier) where this sort of thing was the norm, it would be less so. For now, I can only rely on the good ministrations of the more experienced, as yourself, to set me straight when I err.

        Thanks again.

      BrowserUk wrote:

      $CACHE is used, but never given any value

      have you tried print $INLINE in your program? it prints for me:

      P:/dada/test.pl(00000000000000000259)

      so it *has* a value. it all happens behind your shoulders, but it happens indeed.

      <hint>remember, you're using a module written by </code>TheDamian</hint>

      cheers,
      Aldo

      __END__ $_=q,just perl,,s, , another ,,s,$, hacker,,print;