Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Declaring with my, assigning, and testing in same line (custom routine)

by LanX (Saint)
on Dec 12, 2015 at 03:17 UTC ( [id://1150090]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @v= keys %h;
    die "Got extra Z: @v\n" if @v >1
    
  2. or download this
       
      DB<100> sub check { die "Got extra Z: @_\n" if @_ >1 }
    
    ...
    
      DB<104> check my @v= keys %h
    Got extra Z: a b
    
  3. or download this
      DB<106> sub avoid (&;@) { 
               my $code=shift;
    ...
      DB<109> avoid { "Got extra Z: @_\n" if @_ >1 } my @v = keys %h;
    
      DB<110>
    
  4. or download this
    avoid { "Got extra Z: @_\n" if @_ >1 } 
        my @v = keys %h;
    
  5. or download this
           The declared variable is not introduced (is not visible) until 
    +after
           the current statement.  Thus,
    ...
               my $x = 123 and $x == 123
    
           is false unless the old $x happened to have the value 123.
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1150090]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-04-18 08:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found