Friday, May 21, 2010

How do i open a file?? PERL help?

how do i open a file into a program that i have written to print out the exemptions of that file that i have typed in the command line eg.





home$ testprg.pl colour.txt





how do i get my program "testprg.pl" to open that colour.txt file formt he command line.... help

How do i open a file?? PERL help?
If the Perl program is expecting to read standard input, what you wanted is:





home$ testprg.pl %26lt; colour.txt





The %26lt; is a "redirect" operator.





If you want the program to open it itself, you'll need to code that in your Perl program:





my $fn ,$FILE;


$fn= $ARGV[1];


$file = open($fn) || die "can't open input file";


while(%26lt;FILE%26gt;) {


# do something


}





You get the idea.


No comments:

Post a Comment