[18504] in Perl-Users-Digest
Perl-Users Digest, Issue: 672 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 11 03:05:47 2001
Date: Wed, 11 Apr 2001 00:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <986972712-v10-i672@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 11 Apr 2001 Volume: 10 Number: 672
Today's topics:
Re: $text in a text file - how do I get it to print? <moiraine@qwest.net>
Re: cgi <moiraine@qwest.net>
Re: complaint about moderation of this group (Garry Williams)
Re: complaint about moderation of this group <webmaster@webdragon.unmunge.net>
Re: cookie woes. <moverho1@nycap.rr.com>
Re: DBD::CSV (was Re: complaint about moderation of thi <webmaster@webdragon.unmunge.net>
Default arguments to commands/functions? <gtoomey@usa.net>
format/write <webmaster@webdragon.unmunge.net>
I'm in TrueType GD hell... Help! <bcoon@sequenom.com>
Re: inheritance within one file? (Rafael Garcia-Suarez)
LWP - HTTPS <ng@fnmail.com>
Re: LWP - HTTPS <ng@fnmail.com>
Re: Need 2 cgi scripts -- for trade? <hafner-usenet@ze.tu-muenchen.de>
Newbie hash vs files database?? <"goodrow"@opencity. com>
Re: perl hacker wanted <moiraine@qwest.net>
Re: Perl Timer! (Gwyn Judd)
Re: Private subroutine inside subroutine (Gwyn Judd)
Re: registration script (Steven Smolinski)
Re: save a value of a variable between subroutines run. <NO_SPAM_klubbheads@home.com>
Sort by a given field alphabetically - help :) <cbell@interlog.com>
Re: Sort by a given field alphabetically - help :) (Damian James)
Re: THANK YOU & FINAL CODE <joe+usenet@sunstarsys.com>
Re: Why does DynaLoader fail? <bjoern@hoehrmann.de>
Re: Why is finish() necessary here with DBI? Bug in DBD <cernava@itexas.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 10 Apr 2001 22:22:48 -0700
From: A_Geekette <moiraine@qwest.net>
Subject: Re: $text in a text file - how do I get it to print?
Message-Id: <3AD3EA28.C390C520@qwest.net>
Anno Siegel wrote:
> According to A_Geekette <moiraine@qwest.net>:
> > That all depends on how you read the data and where you put it when you read
> > it.
>
> You must be using the words "read" and "put" in a broader sense than
> customary.
I didn't quote them, therefore they are supposed to be taken as generalizations
and not as specific Perl functions. However, this can also be concluded by taking
a closer look at my statement (statement to be taken as dictionary...etc.).
"how you read the data". How you input the data. How you take in the data. How
you bring the data in to be manipulated...etc. The most likely means "read" or
"open".
"..where you put it when you read it." Assuming you "read" a file what do you do
with it? You can't just "read" it. You have to put it somewhere or declare a
space for it. ie:
open FILE, "path/to/file" or die $!;
$variable = <FILE>; #or
@variable = <FILE>; #or
%variable = <FILE>;
close FILE or die $!;
Now that you have put the data somewhere, you can manipulate it with ease. Also,
if you're doing lengthy manipulation you don't want to have to leave the file open
in case something else might want access.
Have I made myself more clear? Is this enough information for you? I didn't want
to have to go through all this lengthy explanation, but I assumed you all knew
this. I figured a simple statement could cover it. Shall I be this in depth next
time or can I keep my statements (not to be confused with a Perl statement)
simple?
> Nothing I would subsume under these terms would expand
> a Perl variable whose name is embedded in the text.
open MESSAGE, "../messages/$hash{folder}/$hash{mesgid}"
or die "Serious dainbramage: $!";
@themessage = <MESSAGE>;
close MESSAGE;
$name = $themessage[2]
Now $name = "Lastname", where Lastname replaced by whatever happend to be in the
file.
This is an excerpt from a prog I wrote. It's tried and tested. The file I was
opening was a file created by another script, so I already know what's in it.
> Anno
--
Geekette
"Try Not. Do or do not. There is no try."
-If you don't know who said this,
I don't want to talk to you. ;-)
"Nothing* is impossible, no matter how improbable."
-Anonymous
*Except making myself clear to people who can't read between the lines.
------------------------------
Date: Tue, 10 Apr 2001 22:03:56 -0700
From: A_Geekette <moiraine@qwest.net>
Subject: Re: cgi
Message-Id: <3AD3E5BC.FA4A1442@qwest.net>
Abigail wrote:
> Perl does do many things really well, and many things can do CGI really
> well. The question had absolutely nothing to do with Perl.
"I understand, though, that general CGI questions don't apply here."
This is a quote from my earlier message in this thread. As you can see, I
understand that.
> Abigail
--
Geekette
"Try Not. Do or do not. There is no try."
-If you don't know who said this,
I don't want to talk to you. ;-)
"Nothing is impossible, no matter how improbable."
-Anonymous
------------------------------
Date: Wed, 11 Apr 2001 02:07:19 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: complaint about moderation of this group
Message-Id: <slrn9d7f2m.4c9.garry@zfw.zvolve.net>
On Tue, 10 Apr 2001 14:33:13 GMT, ---Pete--- <bogus@erol.com> wrote:
> On Mon, 09 Apr 2001 08:09:30 GMT, Uri Guttman <uri@sysarch.com> wrote:
>
>>>>>>> "-" == ---Pete--- <bogus@erol.com> writes:
[snip]
> Personally, I believe that many times people in general are
> afraid to speak up when they see something that they feel is wrong
> or could be improved upon for fear of being attacked by a few who
> attempt to dominate a particular newsgroup. Everyone loses to
> some degree when this occurs.
I'm not sure I agree. The "fear" of peer review makes me think. I
have cancelled about three follow-ups before posting them recently
because I re-read the question or looked something up and realized my
original thought was incorrect. I think the discipline is helpful.
> I like encourage everyone to
> speak their mind and share their ideas, but to do it in an polite
> a courteous manner.
Well, this may be appropriate in another group, but it rubs me the
wrong way in a news group discussing a programming language.
I get the idea, but I fear that there are too few cases where
"speaking one's mind" is appropriate given the typical posts here.
There are threads where this may apply, but I think Uri's point was
that *wrong* answers hurt more than they help. I see no need to allow
for "expression" when someone misleads a questioner.
> And.. like you suggest, to be mature enough
> to accept constructive critique or discuss controversial issues in
> an civil manner. Then everyone wins!
Agreed. :-)
--
Garry Williams
------------------------------
Date: 11 Apr 2001 03:23:22 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: complaint about moderation of this group
Message-Id: <9b0ina$bh2$0@216.155.33.76>
In article <slrn9d7f2m.4c9.garry@zfw.zvolve.net>,
garry@ifr.zvolve.net (Garry Williams) wrote:
| > Personally, I believe that many times people in general are
| > afraid to speak up when they see something that they feel is wrong
| > or could be improved upon for fear of being attacked by a few who
| > attempt to dominate a particular newsgroup. Everyone loses to
| > some degree when this occurs.
|
|
| I'm not sure I agree. The "fear" of peer review makes me think. I
| have cancelled about three follow-ups before posting them recently
| because I re-read the question or looked something up and realized my
| original thought was incorrect. I think the discipline is helpful.
|
|
| > I like encourage everyone to
| > speak their mind and share their ideas, but to do it in an polite
| > a courteous manner.
|
|
| Well, this may be appropriate in another group, but it rubs me the
| wrong way in a news group discussing a programming language.
|
| I get the idea, but I fear that there are too few cases where
| "speaking one's mind" is appropriate given the typical posts here.
| There are threads where this may apply, but I think Uri's point was
| that *wrong* answers hurt more than they help. I see no need to allow
| for "expression" when someone misleads a questioner.
Indeed.. I've cancelled a few of my own posts after whacking away a bit
at some code only to discover that my take on handling the problem
wasn't functioning in the way that I had expected, and discretion being
the better part of valor, decided to see what else others had to offer,
and compare what I thought with the later results.
learned a lot this way, I can tell you. :)
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Wed, 11 Apr 2001 06:05:34 GMT
From: "Mark" <moverho1@nycap.rr.com>
Subject: Re: cookie woes.
Message-Id: <OuSA6.25701$RV1.4702373@typhoon.nyroc.rr.com>
Im not too sure about a machanic but i need a plumer my water presure is
nothing and now i have to reset my point
any lines on a good pluber?
"Brad Baxter" <bmb@ginger.libs.uga.edu> wrote in message
news:Pine.A41.4.21.0104071555450.10784-100000@ginger.libs.uga.edu...
On Sat, 7 Apr 2001, Jürgen Exner wrote:
> You are asking "I can't get my groceries with my car" in a automobile
> newsgroup but actually you are expecting advice on how to build a road
> between your house and the grocery store. That's not gone work, dude ;-)
#!/usr/local/bin/perl
use warnings;
use strict;
print <<_end_;
I just installed a new battery (hopefully correctly) after paying two
different mechanics to do the same thing, and after paying for two towing
charges.
Could someone tell me how to find a competent mechanic?
_end_
TIA
Brad
------------------------------
Date: 11 Apr 2001 01:14:27 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: DBD::CSV (was Re: complaint about moderation of this group )
Message-Id: <9b0b5j$j48$0@216.155.33.76>
In article <9avr6j$9p8$4@plutonium.btinternet.com>,
Jonathan Stowe <gellyfish@gellyfish.com> wrote:
| Scott R. Godin <webmaster@webdragon.unmunge.net> wrote:
| >
| > I've been attempting to get some answers to a
| > DBD::CSV problem I'm having where a program is generating around 7300
| > "use of uninitialized value" warnings into the ISP weblogs every time
| > the .cgi gets hit.
| >
|
| Then fix the values so they arent uninitialized any longer.
You would think that would be the answer wouldn't you? The data is a
text file of some 3700 records, and each field is filled. (I've looked)
.. as near as I can tell, there ARE no uninitialized values in the data
itself. It's too bad the diagnostic messages don't give more info -- I
could at least nail it down to a variable then. The warning is coming
from the module, not my code, but looking at the section of code
claiming to be generating the warning turns up no clues either.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Wed, 11 Apr 2001 16:49:05 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Default arguments to commands/functions?
Message-Id: <gXSA6.865$482.4147@newsfeeds.bigpond.com>
Good morning guys (and Abigail).
Is there a definitive list of what functions take default arguments?
I'm trying to upgrade my Perl skills from Apprentice to Guru.
Some that some to mind are:
while( <> ) {}
$value =~ s/"/\\"/g;
for (@_) { }
if (/^[-+]/) {}
gtoomey
------------------------------
Date: 11 Apr 2001 01:50:25 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: format/write
Message-Id: <9b0d91$nqm$0@216.155.33.76>
anyone have a handly link around to some more in-depth tutorials on the
format/write combination than what I can find in perldoc and the Camel?
I'm specifically looking for variety in examples. i.e. "different ways
of looking at a problem" and using format to generate the output.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Tue, 10 Apr 2001 18:05:26 -0700
From: Bryan Coon <bcoon@sequenom.com>
Subject: I'm in TrueType GD hell... Help!
Message-Id: <3AD3ADD6.68D2B297@sequenom.com>
Has anyone successfully complied GD.pm with TrueType support?
I desperately need the GD::Text::Align->draw() method (among other
thing), and according to the authors note, drawing text at angles on my
image object requires TrueType font support (which makes sense).
So after looking at all the documentation I could find, heres what I
did:
compiled and installed freetype-2.0.1, no problem with compilation and
installation of libs.
compiled and installed gd-2.0.1, no problem with compilation and
installation of libgd, test worked fine.
compiled GD.pm (v. 1.33) okay, but it croaks on test with the following
error:
PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib
-I/usr/lib/lib/perl5/5.6.1/i686-linux -I/usr/lib/lib/perl5/5.6.1 -e 'use
Test::Harness qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
t/GD................Can't load './blib/arch/auto/GD/GD.so' for module
GD: undefined symbol: FT_New_Face at
/usr/lib/lib/perl5/5.6.1/i686-linux/DynaLoader.pm line 206.
at t/GD.t line 11
Compilation failed in require at t/GD.t line 11.
BEGIN failed--compilation aborted at t/GD.t line 11.
t/GD................dubious
Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 1-10
Failed 10/10 tests, 0.00% okay
Ack! This is on a RH7 box, can anyone help?
Thanks,
Bryan
------------------------------
Date: 11 Apr 2001 06:25:52 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: inheritance within one file?
Message-Id: <slrn9d7u8f.n9l.rgarciasuarez@rafael.kazibao.net>
Abigail wrote in comp.lang.perl.misc:
} Uri Guttman (uri@sysarch.com) wrote on MMDCCLXXIX September MCMXCIII in
} <URL:news:x7zodoo5rt.fsf@home.sysarch.com>:
} ||
} || exporting constants makes sense but i would be careful about exporting
} || constructors. typical perl object constructors expect their first
} || argument to be a class or an object. that is provided by the director
} || indirect method call of the constructor. but if the constructor sub is
} || exported and you have to be explicit about passing in that argument. you
} || could have the constructor not need the argument as it knows what class
} || it is in but that is not common OO perl style.
}
} I was more thinking something like:
}
} use Exporter;
}
} @EXPORT = qw /constructor/;
}
} sub new {
} ... yada, yada, yada ...
} bless $obj => $class;
} }
}
} sub constructor {
} __PACKAGE__ -> new (@_)
} }
}
} Inheritors can call new(), or SUPER::new(), users can call constructor().
First time I see this idiom.
I thought you were talking about 'static constructors' (factories).
Useful also to implement singletons (classes that have only one
instance) :
our $instance = undef;
sub _new {...}
sub instance {
$instance = __PACKAGE__->_new(@_) if not defined $instance;
$instance;
}
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
package Just; sub import { print "@_,\n"; }
package main; BEGIN { %INC = ('Just.pm') } use Just qw/another Perl hacker/;
------------------------------
Date: Wed, 11 Apr 2001 00:12:23 -0500
From: "Enrico Ng" <ng@fnmail.com>
Subject: LWP - HTTPS
Message-Id: <9b0p7n$cqg$1@newsx.cc.uic.edu>
I want to use LWP to get a https page.
when I use get, I get nothing, I am assuming this is because of https
does anyone know what option I need to use to get it to work?
--
Enrico Ng <ng@fnmail.com>
------------------------------
Date: Wed, 11 Apr 2001 01:04:05 -0500
From: "Enrico Ng" <ng@fnmail.com>
Subject: Re: LWP - HTTPS
Message-Id: <9b0s8m$e7s$1@newsx.cc.uic.edu>
I get the error message
501 Protocol scheme 'https' is not supported
--
Enrico Ng <ng@fnmail.com>
"Enrico Ng" <ng@fnmail.com> wrote in message
news:9b0p7n$cqg$1@newsx.cc.uic.edu...
> I want to use LWP to get a https page.
> when I use get, I get nothing, I am assuming this is because of https
> does anyone know what option I need to use to get it to work?
>
> --
> Enrico Ng <ng@fnmail.com>
>
>
------------------------------
Date: 11 Apr 2001 08:54:19 +0200
From: Walter Hafner <hafner-usenet@ze.tu-muenchen.de>
Subject: Re: Need 2 cgi scripts -- for trade?
Message-Id: <srj8zl8hqp0.fsf@w3proj1.ze.tu-muenchen.de>
abigail@foad.org (Abigail) writes:
> chris_severn@chernay.com (chris_severn@chernay.com) wrote on MMDCCLXXIX
> September MCMXCIII in <URL:news:9av9ft$jjn$1@news.netmar.com>:
> ()
> () Greetings,
> ()
> () i am looking for 2 cgi scripts.
>
> Then why are you looking here? Or do you repeat this post in every
> language group?
>
> Try alt.gimme.gimme.gimme
Come on, be fair.
He offered some kind of payment for the scripts. While this is unusual,
you can see it as some kind of job advert ... which reminds me of
another endless thread ... :-)
-Walter
------------------------------
Date: Wed, 11 Apr 2001 02:53:03 -0400
From: Jason Goodrow <"goodrow"@opencity. com>
Subject: Newbie hash vs files database??
Message-Id: <9b0uta$3ph$1@news.panix.com>
Hi newsgroup, newbie here -
I got involved with a really large database - lots of entries of 20
variable length fields.
When the fields were static I was using a flat file and seeking the
records but now they're going to change so updates
get complicated.
I'm thinking of using hashes - one for each entry. I would then have a
directory with
10k of hashes. Or seperate text files that I split for the fields and a
directory with 10k text files.
Am I abusing the unix directory structure with this many entries?
These entries will mostly just sit there with flurries of activity so is
either strategy easier
on the CPU?
thanks in advance,
goodrow@panix.com
------------------------------
Date: Tue, 10 Apr 2001 22:01:03 -0700
From: A_Geekette <moiraine@qwest.net>
Subject: Re: perl hacker wanted
Message-Id: <3AD3E50F.994CF30F@qwest.net>
Jonathan Stowe wrote:
> A_Geekette <moiraine@qwest.net> wrote:
<snip>
> > 3) I'm idealistic.
> I'm cynical.
I said idealistic not optimistic or happy-go-lucky. I'm cynical as well.
> > 4) I don't make a lot of money.
> I take home buckets of money.
Great.
<snip>
> > 6)
<snip rant>
> Sorry, lost you there.
Well...it happens.
Like I said...cynical. I also talk a lot which is why I'm in the site
stats....hehe.
> > 7) Can I blame it on PMS?
> Dunno, can you ?
There're so many rules to this group. People keep pointing those rules out to me
instead of paying attention to the point. I thought I'd ask this time.
> > 8) I'm too impatient to read and too rebelious to follow (some) rules, but...
> Oh Bollocks.
Oh...you know me so well. You're right. I was lying.
> *PLONK*
Sure.
> Jonathan Stowe
--
Geekette
"Try Not. Do or do not. There is no try."
-If you don't know who said this,
I don't want to talk to you. ;-)
"Nothing is impossible, no matter how improbable."
-Anonymous
------------------------------
Date: Wed, 11 Apr 2001 04:26:13 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl Timer!
Message-Id: <slrn9d7n72.8hd.tjla@thislove.dyndns.org>
I was shocked! How could Abigail <abigail@foad.org>
say such a terrible thing:
>Chris Stith (mischief@velma.motion.net) wrote on MMDCCLXXIX September
>MCMXCIII in <URL:news:td74urrcfuodd9@corp.supernews.com>:
>:) Hernux <hernux@etherac.com.ar> wrote:
>:) > Hi, is there a way to make a timer in perl???
>:)
>:) > like settimeout function in javascript.......
>:)
>:) I don't grok javascript. Ar eyou looking for time(), localtime(),
>:) gmtime(), sleep(), alarm(), select(), POSIX::alarm(), POSIX::ctime(),
>:) POSIX::difftime, POSIX::gmtime(), POSIX::localtime(), POSIX::mktime(),
>:) or POSIX::pause()? Or perhaps Time::HiRes on CPAN?
>
>Perhaps he wanted Time::Local.
Or Benchmark::timethese()?
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
QOTD:
"My life is a soap opera, but who gets the movie rights?"
------------------------------
Date: Wed, 11 Apr 2001 04:29:31 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Private subroutine inside subroutine
Message-Id: <slrn9d7nd8.8hd.tjla@thislove.dyndns.org>
I was shocked! How could Brian E. Lavender <brian@brie.com>
say such a terrible thing:
>
>I created a private subroutine inside another subroutine. Rather than
>pass the variables to the private subroutine, I made them visible to
>the private subroutine using local. Is this good coding practice? I am
>still don't completely understand local, but it appears it is making
>$arg2 visible to any block inside outer. Here's my sample chunk of code.
I would say not. If you have to ask what local() does, you shouldn't be
using it. It honestly doesn't do what you think it does. You probably
want to use my(). And remove the 'use vars qw();' bit.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Confucious say:
passionate kiss like spider web, lead to undoing of fly.
------------------------------
Date: Wed, 11 Apr 2001 01:35:08 GMT
From: sjs@linux.ca (Steven Smolinski)
Subject: Re: registration script
Message-Id: <slrn9d7i6n.1m5.sjs@ragnar.stevens.gulch>
Atayarani <amazingkgb@earthlink.net> wrote:
[...the last in a series of posts that seem to miss the point...]
You started this thread with the usual 500 Server Error refrain, showed
no real sign of having read the entry in perlfaq9, then seemingly
ignored a couple of people's advice to run the script from the command
line and debug that, as well as pointers to other documents. And then
you post single-sentence posts which don't help anyone understand your
problem more, or are just plain wrong.
So far, no a very effective strategy for getting peer help on clpm.
Good luck to you, I've tried.
\begin{offtopic}
> Nothing wrong with the page itself, after submitting there were
> issues, but it was solved by changing the case of a few sections
Actually, the HTML really is non-compliant in ways that have nothing to
do with case, and which I detailed in my last post. Because of this,
your Perl program may never see the values you expect. And
http://validator.w3.org/ agrees with me.
\end{offtopic}
Steve
--
Steven Smolinski => http://www.steven.cx/
------------------------------
Date: Wed, 11 Apr 2001 03:26:01 GMT
From: "Roman Filippov" <NO_SPAM_klubbheads@home.com>
Subject: Re: save a value of a variable between subroutines run... (++)
Message-Id: <d9QA6.203208$A6.45069648@news4.rdc1.on.home.com>
"Uri Guttman" <uri@sysarch.com> wrote in message
news:x7bsq5ptls.fsf@home.sysarch.com...
> >>>>> "RF" == Roman Filippov <NO_SPAM_klubbheads@home.com> writes:
>
> RF> I am not sure if it's possible...
>
> it is.
>
> RF> I need to save the value of a localized variable in the
> RF> function. By localized I mean - it is not accessable from the rest
> RF> of the program. It can be "my" or "local", i don't know... Here is
>
>
> {
> my $foo ;
>
> sub bar {
>
> return ++$foo ;
> }
> }
>
> uri
>
> --
I am sorry, Uri. I missunderstood you. Thank you for help. :)
> Uri Guttman --------- uri@sysarch.com ----------
http://www.sysarch.com
> SYStems ARCHitecture and Stem Development ------
http://www.stemsystems.com
> Learn Advanced Object Oriented Perl from Damian Conway - Boston, July
10-11
> Class and Registration info:
http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Tue, 10 Apr 2001 22:31:48 -0500
From: "Chris Bell" <cbell@interlog.com>
Subject: Sort by a given field alphabetically - help :)
Message-Id: <znPA6.44413$9O3.1244285@news.total.net>
I had a quick fix stored somewhere, but alas I cannot find it...
I simply want to sort Field[4] alphabetically
Can u help?
foreach $Ad (@Ads) {
@Field = split (/\t/, $Ad);
if (($Field[0] ne "") {
$Match = 1;
$AdFile[$Count1] = $Ad;
$Count1++;
{&data_display}
}
}
sub data_display {
print qq! $Field[0], $Field[1], $Field[2], $Field[3], $Field[4],
$Field[5]<BR> \n!;
}
------------------------------
Date: 11 Apr 2001 04:22:06 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Sort by a given field alphabetically - help :)
Message-Id: <slrn9d7mt6.398.damian@puma.qimr.edu.au>
Chris Bell chose Tue, 10 Apr 2001 22:31:48 -0500 to say this:
>...
>I simply want to sort Field[4] alphabetically
>
Sorry, this doesn't make much sense -- you are only assigning a scalar
value to that array element. Do you mean you want the array @Ads to be
sorted alphabetically by that field?
If so, this is a FAQ -- see:
perldoc -q sort
"How do I sort an array by (anything)?"
>Can u help?
Probably, but not nearly as much as you can help yourself by reading the
docs.
HTH,
Cheers,
Damian
--
@:=grep!($;+=m!$/|#!),split//,<DATA>;@;=0..$#:;while(@;){for($;=@;;--$;;){;(
$:=rand$;+$|)==$;&&next;@;[$;,$:]=@;[$:,$;]}push@|,shift@;if$;[0]==@|;select
$,,$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker # rev 3 -- a JAPH in progress, I guess...
------------------------------
Date: 10 Apr 2001 21:07:48 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: THANK YOU & FINAL CODE
Message-Id: <m3wv8s5jmj.fsf@mumonkan.sunstarsys.com>
"Roman Filippov" <NO_SPAM_klubbheads@home.com> writes:
> "Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
> news:m31yr076ro.fsf@mumonkan.sunstarsys.com...
> > > sub parse {
> > > my %cache if 0;
> > ^^^^^^^^^^^^^^^^
> > *Don't* use this in real code- and especially not without a comment.
> > It's an unsupported parlor trick and I apologize for encouraging you
> > to use it in your program. From
> >
>
> I thought you said it was not a bug, and nobody is going to fix it, so I
> figured that I could use it. Well, if you say that I should not, then I
> better not.
Simply put, I misremembered the discussion, and so my characterization
of it was misleading. After rereading the p5p thread, my impression is
that the perl developers concluded that they don't want to support that
code's behavior. It's an artifact of a compile-time optimization within
the current implementation of perl5 (the executable).
To my mind, that means they may want change the optimizer which could
change the behavior of that piece of code (and hence breaking your
program if you use it). The p5p discussion I'm summarizing is a
link in the url-
> > http://www.perl.com/pub/2000/05/p5pdigest/THISWEEK-20000521.html
[...]
> >
> > If this is anything more than a throwaway script, it would be far
> > better to write it correctly:
> >
> > {
> > my %cache;
>
>
> As far as I understand - you defined %cache before the actual sybrouting. It
> means that I will have to define it just in the begining of the code, is it
> right?
All you need to do is wrap your subroutine inside a bare {..} block and
put "my %cache;" at the front of the block. You shouldn't need to move
anything else around.
That's the syntax Uri and others suggested a few posts ago. You can read
more about it in "Persistent Private Variables" section of perlsub. See
% man perlsub
for details.
HTH
--
Joe Schaefer "Thought is only a flash between two long nights, but this flash
is everything."
-- Henri Poincare
------------------------------
Date: Wed, 11 Apr 2001 04:26:44 +0200
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: Why does DynaLoader fail?
Message-Id: <3ae8c08b.48451509@news.bjoern.hoehrmann.de>
* Steve K. Brown wrote in comp.lang.perl.misc:
>I received the following error:
>
>Can't load '/usr/local/bin/perl5/lib/5.00503/PA-RISC1.1/auto/IO/IO.sl'
>for module IO: Permission denied at
>So the question is why?
What isn't clear about that?
--
Björn Höhrmann ^ mailto:bjoern@hoehrmann.de ^ http://www.bjoernsworld.de
am Badedeich 7 ° Telefon: +49(0)4667/981028 ° http://bjoern.hoehrmann.de
25899 Dagebüll # PGP Pub. KeyID: 0xA4357E78 # http://learn.to/quote [!]e
-- listen, learn, contribute -- David J. Marcus
------------------------------
Date: Tue, 10 Apr 2001 19:55:40 -0500
From: "Itexas" <cernava@itexas.net>
Subject: Re: Why is finish() necessary here with DBI? Bug in DBD::ODBC?
Message-Id: <9b0g7e0paf@enews2.newsguy.com>
<From http://const.icm.re.kr/Oracle-perl/DBI-Ref/finish.txt>
finish
$rc = $sth->finish;
Indicates that no more data will be fetched from this
statement handle before it is either executed again or
destroyed. It is rarely needed but can sometimes be
destroyed. It is rarely needed but can sometimes be
helpful in order to allow the server to free up
resources currently being held (such as sort buffers).
When all the data has been fetched from a select
statement the driver should automatically call finish
for you. So you should not normally need to call it
explicitly.
Consider a query like
SELECT foo FROM table WHERE bar=? ORDER BY foo
where you want to select just the first (smallest) foo
value from a large table. When executed the database
server will have to use temporary buffer space to store
the sorted rows. If, after executing the handle and
selecting one row, the handle won't be re-executed for
some time or not at all, the finish method can be used
to tell the server that the buffer space can be freed.
Calling finish resets the the Active entry elsewhere in
this document attribute for the statement. It may also
make some statement handle attributes, like NAME and
TYPE etc., unavailable if they have not already been
accessed (and thus cached).
The finish method does not affect the transaction status
of the session. It has nothing to do with transactions.
It's mostly an internal 'housekeeping' method that is
rarely needed. There's no need to call finish if you're
about to destroy or re-execute the statement handle.
See also the disconnect entry elsewhere in this document
and the the Active entry elsewhere in this document
attribute.
</from>
Richard.
------------------------------
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:
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.
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 V10 Issue 672
**************************************