In the curly braces after any, you must specify a code that returns true or false. $line_number returns false only in the first iteration of the loop when it's zero, and stays true afterwards. Moreover, you don't need $line_number, you already have the $li variable that can serve its purpose:
#!/usr/bin/perl use warnings; use strict; use List::MoreUtils qw{ any }; my @line_numbers = (1, 2, 5, 6, 9, 10, 18, 19, 23, 24, 25, 30, 31, 33) +; for my $line_number (1 .. 35) { if (any { $_ == $line_number } @line_numbers) { print "$line_number :\n"; } }

But for the same output, you can just use

print map "$_ :\n", @line_numbers;

Instead of the for loop.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

In reply to Re: Problem in "any" by choroba
in thread Problem in "any" by ravi45722

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.