How to use the __DATA__ handle when no filename supplied in perl -


looking way using data handle if no filename provided perl script.

i'm not skilled in perl.

something like:

use strict; use warnings; use autodie; use diagnostics;  $fd; if( $argv[0] && -f $argv[0] ) {     open $fd, "<", $argv[0]; } else {     $fd = "data";   #what here? }  process($fd); close($fd); #closing file - or data handle too?  sub process {     $handle = shift;     while(<$handle>) {         chomp;         print $_,"\n";     } }  __data__ default content 

$fd=\*data; should trick


Comments