R. Joseph Newton wrote:
> Rob Dixon wrote:
>
>>> $filein = $ARGV[0];
>>> open(filein, "$filein");
>>
>> Filehandles are traditionally all uppercase, and it's not
>> good to put a variable in quotes unless you have a reason
>> to.
>>
>>     open FILEIN, $filein;
>
> You're right, of course, about the quotes.  It seems to me that this
> is the downside of Perlish convenience.  Since Perl offers variable
> interpolation within double quotes, this can be very confusing to a
> novice.  Of course, since the facility is there, I use it.  Still, I
> tend to look at such constuctions as: print "Hello, $User, how are
> you doing?\n";
> as:
> print "Hello, " . $User . ", how are you doing?\n";
> which, as the error messages returned when $User is undefined make
> clear, the way the interpreter handles it internally--it sees the
> string in the first line as the concatenation shown in the second.

Yes, but of course the concatentation operator is implicitly
forcing string context onto $User (who taught you to Capitalise
your scalars :-? ) so the explicit "$User" could be considered
to be clearer!

I tend to force a required coercion to a string or a number by
concatenating the null string or adding zero respectively; then it
looks deliberate.

Interestingly, I found a bug recently due to the opposite problem -
I was passing a URI object reference to a function which required
either a string or an array reference. Because a reference was
acceptable no stringifying was done within the called code and
had to be done in the actual parameter as foo ($uri.'').

Cheers,

Rob





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to