Part Two of an Infinite Series...

STANDARD FILE HANDLES

* By convention, all filehandles and dirhandles are capitalized.

HANDLE PURPOSE

STDIN   Standard Input
STDOUT  Standard Output
STDERR  Standard Error
ARGV    Argument passed on the script's command line
DATA    Data at end of script (after the __END__ or __DATA__
        token)


* The DATA file is basically a fake text file at the end of the program. The file DATA is opened automatically.

1: #!/usr/bin/perl -w
2: while (<DATA>) {
3:        chomp;# strip trailing "\n";
4:        push( @friends,$_);
5: }
6: __DATA__
7: Pooky
8: Bunny
9: Chimpy

* In this example, lines 7-9 are effectively a
3-line text file that is read by the while()
loop in lines 2-5.  At the end of the program,
@friends will be ("Pooky","Bunny","Chimpy").


TOKENS


* The following tokens are expanded.  They are
helpful for debugging.  Note that they are not
interpolated in strings.

  print "Problem at line",__LINE__,"in",__FILE__,"\n";
  # prints "Problem at line 1 in foo.pl"
  print "Problem at line__LINE__in__FILE__\n"
  # prints "Problem at line__LINE__in__FILE__" --
    which means they are NOT interpolated...

TOKEN MEANING

__LINE__ Current line number

__FILE__ Current file name

__END__ End of script

__DATA__ End of script and open DATA filehandle

__DIE__ $SIG{__DIE__}

__WARN__ $SIG{__WARN__}

__PACKAGE__ Current package name



QUESTION - Can anyone tell me the trick to get __DATA__ to read the preceeding program code?


Until next time the insanity strikes... -Bill- __Sx__________________________________________ http://youve-reached-the.endoftheinternet.org/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to