Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Secret Perl Operators: the boolean list squash operator, x!!

by Aristotle (Chancellor)
on Jul 31, 2006 at 16:30 UTC ( #564792=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my   @part = ( 'http://example.net/app' );
    push @part, 'admin'  if $is_admin_link;
    ...
    push @part, $submode if defined $submode;
    
    my $uri = join '/', @parts;
    
  2. or download this
    # [updated: originally had `'admin' ? $is_admin_link : ()`]
    
    ...
    );
    
    my $uri = join '/', @part;
    
  3. or download this
    $a = undef;
    print $a ? 'true' : 'false';  # prints 'false'
    ...
    $a = 'abc';
    print !!$a ? 'true' : 'false';  # prints 'true'
    print !!$a;                     # prints 1
    
  4. or download this
    @_ = ( 'a' ) x 4;
    print join ':', @_;  # prints 'a:a:a:a'
    print scalar @_;     # prints '4'
    
  5. or download this
    @_ = ( 'a' ) x 1;
    print join ':', @_;  # prints 'a'
    ...
    @_ = ( 'a' ) x 0;
    print join ':', @_;  # prints ''
    print scalar @_;     # prints '0'
    
  6. or download this
    my @part = (
        'http://example.net/app',
    ...
    );
    
    my $uri = join '/', @parts;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://564792]
Approved by Corion
Front-paged by rinceWind
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (16)
As of 2014-07-28 19:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (207 votes), past polls