[33161] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4440 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 28 21:09:20 2015

Date: Thu, 28 May 2015 18:09:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 28 May 2015     Volume: 11 Number: 4440

Today's topics:
        Comparing Lists <see.my.sig@for.my.address>
    Re: Comparing Lists <peter@makholm.net>
    Re: Comparing Lists <gravitalsun@hotmail.foo>
    Re: Comparing Lists <rweikusat@mobileactivedefense.com>
    Re: Comparing Lists <rweikusat@mobileactivedefense.com>
    Re: Comparing Lists <rweikusat@mobileactivedefense.com>
    Re: Comparing Lists <derykus@gmail.com>
    Re: Comparing Lists <see.my.sig@for.my.address>
    Re: Comparing Lists <rweikusat@mobileactivedefense.com>
    Re: Comparing Lists <see.my.sig@for.my.address>
        sort list according to field 3 shulamitmi3@gmail.com
    Re: sort list according to field 3 <gravitalsun@hotmail.foo>
    Re: sort list according to field 3 <rweikusat@mobileactivedefense.com>
    Re: sort list according to field 3 <rweikusat@mobileactivedefense.com>
    Re: sort list according to field 3 <gravitalsun@hotmail.foo>
    Re: sort list according to field 3 <gravitalsun@hotmail.foo>
    Re: Why proxy the YouTube data in the following code. <cdalten@gmail.com>
    Re: Why proxy the YouTube data in the following code. <*@eli.users.panix.com>
    Re: word boundrary and umlaut in Perl regex <bauhaus@futureapps.invalid>
    Re: word boundrary and umlaut in Perl regex <rweikusat@mobileactivedefense.com>
    Re: word boundrary and umlaut in Perl regex <bauhaus@futureapps.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 27 May 2015 21:37:28 -0700
From: Robbie Hatley <see.my.sig@for.my.address>
Subject: Comparing Lists
Message-Id: <-eSdnTN_qMvnBvvInZ2dnUVZ57ydnZ2d@giganews.com>


I'm starting to come across situations in which I need to compare
two lists item-for-item, and it occurs to me that Perl doesn't
have any easy way to do that. I'm ending up having to compare
one element at a time, like so:

    elsif
       (
              48 == $bytes[ 0] &&  38 == $bytes[ 1] && 178 == $bytes[ 2]
          && 117 == $bytes[ 3] && 142 == $bytes[ 4] && 102 == $bytes[ 5]
          && 207 == $bytes[ 6] &&  17 == $bytes[ 7] && 166 == $bytes[ 8]
          && 217 == $bytes[ 9] &&   0 == $bytes[10] && 170 == $bytes[11]
          &&   0 == $bytes[12] &&  98 == $bytes[13] && 206 == $bytes[14]
          && 108 == $bytes[15]
       )
    {
       $new_suffix = '.wma';
    }

That seems clumsy, but trying to compare two lists directly doesn't
work in Perl because Perl interprets them as scalar expressions using
the "comma operator", like so:

say "YES" if (7,6,4) == (3,9,4); # compares 4 to 4, so "YES"

Arrayifying those doesn't work either, because of scalar context:

say "YES" if @{[7,6,4]} == @{[2,9,8]}; # compares 3 to 3, so "YES"

Switching to smartmatch *does* work, but YIKES this syntax is weird:

say "YES" if @{[7,6,4]} ~~ @{[7,5,4]}; # prints nothing
say "YES" if @{[7,6,4]} ~~ @{[7,6,4]}; # prints YES

so in my first example above I could do:

    elsif ( @bytes[0,1,2,3,4,5,6,7,8,910,11,12,13,14,15]
    ~~ @{[48,38,178,117,142,102,207,17,166,217,0,170,0,98,206,108]} )
    {
       $new_suffix = '.wma';
    }

It works, but seems overly complex to me.

Is there a simpler, more-direct way to do list comparisons?

Wait, I can see a couple of simplifications. Replace the indices
with 0..15, and try leaving out the @{}. Probably won't work, though:

    elsif ( @bytes[0..15]
    ~~ [48,38,178,117,142,102,207,17,166,217,0,170,0,98,206,108] )
    {
       $new_suffix = '.wma';
    }

HUH.  That actually works.  Apparently ~~ implicitly dereferences [].

