[13904] in Perl-Users-Digest

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

No subject found in mail header

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 10 17:44:59 1999

Date: Mon, 8 Nov 1999 11:47:54 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942090474-v9-i1300@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 8 Nov 1999     Volume: 9 Number: 1300

Today's topics:
        How do U parse from the end of the line? mirranda@my-deja.com
    Re: How do U parse from the end of the line? <bwalton@rochester.rr.com>
    Re: How do U parse from the end of the line? (Kragen Sitaker)
    Re: How do U parse from the end of the line? <wyzelli@yahoo.com>
    Re: How do U parse from the end of the line? (Sam Holden)
    Re: How do U parse from the end of the line? (Sam Holden)
    Re: How do U parse from the end of the line? <wyzelli@yahoo.com>
    Re: How do U parse from the end of the line? (Sam Holden)
    Re: How do U parse from the end of the line? <wyzelli@yahoo.com>
    Re: How do U parse from the end of the line? (Rob Manchester)
    Re: how sort an array? (Neko)
    Re: how sort an array? (Abigail)
    Re: how sort an array? raju_k@iname.com
    Re: how sort an array? <lr@hpl.hp.com>
    Re: how sort an array? <lr@hpl.hp.com>
    Re: how sort an array? <lr@hpl.hp.com>
    Re: how sort an array? <uri@sysarch.com>
    Re: how sort an array? (Peter J. Kernan)
    Re: how sort an array? (Anno Siegel)
    Re: how to call a sub roght by form <cramirez@gte.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 08 Nov 1999 03:04:51 GMT
From: mirranda@my-deja.com
Subject: How do U parse from the end of the line?
Message-Id: <805eki$4t7$1@nnrp1.deja.com>

How do U parse from the end of the line to get the file extension and
the file name only?

i.e.:
/mypath/another_path/foo_diretory/myfile.ext1

and you want to replace the extension and just get the file name
i.e.
myfile.abc

I am a beginner....
Thanks.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 07 Nov 1999 22:21:02 -0500
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: How do U parse from the end of the line?
Message-Id: <3826419E.ABB361BC@rochester.rr.com>

mirranda@my-deja.com wrote:
> 
> How do U parse from the end of the line to get the file extension and
> the file name only?
> 
> i.e.:
> /mypath/another_path/foo_diretory/myfile.ext1
> 
> and you want to replace the extension and just get the file name
> i.e.
> myfile.abc
 ...
Mirranda, one way is:

$s='/mypath/another_path/foo_diretory/myfile.ext1';
if($s=~m#(?:/|^)([^/]+)$#){
	print "filename: $1\n";
}
else{
	print "error: bad path/filename\n";
}
-- 
Bob Walton


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

Date: Mon, 08 Nov 1999 03:21:42 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: How do U parse from the end of the line?
Message-Id: <alrV3.55713$23.2084225@typ11.nn.bcandid.com>

In article <805eki$4t7$1@nnrp1.deja.com>,  <mirranda@my-deja.com> wrote:
>How do U parse from the end of the line to get the file extension and
>the file name only?
>
>i.e.:
>/mypath/another_path/foo_diretory/myfile.ext1
>
>and you want to replace the extension and just get the file name
>i.e.
>myfile.abc

s/\.ext1$/.abc/;
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Nov 02 1999
6 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Mon, 8 Nov 1999 13:24:18 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: How do U parse from the end of the line?
Message-Id: <LPrV3.100$aq3.14560@vic.nntp.telstra.net>

<mirranda@my-deja.com> wrote in message news:805eki$4t7$1@nnrp1.deja.com...
> How do U parse from the end of the line to get the file extension and
> the file name only?
>
> i.e.:
> /mypath/another_path/foo_diretory/myfile.ext1
>
> and you want to replace the extension and just get the file name
> i.e.
> myfile.abc
>
> I am a beginner....
> Thanks.
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

Here is one way:

#!/usr/bin/perl -w
use strict;
my $oldext = 'ext1';
my $newext = 'abc';
my $oldfilename = '/mypath/another_path/foo_diretory/myfile.ext1';
$oldfilename =~ m/.*\/(.*)/;
my $newfilename = $1;
$newfilename =~ s/\.$oldext/\.$newext/;
print "$oldfilename\n";
print "$newfilename\n";

