princepawn has asked for the wisdom of the Perl Monks concerning the following question:

use Parse::RecDescent; local $/; my $grammar = <DATA>; my $parser = Parse::RecDescent->new($grammar); my $text = <>; # <------ Line in Question parser->translation_unit($text) or die "bad C code";
  • Comment on What is function of a filehandle read operation operation when no filehandle is specified?
  • Download Code

Replies are listed 'Best First'.
Re: What is function of a filehandle read operation
by BlueLines (Hermit) on Aug 07, 2000 at 23:25 UTC
    Actually, the null file handle "magically gives you all the lines from all the file mentioned on the command line. If no files were mentioned, it gives you standard input instead." -from the camel book, page 54

    BlueLines

    Disclaimer: This post may contain inaccurate information, be habit forming, cause atomic warfare between peaceful countries, speed up male pattern baldness, interfere with your cable reception, exile you from certain third world countries, ruin your marriage, and generally spoil your day. No batteries included, no strings attached, your mileage may vary.
Re: What is function of a filehandle read operation
by cwest (Friar) on Aug 07, 2000 at 23:21 UTC
    I'm not sure what your question is, but if you want to know what that does... it reads from STDIN
    perl -ne print # equal to perl -e 'while (<>){print}'
    Oh.. it also checks the files on the command line... (which is probably how you're using it anyhow)

    Enjoy!

    --
    Casey
    
      It reads from STDIN only when there are no entries in @ARGV. So, you're partially right, but wrong if there are command line arguments.

      -- Randal L. Schwartz, Perl hacker

Re: What is function of a filehandle read operation operation when no filehandle is specified?
by takshaka (Friar) on Aug 08, 2000 at 01:19 UTC
    And for those who don't own the Camel, this behavior is described in the I/O Operators section of the perlop manpage.