Hi Rick,

On Wed, 4 Jul 2018 09:16:19 -0500
Rick T <p...@reason.net> wrote:

> The following line works, even though I forgot to double quote the variable.
> 
> my $student_directory =  '/data/students/' . $student_id;
> 

see http://perl-begin.org/tutorials/bad-elements/#vars_in_quotes . Perl often
stringifies expressions even outside interpolation, such as when being
string-concatenated.

> When I noticed this, I thought this was convenient: perl is trying to “do the
> right thing.” But I worry that leaving them out may be bad coding practice;
> if so, or you see other worthwhile improvements, please let me know.
> 
> More importantly, I wonder how perl knows to do this. Perhaps  context
> provided by the assignment operator or the concatenation operator? If there
> is a general rule on this, it would help me to know more widely when I can
> omit double quotes.
> 
> Thanks!
> 
> Rick Triplett


-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
First stop for Perl beginners - http://perl-begin.org/

After all is said and done, a hell of a lot more is said than done.
    — Unclear source, via fortune-mod.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to