Wyzelli




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

Date: 8 Nov 1999 03:58:23 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How do U parse from the end of the line?
Message-Id: <slrn82cij6.skt.sholden@pgrad.cs.usyd.edu.au>

On Sun, 07 Nov 1999 22:21:02 -0500, Bob Walton <bwalton@rochester.rr.com> wrote:
>mirranda@my-deja.com wrote:
>> 
>> How do U parse from the end of the line to get the file extension and
>> the file name only?
>> 
>> i.e.:
>> /mypath/another_path/foo_diretory/myfile.ext1
>> 
>> and you want to replace the extension and just get the file name
>> i.e.
>> myfile.abc
>...
>Mirranda, one way is:
>
>$s='/mypath/another_path/foo_diretory/myfile.ext1';
>if($s=~m#(?:/|^)([^/]+)$#){
>	print "filename: $1\n";
>}
>else{
>	print "error: bad path/filename\n";
>}

Or much simpler :

use File::Basename;

And then at least you can use it under Windows, VMS, Mac, etc... 

perldoc File::Basename will explain it's usage though the 'basename'
function is probably what you want...

-- 
Sam

Some of you know what the Perl slogan on Windows is, and you can say it
with me: "It's a good thing there's more than one way to do it, because
most of them don't work."  --Larry Wall


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

Date: 8 Nov 1999 04:05:42 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How do U parse from the end of the line?
Message-Id: <slrn82cj0t.skt.sholden@pgrad.cs.usyd.edu.au>

On Mon, 8 Nov 1999 13:24:18 +0930, Wyzelli <wyzelli@yahoo.com> wrote:
><mirranda@my-deja.com> wrote in message news:805eki$4t7$1@nnrp1.deja.com...
>> How do U parse from the end of the line to get the file extension and
>> the file name only?
>>
>> i.e.:
>> /mypath/another_path/foo_diretory/myfile.ext1
>>
>> and you want to replace the extension and just get the file name
>> i.e.
>> myfile.abc
>>
>> I am a beginner....
>> Thanks.
>>
>>
>> Sent via Deja.com http://www.deja.com/
>> Before you buy.
>
>Here is one way:
>
>#!/usr/bin/perl -w
>use strict;
>my $oldext = 'ext1';
>my $newext = 'abc';
>my $oldfilename = '/mypath/another_path/foo_diretory/myfile.ext1';
>$oldfilename =~ m/.*\/(.*)/;
>my $newfilename = $1;

What if the regex failed. Say for the oldfilename of 'test.txt'.

What about the perfectly valid file: "/tmp/a\nfile.txt".

-- 
Sam

Remember that the P in Perl stands for Practical.  The P in Python
doesn't seem to stand for anything.
	--Randal Schwartz in <8cemsabtef.fsf@gadget.cscaper.com>


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

Date: Mon, 8 Nov 1999 14:16:30 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: How do U parse from the end of the line?
Message-Id: <FAsV3.101$aq3.14847@vic.nntp.telstra.net>

Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote in message
news:slrn82cj0t.skt.sholden@pgrad.cs.usyd.edu.au...
> On Mon, 8 Nov 1999 13:24:18 +0930, Wyzelli <wyzelli@yahoo.com> wrote:
>
> What if the regex failed. Say for the oldfilename of 'test.txt'.
>
> What about the perfectly valid file: "/tmp/a\nfile.txt".

Input: /tmp/a\nfile.txt
Output: a\nfile.abc

What is your problem with that?  Or are you implying that someone would use
both / and \ in the same path-filename entry?  (Iknow you gotta allow for
them users to be dumb dumb dumb... but...)

If the more common readdir was used to grab all the filenames, that problem
can't occur.

If the \ is part of the filename (on a system which uses / as the directory
separator) it stays as part of the name.

If you are on a system which used \ as the directory separator, then you can
figure out how to modify the regex... (hint \\)

> --
> Sam
>
> Remember that the P in Perl stands for Practical.  The P in Python
> doesn't seem to stand for anything.
> --Randal Schwartz in <8cemsabtef.fsf@gadget.cscaper.com>

Wyzelli




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

