CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Cannot open .txt file

 



onephattai
Novice

Apr 22, 2009, 5:17 PM

Post #1 of 3 (374 views)
Cannot open .txt file Can't Post

I cannot open the file by doing this. Can someone point out that I did wrong here? Thanks



open (INFILE, "$ARGV[0] || die "Cannot open $ARGV[0] for reading.\n";
open (OUTFILE, "$ARGV[1] || die "Cannot open $ARGV[1] for writing.\n";

So basically the command line would look like this:
perl script.pl textfile1.txt textfile2.txt

but I cannot open textfile1.txt for reading.


(This post was edited by onephattai on Apr 22, 2009, 5:52 PM)


ichi
User

Apr 22, 2009, 7:55 PM

Post #2 of 3 (366 views)
Re: [onephattai] Cannot open .txt file [In reply to] Can't Post


Code
open (INFILE, "$ARGV[0]") || die "Cannot open $ARGV[0] for reading.\n";


read perldoc perlopentut for more info


FishMonger
Veteran / Moderator

Apr 22, 2009, 8:12 PM

Post #3 of 3 (364 views)
Re: [ichi] Cannot open .txt file [In reply to] Can't Post

perldoc -q quoting

This is the preferred syntax.


Code
open my $inifile, $ARGV[0] or die "Cannot open $ARGV[0] for reading. $!";


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives