ravi45722 has asked for the wisdom of the Perl Monks concerning the following question:
I want to print only particular lines. For that I wrote like this. But its writing all the lines.
#!/usr/bin/perl # use strict; use warnings; use List::MoreUtils qw(any uniq); my @line_numbers = (1,2,5,6,9,10,18,19,23,24,25,30,31,33); my $line_number = 0; foreach my $li (1..35) { if (any {$line_number} @line_numbers) { print "$line_number :\n"; } $line_number++; }
Where am I missing??//
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem in "any"
by poj (Abbot) on Jan 23, 2016 at 13:42 UTC | |
|
Re: Problem in "any"
by choroba (Cardinal) on Jan 23, 2016 at 13:46 UTC | |
|
Re: Problem in "any"
by Anonymous Monk on Jan 23, 2016 at 13:44 UTC |