Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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 = ( '' );
    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 = (
    my $uri = join '/', @parts;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://564792]
Approved by Corion
Front-paged by rinceWind
[Cosmic37]: should I slurp? should I grep? Noble Lords I wish you good karma and beg your advice
[Corion]: Cosmic37: Ah, see perlfaq4, about How do I compute the intersection of two arrays
[Cosmic37]: I am out of practice; I use Perl for scientific programming for number crunching
[Corion]: Cosmic37: Basically, you read one file into a hash, keyed by your key, and then match the lines from the second file to that hash
[Cosmic37]: note that the two files only have datetimes which may match whereas other data per line is different format in file1 and file2 - is that really intersection?
[jedikaiti]: Hi Monks
[Corion]: Cosmic37: Well, if you want to use only parts of a line for the key, see split or whatever other mechanism to extract the key from the line
[Corion]: Hi jedikaiti!
[Cosmic37]: is there a webpage for full CB for this chat rather than side panel chat?
[Cosmic37]: thank you for advice

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2017-06-29 16:18 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (672 votes). Check out past polls.