Walt Mankowski on 27 Mar 2006 16:30:13 -0000 |
On Mon, Mar 27, 2006 at 11:16:47AM -0500, Eric wrote: > Quoting Jeff Watson <redgibson@gmail.com>: > > > I am having an issue with this part of my perl script. > > > > # eat output file, chop all lines but the load lines > > my $output = "c:\\TEST.out"; > > > > if($ARGV[0]) { > > print $ARGV[0] . "\n"; > > my $input = $ARGV[0]; > > print $input > > } > > else { > > print "BAD INPUT: Missing parse target filename!"; > > exit(0); > > } > > > > # ASSUME $input = C:\test.chm' !! > > #open(MYFILE, 'c:\test.chm'); # THIS WORKS!!! > > open(MYFILE, $input); # THIS FAILES!! :-/ > > > > while(<MYFILE>) #Drops out on this line becuase the file is not able to be > > opened? > > ....... > > > > > > -Jeff Watson > > -RedGibson@gmail.com > > Jeff: > > I always code the open statements as: > > open MYFILE, "<$input" or die "Cannot open file $input" ; > so when it cannot open the file it will tell you. Even better, you should include the $! variable in your error message to see the actual reason why it couldn't open the file. My usual code for opening input files is this: open MYFILE, $input or die "Can't open $input: $!\n"; > I don't use perl in Windows a lot but I'd try double back-slash '\\' > in the file name because perl may be seeing the single backslash as > an escape for the next char when you pass it to the open function. That should only matter if the string is inside double quotes, which doesn't seem to be the case here. Anyway, it's easy to test. When he prints out $input he'll either see a backslash or a tab (which is "\t" between the ":" and the "e". Walt Attachment:
signature.asc ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|