By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,583 Members | 594 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,583 IT Pros & Developers. It's quick & easy.

How to open file whose name is stored in a variable

P: 4
How can I open a file whose file name is stored in a variable

Thank you in advance
May 27 '10 #1
Share this Question
Share on Google+
1 Reply

P: 70
The following will try to open the file named foo.txt for input:
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  4. my $filename = 'foo.txt';
  5. open my $fh, '<', $filename or die "can not open file $filename: $!";
There is a tutorial:
Expand|Select|Wrap|Line Numbers
  1. perldoc opentut
May 27 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.