Date: 8 Nov 1999 05:31:13 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How do U parse from the end of the line?
Message-Id: <slrn82co18.i1.sholden@pgrad.cs.usyd.edu.au>

On Mon, 8 Nov 1999 14:16:30 +0930, Wyzelli <wyzelli@yahoo.com> wrote:
>Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote in message
>news:slrn82cj0t.skt.sholden@pgrad.cs.usyd.edu.au...
>> On Mon, 8 Nov 1999 13:24:18 +0930, Wyzelli <wyzelli@yahoo.com> wrote:
>>
>> What if the regex failed. Say for the oldfilename of 'test.txt'.
>>
>> What about the perfectly valid file: "/tmp/a\nfile.txt".
>
>Input: /tmp/a\nfile.txt
>Output: a\nfile.abc
>
>What is your problem with that?  Or are you implying that someone would use
>both / and \ in the same path-filename entry?  (Iknow you gotta allow for
>them users to be dumb dumb dumb... but...)

There is no \ in the name I specified... Notice I used double quotes. I
meant a file with a newline in its name.

>
>If the more common readdir was used to grab all the filenames, that problem
>can't occur.
>
>If the \ is part of the filename (on a system which uses / as the directory
>separator) it stays as part of the name.
>
>If you are on a system which used \ as the directory separator, then you can
>figure out how to modify the regex... (hint \\)

Or I could just use File::Basename and have all the hard work
done for me.

-- 
Sam

Computers in the future may weigh no more than 1.5 tons.
	--Popular Mechanics, 1949


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

Date: Mon, 8 Nov 1999 15:05:02 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: How do U parse from the end of the line?
Message-Id: <1ktV3.102$aq3.14822@vic.nntp.telstra.net>

Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote in message
news:slrn82co18.i1.sholden@pgrad.cs.usyd.edu.au...
>
> There is no \ in the name I specified... Notice I used double quotes. I
> meant a file with a newline in its name.
>
That is definitely one I have never seen... but ... hmmm
>
> --
> Sam
>
> Computers in the future may weigh no more than 1.5 tons.
> --Popular Mechanics, 1949

BTW sorry for the email.. I accidentally hit the wrong 'reply to' button,
didn't mean to be rude.

Wyzelli




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

Date: 8 Nov 1999 18:59:47 GMT
From: chesta@brown.edu (Rob Manchester)
Subject: Re: How do U parse from the end of the line?
Message-Id: <slrn82e7c5.rg8.chesta@lester.manchero.org>

In article <LPrV3.100$aq3.14560@vic.nntp.telstra.net>, Wyzelli wrote:
:<mirranda@my-deja.com> wrote in message news:805eki$4t7$1@nnrp1.deja.com...
:> How do U parse from the end of the line to get the file extension and
:> the file name only?
:>
:> i.e.:
:> /mypath/another_path/foo_diretory/myfile.ext1
:>
:> and you want to replace the extension and just get the file name
:> i.e.
:> myfile.abc
:>
:> I am a beginner....
:> Thanks.
:>
:>
:> Sent via Deja.com http://www.deja.com/
:> Before you buy.
:
:Here is one way:
:
:#!/usr/bin/perl -w
:use strict;
:my $oldext = 'ext1';
:my $newext = 'abc';
:my $oldfilename = '/mypath/another_path/foo_diretory/myfile.ext1';
:$oldfilename =~ m/.*\/(.*)/;
:my $newfilename = $1;
:$newfilename =~ s/\.$oldext/\.$newext/;
:print "$oldfilename\n";
:print "$newfilename\n";
:
:Wyzelli

how about...

my $ext="abc";
my @name = split(/[\.\/]/,"/some/path.txt");
print STDOUT "$name[@name -2].$ext\n";

see man perlfunc 
look up split
man perlregex

-rob
-- 
whoami?  Just a kid trying to get by.
insight? Hell is a place off the highway, there's a Roy Rodgers there.-JP
advice?  Waltz like a couple of Papish cats doing the Aztec two-step. -LF


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

Date: Fri, 05 Nov 1999 06:49:59 -0800
From: tgy@chocobo.org (Neko)
Subject: Re: how sort an array?
Message-Id: <SeEiOMU3YXnK2flUTN=lehFsBmpT@4ax.com>

