I am glad that you are happy with the outcome. However, it would be remiss of me not to explain a little more about my example code as it seems that perhaps you have not fully grasped its meaning or method of construction.

Firstly, the braces are important because they form a block which limits the scope of the warnings pragma. This is why in that example you see a warning when assigning to $foo (outside the block) but not to $bar (inside the block, with the scoped pragma). Secondly, the variables $bar, $bot and $foo are only present to illustrate the technique. So, if I were to amend your loop just to silence this one warning, I would do something more like this:

# first process all available player entries for (my $i = 0; exists $rx->{"player_$i"}; $i++) { # add player info to UPI and remove from hash my @player; push @player, $sid; push @player, delete $rx->{"player_$i"} || "Derp"; push @player, delete $rx->{"team_$i"}; push @player, int (delete $rx->{"frags_$i"} || 0); push @player, delete $rx->{"mesh_$i"}; push @player, delete $rx->{"skin_$i"}; push @player, delete $rx->{"face_$i"}; { # You should put a comment here to say why you are muting these +warnings. no warnings 'numeric'; push @player, int (delete $rx->{"ping_$i"} || 0); } push @player, delete $rx->{"ngsecret_$i"}; push @upi, \@player; }

In this way the warning is only silenced when trying to call int (delete $rx->{"ping_$i"} || 0) and nothing else in the loop or enclosing subroutine.

Finally, in silencing the warning you are potentially losing valuable information. Why are you trying to call int on a potentially non-numeric value in the first place? Would it not be better for your code to handle this eventuality properly? Writing robust code will save you time in the long run. Consider spending 5 minutes now to handle non-numeric values of $rx->{"ping_$i"} to save you hours of painful debugging later (especially because you have now silenced the warnings which might otherwise alert you to the problem). Caveat programmer.


🦛


In reply to Re^3: Argument spamming terminal by hippo
in thread Argument spamming terminal by CougarXR7

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.