Now, I wonder if there's a way to do "are these lists identical?"
comparisons without the smartmatch operator? (Other than &&ing together
comparisons of individual elements, that is.)


-- 
Cheers,
Robbie Hatley
Midway City, CA, USA
perl -le 'print "\154o\156e\167o\154f\100w\145ll\56c\157m"'
http://www.well.com/user/lonewolf/
https://www.facebook.com/robbie.hatley


------------------------------

Date: Thu, 28 May 2015 09:17:14 +0200
From: Peter Makholm <peter@makholm.net>
Subject: Re: Comparing Lists
Message-Id: <87zj4pyxvp.fsf@vps1.hacking.dk>

Robbie Hatley <see.my.sig@for.my.address> writes:

> Now, I wonder if there's a way to do "are these lists identical?"
> comparisons without the smartmatch operator? (Other than &&ing together
> comparisons of individual elements, that is.)

What about something like:

    use List::Util qw(all);

    say "Identical" if scalar(@foo) == scalar(@bar)
                    && all { $foo[$_] == $bar[$_] } $0..$#foo;

It is a little bit stronger than your original && based code as it also
compares the length of the arrays, but otherwise it should be quite
equivalent to it.

This is probably one of the cases where I would actually like to use the
smartmatch operator, but most of the complex rules keeps me from adding
smartmatch to my active use of perl.

//Makholm


------------------------------

Date: Thu, 28 May 2015 12:07:40 +0300
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: Comparing Lists
Message-Id: <mk6lsr$gkc$1@news.grnet.gr>

On 28/5/2015 7:37 πμ, Robbie Hatley wrote:
>
> I'm starting to come across situations in which I need to compare
> two lists item-for-item, and it occurs to me that Perl doesn't
> have any easy way to do that. I'm ending up having to compare
> one element at a time, like so:

you did not defy clear what your want, only some no-sense snippets
so here is something that make sense to me

my @list1 = qw/a b c/;
my @list2 = qw/a D c/;