On 5 Nov 1999 01:12:18 -0600, abigail@delanet.com (Abigail) wrote:

>Suppose you want to sort a list of code references. (What, noone
>does that on a regular basis...?)
>
>Simple sort:  @out = sort {$a -> () cmp $b -> ()} @in;
>ST:           @out = map  {$_ -> [0]}
>                     sort {$a -> [1] cmp $b -> [1]}
>                     map  {[$_, $_ -> ()]} @in;
>GR Prefix:    ??
>GR Packed:    ??

Pack the array index instead of the code reference:

    @out = map  { $in[substr($_, 1 + rindex($_, "\0"))] }
           sort
           map  { $in[$_]->() . "\0$_" } 0..$#in;

>Note that there also exists a modified ST, that like GR Prefix and
>GR Pack has the advantage of not having a code block with sort, and
>like ST, doesn't like itself to strings or package objects. It's also
>stable.

Rerunning your benchmark code, minus all but 'ST' and 'abigail' code, and
including new GR Prefix code named 'ROGUE':

    #!/usr/bin/perl -w

    use strict;
    use Benchmark;

    my $iterations = 20;
    my $size       = 10000;

    $#::in = $size - 1;

    for (my $i = 0; $i < $size; $i ++) {
        my $rand   = join '' => ('a' .. 'z') [map {rand 26} 1 .. 5];
        $::in [$i] = sub {$rand};
    }

    print "Array size = $size\n";

    timethese ($iterations  => {
        ST        =>  'my @out =     map  {$_ -> [0]}
                                     sort {$a -> [1] cmp $b -> [1]}
                                     map  {[$_, $_ -> ()]} @::in;',
        abigail   =>  'my @out = do {my %hash;
                                     push  @{$hash {$_ -> ()}} => $_ for @::in;
                                     map  {@{$hash {$_}}}
                                     sort  keys %hash};',
        ROGUE     =>  'my @out =     map { $::in[substr($_, 5)] }
                                     sort
                                     map { $::in[$_]->() . $_ } 0..$#::in;',
    });

__END__

Array size = 10000
Benchmark: timing 20 iterations of ROGUE, ST, abigail...
     ROGUE:  7 wallclock secs ( 6.98 usr +  0.00 sys =  6.98 CPU)
        ST: 15 wallclock secs (14.88 usr +  0.00 sys = 14.88 CPU)
   abigail:  9 wallclock secs ( 9.45 usr +  0.00 sys =  9.45 CPU)

-- 
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=


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

Date: 5 Nov 1999 09:28:05 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: how sort an array?
Message-Id: <slrn825u35.dk.abigail@alexandra.delanet.com>

Neko (tgy@chocobo.org) wrote on MMCCLVII September MCMXCIII in
<URL:news:SeEiOMU3YXnK2flUTN=lehFsBmpT@4ax.com>:
,, 
,, Pack the array index instead of the code reference:
,, 
,,     @out = map  { $in[substr($_, 1 + rindex($_, "\0"))] }
,,            sort
,,            map  { $in[$_]->() . "\0$_" } 0..$#in;

Ah, yes, of course. I should have remembered that.

,,     timethese ($iterations  => {
,,         ST        =>  'my @out =     map  {$_ -> [0]}
,,                                      sort {$a -> [1] cmp $b -> [1]}
,,                                      map  {[$_, $_ -> ()]} @::in;',
,,         abigail   =>  'my @out = do {my %hash;
,,                                      push  @{$hash {$_ -> ()}} => $_ for @::in;
,,                                      map  {@{$hash {$_}}}
,,                                      sort  keys %hash};',
,,         ROGUE     =>  'my @out =     map { $::in[substr($_, 5)] }
,,                                      sort
,,                                      map { $::in[$_]->() . $_ } 0..$#::in;',
,,     });
,, 
,, Array size = 10000
,, Benchmark: timing 20 iterations of ROGUE, ST, abigail...
,,      ROGUE:  7 wallclock secs ( 6.98 usr +  0.00 sys =  6.98 CPU)
,,         ST: 15 wallclock secs (14.88 usr +  0.00 sys = 14.88 CPU)
,,    abigail:  9 wallclock secs ( 9.45 usr +  0.00 sys =  9.45 CPU)


