[11343] in Perl-Users-Digest
Perl-Users Digest, Issue: 4943 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 19 17:07:34 1999
Date: Fri, 19 Feb 99 14:00:31 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 19 Feb 1999 Volume: 8 Number: 4943
Today's topics:
Re: can I run perl on Win 98?????? <davemck@cgocable.net>
Re: DEMO: dynamic scoping and typeglob trickery (Ilya Zakharevich)
Re: DEMO: new qr// operator (Ilya Zakharevich)
Re: efficient , -> TAB substitution? <kenhirsch@myself.com>
Re: Encrypting then Decrypting a Password? <akalnins@ford.com>
EXCUSE ME!!! <curweb@cur.org>
Executing a Program <nullspace@hotmail.com>
Re: FAQ 5.17: How can I lock a file? (Ilya Zakharevich)
Re: FAQ 5.29: How do I close a file descriptor by numbe (Ilya Zakharevich)
FAQ 8.22: Why do setuid perl scripts complain about ker <perlfaq-suggestions@perl.com>
FAQ 8.23: How can I open a pipe both to and from a comm <perlfaq-suggestions@perl.com>
Re: FAQ 8.3: How do I do fancy stuff with the keyboard/ (Ilya Zakharevich)
Re: FAQ 8.7: How do I clear the screen? (Ilya Zakharevich)
Re: FMTEYEWTK: Sorting <kenhirsch@myself.com>
Re: FMTEYEWTK: Switch Statements <bmb@ginger.libs.uga.edu>
Getopt::Std with perl 5.00402 (WinNT) problem <voorhees@sdd.hp.com>
grabbing websites with time limit? <arudnick@inet.net>
HELP me with flock please!! msztipan@bellsouth.net
Installation Errors <scott.ranzal@mci.com>
metasearch msfruch@banet.net
Re: metasearch (Clay Irving)
Re: NEWBIE: Uninitialized value problem scraig@my-dejanews.com
Re: perl compiled code cacheing (Sam Curren)
Re: Perl evangelism (Randal L. Schwartz)
Re: Perl evangelism (Sam Curren)
Re: Perl flock question droby@copyright.com
Re: Perl tutorials?? <davemck@cgocable.net>
Re: Printing all environment variables latsharj@my-dejanews.com
Re: Printing all environment variables (Christian M. Aranda)
Re: Search engine <arudnick@inet.net>
Re: SSI question? <emschwar@mail.uccs.edu>
Re: String Manipulation (yet another newbie question) (Larry Rosler)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 19 Feb 1999 15:36:59 -0500
From: "Dave Mckeown" <davemck@cgocable.net>
Subject: Re: can I run perl on Win 98??????
Message-Id: <36cdcb27.0@news.cgocable.net>
yes you can
--
Net-Studios, full service website hosting and design.
Website URL: http://www.net-studios.com
Need Web hosting?: http://www.net-studios.com/hosting/
Contact me : dave@net-studios.com
<t_alter@hotmail.com> wrote in message
news:7akdfb$4p8$1@nnrp1.dejanews.com...
>Hi everybody;
>I am starting to learn perl. Can I do it with my Win98 PC?
>I have been informed that I will have to go for Either UNIX or WinNT for
that.
>
>Please drop an email at t_alter@hotmail.com
>
>Thanks a million.
>
>Tom
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 19 Feb 1999 21:18:20 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: DEMO: dynamic scoping and typeglob trickery
Message-Id: <7akkes$8kf$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <36cc71f4@csnews>:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc, gward@cnri.reston.va.us (Greg Ward) writes:
> :> defined $id{$id} ? $id{$id} : ($id{$id} = id);
> :
> :Shouldn't that be either "&id" or "id()"? As it stands, it gets
> :compiled as a bareword, and the script's output is
>
> That's right. It should be &id. The darn compiler refuses
> to count it as a function until it's done compiling it. This
> always tricks me.
And it is hard to warn in such a situation, since this is a "normal
practice" to use this misfeature to override a builtin with the same
name...
Hmm, looks like I'm lost: the override will not happen without a `sub'
directive or import, right? So what is the purpose of this "feature"?
Why not "mandatory" warn about this (now when we can switch off warnings)?
Ilya
------------------------------
Date: 19 Feb 1999 21:24:06 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: DEMO: new qr// operator
Message-Id: <7akkpm$8qt$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Randal L. Schwartz
<merlyn@stonehenge.com>],
who wrote in article <m14soj1jlz.fsf@halfdome.holdit.com>:
> Ilya> And I repeat: there should be no need to use qr// in such simple
> Ilya> contexts.
> Ilya> print $line if $line =~ /$pat/;
> Ilya> *should* cache the results of compilation - behind the scenes (say, to
> Ilya> speed up old programs, *and* to simplify new ones). A 3-line patch
> Ilya> which implemented this is available on p5p archives.
>
> But when would the cache be freed?
When the $pat's are free()ed.
> With qr//, I can "manage a cache"
> myself. Think "mod_perl" and other long-living applications.
This is a relevant remark. However, note that Perl *always* trades
space for speed. If there is a tiny chance that the memory might be
requested again at the same spot, it is not free()ed.
I see no point in having RExen behave differently.
Ilya
------------------------------
Date: Fri, 19 Feb 1999 16:13:53 -0500
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: efficient , -> TAB substitution?
Message-Id: <7akk6d$t1v$1@fir.prod.itd.earthlink.net>
Robert D Trent wrote in message ...
...
>Another interesting thing... The original files have a little more than 2
>null characters per line which get stripped out by the sed approach. perl
>leaves them in - the output file is the exact same size as the input. I
>don't think they're causing any harm, just thought it odd there was a
>difference.
Perl keeps nulls and any other characters on purpose. Many older Unix text
programs use C null-terminated strings for each line. Either nulls have to
be deleted or anything past the null is lost.
If you want to delete the nulls at the same time, you can:
perl -pi.bak -e 's/","/"\t"/g; s/\0//g;' filename
or
perl -pi.bak -e 's/","/"\t"/g; tr/\0//d;' filename
On a very pedantic note, in the unlikely case that you have a field that
consists of just a comma, your program will replace that with a tab.
Unfortunately there is no fast program that will work correctly in this
case.
Ken Hirsch
Carrboro, NC
------------------------------
Date: Fri, 19 Feb 1999 16:26:13 -0500
From: Atis Kalnins <akalnins@ford.com>
Subject: Re: Encrypting then Decrypting a Password?
Message-Id: <36CDD6F5.5A2A354@ford.com>
Why try to crypt it? Even if you could, you would be still passing the
file back into the SQL system. It isn't like someone else couldn't do the
same thing?
-jk
Mike Skimin wrote:
> Hello All,
>
> Please excuse my ignorance on this.
>
> I have a Perl program that connects to a MySQL Database. In order
> for the connection to work I must put in my admin password, in non
> encrypted form in the script.
>
> This frightens me a little. Is there a way I can put an encrypted
> password in the script then have the script decrypt it so when it is
> passed to MySQL it is the correct password. Thus never having my admin
> password in plan form?
>
> I kind of understand the crypt function but can't figure out how to
> go from a crypt password back to normal.
>
> Any and all help is appreciated.
>
> --
> Mike Skimin, Webmaster
> Emerge Inc.
> http://www.EmergeInc.com
> http://www.LorainCounty.com
------------------------------
Date: Fri, 19 Feb 1999 15:18:28 -0500
From: "Christopher Pieper" <curweb@cur.org>
Subject: EXCUSE ME!!!
Message-Id: <7akgos$20j$1@news1.Radix.Net>
Ok, the mass emailing is to notify our Members that the online ballots are
up and asks them to vote. This is not just some random email being sent to
just anyones. It is just being sent to our members that are in our database.
however when dealing with a database of 25000 members you are bound to have
a few bad email's, try a few hundred. So I was wondering if there was a way
I could search or rather gather all the returned emails into a list so I can
drop those email addresses from the database.
My question wasn't mean't to offend anyone, it was just a question for help,
I am actually surprised that i got such a response, being that I thought the
whole purpose of this group is to help others.
Christopher M. Pieper
curweb@cur.org
Council On Undergraduate Research
Clinton Pierce wrote in message <36ce8451.343812559@news.ford.com>...
>On Fri, 19 Feb 1999 09:53:35 -0500, "Christopher Pieper"
><curweb@cur.org> wrote:
>
>> [potential spamming scheme]
>> Is this at all possible
>
>Probably.
>
>> or am I just asking for too much here?
>
>No, you're asking the wrong crowd. Nobody likes a spammer, and so far
>you've walked like one, talked like one...
>
>Try asking abortion questions in soc.women, you'll get a friendlier
>response.
>
------------------------------
Date: Fri, 19 Feb 1999 16:48:12 -0400
From: "nullspace" <nullspace@hotmail.com>
Subject: Executing a Program
Message-Id: <7akil1$j5a$1@News.Dal.Ca>
Hi,
I'm trying to write a script that looks something like this (in chuncks):
1)Writes two values to a file
2)Run a complied program from inside the script by calling it(it accesses
the above file)
3)Reads an outfile that the program creates back into the script for
manipulation.
So far, I can do (1) and (3) but I'm having trouble with the code for
running the compiled program from my script. I thought it was the exec("
/test/a.out & ") command. It works to a point. The program runs but anything
after that call in my perl script doesn't get reached. I thought that there
must be a way to find out if a.out has finished but I just don't know the
proper code. Any help would definitely be appreciated. Thanks!!
Chris
------------------------------
Date: 19 Feb 1999 21:34:19 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: FAQ 5.17: How can I lock a file?
Message-Id: <7aklcr$973$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <36cc80bc@csnews>:
> : 4 On some systems locking files is advisory only.
>
> Perl locking is defined to be advisory only.
This is a blatant lie. And if it were defined so, it would be a
blatant lie too, since on many platforms (excluding MacOS and similar
poorly designed platforms) flock() it is mandatory.
> This is obviously more powerful, because with advisory locking you
> can implement things that with mandatory locking you cannot.
Sorry to disappoint you, but the situation is exactly the opposite.
To emulate advisory locks just lock some other file.
Btw, anybody knows why the guys who gave us fork()/exec() paradigm (so
they clearly *thought* about multiprocessing) did not think about file
locking? Did they think about multiprocessing at all? I would think
that mainframes people had resolved these issues long time before *nix?
Ilya
------------------------------
Date: 19 Feb 1999 21:39:57 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: FAQ 5.29: How do I close a file descriptor by number?
Message-Id: <7aklnd$9d3$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<perlfaq-suggestions@perl.com>],
who wrote in article <36cca1e3@csnews>:
> How do I close a file descriptor by number?
>
> This should rarely be necessary, as the Perl close() function is to be
> used for things that Perl opened itself, even if it was a dup of a
> numeric descriptor, as with MHCONTEXT above. But if you really have to,
> you may be able to do this:
>
> require 'sys/syscall.ph';
> $rc = syscall(&SYS_close, $fd + 0); # must force numeric
> die "can't sysclose $fd: $!" unless $rc == -1;
Why not do (an equivalent of)
{ local *F; open F, "<&=$fd" or die "Cannot reopen fd=$fd for read" }
(I suppose that $fd is opened for read)?
Ilya
------------------------------
Date: 19 Feb 1999 13:34:23 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 8.22: Why do setuid perl scripts complain about kernel problems?
Message-Id: <36cdcacf@csnews>
(This excerpt from perlfaq8 - System Interaction
($Revision: 1.36 $, $Date: 1999/01/08 05:36:34 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq8.html
if your negligent system adminstrator has been remiss in his duties.)
Why do setuid perl scripts complain about kernel problems?
Some operating systems have bugs in the kernel that make setuid scripts
inherently insecure. Perl gives you a number of options (described in
the perlsec manpage) to work around such systems.
--
"Software is like sex: It's better when it's free." (Linus Torvalds, from
FSF T-shirt)
------------------------------
Date: 19 Feb 1999 14:34:26 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 8.23: How can I open a pipe both to and from a command?
Message-Id: <36cdd8e2@csnews>
(This excerpt from perlfaq8 - System Interaction
($Revision: 1.36 $, $Date: 1999/01/08 05:36:34 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq8.html
if your negligent system adminstrator has been remiss in his duties.)
How can I open a pipe both to and from a command?
The IPC::Open2 module (part of the standard perl distribution) is an
easy-to-use approach that internally uses pipe(), fork(), and exec() to
do the job. Make sure you read the deadlock warnings in its
documentation, though (see the IPC::Open2 manpage). See the section on
"Bidirectional Communication with Another Process" in the perlipc
manpage and the section on "Bidirectional Communication with Yourself"
in the perlipc manpage
You may also use the IPC::Open3 module (part of the standard perl
distribution), but be warned that it has a different order of arguments
from IPC::Open2 (see the IPC::Open3 manpage).
--
"Even egotists are allowed to have opinions." --Larry Wall
------------------------------
Date: 19 Feb 1999 21:46:29 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: FAQ 8.3: How do I do fancy stuff with the keyboard/screen/mouse?
Message-Id: <7akm3l$9kl$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<perlfaq-suggestions@perl.com>],
who wrote in article <36ccf7f2@csnews>:
> Mouse
> Tk CPAN
>
> Some of these specific cases are shown below.
Anybody having useful snippets for mouse with Curses.pm (assuming
ncurses, of course)?
Ilya
------------------------------
Date: 19 Feb 1999 21:49:17 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: FAQ 8.7: How do I clear the screen?
Message-Id: <7akm8t$9nd$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Marc-A. Woog
<mwoog@gmx.net>],
who wrote in article <36cd6efb.18847139@news.datacomm.ch>:
> On 19 Feb 1999 02:34:50 -0700, Tom Christiansen
> <perlfaq-suggestions@perl.com> wrote in <36cd303a@csnews>:
>
> > How do I clear the screen?
> >
> > If you only have to so infrequently, use `system':
> >
> > system("clear");
>
> For us (WIN)DOSlers: system("cls").
I do not think this is portable enough. Say, EMX port will not call
shell commands without explicitly specifying the shell, like
system("cmd /c cls");
Ilya
------------------------------
Date: Fri, 19 Feb 1999 15:49:33 -0500
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: FMTEYEWTK: Sorting
Message-Id: <7akiop$qp9$1@fir.prod.itd.earthlink.net>
Tom Christiansen wrote:
>(This document is part of the FMTEYEWTK series at
>http://language.perl.com/doc/FMTEYEWTK/ )
> Far More Than Everything You've Ever Wanted to Know About Sorting
...
You're missing a 't' in this line:
>It's true tha this is verging on the inscrutable, but we're trying to get
>closer to Randal's obfuscated perl entry he presented way at the beginning
>of this.
...
>Now, it turns out that in this case it actually works, at least on my
>system. I wrote all my input do the pipe first, which gladly read it all in
>up until end of file, and then spit it out. That's how sort work. But cat
>isn't so friendly, and works far more like most programs.
You're missing an 's' on "work".
More importantly, I've always thought that you were too discouraging about
_open2_ here. This IS the perfect use for open2--almost the only use--and
it must work as long as you close OUTPUT before you read INPUT, not just on
your system but on any system where pipes and sort function correctly.
Ken Hirsch
Carrboro, NC
------------------------------
Date: Fri, 19 Feb 1999 15:33:37 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: FMTEYEWTK: Switch Statements
Message-Id: <Pine.A41.4.02.9902191531160.62124-100000@ginger.libs.uga.edu>
Sure, but why doesn't Perl have a switch statement? >:-)
-Brad
On 19 Feb 1999, Tom Christiansen wrote:
> So, anybody read this far? :-)
>
> --tom
> --
> "If ease of use is the highest goal, we should all be driving golf carts."
> --Larry Wall
--
"Beauty lies in the hand of the beer holder" --I forget
------------------------------
Date: Fri, 19 Feb 1999 12:09:44 -0800
From: "Joseph T. Voorhees III" <voorhees@sdd.hp.com>
Subject: Getopt::Std with perl 5.00402 (WinNT) problem
Message-Id: <36CDC508.5039@sdd.hp.com>
I can't seem to get perl to recognize any options that I
pass to it or to even get it to acknowledge that I'm passing
arguements to [this excerpt of] the following code. Any ideas?,
I'm probably missing something obvious (I'm used to UNIX, and
am trying to port this to Windows NT.).
Thanx-in-advance,
Joe
voorhees@sdd.hp.com
#!perl -w
use strict;
use Socket;
use Getopt::Std;
use vars qw($opt_c $opt_d $opt_h $opt_r);
getopts('dhrc:');
if (defined $opt_h || $#ARGV<0) { &help; }
my $config_file;
if (defined $opt_c) {
$config_file = $opt_c;
} else {
(!$ENV{'JZCONFIG'}) ?
($config_file = ($ENV{'HOME'}.'/.jzconfig')) :
($config_file = $ENV{'JZCONFIG'});
}
if ($opt_d) {
print STDOUT "\nCONFIGURATION FILE: $config_file";
}
if (!-e $config_file) {
print STDOUT "\n\nConfiguration file $config_file doesn't
exist.\n";
&help;
}
if (!-r $config_file) {
print STDOUT "\n\nConfiguration file $config_file is
unreadable.\n";
&help;
}
my ($proxy_server, $proxy_omit) = &get_config;
while ($_ = shift @ARGV) {
&fetch_url($_, $opt_d, $opt_r);
}
exit(0);
------------------------------
Date: Fri, 19 Feb 1999 15:19:42 -0500
From: "Adam Rudnick" <arudnick@inet.net>
Subject: grabbing websites with time limit?
Message-Id: <36cdc946.0@news.inet.net>
I am grabbing sites from the web with perl, but when a server is up but too
slow to respond the script just hangs and waits. Is there a way to provide
a limit to the amount of time the attempt to grab the site may take?
------------------------------
Date: Fri, 19 Feb 1999 21:21:29 GMT
From: msztipan@bellsouth.net
Subject: HELP me with flock please!!
Message-Id: <7akkkd$bfr$1@nnrp1.dejanews.com>
Hello,
I am trying to write a working file locking example between a
couple of process on one file system.
anyway I have written this simple thing and I do not understand
why flock allows both locks??
#if ($ARGV[0] =~ /lock/) {
# open FH, "./testdb";
# my $FH_ref = \*FH;
# print "locking ..\n";
# if (flock(FH, 2) == 0) {
# print scalar localtime, " trying second lock ...\n";
# if (flock(FH, 2) == 0) {
# print " .... GOT second lock.\n";
# }
# else {
# print " .... COULD NOT GET second lock\n";
# }
# }
# else {
# print "COULD NOT LOCK b/c: $!\n";
# }
# print scalar localtime, " removing lock ..\n";
# close(FH);
#}
this gives me:
locking ..
Fri Feb 19 16:27:32 1999 trying second lock ...
.... GOT second lock.
Fri Feb 19 16:27:32 1999 removing lock ..
WHY?? why does it give me the second lock as well?
am I missing something ?
if you know could you let me know at msztipan@bellsouth.net
thanks so much
--Mate'
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 19 Feb 1999 21:25:31 GMT
From: "Scott Ranzal" <scott.ranzal@mci.com>
Subject: Installation Errors
Message-Id: <fFkz2.194$DG2.80592@PM01NEWS>
Trying to install Perl5.005_02 on a SCO Unix Release 3.2. I am able to get
through all the default options and then when I run make I hit problems.
cc my way through things and then I get to:
cc miniperl miniperlmain.o libperl.a and it comes up with
undefined first referenced
symbols in file
atan2 libperl.a
cos libperl.a
exp libperl.a
log libperl.a
sqrt libperl.a
... libperl.a
ld fatal: Symbol referencing errors. No output written to miniperl
*** Error code 13
#
I am defintely not a compiler expert(in fact very new to compiling on Unix
systems). Seems like it wants to find something and can't.
What steps should I take to get Perl compiled on this system ?
Thanks for any and all help.
Scott Ranzal
scott.ranzal@mci.com
# (415)-544-0508
------------------------------
Date: Fri, 19 Feb 1999 16:05:55 +0000
From: msfruch@banet.net
Subject: metasearch
Message-Id: <36CD8BE3.7991EB0D@banet.net>
Hi,
does anyone know where I might find a metasearch script to search
multiple search engines? I've searched and searched but haven't found
any...
Thanks in advance,
-Marc
------------------------------
Date: 19 Feb 1999 16:19:04 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: metasearch
Message-Id: <7akkg8$kav$1@panix.com>
In <36CD8BE3.7991EB0D@banet.net> msfruch@banet.net writes:
>does anyone know where I might find a metasearch script to search
>multiple search engines? I've searched and searched but haven't found
>any...
There are a few in the `cgi' section of Perl Reference:
http://reference.perl.com
--
Clay Irving
clay@panix.com
------------------------------
Date: Fri, 19 Feb 1999 21:34:38 GMT
From: scraig@my-dejanews.com
Subject: Re: NEWBIE: Uninitialized value problem
Message-Id: <7aklde$c2a$1@nnrp1.dejanews.com>
In article <36CD53A6.B8B12683@ff.cuni.cz>,
Petr Zemanek <petr.zemanek@ff.cuni.cz> wrote:
>
> I have a script that should read a file into an array and sort it by
> columns. I used the example from perlfaq4, but for some reason, perl -w
> tells me that I use uninitialized value (it seems to be field1($a))
>
> #!perl -w
> #open a file, read its lines to an array and sort by columns ...
>
> $filename = $ARGV[0];
> open (F, $filename) or die ("can't open $filename: $!\n");
> @lines = <F>;
>
> @sorted = sort { field1($a) <=> field2($b) ||
> field2($a) cmp field2($b) ||
> field3($a) cmp field3($b)
> } @lines;
>
> open(F, ">$filename");
> print {F} @sorted;
> # end
The warning applies to the statement that begins on the reported line
number. This statement is four lines long. The subject of the warning is not
necessarily in the first one.
In the present case, all the fieldx($x) are uninitialized. The FAQ is
presuming that you have some functions, field1(), field2(), field3(), that
extract the elements from the lines for you. The FAQ does not suggest this is
the only way to get the elements, however, but it's easier to follow.
If the data is in specific columns, you might try, say,
sub field1 {
my $line = shift;
return substr $line, 5, 7;
}
If the lines are space or tab delimited, you can do something similar with
split().
If you like to use map(), and the data is space delimited, try this:
@sorted = map { $_ -> [0] }
sort{
$a->[1] <=> $b->[1]
or
$a->[2] cmp $b->[2]
or
$a->[3] cmp $b->[3]
}
map { [ $_, split ] }
@lines;
HTH
Scott
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 19 Feb 1999 12:46:12 -0800
From: samc@empirewest.com (Sam Curren)
Subject: Re: perl compiled code cacheing
Message-Id: <MPG.11376d6aaa74bfd49896e4@news.sonic.net>
In article <comdog-ya02408000R1902991450090001@news.panix.com>,
comdog@computerdog.com says...
>but, if you don't like any of this, make your own code caching
>system and when you have it to a reasonable point, release it
>as open source. no sense continuing to carp over something you
>didn't get with the already free perl, apache, and mod_perl if
>you aren't going to help.
My posting was simply a study of the idea. I agree with the excellence of
mod_perl, and was not trying to replace it or degrade it. I believe that
the best programming work is done with a resonable amount of
collaberation, and I was looking for ideas and thoughts, not total
solutions. Tom answered my orgininal inquiry and thoughs perfectly in his
previous post. That was exactly what I was looking for.
-Sam
------------------------------
Date: 19 Feb 1999 12:29:40 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl evangelism
Message-Id: <m13e423znv.fsf@halfdome.holdit.com>
>>>>> "Sam" == Sam Curren <samc@empirewest.com> writes:
Sam> As for altavista containing the database, I would imagine that
Sam> they would simply query askjeeves databases in the background,
Sam> not replicate the database.
Again, I can't tell you how I know, but you're wrong. :-) The AV
interface has a much better performance, and therefore it couldn't
simply be accessing the same database that the AJ interface provides.
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Fri, 19 Feb 1999 12:51:53 -0800
From: samc@empirewest.com (Sam Curren)
Subject: Re: Perl evangelism
Message-Id: <MPG.11376ec22ff3983f9896e5@news.sonic.net>
> Again, I can't tell you how I know, but you're wrong. :-) The AV
> interface has a much better performance, and therefore it couldn't
> simply be accessing the same database that the AJ interface provides.
Hmm. It seems silly to replicate a database, but not so when you review
performance.
If you had to do the same thing (license content from another company)
would you use the same system or replicate it?
-Sam
------------------------------
Date: Fri, 19 Feb 1999 20:20:13 GMT
From: droby@copyright.com
Subject: Re: Perl flock question
Message-Id: <7akh18$82t$1@nnrp1.dejanews.com>
In article <36CC5660.5B91D972@wfubmc.edu>,
Steve Miles <smiles@wfubmc.edu> wrote:
> Say you have two single file scripts that call and write to the same
> database. If both scripts are frequently used,
> you would have to flock your database in each script so they don't
> compete with each other and
> possibly corrupt the database.
>
> My question is: What if in each script you 'require "otherscript.cgi";'
> so that when one script is called it requires the other - in that case
> would that solve the database locking problem?
>
No. The need for locking has nothing to do with multiple scripts accessing
the same file. The problem is with multiple simultaneous updates to the data
by different processes. Multiple invocations of the *same* script will screw
the data just as nicely as multiple scripts.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 19 Feb 1999 15:03:36 -0500
From: "Dave Mckeown" <davemck@cgocable.net>
Subject: Re: Perl tutorials??
Message-Id: <36cdc351.0@news.cgocable.net>
There are a few at
http://www.perlfect.com/articles/index.shtml
--
Net-Studios, full service website hosting and design.
Website URL: http://www.net-studios.com
Need Web hosting?: http://www.net-studios.com/hosting/
Contact me : dave@net-studios.com
Bill Garrett <bgarrett@hamilton.net> wrote in message
news:36C3B984.3FCB4BF3@hamilton.net...
>I am looking for a good free perl tutorial.
>Anyone know wherer I can get one form?
>Jason@wbdet.com
>
------------------------------
Date: Fri, 19 Feb 1999 20:34:12 GMT
From: latsharj@my-dejanews.com
Subject: Re: Printing all environment variables
Message-Id: <7akhs4$8ol$1@nnrp1.dejanews.com>
In article <alecler-1902991249260001@dialup-654.hip.cam.org>,
alecler@cam.org (Andre L.) wrote:
> In article <36CD98FE.3CE3C41B@giss.nasa.gov>, jglascoe@giss.nasa.gov wrote:
>
> > my @env_keys = keys %ENV;
> > @env_keys = sort { $a cmp $b } @env_keys;
> > for my $key (@env_keys)
> > {
> > my $val = $ENV{$key};
> > print "$key\t$val\n"
> > }
>
> Or, if you don't have the budget for superfluous variables :-),
>
> foreach (sort keys %ENV) {
> print "$_\t$ENV{$_}\n";
> }
Or, to trim a few more chars :-)
for (sort keys %ENV) {
Regards,
Dick
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 19 Feb 1999 21:53:06 GMT
From: christian.arandaNOSPAM@NOSPAMiiginc.com (Christian M. Aranda)
Subject: Re: Printing all environment variables
Message-Id: <36cedbe9.13382405@news.bbn.com>
On 19 Feb 1999 18:34:16 GMT, gward@cnri.reston.va.us (Greg Ward)
wrote:
>Christian M. Aranda <christian.arandaNOSPAM@NOSPAMiiginc.com> wrote:
>> Now, I know that I can print %ENV and get all the environment
>> variables. But because it's a hash, it won't print very legibly. Is
>> there any good way to print them all so I can compare them?
>
>Surely this is a FAQ... but what the hell:
Actually, I checked the FAQ but came up short. Thanks for the help,
tho. All the suggestions worked great!
> Greg
------------------------------
Date: Fri, 19 Feb 1999 15:26:51 -0500
From: "Adam Rudnick" <arudnick@inet.net>
Subject: Re: Search engine
Message-Id: <36cdcaf3.0@news.inet.net>
Go to http://www.extropia.com/download.html
In the form, where it asks you what application you want, choose SiteSearch
on the pulldown menu.
Kerry J. Cox wrote in message <36CDC19C.32584377@vii.com>...
>Just wondering if anyone could point me to a nice Perl script that
>searches out words or keywords
------------------------------
Date: 19 Feb 1999 14:12:58 -0700
From: Eric The Read <emschwar@mail.uccs.edu>
Subject: Re: SSI question?
Message-Id: <xkfpv76ksh1.fsf@valdemar.col.hp.com>
abbott in Northfield <jabbott@dingo.smig.net> writes:
> "Guo, Yongping" wrote:
> > <!--#exec cgi="http://cs.franklin.edu/class-cgi-bin/guo/count.pl"-->,
> > it give me an error for access the directory.(cs.franklin.edu is the
> > server)
> >
> > Any help is appreciated!
>
> You don't need to exec cgi this. Just put it in as an image <img
> src="etc.ect/quo/count.pl">
How do you know his script doesn't output text? That'd look pretty silly
in the src of an IMG tag, wouldn't it?
Besides, this isn't a perl question, or a perl solution. Take it to
comp.infosystems.www.*
-=Eric
------------------------------
Date: Fri, 19 Feb 1999 12:29:23 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: String Manipulation (yet another newbie question)
Message-Id: <MPG.1137697d100433bb989a60@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <ouqja7.44h.ln@magna.metronet.com> on Fri, 19 Feb 1999
08:03:04 -0600, Tad McClellan <tadmc@metronet.com> says...
> Larry Rosler (lr@hpl.hp.com) wrote:
...
> : ... And that's why I think that Tad McClellan's using $[ to answer
> : a simple post (instead of just 0, as I did earlier :-) is pointless
> : pedantry and potentially misleading.
> ^^^
> ^^^
>
> Actually I meant it to be _leading_.
>
> In the spirit of learning to fish vs. giving a fish, I figured
> a reader that was not aware of $[ would say "Huh?".
>
> The thinking reaction to "Huh?" is to check the docs, either
> $[ in perlvar or index() in perlfunc.
>
> Either place would point out that you shouldn't be changing $[.
You shouldn't even know that $[ exists!
pointless -- 1: devoid of meaning 2: devoid of effectiveness
pedant[ry] -- 2a: one who parades his learning b: one who is
unimaginative or who unduly emphasizes minutiae in the
presentation or use of knowledge c: a formalist or
precisionist in teaching
Take your pick of the above options; any or all might apply! :-)
I think that *any* mention here of $[, $*, $;, or any other obsolete
arcanum in perlvar is pointless pedantry. The variable $[ is indeed
discussed in `perlfunc -f index`, but that is primarily historical --
perhaps it should be removed. The description of $[ should be left in
perlvar, in case anybody trying to read very old Perl code stumbles on
it.
BTW: Did anyone notice that the decription of the 'index' function is
not available in the Web-accessible documentation at
... /perl/CPAN/doc/manual/html/pod/perlfunc.html
Think about why that is! I have submitted a perlbug. Someone should
address this silly problem.
BTW2: I always hated the C function names 'index' and 'rindex', and
persuaded the owners of the Standard C Library to call them 'strchr' and
'strrchr' to conform to the other 'str...' functions (though this caused
some grief for the BSD-based C libraries). Now I have another,
unanticipated reason to despise 'index'. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4943
**************************************