Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Concantenation

by ajt (Prior)
on May 05, 2003 at 17:53 UTC ( #255688=note: print w/ replies, xml ) Need Help??


in reply to Concantenation

chriso

You don't show the whole code, but on the face of it what you show isn't going to work, and worse still it may be very dangerous.

I hope you have properly de-tainted and verified that the value of $course_no is nice and safe, otherwise all sorts of undesirable things may happen!!!

Once you are happy that things are safe, then the following may work better with your concatination:

my $file = "/usr/local/apache2/htdocs/crs_desc/" . $course_no . "desc. +txt"; open DESCDOC, "<", $file || die "Unable to open $file";

Your concatination is a bit messy, which I clearly spelt out, so it should be okay now. Other solutions would work too. I've change your fatal to report which file it couldn't open, in case the name isn't what you expected - your error handling won't take care of that unless you pass the filename to it.

Others will have more advice, but also see (from an earlier node of mine):


--
ajt


Comment on Re: Concantenation
Select or Download Code
Re^2: Concantenation (variable name disambiguation)
by Aristotle (Chancellor) on May 05, 2003 at 18:48 UTC
    The other alternative to spelling out the concatenation is to use Perl's provisions for disambiguating the variable name (which is why the OP split up the concatenation):
    my $file = "/usr/local/apache2/htdocs/crs_desc/${course_no}desc.txt";

    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://255688]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-09-16 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (155 votes), past polls