Setting aside why you want to do this, how about:
That example seems to do all that you want.#!/usr/bin/env perl use strict; sub f { return 2; } sub g { my ($y) = shift @_; return $y*2; } if ( my $k = g(my $x = f()) ) { print "If the answer is four I'm happy. Answer == $k\n"; }
In reply to Re: scope of my $x in if statements
by mikeraz
in thread scope of my $x in if statements
by perl5ever
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |