in reply to Problem printing contents of file
If all you're telling is true, the only explanation is that ../frame.txt is an empty file. Note that it is a good practice to mention the filename as well. Also, it is a bad practice to use relative filenames unless you know which directory is the current directory when your script is run. Notably, webservers set a different current directory when they run scripts. The following code works for me, but it is not substantially different from your code:
#!/usr/bin/perl -w use strict; #my $filename = '../frame.txt'; my $filename = $0; open my $fh, '<', $filename or die "Couldn't open '$filename': $!"; while (<$fh>) { print "$_\n"; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem printing contents of file
by ketaki (Acolyte) on Jun 18, 2008 at 06:32 UTC | |
by syphilis (Archbishop) on Jun 18, 2008 at 06:50 UTC | |
by ketaki (Acolyte) on Jun 18, 2008 at 07:55 UTC | |
by Corion (Patriarch) on Jun 18, 2008 at 08:06 UTC | |
by ketaki (Acolyte) on Jun 18, 2008 at 08:21 UTC | |
by linuxer (Curate) on Jun 18, 2008 at 08:07 UTC | |
by Corion (Patriarch) on Jun 18, 2008 at 06:53 UTC |