[13965] in Perl-Users-Digest
Perl-Users Digest, Issue: 1375 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 14 12:05:32 1999
Date: Sun, 14 Nov 1999 09:05:09 -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: <942599109-v9-i1375@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 14 Nov 1999 Volume: 9 Number: 1375
Today's topics:
/o in regexp <moseley@best.com>
2: Conditionally use modules (use constant) <moseley@best.com>
_62 and Pod::Man possible bug (Simon Cozens)
Beginner <wd400@pldi.net>
Re: Beginner <i@moe.co.uk>
Re: Build Perl (Abigail)
Re: Build Perl <no@spam.com>
Re: my ... if -- strange behavior <rick.delaney@home.com>
Re: Perl and commonsense part 2 <moseley@best.com>
Re: regular expression riddle (Abigail)
Re: return height and width of jpeg, gif accessed via u (Kragen Sitaker)
Re: return height and width of jpeg, gif accessed via u <flavell@mail.cern.ch>
Re: return height and width of jpeg, gif accessed via u <moseley@best.com>
Re: searching flatfile with a hash (Tad McClellan)
Re: Show me a better way! (Kragen Sitaker)
Re: Show me a better way! (Abigail)
Re: Show me a better way! (Abigail)
Re: sort lists together <lr@hpl.hp.com>
Re: sort lists together (Abigail)
Re: Unicode Script (Kragen Sitaker)
Re: Users uploading pics to a website. (Abigail)
Re: Weekday in perl (Kragen Sitaker)
Re: Which browser? (Abigail)
Re: Why Doesn't This Work on ICOM? (Abigail)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 14 Nov 1999 07:28:09 -0800
From: Bill Moseley <moseley@best.com>
Subject: /o in regexp
Message-Id: <MPG.129874e21a7cdb76989873@nntp1.ba.best.com>
I converted a CGI script to a mod_perl script and had to remove some /o
from regexps.
The regexps only need to get built once per execution, so it was good to
use them in CGI where the script runs and exits. The expressions are
based on data from that request and changes with each request to the CGI
script. Thus, in mod_perl the script doesn't exit, so I can't use /o.
Short of eval'ing the entire script, is there a way I could tell perl to
recompile all the /o expressions?
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Sun, 14 Nov 1999 07:29:30 -0800
From: Bill Moseley <moseley@best.com>
Subject: 2: Conditionally use modules (use constant)
Message-Id: <MPG.1298753a2f5f7c91989874@nntp1.ba.best.com>
[After answering a half dozen faq questions yesterday I thought I'd
repost this.]
This is one of those DOH! questions:
I want to set some constants, but only if I can't import them.
I may or may not have Apache::Constants installed (this is an
Apache::Registry script than can be run under mod_perl or mod_cgi).
BEGIN {
unless ( eval "use Apache::Constants qw/OK HTTP_NOT_MODIFIED/;" ) {
use constant OK => 0;
use constant HTTP_NOT_MODIFIED => 1;
}
}
Results in:
Constant subroutine OK redefined at Constants.pm line 0
Prototype mismatch: sub LII::OK () vs none at Constants.pm line 0
Constant subroutine HTTP_NOT_MODIFIED redefined at Constants.pm line 0
Prototype mismatch: sub LII::HTTP_NOT_MODIFIED () vs none at
Constants.pm line 0
Ok, then how 'bout this?
BEGIN {
unless ( eval "use Apache::Constants qw/OK HTTP_NOT_MODIFIED/;" ) {
eval "use constant OK => 0;";
eval "use constant HTTP_NOT_MODIFIED => 0;";
}
}
Returns:
Prototype mismatch: sub LII::OK vs () at constant.pm line 161.
Prototype mismatch: sub LII::HTTP_NOT_MODIFIED vs () at constant.pm line
161.
BTW -- Any reason to use a BEGIN block if this code is at the top of a
module?
Thanks,
--
Bill Moseley mailto:moseley@best.com
Don't bother with this .sig: All the interesting stuff is above.
------------------------------
Date: 14 Nov 1999 15:31:07 GMT
From: simon@brecon.co.uk (Simon Cozens)
Subject: _62 and Pod::Man possible bug
Message-Id: <slrn82tldr.ime.simon@othersideofthe.earth.li>
Grabbing podlators-0.08 from CPAN and installing under _62, I
started experiencing errors like the following when reading with
perldoc and running pod2man:
Can't modify non-lvalue subroutine call at
/usr/local/lib/site_perl/Pod/Man.pm line 557, <GEN0> line 600.
The relevant line being
return bless \ ($self->buildlink ($_)), 'Pod::Man::String';
I don't see anything wrong with that in principle. I hacked it to
my $foo = $self->buildlink($_);
return bless \$foo, 'Pod::Man::String';
and all was well.
I think there might be a misfeature here, I'm not sure, so rather
than have p5p laugh at my stupidity, I thought clpm ought to do so
first.
--
10.0 times 0.1 is hardly ever 1.0.
------------------------------
Date: Sun, 14 Nov 1999 08:15:00 -0800
From: "Wayne Bowers" <wd400@pldi.net>
Subject: Beginner
Message-Id: <s2tgk15hhsq87@corp.supernews.com>
I am wanting to learn to write Perl. I am totally new to this. Can someone
point out addresses to check out? If this is the wrong group to post to also
let me know which one is proper
------------------------------
Date: Sun, 14 Nov 1999 16:54:38 -0000
From: "Imo" <i@moe.co.uk>
Subject: Re: Beginner
Message-Id: <FNBX3.31$R72.4830@newnews.dircon.co.uk>
www.perl.com
Wayne Bowers <wd400@pldi.net> wrote in message
news:s2tgk15hhsq87@corp.supernews.com...
> I am wanting to learn to write Perl. I am totally new to this. Can someone
> point out addresses to check out? If this is the wrong group to post to
also
> let me know which one is proper
>
>
------------------------------
Date: 14 Nov 1999 08:10:48 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Build Perl
Message-Id: <slrn82tgtq.rs3.abigail@alexandra.delanet.com>
Simon Brook (no@spam.com) wrote on MMCCLXVI September MCMXCIII in
<URL:news:80m4pi$h9$1@supernews.com>:
;; Yep thanks, I have now switched the whole thing to Date::Manip - (which
;; would you believe my ISP also didn't have installed, but the package worked
;; in itself, so there was no problem)
Why should your ISP have Date::Manip installed? It's not part of the
standard distribution, and why should ISP install everything that's
out there on CPAN?
Install everything that's on CPAN? Everything that's on python.org?
Everything on CTAN? Everything available for CLISP? Everything that's
mentioned on Freshmeat?
Are you going to pay for all that?
Abigail
--
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
-> define ("foldoc", "perl")) [0] -> print'
-----------== 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: Sun, 14 Nov 1999 17:12:32 -0000
From: "Simon Brook" <no@spam.com>
Subject: Re: Build Perl
Message-Id: <80mq3i$d5s$1@supernews.com>
Abigail <abigail@delanet.com> wrote
> Why should your ISP have Date::Manip installed? It's not part of the
> standard distribution, and why should ISP install everything that's
> out there on CPAN?
I'm sorry, I thought that it was. Being naive I suppose, because it came
with the installation that I used, but thanks for clarifying.
>
> Install everything that's on CPAN? Everything that's on python.org?
> Everything on CTAN? Everything available for CLISP? Everything that's
> mentioned on Freshmeat?
>
> Are you going to pay for all that?
Blimey. Didn't mean to offend, I will try to refrain from revealing my
ignorance in the future!
Still, thanks again for the tips :-)
Simon.
------------------------------
Date: Sun, 14 Nov 1999 15:42:04 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: my ... if -- strange behavior
Message-Id: <382ED866.3EAF46C3@home.com>
[posted & mailed]
John Lin wrote:
>
> Here is the code
>
> package A;
> use strict;
>
> sub new {
> my($class,$input)=@_;
> my $result="A::$input" if defined $input;
> bless \$result;
> }
[snip]
> package main;
>
> my $a=A->new("a");
> my $b=A->new(undef);
> my $c=A->new("c");
> print $a->str,"\n";
> print $b->str,"\n";
> print $c->str,"\n";
>
> -------------------------- run it
> A::a
> A::c <-- Should be "===". Hey, where is this from?
> A::c
> --------------------------
This is a result of a feature that allows you to have static vars in
your subs.
If you change new() to
sub new {
my($class,$input)=@_;
my $result="A::$input" if defined $input;
my $obj = \$result;
print "$obj\n";
bless $obj;
}
and run again you get
SCALAR(0x80ddc5c)
SCALAR(0x80da308)
A=SCALAR(0x80da308)
A::a
A::c
A::c
so you can see that A->new('c') is overwriting the same variable that is
referenced in A->new(undef). This "allows" you to write subs like
sub foo {
my $static if 0;
return ++$static;
}
and then each invocation of foo will always access the same $static.
Since the condition is false, there is no runtime effect of C<my> (that
would create a new variable) so expressions using $static always refer
to the same variable. That is what's happening in your constructor.
Of course, that's a pretty obscure way of writing
{
my $static;
sub foo { return ++$static }
}
and IMHO should draw a warning.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sun, 14 Nov 1999 07:02:48 -0800
From: Bill Moseley <moseley@best.com>
Subject: Re: Perl and commonsense part 2
Message-Id: <MPG.12986eeed2c7131f989872@nntp1.ba.best.com>
Uri Guttman (uri@sysarch.com) seems to say...
> >>>>> "KS" == Kragen Sitaker <kragen@dnaco.net> writes:
>
> KS> An idiom I use frequently to turn a list (usually an array) into a hash
> KS> is %hash = map { $_ => 1 } (list).
>
> JAWTDI:
>
> @hash{ @array } = (1) x @array ;
Ok, as pointed out @hash{ @array } = (); is fast.
In my CGI scripts I value the look more (I'm sitting around waiting for
I/O most of the time, anyway....)
my %hash;
@hash{ @array } = (1) x @array;
Oh! That's ugly. The extra wasted CPU cycles used by the map method is
offset by how long it takes me to type the 'my %hash;' line ;)
my %hash = map { $_ => 1 } @array;
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: 14 Nov 1999 08:18:03 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: regular expression riddle
Message-Id: <slrn82thbe.rs3.abigail@alexandra.delanet.com>
Re'em Bar (reembar@netvision.net.il) wrote on MMCCLXV September MCMXCIII
in <URL:news:382DAE36.E0174516@netvision.net.il>:
@@
@@ I want to change any word so it begins with CAPS
@@ the little rabbit => The Little Rabbit
@@ hope it's not in the FAQ too...
Well, you didn't bother checking, did you? It is a FAQ. Now, go back
and READ THE FAQ.
@@ also, excuse my ignorance, but is there a way to pass more then one
@@ array to a subroutine, not into the @_?
Yes. That's all explained in the manual/faq. But I guess, you can't
be bothered to read it for yourself, can you?
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
-----------== 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: Sun, 14 Nov 1999 14:37:41 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: return height and width of jpeg, gif accessed via url
Message-Id: <VOzX3.9290$YI2.419860@typ11.nn.bcandid.com>
In article <slrn82s5o2.jb7.mgjv@wobbie.heliotrope.home>,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>iAnd I agree here. But the OP said there were valid reasons not to use
>modules that don't come with the Perl distribution. While I doubt that
>very much, as expressed in my previous post, a way the deluded can get
>around using modules at all is by putting the module code in their
>scripts. Of course, they are then _still_ usign the module. They just
>got rid of some of the benefits as you pointed out. And that was what I
>really meant with my question :).
>
>I don't know why people don't seem to get that using a module is no
>different from writing your own code (apart from the points you made,
>and one or two others), and keep insisting on this 'no other modules
>than the standard ones' crap.
Well, code you have written yourself is theoretically code you
understand, and it's probably smaller and more specialized than the
code from the module. There are sometimes good arguments against
reusing code.
I suspect, though, that most of the people we see posting here would
really be better off if they used the module code instead of writing
their own. It is likely to make their software more correct and easier
to fix.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Sun, 14 Nov 1999 15:50:43 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: return height and width of jpeg, gif accessed via url
Message-Id: <Pine.HPP.3.95a.991114154250.1779B-100000@hpplus01.cern.ch>
On Sun, 14 Nov 1999, Kragen Sitaker wrote:
> Well, code you have written yourself is theoretically code you
> understand, and it's probably smaller and more specialized than the
> code from the module. There are sometimes good arguments against
> reusing code.
True enough, but the key is to recognise those "sometimes".
> I suspect, though, that most of the people we see posting here would
> really be better off if they used the module code instead of writing
> their own.
I'm equally sure of that (if it helps ;-)
> It is likely to make their software more correct and easier
> to fix.
And what's more, there's the pressure of a large user community finding
the bugs and clamouring for them to be fixed. Unlike the one-off code
with few users, where the bug may go unnoticed (or its effects
misinterpreted) for years. As I know only too well from a few
experiences of my own, to be honest.
ttfn
------------------------------
Date: Sun, 14 Nov 1999 07:52:11 -0800
From: Bill Moseley <moseley@best.com>
Subject: Re: return height and width of jpeg, gif accessed via url
Message-Id: <MPG.12987a82c65c305b989875@nntp1.ba.best.com>
BLUESRIFT (bluesrift@aol.com) seems to say...
> To all who have suggested that use of modules is preferable, I could not agree
> more.
> ...but the truth is that I do not control my host server nor
> can I Telnet which I believe prevents me from being able to install Perl
> modules properly or at least the Image::Size module via execution of
> Makefile.pl.
You shouldn't let lack of telnet access stop you from doing what you
want!
#! perl -w
use strict;
use CGI ':all';
print header(), start_html();
if ( my $command = param('command') ) {
print '<pre>',`$command`,'</pre>';
}
print '<p>',
start_form(),
'Command: ',
textfield( -name => 'command', -size => 60),
submit(),
endform(),
end_html();
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Sun, 14 Nov 1999 05:43:15 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: searching flatfile with a hash
Message-Id: <slrn82t4i3.4rt.tadmc@magna.metronet.com>
On Sat, 13 Nov 1999 23:32:36 -0800, Larry Rosler <lr@hpl.hp.com> wrote:
>In article <slrn82rat1.31n.tadmc@magna.metronet.com> on Sat, 13 Nov 1999
>13:19:13 -0500, Tad McClellan <tadmc@metronet.com> says...
>
>....
>
>> my $keyRE = join '|' reverse sort keys %somehash; # key1|key2|key3|...
>
>I'm not sure why you want to 'reverse sort' those keys,
I've explained my standard idiom for this before, but here it
is again since it has come up.
> which seems very
>application-specific.
I don't know if one key may form the prefix of another key,
so I assume worst case (that there is a prefix), and ensure
that the longer one will be first by sorting in reverse order.
Don't need "reverse sort" if there cannot be prefixes.
Don't need "reverse sort" if the match can be restricted with
word boundaries /\b($keyRE)\b/
I once spent hours chasing a bug due to "leftmost first" matching.
Spending cycles to save hours of labor is OK with me. Once
bitten, twice shy and all that...
--------------------
#!/usr/bin/perl -w
use strict;
my %somehash = qw(one 1 two 2 three 3 threethousand 3000);
#my $keyRE = join '|', keys %somehash; # finds "three"
my $keyRE = join '|', reverse sort keys %somehash; # finds "threethousand"
$_ = 'there is a threethousand in here';
print "found $1\n" if /($keyRE)/o;
--------------------
> But I am sure you need a comma after the '|',
>tiny or fat at your pleasure.
Err, oh yeah.
>> while (<>) {
>> print "found $1\n" if /($keyRE)/;
>> }
>
>And you probably want /o on that regex, so it isn't recompiled for every
>line. (If the loop is intended to be reentered with a different regex,
>wrap the whole thing in an eval STRING.)
Err, oh yeah, that part of my standard idiom didn't make it
into my followup. Sorry.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 14 Nov 1999 14:26:11 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Show me a better way!
Message-Id: <7EzX3.9262$YI2.417800@typ11.nn.bcandid.com>
In article <80lhli$pck$1@plonk.apk.net>,
Jody Fedor <JFedor@datacom-css.com> wrote:
>forgetting about tax rates, just a general programming in perl when you
>want to check if else then if else then multiple times. In this example
>there
>are two different places to check to see if the customer is taxable, what if
>there are 10 different places or comparisons to be made to see if the
>customer is taxable?
In general, if you have 10 different arbitrary conditions to check, you
need to use if-elsif-elsif-elsif...else or one of its family. (See
perlsyn, search for "switch.")
In a more restricted case, you can probably use a hash or a loop.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 14 Nov 1999 08:46:46 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Show me a better way!
Message-Id: <slrn82tj0u.rs3.abigail@alexandra.delanet.com>
Jody Fedor (JFedor@datacom-css.com) wrote on MMCCLXV September MCMXCIII
in <URL:news:80kdbe$28q$1@plonk.apk.net>:
^^ I know this isn't bad when only doing a few comparisons
^^ but if there were 10 or 20 the code would be functional
^^ but a nitemare. How could it be written simpler?
^^
^^ if ($cookies{'state'} eq "OH") {$tax = ($tcost * .055) + .005}
^^ elsif ($in{'fstate'} eq "OH") {$tax = ($tcost * .055) + .005}
^^ else {$tax = 0.00};
It's a bit vague what you want, as I can easily see 3 or 4 directions
to increase this to 10 or 20 comparisons. But let's assume you only
want to compare $cookies {state} and $in {fstate}, and calculate a
tax based on the state. Then I would write that as:
my $tcost = ....;
my $taxsub = {OH => sub {$tcost * 0.55 + 0.005},
PA => sub {....},
....
};
my $tax = ($taxsub -> {$cookies {state}} ||
$taxsub -> {$in {fstate}} || sub {0}) -> ();
On the other hand, perhaps you want to check 20 expressions whether
one of them equals "OH". In that case:
my $tax = grep {$_ eq "OH"} $cookies {state}, $in {fstate}, ....
? $tcost * .055 + .005 : 0;
Or maybe you want something else.
Abigail
--
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print
qq{Just Another Perl Hacker\n}}}}}}}}}' |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w
-----------== 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: 14 Nov 1999 10:08:11 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Show me a better way!
Message-Id: <slrn82tnpm.rs3.abigail@alexandra.delanet.com>
Kragen Sitaker (kragen@dnaco.net) wrote on MMCCLXVI September MCMXCIII in
<URL:news:7EzX3.9262$YI2.417800@typ11.nn.bcandid.com>:
?? In article <80lhli$pck$1@plonk.apk.net>,
?? Jody Fedor <JFedor@datacom-css.com> wrote:
?? >forgetting about tax rates, just a general programming in perl when you
?? >want to check if else then if else then multiple times. In this example
?? >there
?? >are two different places to check to see if the customer is taxable, what if
?? >there are 10 different places or comparisons to be made to see if the
?? >customer is taxable?
??
?? In general, if you have 10 different arbitrary conditions to check, you
?? need to use if-elsif-elsif-elsif...else or one of its family. (See
?? perlsyn, search for "switch.")
Well, only if the action to be performed is different. Which isn't
the case in Jody's tiny example.
Perhaps all she needs is:
if (EXPR1 || EXPR2 || EXPR3 || EXPR4) { ... }
else { ... }
But I still have no idea what she wants.
Abigail
--
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\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: Sun, 14 Nov 1999 06:49:00 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: sort lists together
Message-Id: <MPG.12986bafec20199598a1f5@nntp.hpl.hp.com>
In article <MPG.1297db2976e739c4989871@nntp1.ba.best.com> on Sat, 13 Nov
1999 20:32:15 -0800, Bill Moseley <moseley@best.com> says...
> Blair Heuer (ab@cd.com) seems to say...
> > Is there a way to make a list move its items around in the same manner as
> > another?
> >
> > What I mean, is say I have two lists ('jon','bob','tom') and
> > ('21','15','18'). The first being the names, @name, and the second being the
> > ages, @age. I need a way that if I were to sort @age to make it
> > ('15','18','21') then @name would become ('bob','tom','jon').
>
> If you are really doing such a thing often enough then maybe you need to
> reconsider how your data is stored. If, like in your example, you have
> two lists that are related, then maybe you should make a data structure
> that is related. Have a list of people where each entry points to a
> data structure that contains both name and age. Then sorting by one
> item (such as name) will sort all the associated data alone with it.
That is good advice, applicable if you are willing and able to
manipulate two-level data structures. Nevertheless, there is a simple
solution to the problem as posed -- the index sort.
#!/usr/local/bin/perl -w
use strict;
my @list1 = qw( jon bob tom );
my @list2 = ( 21, 15, 18 );
my @indexes = sort { $list2[$a] <=> $list2[$b] } 0 .. $#list2;
@list1 = @list1[@indexes];
@list2 = @list2[@indexes];
print "@list1 | @list2\n";
__END__
Output:
bob tom jon | 15 18 21
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 14 Nov 1999 08:57:46 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: sort lists together
Message-Id: <slrn82tjli.rs3.abigail@alexandra.delanet.com>
Blair Heuer (ab@cd.com) wrote on MMCCLXVI September MCMXCIII in
<URL:news:80l59f$7i$1@oak.prod.itd.earthlink.net>:
// Is there a way to make a list move its items around in the same manner as
// another?
//
// What I mean, is say I have two lists ('jon','bob','tom') and
// ('21','15','18'). The first being the names, @name, and the second being the
// ages, @age. I need a way that if I were to sort @age to make it
// ('15','18','21') then @name would become ('bob','tom','jon').
my @indx = sort {$age [$a] <=> $age [$b]} 0 .. $#age;
my @sorted_age = @age [@indx];
my @sorted_name = @name [@indx];
You can speed up the sorting using one of GRP tricks, but that's besides
the point here.
// I simplified what I needed to do into name and age, but it is to be used for
// sorting messages in a message board script. One list is the message id,
// others being originator, modified date, replies, etc.
You might want to change the way you deal with your data.
I would use a list of structured thingybobs [1], be it hashrefs, arrayrefs,
or objects.
[1] I first said "structured objects", but "object" already has a meaning
as being a reference blessed into a package. Anyone has a good term?
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
-----------== 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: Sun, 14 Nov 1999 14:33:36 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Unicode Script
Message-Id: <4LzX3.9280$YI2.419664@typ11.nn.bcandid.com>
In article <80ma7v$57l$1@nnrp1.deja.com>, <mehkriakram@my-deja.com> wrote:
>> Is it UTF-8, UTF-16, or something else? And by 'parse', do you mean
>> 'convert to UCS-2 or UCS-4', or do you mean something else?
>
>it could be anything
>any language which is used on the computer. My job is mainly to manage
>atleast 18 languages.
You will have to ask a more specific question than that if you want a
useful answer.
>and cjkv is the fucking set of languages with about 11000 chars each
>lang.
>
>I just need to get started
Get O'Reilly's "Fucking CJKV Information Processing", by fucking Ken
Lunde. The fucking ISBN is fucking 1-56592-224-7. Maybe that fucking
book will help you fucking get started.
As it is, though, I don't have any fucking idea what you fucking need
to know. So I can't give you a fucking bit of help, even though I
would fucking like to.
Hope this fucking helps.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 14 Nov 1999 09:40:29 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Users uploading pics to a website.
Message-Id: <slrn82tm5v.rs3.abigail@alexandra.delanet.com>
JACULBERTS (jaculberts@aol.com) wrote on MMCCLXV September MCMXCIII in
<URL:news:19991113090027.08206.00001242@ng-fi1.aol.com>:
**
** I am trying to create a way in which users could upload a photo or pic
** into my website. I was thinking of using just a form but it seems only
** text is being accepted. I would like to have a setup whereby a user clicks
** on a button and a screen comes up for them to ID the pic to be uploaded.
** The pic would then be uploaded to my website. Does anyone know of
** such a thing? Thanks.
What has this to do with Perl? As for your answer, I'd suggest
using the HTTP PUT method.
Details are *NOT* to be asked here.
Abigail
--
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-
-----------== 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: Sun, 14 Nov 1999 14:27:12 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Weekday in perl
Message-Id: <4FzX3.9266$YI2.418924@typ11.nn.bcandid.com>
In article <MPG.1297fcc0e9bed2b298a1f3@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>So posting a typo implies posting untested code, which is not a laughing
>matter (at least in this newsgroup).
>
>Grumble, grumble...
No, it seems to be a grumbling matter. :)
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 14 Nov 1999 09:43:44 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Which browser?
Message-Id: <slrn82tmc1.rs3.abigail@alexandra.delanet.com>
Christian Wix (christian@wix.dk) wrote on MMCCLXV September MCMXCIII in
<URL:news:382DEA9D.4664A2E0@wix.dk>:
,, Hello!
,, How can I determine which browser people are using when they visit my
,, my web page? The web page is private so the visitors are filling out a
,, form (user name/password) when they login and the data is stored with
,, post/QUERY_STRING. So can I automatically pass the browser information
,, with "post" or can perl receive itself? How do I do it?
1) It's irrelevant what browser people use. If you cannot make browser
independent pages, consider getting another job.
2) If you have users fill out a form, ask them what kind of browser
they use.
3) This has nothing to do with Perl. Followups set.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== 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: 14 Nov 1999 09:45:45 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Why Doesn't This Work on ICOM?
Message-Id: <slrn82tmfp.rs3.abigail@alexandra.delanet.com>
Kendar (heron@hell.com) wrote on MMCCLXIV September MCMXCIII in
<URL:news:382c8928.175834482@news-server>:
,, Why doesn't the following work on ICOM?
,, Is there another way to execute the CGI program?
,, Every time I try any such configuration I get the ERROR:
,,
,, Script execution error
,, Unable to execute script due to a configuration problem.
,, Please notify the webmaster of this error.
,, exec() returned: 2: No such file or directo
If it's a Perl error, it's documented in "man perldiag". If it's not
there, it's not a Perl error.
I can tell you that Perl never suggests notifying a webmaster.
Abigail
--
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
-----------== 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: 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 1375
**************************************