in reply to Re: usage of "my" keyword (quibble re clarity)
in thread usage of "my" keyword

I read all the manuals above suggested. But i have a small doubt

#!/usr/bin/perl use strict; # my $row; . . for $row ($min..$max) { if($data == $required) { last; } } print "Data presented in:: $row \n";

Here i am declaring the $row above the for loop. But the $row loosing its scope after the for loop. As per documents the scope of my variable does not lose.

if i dont want to loose that variable scope & also i want to use strict then how can i edit it

Replies are listed 'Best First'.
Re^3: usage of "my" keyword (quibble re clarity)
by Anonymous Monk on Aug 20, 2015 at 07:17 UTC

    if i dont want to loose that variable scope & also i want to use strict then how can i edit it

    Its simple, use another variable that isn't $row

    my $what; for my $row ( $min .. $max ){ if( $data == $required ){ $what = $row; last; } } print "Data presented in:: $row \n";

      I am done in the same way. But i think MONKS will reduce the code without creating another module. Anyway thanks for your reply

        I am done in the same way. But i think MONKS will reduce the code without creating another module. Anyway thanks for your reply

        :) I am MONKS, and yes I'm fairly confident its not possible to do this without another variable (not module)