To be fair, you should put the "\0" and rindex in, so that it would also
work on an array with variable string length. ROGUE still beats the other
approaches though.


Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Fri, 05 Nov 1999 17:25:30 GMT
From: raju_k@iname.com
Subject: Re: how sort an array?
Message-Id: <7vv3u3$v01$1@nnrp1.deja.com>



Jumped the gun, if the sort block return 'equals', a byte-by-byte
comparison is done to determine the order.  Got that out of the
man pages, but I doesn't seem to do that in practice, I seem to always
get it in the order that it appears in the file. sort(1), on the other
hand, seems to behave that way though.  Thanks for the heads up, I do
a little more digging ..

--raju


In article <MPG.128b80bdcec729a998a1aa@nntp.hpl.hp.com>,
  Larry Rosler <lr@hpl.hp.com> wrote:
> In article <7vsdpp$m5$1@nnrp1.deja.com> on Thu, 04 Nov 1999 16:55:22
> GMT, raju_k@iname.com <raju_k@iname.com> says...
>
> ...
>
> > > $_ = <>;
> > > while ( <> ) {
> > >      @fields = split /\|/;
> > >      my $obj = { 'line' => $_, 'rating' => $field[3] };
> > >      push @lines, $obj;
> > > }
> > >
> > > foreach $obj ( sort { $a->{'rating'} <=> $b->{'rating'} } @lines )
{
> > >     print $obj->{'line'};
> > > }
> >
> >   actually, with the above code, it doesn't matter if the rating is
> >   unique "<=>" will resolve that (you'll get lines with the same
rating,
> >   in the order they appear in the original file).
>
> What makes you think that?  (Hint:  It isn't so.  The order isn't
> correlated to the order they appear in the original file.  Try a few
> cases and see.)
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 5 Nov 1999 10:10:09 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: how sort an array?
Message-Id: <MPG.128cbd5c5ba3411998a1bb@nntp.hpl.hp.com>

In article <7vu9ov$f2v$1@lublin.zrz.tu-berlin.de> on 5 Nov 1999 09:58:55 
-0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> says...
+ Larry Rosler  <lr@hpl.hp.com> wrote in comp.lang.perl.misc:
+ 
+ [snip]
+ 
+ >Output (2 runs on single-user HP-UX 9.05, perl 5.005_03):
+ >
+ >2.04           1.93
+ >0.29           0.45
+ >10.33          10.07
+ >0.6            0.57
+ >
+ >6.7            6.61
+ >0.3            0.27
+ >0              0
+ >0              0
+ >
+ >Interpretation:
+ >
+ >The input file is 100000 lines of about 35 characters/line (the same 
+ >file as used in the benchmarks for the sorting paper).
+ >
+ >The internal sort seems to run about twice as fast, for this one
+ > test.
+ >
+ >Any other experiments would be welcome.
+ 
+ A single run under Linux on a 90 MHz Pentium (don't look at me, it's
+ quite adequate) gives me this
+ 
+ 5.34
+ 1.61
+ 3.92
+ 1.43
+ 
+ 11.58
+ 0.91
+ 0
+ 0
+ 
+ So there's no significant difference between perl's sort and the
+ sort command.  Interesting, though I don't claim to have an idea
+ why this would happen.  Both runs seem to grab the roughly 16 MB
+ of currently available memory (no surprise there).

I ran it again, this time on a Windows NT 4.0 system, perl 5.005_03 
build 822.  The sort command is the MKS ToolKit version of the 
Unix/POSIX sort command.  Unfortunately, the times() function seems 
unable to record child times, so I prepended the elapsed (wallclock) 
time.

9
1.703
0.75
0
0

4
3.578
0.125
0
0

Once again, for what it's worth, the internal sort was twice as fast as 
the external sort.

+ I failed to find the ips.txt you used starting from your home page,
+ so I rolled my own (100000 lines of exactly 35 random characters).
+ I'd like to  do a re-run with the original data, though a big
+ difference in performance would be a surprise.

I put the data there now, at 
<URL:http://www.hpl.hp.com/personal/Larry_Rosler/sort/ips.txt>.  I agree 

