papillon has asked for the wisdom of the Perl Monks concerning the following question:
I'm calling a sub inside a while loop and it break the $_ from getgrent. I tried to used local($_) before calling the sub but to no avail.
while( (my $name,$passwd,$gid,$members) = getgrent() ){ if ( $name =~ m/^sometext_(\w+)/ ) { local($_); my $var = sub($name, $1); print ($name."\n"); } }
the while loop execute correctly until it reach a $name that start with sometext_. At that point, the while loop just repeat the over the same group and never exit.
Is there a way to let getgrent continue where it was?
Thanks,
Mélanie
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: while loop break when sub call
by kennethk (Abbot) on Jan 09, 2015 at 17:04 UTC | |
by papillon (Initiate) on Jan 09, 2015 at 18:16 UTC | |
by locked_user sundialsvc4 (Abbot) on Jan 09, 2015 at 22:39 UTC | |
|
Re: while loop break when sub call
by toolic (Bishop) on Jan 09, 2015 at 15:06 UTC | |
|
Re: while loop break when sub call
by locked_user sundialsvc4 (Abbot) on Jan 09, 2015 at 15:09 UTC | |
by papillon (Initiate) on Jan 09, 2015 at 15:26 UTC | |
|
Re: while loop break when sub call
by LanX (Saint) on Jan 09, 2015 at 15:24 UTC | |
by papillon (Initiate) on Jan 09, 2015 at 15:28 UTC |