for(my $i=0; $i<= ($#list1 == $#list2 ? $#list1 : die 'dif size'); $i++)
{ ie "no at $i" unless $list1[$i] eq $list2[$i]}


------------------------------

Date: Thu, 28 May 2015 12:52:27 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Comparing Lists
Message-Id: <878uc8dimc.fsf@doppelsaurus.mobileactivedefense.com>

Robbie Hatley <see.my.sig@for.my.address> writes:
> I'm starting to come across situations in which I need to compare
> two lists item-for-item, and it occurs to me that Perl doesn't
> have any easy way to do that. I'm ending up having to compare
> one element at a time, like so:
>
>    elsif
>       (
>              48 == $bytes[ 0] &&  38 == $bytes[ 1] && 178 == $bytes[ 2]
>          && 117 == $bytes[ 3] && 142 == $bytes[ 4] && 102 == $bytes[ 5]
>          && 207 == $bytes[ 6] &&  17 == $bytes[ 7] && 166 == $bytes[ 8]
>          && 217 == $bytes[ 9] &&   0 == $bytes[10] && 170 == $bytes[11]
>          &&   0 == $bytes[12] &&  98 == $bytes[13] && 206 == $bytes[14]
>          && 108 == $bytes[15]
>       )
>    {
>       $new_suffix = '.wma';
>    }

[...]

>    elsif ( @bytes[0..15]
>    ~~ [48,38,178,117,142,102,207,17,166,217,0,170,0,98,206,108] )
>    {
>       $new_suffix = '.wma';
>    }
>
> HUH.  That actually works.

For some definition of 'works', namely, when what the smart match
operator happens to do for a given pair of arguments happens to be what
you want, cf

perl -e 'print [1,2,3] ~~ [1,[4, sub { 1 },'Terpsichore'], 3], "\n"'

This prints 1 because the 2 from the first array is smart-matched
against all elements of the array in the 2nd position of the 2nd
array. Since the subroutine in the 2nd position of that always returns
1, the 'scalar sub truth' (people who come up with terms like 'sub
truth' without noticing that this is nonsense should never be in charge of
'abstractions' ...) test for this subroutine will succeed no matter what
the left argument happens to be.

It's generally impossible to write a general comparison routine in Perl,
anyway, because depending on what is supposed to be compared how, either
== or eq needs to be used. And both of them can be overloaded. Provided
there's some idea how to deal with the expected elements on both lists,
I'd use something a la

sub cmpl
{
        return unless @{$_[0]} == @{$_[1]};
        $_[0][$_] == $_[1][$_] or return for 0 .. $#{$_[0]};
        
        return 1;
}

This could be

cmpl(\@\@)

then, 'literal' array could be used as arguments instead of references
to arrays but I don't like the idea that it's impossible to tell how a
subroutine will handle its arguments without knowing its definition.


------------------------------

Date: Thu, 28 May 2015 12:59:19 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Comparing Lists
Message-Id: <87a8wozze0.fsf@doppelsaurus.mobileactivedefense.com>

George Mpouras <gravitalsun@hotmail.foo> writes:
> On 28/5/2015 7:37 πμ, Robbie Hatley wrote:
>>
>> I'm starting to come across situations in which I need to compare
>> two lists item-for-item, and it occurs to me that Perl doesn't
>> have any easy way to do that. I'm ending up having to compare
>> one element at a time, like so:
>
> you did not defy clear what your want, only some no-sense snippets
> so here is something that make sense to me
>
> my @list1 = qw/a b c/;
> my @list2 = qw/a D c/;
>
> for(my $i=0; $i<= ($#list1 == $#list2 ? $#list1 : die 'dif size'); $i++)
> { ie "no at $i" unless $list1[$i] eq $list2[$i]}

Doing the $#list1 == $#list2 ? $#list1 : die 'dif size' comparison after
every iteration despite it's result will (ordinarily) never change seems
wasteful (and also confusing) to me.


------------------------------

Date: Thu, 28 May 2015 13:08:43 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Comparing Lists
Message-Id: <87382gzyyc.fsf@doppelsaurus.mobileactivedefense.com>

Robbie Hatley <see.my.sig@for.my.address> writes:

[...]

>              48 == $bytes[ 0] &&  38 == $bytes[ 1] && 178 == $bytes[ 2]
>          && 117 == $bytes[ 3] && 142 == $bytes[ 4] && 102 == $bytes[ 5]
>          && 207 == $bytes[ 6] &&  17 == $bytes[ 7] && 166 == $bytes[ 8]
>          && 217 == $bytes[ 9] &&   0 == $bytes[10] && 170 == $bytes[11]
>          &&   0 == $bytes[12] &&  98 == $bytes[13] && 206 == $bytes[14]
>          && 108 == $bytes[15]

Unrelated remark: I think you should consider getting rid of the
mathematician's folly of eternally assserting that you PROTEST(!!1)
against the fact that = is both used for assignment and returns a value
by dancing the Yoda whenever something mutable is to be compared with
a constant: A question usually asks for attributes of an object, eg 'Is
the car blue' and not whether a certain attribute belongs to the object,
'Is blue the car?'.


------------------------------

Date: Thu, 28 May 2015 14:10:32 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: Comparing Lists
Message-Id: <3b4dd0bc-3534-4bd7-ac44-9dcc69d3bec4@googlegroups.com>

On Wednesday, May 27, 2015 at 9:37:19 PM UTC-7, Robbie Hatley wrote:
> I'm starting to come across situations in which I need to compare
> two lists item-for-item, and it occurs to me that Perl doesn't
> have any easy way to do that. I'm ending up having to compare
> one element at a time, like so:
> 
> ...
> It works, but seems overly complex to me.
> 
> Is there a simpler, more-direct way to do list comparisons?
> 

Assuming no binary data or memory-busting lists:

say "same" if join("\0",@list1) eq join("\0",@list2);


-- 
Charles DeRykus



------------------------------

Date: Thu, 28 May 2015 15:10:20 -0700
From: Robbie Hatley <see.my.sig@for.my.address>
Subject: Re: Comparing Lists
Message-Id: <y-KdnQRpJregD_rInZ2dnUVZ57ydnZ2d@giganews.com>

On 5/28/2015 5:08 AM, Rainer Weikusat wrote:
> Robbie Hatley <see.my.sig@for.my.address> writes:
>
> [...]
>
>>               48 == $bytes[ 0] &&  38 == $bytes[ 1] && 178 == $bytes[ 2]
>>           && 117 == $bytes[ 3] && 142 == $bytes[ 4] && 102 == $bytes[ 5]
>>           && 207 == $bytes[ 6] &&  17 == $bytes[ 7] && 166 == $bytes[ 8]
>>           && 217 == $bytes[ 9] &&   0 == $bytes[10] && 170 == $bytes[11]
>>           &&   0 == $bytes[12] &&  98 == $bytes[13] && 206 == $bytes[14]
>>           && 108 == $bytes[15]
>
> Unrelated remark: I think you should consider getting rid of the
> mathematician's folly of eternally assserting that you PROTEST(!!1)
> against the fact that = is both used for assignment and returns a value
> by dancing the Yoda whenever something mutable is to be compared with
> a constant: A question usually asks for attributes of an object, eg 'Is
> the car blue' and not whether a certain attribute belongs to the object,
> 'Is blue the car?'

LOL! Noticed that, you did? ;-) Yep, that's a personal habbit I fostered
back in 2002-2008 when I was doing heavy programming in C and C++.
After getting bit a few times by writing "if (c=3) {z=f(B);}"
when I actually meant "if (c==3)", I got fed up and started writing
such things back-assward:

if (37 == blue_cars)
{
    Thoughts = tell_me_all_your_thoughts_on_God(Bob);
}

Puzzling, it may seem; but works, it does.


-- 
Cheers,
Robbie Hatley
Midway City, CA, USA
perl -le 'print "\154o\156e\167o\154f\100w\145ll\56c\157m"'
http://www.well.com/user/lonewolf/
https://www.facebook.com/robbie.hatley


------------------------------

Date: Thu, 28 May 2015 23:22:35 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Comparing Lists
Message-Id: <87d21ks5p0.fsf@doppelsaurus.mobileactivedefense.com>

Robbie Hatley <see.my.sig@for.my.address> writes:
> On 5/28/2015 5:08 AM, Rainer Weikusat wrote:
>> Robbie Hatley <see.my.sig@for.my.address> writes:
>>
>> [...]
>>
>>>               48 == $bytes[ 0] &&  38 == $bytes[ 1] && 178 == $bytes[ 2]
>>>           && 117 == $bytes[ 3] && 142 == $bytes[ 4] && 102 == $bytes[ 5]
>>>           && 207 == $bytes[ 6] &&  17 == $bytes[ 7] && 166 == $bytes[ 8]
>>>           && 217 == $bytes[ 9] &&   0 == $bytes[10] && 170 == $bytes[11]
>>>           &&   0 == $bytes[12] &&  98 == $bytes[13] && 206 == $bytes[14]
>>>           && 108 == $bytes[15]
>>
>> Unrelated remark: I think you should consider getting rid of the
>> mathematician's folly of eternally assserting that you PROTEST(!!1)
>> against the fact that = is both used for assignment and returns a value
>> by dancing the Yoda whenever something mutable is to be compared with
>> a constant: A question usually asks for attributes of an object, eg 'Is
>> the car blue' and not whether a certain attribute belongs to the object,
>> 'Is blue the car?'
>
> LOL! Noticed that, you did? ;-) Yep, that's a personal habbit I fostered
> back in 2002-2008 when I was doing heavy programming in C and C++.
> After getting bit a few times by writing "if (c=3) {z=f(B);}"
> when I actually meant "if (c==3)", I got fed up and started writing
> such things back-assward:
>
> if (37 == blue_cars)
> {
>    Thoughts = tell_me_all_your_thoughts_on_God(Bob);
> }
>
> Puzzling, it may seem; but works, it does.

Considering that this has been handed down as "r3@lly ph@t 1ns1d3rz
tr1ck" among generations of people who felt the desire to put their
refusal to learn this in writing, it's not puzzling at all, just
annoying to anyone else. Which is IMHO the whole point of it, especially
considering that it doesn't work as lvalues also need to be compared
with other lvalues.



------------------------------

Date: Thu, 28 May 2015 16:24:05 -0700
From: Robbie Hatley <see.my.sig@for.my.address>
Subject: Re: Comparing Lists
Message-Id: <pLidnSP-erUbPvrInZ2dnUVZ57ydnZ2d@giganews.com>


On 5/28/2015 2:10 PM, C.DeRykus wrote:

> say "same" if join("\0",@list1) eq join("\0",@list2);

Hmmm. Yes, that might work.

Or even...

    elsif
    (
       substr($buffer, 0, 16) eq
       join '', map {chr}
       48,38,178,117,142,102,207,17,166,217,0,170,0,98,206,108
    )
    {
       $new_suffix = '.wma';
    }

$buffer is the first 50 bytes of a file. What I'm doing here is
looking at the first 50 bytes of each file in a set of files of
unknown type, and using that info to decide what types of files
I'm dealing with, then set the extensions accordingly. This is
useful for files scavenged from browser caches, as those generally
do not have file name extensions such as ".txt", ".jpg", ".mp3",
etc.

I pulled out the ordinals into an array called @bytes, thinking that
it would be easier to compare byte patterns that way. But I now think
that best way to compare lists in Perl is... DON'T.

Since all the numbers on both sides of the comparisons are in the
0-255 range, I can use the join/map/chr construct above to convert
various byte patterns to strings and compare them to same-size
substrings of $buffer.

Of course I could skip the "join '', map {chr}" and just make strings
out of the byte patterns like so:

    "\x3b\x25\xd2\x1e\x6b\xc2\x97\x8e\xa7"

BUT, that would require converting all the numbers form decimal to hex,
and involves lots of ugly \x\x\x\x\x\x\x\.

I like my "join '', map {chr}" idea better. (Provided that it works;
I haven't tried it yet.)


-- 
Cheers,
Robbie Hatley
Midway City, CA, USA
perl -le 'print "\154o\156e\167o\154f\100w\145ll\56c\157m"'
http://www.well.com/user/lonewolf/
https://www.facebook.com/robbie.hatley


------------------------------

Date: Thu, 28 May 2015 04:30:36 -0700 (PDT)
From: shulamitmi3@gmail.com
Subject: sort list according to field 3
Message-Id: <cb4840af-9acc-41da-bfe2-b828f7fe644c@googlegroups.com>



I have a list with such elements:


@my_list=("app  :  c_file\n" , "ref  :  b_file\n" , "app  :  a_file\n");
print @my_list;

Output:
app  :  c_file
ref  :  b_file
app  :  a_file



How can I sort the list according to file name (field 3 and not field 1)?

The expected output is:

app  :  a_file
ref  :  b_file
app  :  c_file

thanks!


------------------------------

Date: Thu, 28 May 2015 15:30:04 +0300
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: sort list according to field 3
Message-Id: <mk71oc$1cb$1@news.grnet.gr>

On 28/5/2015 2:30 μμ, shulamitmi3@gmail.com wrote:
> I have a list with such elements:
>
>
> @my_list=("app  :  c_file\n" , "ref  :  b_file\n" , "app  :  a_file\n");
> print @my_list;
>
> Output:
> app  :  c_file
> ref  :  b_file
> app  :  a_file
>
>
>
> How can I sort the list according to file name (field 3 and not field 1)?
>
> The expected output is:
>
> app  :  a_file
> ref  :  b_file
> app  :  c_file
>
> thanks!




use strict; use warnings;

my @my_list = ("app  :  c_file\n" , "ref  :  b_file\n" , "app  : 
a_file\n");

my @my_better_list;

foreach (@my_list) {
push @my_better_list, /^(.+?)\s*:\s*(.*?)\s*$/ ? [$1,$2] : next
}

for (sort {$a->[1] cmp $b->[1]} @my_better_list) {
print "$_->[0] : $_->[1]\n"
}













------------------------------

Date: Thu, 28 May 2015 15:42:55 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: sort list according to field 3
Message-Id: <874mmwu5jk.fsf@doppelsaurus.mobileactivedefense.com>

George Mpouras <gravitalsun@hotmail.foo> writes:
> On 28/5/2015 2:30 μμ, shulamitmi3@gmail.com wrote:
>> I have a list with such elements:
>>
>>
>> @my_list=("app  :  c_file\n" , "ref  :  b_file\n" , "app  :  a_file\n");
>> print @my_list;
>>
>> Output:
>> app  :  c_file
>> ref  :  b_file
>> app  :  a_file
>>
>>
>>
>> How can I sort the list according to file name (field 3 and not field 1)?
>>
>> The expected output is:
>>
>> app  :  a_file
>> ref  :  b_file
>> app  :  c_file
>>
>> thanks!
>
> use strict; use warnings;
>
> my @my_list = ("app  :  c_file\n" , "ref  :  b_file\n" , "app  :
> a_file\n");
>
> my @my_better_list;
>
> foreach (@my_list) {
> push @my_better_list, /^(.+?)\s*:\s*(.*?)\s*$/ ? [$1,$2] : next
> }
>
> for (sort {$a->[1] cmp $b->[1]} @my_better_list) {
> print "$_->[0] : $_->[1]\n"
> }

Building on this idea: Use a hash whose keys are the filenames and whose
values are the position of the respective element in the original
array. Perl can than be told to re-order the contents of this array
according to the sequence of values corresponding with the sequence of
sorted hash keys:

-------
use strict; use warnings;

my @my_data = ("app  :  c_file\n" , "ref  :  b_file\n" , "app  : a_file\n");

my %my_keys;
for (0 .. $#my_data) {
    $my_data[$_] =~ /(\S+)$/;
    $my_keys{$1} = $_;
}

@my_data = @my_data[@my_keys{sort keys(%my_keys)}];

print(@my_data);      
--------

Another, more standard ('Schwartzian transform') idea would be to
create a temporary list consisting of pairs (<original data>, <key>),
sort that based on the keys and create a sorted, final list by throwing
the keys away again:

@my_data = map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [$_, /(\S+)$/] } @my_data;


------------------------------

Date: Thu, 28 May 2015 16:24:09 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: sort list according to field 3
Message-Id: <87twuwsp2e.fsf@doppelsaurus.mobileactivedefense.com>

shulamitmi3@gmail.com writes:
> I have a list with such elements:
>
>
> @my_list=("app  :  c_file\n" , "ref  :  b_file\n" , "app  :  a_file\n");
> print @my_list;
>
> Output:
> app  :  c_file
> ref  :  b_file
> app  :  a_file
>
> How can I sort the list according to file name (field 3 and not field
> 1)?

Some more general things not mentioned so far: In order to do this, you
need to extract the sort key from each input element and compare this
sort keys with each other. Since your sort key is the last, white-space
separated field of an input element, the regex

/(\S+)$/

captures that and puts it into $1 (in list context, it's also
returned). One way to sort as desired is to define a custom comparison
routine working in this way, eg,

---------
use strict; use warnings;

my @my_data = ("app  :  c_file\n" , "ref  :  b_file\n" , "app  : a_file\n");

sub cmp_last
{
    my ($ka, $kb);

    $a =~ /(\S+)$/, $ka = $1;
    $b =~ /(\S+)$/, $kb = $1;

    return $ka cmp $kb;
}

print(sort cmp_last @my_data);
----------

This is, however, wasteful, as elements are compared to other elements
many times during sorting and each comparison has to extract the keys
from afresh despite they never change. Various ways to get around that
were shown in the other postings.


------------------------------

Date: Thu, 28 May 2015 18:42:06 +0300
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: sort list according to field 3
Message-Id: <mk7d0e$do1$1@news.grnet.gr>

On 28/5/2015 2:30 μμ, shulamitmi3@gmail.com wrote:
> @my_list=("app  :  c_file\n" , "ref  :  b_file\n" , "app  :  a_file\n");
> print @my_list;



my @my_list = ("app  :  c_file\n" , "ref  :  b_file\n" , "app  : 
a_file\n");

my $regex = qr/\s*(.*?)\s*$/;


foreach (sort {($a=~$regex)[0] cmp ($b=~$regex)[0]} @my_list)
{
print "$_\n"
}




------------------------------

Date: Thu, 28 May 2015 18:43:19 +0300
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: sort list according to field 3
Message-Id: <mk7d2n$do1$2@news.grnet.gr>

On 28/5/2015 6:42 μμ, George Mpouras wrote:
> On 28/5/2015 2:30 μμ, shulamitmi3@gmail.com wrote:
>> @my_list=("app  :  c_file\n" , "ref  :  b_file\n" , "app  :  a_file\n");
>> print @my_list;
>
>
>
> my @my_list = ("app  :  c_file\n" , "ref  :  b_file\n" , "app  :
> a_file\n");
>
> my $regex = qr/\s*(.*?)\s*$/;
>
>
> foreach (sort {($a=~$regex)[0] cmp ($b=~$regex)[0]} @my_list)
> {
> print "$_\n"
> }
>
>


i was late !


------------------------------

Date: Tue, 26 May 2015 20:55:10 -0700 (PDT)
From: Chad <cdalten@gmail.com>
Subject: Re: Why proxy the YouTube data in the following code.
Message-Id: <aeb44553-63e4-4bdd-97c3-cbe6b904229c@googlegroups.com>

Maybe I'm being a bit daft, but under what conditions would you redirect? Would it be if I am subscribing to a particular channel?


------------------------------

Date: Thu, 28 May 2015 20:49:09 +0000 (UTC)
From: Eli the Bearded <*@eli.users.panix.com>
Subject: Re: Why proxy the YouTube data in the following code.
Message-Id: <eli$1505281644@qz.little-neck.ny.us>

In comp.lang.perl.misc, Chad  <cdalten@gmail.com> wrote:
> Maybe I'm being a bit daft, but under what conditions would you redirect?
> Would it be if I am subscribing to a particular channel?

You proxy when you want the server running the CGI to download it first
and then send it to the browser.

You redirect when you want the broswer to download directly.

The first case is probably useful for getting around regional blocking.
The second case is probably faster.

I don't think subscriptions enter into the concerns at all. You want
that, you can use the youtube.com web interface instead of futzying
around with a download tool.

Did you have any further perl questions?

Elijah
------
again: has only used youtubedown from the command line


------------------------------

Date: Wed, 27 May 2015 14:08:11 +0200
From: "G.B." <bauhaus@futureapps.invalid>
Subject: Re: word boundrary and umlaut in Perl regex
Message-Id: <mk4c11$mqj$1@dont-email.me>

On 24.05.15 22:38, Rainer Weikusat wrote:
> perl -CSAD -e '$s = $ARGV[0];  print STDOUT int($s =~ m/\bnf/i), "\n";' "Fünf"

Maybe I/O would have become more functional in programming
if numbers had had different text encodings, too?

$ ls
Fünf	Vier

$ perl -CSAD -w -e \
'print STDOUT (map { $_ => int(m/\bnf/) } @ARGV), "\n"' *
Fünf0Vier0

$ perl -CSAD -w -e \
'print STDOUT (map { $_ => int(m/\bnf/) } <"*">), "\n"'
Fünf1Vier0




------------------------------

Date: Wed, 27 May 2015 15:18:37 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: word boundrary and umlaut in Perl regex
Message-Id: <87fv6im7cy.fsf@doppelsaurus.mobileactivedefense.com>

"G.B." <bauhaus@futureapps.invalid> writes:
> On 24.05.15 22:38, Rainer Weikusat wrote:
>> perl -CSAD -e '$s = $ARGV[0];  print STDOUT int($s =~ m/\bnf/i), "\n";' "Fünf"
>
> Maybe I/O would have become more functional in programming
> if numbers had had different text encodings, too?
>
> $ ls
> Fünf	Vier
>
> $ perl -CSAD -w -e \
> 'print STDOUT (map { $_ => int(m/\bnf/) } @ARGV), "\n"' *
> Fünf0Vier0
>
> $ perl -CSAD -w -e \
> 'print STDOUT (map { $_ => int(m/\bnf/) } <"*">), "\n"'
> Fünf1Vier0

http://perldoc.perl.org/perlunicode.html#When-Unicode-Does-Not-Happen

To quote Vincent Hoefler: It's documented and since it's not documented
as a bug, it's a feature.



------------------------------

Date: Wed, 27 May 2015 19:04:24 +0200
From: "G.B." <bauhaus@futureapps.invalid>
Subject: Re: word boundrary and umlaut in Perl regex
Message-Id: <mk4tcf$sbm$1@dont-email.me>

On 27.05.15 16:18, Rainer Weikusat wrote:

> http://perldoc.perl.org/perlunicode.html#When-Unicode-Does-Not-Happen
>
> To quote Vincent Hoefler: It's documented and since it's not documented
> as a bug, it's a feature.

A feature, though, that Perl shares with about any language
I know. Fortunately, we are all paid for spending much time
on getting encodings sorted out, therefore there is no relative
economic disadvantage caused by fighting the ubiquitous
Unicode Bug.

All the while, all file systems that I (superficially)
know have extended attributes, as do archiving programs.

So, with the usual caveats when performing I/O, I take it
that using in programs what's there (extended attributes)
could actually happen as soon as someone popular creates
an OS function in C that reads directories and takes
advantage of extended attributes. — Or maybe not.



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 4440
***************************************


home help back first fref pref prev next nref lref last post