it shouldn't matter, as these sorts don't use fields, the way the 
benchmark sorts did.  I'll post them too, Real Soon Now.  :-(

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 5 Nov 1999 10:22:50 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: how sort an array?
Message-Id: <MPG.128cc05736d97ddb98a1bc@nntp.hpl.hp.com>

In article <SeEiOMU3YXnK2flUTN=lehFsBmpT@4ax.com> on Fri, 05 Nov 1999 
06:49:59 -0800, Neko <tgy@chocobo.org> says...
> On 5 Nov 1999 01:12:18 -0600, abigail@delanet.com (Abigail) wrote:
> 
> >Suppose you want to sort a list of code references. (What, noone
> >does that on a regular basis...?)
> >
> >Simple sort:  @out = sort {$a -> () cmp $b -> ()} @in;
> >ST:           @out = map  {$_ -> [0]}
> >                     sort {$a -> [1] cmp $b -> [1]}
> >                     map  {[$_, $_ -> ()]} @in;
> >GR Prefix:    ??
> >GR Packed:    ??
> 
> Pack the array index instead of the code reference:
> 
>     @out = map  { $in[substr($_, 1 + rindex($_, "\0"))] }
>            sort
>            map  { $in[$_]->() . "\0$_" } 0..$#in;
> 
> >Note that there also exists a modified ST, that like GR Prefix and
> >GR Pack has the advantage of not having a code block with sort, and
> >like ST, doesn't like itself to strings or package objects. It's also
> >stable.

The sort given above can be stabilized by padding or packing the indexes 
to fixed length, as Uri showed in another response in this thread.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 5 Nov 1999 10:27:30 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: how sort an array?
Message-Id: <MPG.128cc16b737b17de98a1bd@nntp.hpl.hp.com>

In article <U5QiOKxmc1TfuP4zLeobXkCeUMRK@4ax.com> on Fri, 05 Nov 1999 
07:26:43 GMT, Marcel Grunauer <marcel.grunauer@lovely.net> says...
> On Fri, 05 Nov 1999 06:18:54 GMT, andrew-johnson@home.com (Andrew
> Johnson) wrote:
> 
> > something like the 'ROGUE' pack sort sounds rather cool and
> > mysterious  --- with a few alternatives for the E:
> > 
> > ROsler GUttman Efficient   pack sort
> >                Effective
> >                Elusive
> >                Egregious
> >                Economic
> >                Emancipated
> >                Eminent
> >                Elderberry
> 
>                  Eccentric
>                  Eclectic
>                  Enigmatic

I like this idea.  You forgot the correct ones, though:

                   Excellent
                   Exemplary
                   Extraordinary

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 06 Nov 1999 01:47:15 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: how sort an array?
Message-Id: <x766zg3ymk.fsf@home.sysarch.com>


>>>>> "DC" == David Cassell <cassell@mail.cor.epa.gov> writes:
  DC> Besides, if you want to look like a Perl guru, you have to use the
  DC> latest, most obscure technique: GRP, the Guttman-Rosler Packsort.
  DC> Pronounce it 'gripe' or 'group' or 'grope' or 'grape' or 'garp'
  DC> depending on your feelings about it...

i came up with this name:

the sort according to GaRP (Guttman and Rosler Packed).

:-)

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 6 Nov 1999 15:15:25 GMT
From: pete@theory2.phys.cwru.edu (Peter J. Kernan)
Subject: Re: how sort an array?
Message-Id: <slrn828hgd.jsg.pete@theory2.phys.cwru.edu>

On 06 Nov 1999 01:47:15 -0500, Uri Guttman <uri@sysarch.com> wrote:
 .=
 .=>>>>> "DC" == David Cassell <cassell@mail.cor.epa.gov> writes:
 .=  DC> Besides, if you want to look like a Perl guru, you have to use the
 .=  DC> latest, most obscure technique: GRP, the Guttman-Rosler Packsort.
 .=  DC> Pronounce it 'gripe' or 'group' or 'grope' or 'grape' or 'garp'
 .=  DC> depending on your feelings about it...
 .=
 .=i came up with this name:
 .=
 .=the sort according to GaRP (Guttman and Rosler Packed).
 .=

what is more fun than a word game?

UPGRADE:
  Use Packed Guttman Rossler Analytically Designed Efficient Sorts

PULSE:
  Packed Uri Larry Sorting Environment

