Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by Aristotle (Chancellor)
on Jul 31, 2006 at 16:30 UTC ( [id://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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-19 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found