On Wed, Nov 28, 2007 at 05:09:57PM -0500, Mr. Shawn H. Corey wrote:
> Philippe Bruhat (BooK) wrote:
>> Hi,
>>
>> Just thought I should share this with the FWP crowd.
>>
>> I had to do something special with the first line of a file, before
>> running the whole while(<>) loop on it. I ended up with this:
>>
>>     @[EMAIL PROTECTED] =<>=~ $re;
>>
>> Rafael helped me give this new operator a name (#perlfr transcript):
>>
>>     15:13 <@BooK> OMG c'est quoi =<>=~ comme secret op ?
>>     15:14 <@rgs> le x-wing touché avec une aile en feu
>>
>> Rough translation:
>>
>>     15:13 <@BooK> OMG what is =<>=~ for a secret op ?
>>     15:14 <@rgs> the hit x-wing starfighter with a wing on fire
>>
>> Cog, are you still writing this OGSOP book? ;-)
>>
>
> Actually, it's:
>
>  @[EMAIL PROTECTED] = ( <> =~ $re );
>

Actually, it's not:

    use strict;
    use warnings;
    use Data::Dumper;
    
    my @fields = qw( H M S );
    my $re = qr/(\d\d):(\d\d):(\d\d)/;
    my %data;
    
    # DATA is the pilot, for the sake of the example
    @[EMAIL PROTECTED] =<DATA>=~ $re;
    
    print Dumper \%data;
    
    __DATA__
    the time is now 03:14:15

Which outputs:

    $VAR1 = {
              'H' => '03',
              'M' => '14',
              'S' => '15'
            };

Why would I need parentheses, when the hash slice gives me a list
context already?

-- 
 Philippe Bruhat (BooK)

 For every winner, there must be one or more losers.
                                (Moral to the Sage story in Groo #111 (Epic))

Reply via email to