Scope of variables in a function

Hakim Cassimally hakim.cassimally at gmail.com
Sat Jun 1 22:08:32 BST 2013


Definitely agree that this should be deprecated.

[Andrew]: there is nothing wrong with wanting to use a conditional in a
declaration.  You can do it like this:

my $x = $condition ? 'FOO' : undef;

or like this

my $x = do { if ($condition) {  'FOO' } };

osf'



On 1 June 2013 21:40, Andrew Beverley <andy at andybev.com> wrote:

> On Sat, 2013-06-01 at 21:08 +0100, Dominic Thoreau wrote:
> > On 1 June 2013 20:59, Andrew Beverley <andy at andybev.com> wrote:
> >
> > > On Sat, 2013-06-01 at 20:33 +0100, Anthony Lucas wrote:
> > > > Relying on its _contents_ is what you shouldn't be doing. There' a
> > > > difference.
> > >
> > > Okay, in which case I reckon there should be a warning when trying to
> > > use the contents, when the declaration hasn't happened because of the
> > > condition ;-)
> > >
> > Although the code you published didn't have 'use warnings;' on it, so I'm
> > suspecting most people thought it wouldn't be there (silly, I know)
>
> Yes, I should have explicitly stated that. I've already learnt the
> lesson of not putting that in my code ;-)
>
>
>


More information about the london.pm mailing list