DEV Community

Discussion on: Perl 5.30 deprecates use of my() in a false conditional

Collapse
 
maxatome profile image
Maxime Soulé

Other alternatives:

# same length, but if $bar is false, $foo equals $bar, so not necessarily undef:
my $foo = $bar && 'foobar';

# otherwise, less perlish and longer:
my $foo = $bar ? 'foobar' : undef;
Collapse
 
mitchjacksontech profile image
Mitch Jackson

Thanks, also good alternatives.