There's more than one way to do things | |
PerlMonks |
Re: Use scalars to define a filenameby Ovid (Cardinal) |
on Oct 17, 2011 at 14:13 UTC ( [id://931935]=note: print w/replies, xml ) | Need Help?? |
There are a couple of issues here. First, when you get the "string found or bareword..." error message, it will include a line number. That line number is likely not the line you're pointing to because there are no barewords or syntax errors in the code above. You'll want to post a larger code snippet. That being said, in Perl an identifier should start with a letter or underscore and is followed by zero or more word characters. A scalar variable in Perl is defined as a dollar sign ($) followed by an identifier. When you have a this line:
When you fix your other issue, you'll probably get an error message similar to: Global symbol "$var1_" requires explicit package name at temp.pl line 10. (Note: If you're on a version of Perl less than 5.10, you won't see the variable name) Perl thinks that $var1_ is a variable name. You need to tell Perl that the trailing underscore (_) is not part of the variable name. You can fix this one of two ways:
Also, I suspect that you wanted fileLocn to begin with a dollar sign? Cheers,
In Section
Seekers of Perl Wisdom
|
|