SUPPLE:
  Sort Uri Please, Pack Larry Excellent

TULIPS:
  Thanks Uri Larry Insiteful Packed Sort

GRAPES:
  Guttman Rosler Astute Packed Efficient Sort

GROPES:
  Guttman Rosler Outstanding Packed Enlightened Sort

PAGERS:
  Packed Analytical Guttmanized Effervescent Rosslerian Sort


but GRP doesnt roll off the tongue badly. by the way i am working
through the paper and enjoying it.
-- 
  Pete

-- 
  Pete


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

Date: 6 Nov 1999 17:08:06 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how sort an array?
Message-Id: <801n9m$gr1$1@lublin.zrz.tu-berlin.de>

Larry Rosler  <lr@hpl.hp.com> wrote in comp.lang.perl.misc:
>In article <7vu9ov$f2v$1@lublin.zrz.tu-berlin.de> on 5 Nov 1999 09:58:55 
>-0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> says...

[snip earlier benchmarks]
 
>+ A single run under Linux on a 90 MHz Pentium (don't look at me, it's
>+ quite adequate) gives me this
>+ 
>+ 5.34
>+ 1.61
>+ 3.92
>+ 1.43
>+ 
>+ 11.58
>+ 0.91
>+ 0
>+ 0
>+ 
>+ So there's no significant difference between perl's sort and the
>+ sort command.  Interesting, though I don't claim to have an idea
>+ why this would happen.  Both runs seem to grab the roughly 16 MB
>+ of currently available memory (no surprise there).
>
>I ran it again, this time on a Windows NT 4.0 system, perl 5.005_03 
>build 822.  The sort command is the MKS ToolKit version of the 
>Unix/POSIX sort command.  Unfortunately, the times() function seems 
>unable to record child times, so I prepended the elapsed (wallclock) 
>time.
>
>9
>1.703
>0.75
>0
>0
>
>4
>3.578
>0.125
>0
>0
>
>Once again, for what it's worth, the internal sort was twice as fast as 
>the external sort.
>
>+ I failed to find the ips.txt you used starting from your home page,
>+ so I rolled my own (100000 lines of exactly 35 random characters).
>+ I'd like to  do a re-run with the original data, though a big
>+ difference in performance would be a surprise.
>
>I put the data there now, at 
><URL:http://www.hpl.hp.com/personal/Larry_Rosler/sort/ips.txt>.  I agree 

Thanks.

>it shouldn't matter, as these sorts don't use fields, the way the 
>benchmark sorts did.  I'll post them too, Real Soon Now.  :-(

It didn't matter.  Both runs took about 4% less time with your
data which are 3% less than mine, so that's entirely plausible.
The basic fact remains that I don't see a significant difference
in the system sort vs. perl's internal sort.  *shrug*

Anno


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

Date: Sun, 07 Nov 1999 11:24:11 GMT
From: Carlos Ramirez <cramirez@gte.net>
Subject: Re: how to call a sub roght by form
Message-Id: <382560B5.A8EF799F@gte.net>

Try using the CGI.pm module:

use  CGI;
$form = new CGI;

$action      = $form->param('action'); ## Get the field value of "action"
$password = $form->param('password'); ## Get the field value of password

 ..Now do stuff with these values


Yuval Hamberg wrote:

> hi,
> I want that the user will enter his password in a cgi output like this:
> <html><body>
> <h1>Password?</h1><form method="POST">
> <input type="hidden" name="action" value="main">
> <input type="password" name="password"><br>
> <input type="submit" value=" Enter ">
> </form></body></html>
>
> than the cgi will do:
> if ($FORM{'action'}) { &checkpassword; }
> if ($FORM{'action'} eq "main") { &main; }
>
> But that dosent work. i lerned that i sould put this in before:
> # Read and Parse Form:
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs)
>  {
>  ($name, $value) = split(/=/,$pair);
>  $value =~ tr/+/ /;
>  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
>  $value =~ s/<!--(.|\n)*-->//g;
>  $FORM{$name} = $value;
>  }
> # Finished with parsing the input.
>
> But i don't know excekly what it does and not why he does it. anyway it
> still wont work...
>
> any ideas
> thanks



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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

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 V9 Issue 1300
**************************************


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