[8424] in Perl-Users-Digest
Perl-Users Digest, Issue: 2041 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 6 11:38:08 1998
Date: Fri, 6 Mar 98 08:01:14 -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, 6 Mar 1998 Volume: 8 Number: 2041
Today's topics:
Re: $0: which OSes? <quentin@jihad.amd.com>
[HELP] pod2html doesn't do URLs anymore (Han-Wen Nienhuys)
Re: Calling a Perl Script via a hyperlink (Bernie Cosell)
Re: commify [FAQ] (Greg Bacon)
commify (Chuck Stewart)
Re: commify <dboorstein@shopcfn.com>
Re: Create directory from input in file? (Clinton Pierce)
DB failures on DEC Alpha if DB created elsewhere (HMahaffey)
Finding absolute pathname <jgoerzen@southwind.net>
Re: How to double sort a hash of hashes???? (Andrew M. Langmead)
Re: isn't perl clever: short-circuit logic <Dave.Cross@gb.swissbank.com>
Re: Length of an array? (John Moreno)
Re: Length of an array? <steve@prilnari.com>
local/global and my (Michael Wang)
Re: local/global and my <etmgero@etm.ericsson.se>
Multicast (Eric A. Mathiasen)
Re: padding a file -- Better way?? <jdporter@min.net>
Perl <-> Sybase <etmgero@etm.ericsson.se>
Re: Perl Script count lines of c/c++ code (Joel Coltoff)
Re: problems with one-liners on the command line (Tom Grydeland)
Re: Quiz <jdporter@min.net>
Reading BLOBs with DBD:ODBC <tom.wouters@sd.be>
Re: Running a perl script on Windows 95 <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Re: Sort a hash table by it's values (Jeffrey R. Drumm)
Re: Sort a hash table by it's values (Jim Allenspach)
Re: Sort a hash table by it's values <alexs@online.emap.com>
Re: Sort a hash table by it's values (Andrew M. Langmead)
Sorting text files cursor@cas.nutecnet.com.br
Re: Sorting text files (Clinton Pierce)
Re: Sorting text files (Greg Bacon)
Sybperl documentation <alex_nixon@ml.com>
Re: Sybperl documentation <etmgero@etm.ericsson.se>
Re: Sybperl documentation (Randy Kobes)
Re: Sys::Syslog basics <quentin@jihad.amd.com>
Re: The -w switch (was Re: better way to do this?) (Earl Hood)
Re: The -w switch (was Re: better way to do this?) (Earl Hood)
Two scripts at once? <miller@bigsky.net>
Re: utime not working (Joel Coltoff)
Re: What is PERL? Learn JAVA instead? <neeri@iis.ee.ethz.ch>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 06 Mar 1998 09:51:10 -0600
From: Quentin Fennessy <quentin@jihad.amd.com>
Subject: Re: $0: which OSes?
Message-Id: <ximyaynes29.fsf@jihad.amd.com>
mkelly99@NOSPAMgate.net (Michael Kelly) writes:
>
> Perhaps the /proc filesystem Linux uses is the link between the
> app, $0 and ps? Just a wild guess as I believe /proc is unique
> to Linux.
/proc dates back to either Version 8 or Version 9 of Research Unix.
SVR4 implemented it from the start..
SVR4 also predates Linux.
--
Quentin Fennessy AMD, Austin Texas
------------------------------
Date: 6 Mar 1998 14:14:36 GMT
From: hanwen@cs.ruu.nl (Han-Wen Nienhuys)
Subject: [HELP] pod2html doesn't do URLs anymore
Message-Id: <6dp0cc$s69$1@krant.cs.ruu.nl>
Hello net!
I recently upgraded to perl-5.004. Unfortunately, my scripts to
generate websites now fail, because URLs that were in the input text before,
are not converted to real URLs by pod2html, as used to be the case.
My documents now don't have any hyperlinks.
Is this bug? A feature?
--
Han-Wen Nienhuys, hanwen@cs.ruu.nl ** GNU LilyPond- The Music Typesetter
http://www.cs.ruu.nl/people/hanwen/lilypond/index.html
------------------------------
Date: Fri, 06 Mar 1998 14:11:07 GMT
From: bernie@fantasyfarm.com (Bernie Cosell)
Subject: Re: Calling a Perl Script via a hyperlink
Message-Id: <3500035f.668395786@nntp.infoave.net>
"Adam Carden" <adam@pacific-artists.demon.co.uk> wrote:
} I have a database search script which searches a tab delimited text file,
} The user enters the data on a form then presses the submit button and the
} data is sent by "POST". However I would like yo call the script from a url.
} e.g.
} http://www.nightflightinternational.co.uk/cgi-bin/product-search.cgi?action=
} search&Keywords=access
We do this *all* the time and it is a no-brainer. Use CGI.pm. One of the
-best- thing that it does is takes *every* way that a parameter can be
passed to a CGI program and homogenizes it all. So in your program you can
just pick up $rq->param('action') and it will NOT MATTER whether that came
in via a field on a form or a parameter tacked onto a URL.
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: 6 Mar 1998 14:54:33 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: commify [FAQ]
Message-Id: <6dp2n9$i7d$1@info.uah.edu>
[Posted and mailed]
In article <34fff117.419657@news.flash.net>,
cstewart@flash.net (Chuck Stewart) writes:
: $total = 1234345
: $total=~ s/^(-?\d+)(\d{3})/$1,$2/;
:
: This will results in 1234,345
: How can I print 1,234,345
This is answered in section five of the Perl FAQ.
% perldoc perlfaq5
or
http://www.perl.com/CPAN/doc/FAQs/FAQ/PerlFAQ.html
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Fri, 06 Mar 1998 12:54:04 GMT
From: cstewart@flash.net (Chuck Stewart)
Subject: commify
Message-Id: <34fff117.419657@news.flash.net>
$total = 1234345
$total=~ s/^(-?\d+)(\d{3})/$1,$2/;
This will results in 1234,345
How can I print 1,234,345
Thanks
------------------------------
Date: Fri, 06 Mar 1998 09:41:20 -0500
From: Dan Boorstein <dboorstein@shopcfn.com>
To: cstewart@flash.net
Subject: Re: commify
Message-Id: <35000B10.8339AEBA@shopcfn.com>
Chuck Stewart wrote:
>
> $total = 1234345
> $total=~ s/^(-?\d+)(\d{3})/$1,$2/;
>
> This will results in 1234,345
> How can I print 1,234,345
>
check out perlfaq5: How can I output my numbers with commas added?
a great resource, well worth your attention. you can find it at
http://www.perl.com/, or maybe even on your very own system with
'perldoc perlfaq5'.
cheers,
--
#!/usr/bin/perl -w -- 2 for 1 dan boorstien <dboorstein@shopcfn.com>
# my first Just another Perl hacker,
seek DATA,0,0;{$_=<DATA>,/!/&&redo}print join(' ',(split)[3..6])__END__
# my second Just another Perl hacker,
------------------------------
Date: 6 Mar 1998 14:43:02 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
To: as646@FreeNet.Carleton.CA (John Robson)
Subject: Re: Create directory from input in file?
Message-Id: <6dp21m$hc72@eccws1.dearborn.ford.com>
*************************************************************************
************************** FREE RANDAL **********************************
*************************************************************************
In article <6dms7j$8sg@freenet-news.carleton.ca>,
as646@FreeNet.Carleton.CA (John Robson) writes:
>
>How do I read the first field of each line
Camel, read up on "split".
>create a directory with the
Modules, try www.perl.com. But you should already have it installed.
try "perldoc Path".
>and then copy the actual file from the second field into the directory
try "perldoc Copy"
>How do I do this for Perl in Windows 95 or DOS ? In Unix?
www.perl.com, read up on Win32 Perl. Specifically, look for filesystem
differences handling.
>Problem 2: How do I do the reverse?
*sigh* USENET is no substitute for learning computer programming.
*************************************************************************
************************** FREE RANDAL **********************************
*************************************************************************
--
+------------------------------------------------------------------------+
| Clinton A. Pierce | "If you rush a Miracle Man, | http://www. |
| cpierce1@ford.com | you get rotten miracles" | dcicorp.com/ |
| fubar@ameritech.net |--Miracle Max, The Princess Bride| ~clintp |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*
------------------------------
Date: 6 Mar 1998 14:46:42 GMT
From: hmahaffey@aol.com (HMahaffey)
Subject: DB failures on DEC Alpha if DB created elsewhere
Message-Id: <19980306144600.JAA17346@ladder03.news.aol.com>
We wrote a multi-platform Build Management tool in Perl. We store information
about the builds in a DB (nothing fancy, just the one that comes bundled with
Perl... what is that, SDBM?) No problems reading and writing on HP, Solaris
2.6, Irix 5, and Irix 6. Then we come to DEC OSF 4b, where we can't read
anything written by the other platforms. If the DEC CREATES the database, it
can read and write fine, but it can't do so if some other platform originally
created the database.
Is this some 64-bit issue? An option on the installation of Perl I can tweak?
Has anyone else seen anything like this? Please don't say that multiple
platform types can't update the same database.....
Thanks!
:)hal mahaffey
hmahaffey@aol.com (Please copy replies here also... thanks!)
------------------------------
Date: 06 Mar 1998 09:20:01 -0600
From: John Goerzen <jgoerzen@southwind.net>
Subject: Finding absolute pathname
Message-Id: <r6zg1kvg82m.fsf@peridot.southwind.net>
Hi,
When given a filename, say in $0, what is a good way to get the
absolute path to the filename? For instance, $0 might contain
"./test.pl" and I want to get /home/jgoerzen/test.pl out of it.
There is a realpath(3) call in C that accomplishes this but I see no
equivolent in Perl. Ideas?
Thanks,
John
--
John Goerzen Southwind Internet Access, Inc.
E-mail: Business, jgoerzen@southwind.net; Personal, jgoerzen@complete.org
Computer Science Dept., Wichita State University, jgoerzen@cs.twsu.edu
Developer, Debian GNU/Linux <http://www.debian.org>
------------------------------
Date: Fri, 6 Mar 1998 14:33:44 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: How to double sort a hash of hashes????
Message-Id: <EpEJ49.8EA@world.std.com>
Aaron Hanson <aahanson@students.uiuc.edu> writes:
>Hi all. I am in dire need of a solution to my problem. I have a hash
>of hashes in this one program, and I want to sort the hash by one
>variable, and then by another. I had tried this:
What I'm assuming you need is to do a primary sort on the first key,
and if equal then sort by the second key.
foreach $var (sort { $data{$b}{$key1} <=> $data{$a}{$key1} or
$data{$b}{$key2} <=> $data{$a}{$key2} } keys %data) {
print $var;
}
--
Andrew Langmead
------------------------------
Date: Fri, 6 Mar 1998 13:26:11 GMT
From: David Cross <Dave.Cross@gb.swissbank.com>
Subject: Re: isn't perl clever: short-circuit logic
Message-Id: <y4d90qo9ci4.fsf@gb.swissbank.com>
Kevin,
There's More Than One Way To Do It.
In this case, I think the script below may be more efficient.
#!/usr/perl/bin/perl -w
use strict
my $syllable = shift;
$syllable =~ /^([bcdfghjklmnpqrstvwxyz]*)(.*)$/;
my ($onset, $rime) = ($1, $2);
print "onset = $onset\nrime = $rime\n";
Someone will undoubtedly produce a one-liner.
hth,
Dave...
kevin@cmhcsys.com writes:
> # i've got a syllable which i've gotten by splitting up a word. now i want
> to split the # syllable into its initial consonant(s), or "onset," and the
> rest of it, or its "rime."
>
> # i've got a list of possible syllable-initial consonants, which i'll put
> into a character class. $InitialConsonants = "bcdfghjklmnpqrstvwxyz";
>
> # if any of those initial consonants are present, i want to peel them off and
> put them into # the variable $onset; the remainder should go into the
> variable $rime.
>
> # what if there is no onset consonant? then the whole syllable is the rime.
>
> # this first short-circuit line sets $onset if there be one, and puts the
> syllable into $rime # if there be'n't one.
>
> (($onset) = /^([$Conset]+)/) || ($rime = $syllable);
>
> # the next short-circuit line takes care of setting the $rime in the normal
> case, i.e. # where there WAS an onset consonant.
>
> ($rime) || ($rime = $');
>
> yes, i think perl IS clever, and i delight in it. question is, am I clever?
> is there a more efficient way of defining $onset and $rime?
--
If I wasn't so busy writing status reports,
my status report might just become a progress report.
Dave.Cross@gb.swissbank.com
------------------------------
Date: Fri, 6 Mar 1998 09:00:19 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Length of an array?
Message-Id: <D962440771670E55.4B9D793C6BA9C932.046264A3134F4A4F@library-proxy.airnews.net>
David Waring <dwaring@nwsr.com> wrote:
> Keith L. Miller wrote:
> >
> > If I have a string stored in $_ and I split it into an array, how can I
> > know what the length of the array (how many fields there are in the
> > array)?
>
> <steve@prilnari.com> wrote:
>
> > You should read the FAQ but since this is so easy...
> >
> > $length = @fields;
> >
> It is interesting how many people say read the FAQ in response to
> questions that are not in the FAQ. Yes this question is covered in the
> books but I could not find it in the FAQ.
You're right, it's not in the FAQ - it in the manual, in perldata.pod,
almost the first thing in fact.
--
John Moreno
I am trying to convince the author of YA-NewsWatcher that the latest
version should be released to the public. He doesn't think there's much
interest in a new version. Help me prove him wrong. To do so, send me
mail <mailto:phenix@interpath.com> with a Subject of New YA. Comments
on what you like/dislike in the current version will be appreciated.
------------------------------
Date: Fri, 06 Mar 1998 15:19:44 GMT
From: Steve Wells <steve@prilnari.com>
Subject: Re: Length of an array?
Message-Id: <3500158A.B47D861E@prilnari.com>
Hmm... guess I should read the FAQ. ;-)
STEVE
John Moreno wrote:
>
> David Waring <dwaring@nwsr.com> wrote:
>
> > Keith L. Miller wrote:
> > >
> > > If I have a string stored in $_ and I split it into an array, how can I
> > > know what the length of the array (how many fields there are in the
> > > array)?
> >
> > <steve@prilnari.com> wrote:
> >
> > > You should read the FAQ but since this is so easy...
> > >
> > > $length = @fields;
> > >
> > It is interesting how many people say read the FAQ in response to
> > questions that are not in the FAQ. Yes this question is covered in the
> > books but I could not find it in the FAQ.
>
> You're right, it's not in the FAQ - it in the manual, in perldata.pod,
> almost the first thing in fact.
>
> --
> John Moreno
> I am trying to convince the author of YA-NewsWatcher that the latest
> version should be released to the public. He doesn't think there's much
> interest in a new version. Help me prove him wrong. To do so, send me
> mail <mailto:phenix@interpath.com> with a Subject of New YA. Comments
> on what you like/dislike in the current version will be appreciated.
------------------------------
Date: 6 Mar 1998 15:02:39 GMT
From: mwang@alhena.ibk.ml.com (Michael Wang)
Subject: local/global and my
Message-Id: <6dp36f$ikh$1@news.ml.com>
>Well , the only truly local variables are "my" variables or lexical
>variables. all others are global or pseudo - local
well, my variable can be accessed in subroutine, if it is not my'ed
there. so does this still fit your definition of "local"?
I myself find my, and local very confusing. It does not seem C suffers
from the problem.
------------------------------
Date: Fri, 06 Mar 1998 16:37:48 +0100
From: Geert Roovers <etmgero@etm.ericsson.se>
Subject: Re: local/global and my
Message-Id: <3500184C.7D3@etm.ericsson.se>
Michael Wang wrote:
>
> >Well , the only truly local variables are "my" variables or lexical
> >variables. all others are global or pseudo - local
>
> well, my variable can be accessed in subroutine, if it is not my'ed
> there. so does this still fit your definition of "local"?
>
> I myself find my, and local very confusing. It does not seem C suffers
> from the problem.
I thought that was the whole point? when not using my, you can use the
variable in the subroutine, but also outside the sub. When you use my in
the subroutine, you can't access it from outside the subroutine. Which
would mean you can use a variable name for two different thing (but I'm
not sure about that (yet))
~Geert
------------------------------
Date: 6 Mar 1998 15:44:02 GMT
From: emathias@wwa.com (Eric A. Mathiasen)
Subject: Multicast
Message-Id: <6dp5k2$eur$1@hirame.wwa.com>
I'm pretty new to Perl, and even newer to network programming (no, I don't mean
deciding what NBC will show without Seinfeld). I've been watching this group
for about a week, and have spent a good two-three days webhunting for proof
that multicasting is something that can be done in Perl. Some of the more
senior sysadmins here are convinced that it can't be done, but if it can I'd like
to do it. Do any of you have any experience in this matter, and maybe a book or
web site to recommend? I'd be interested to hear any stories at all.
Thanks,
-Eric
emathias@wwa.com
------------------------------
Date: Fri, 06 Mar 1998 09:03:15 -0500
From: John Porter <jdporter@min.net>
Subject: Re: padding a file -- Better way??
Message-Id: <35000223.5F6D@min.net>
Craig Berry wrote:
>
> John Porter (jdporter@min.net) wrote:
> : Why do you have 80.80 ??? This works the same for me:
> :
> : sprintf("%-80s",$_)
>
> Doesn't work the same if $_ is longer than 80 characters. The - means
> 'left justify'; the first 80 means 'pad to 80 characters width'; the
> final .80 means 'truncate to 80 characters width'. Without the .80 part,
> an 85 character $_ would remain 85 characters long on the output,
> spoiling the formatting.
O.k., thanks for the enlightenment.
John Porter
------------------------------
Date: Fri, 06 Mar 1998 14:17:26 +0100
From: Geert Roovers <etmgero@etm.ericsson.se>
Subject: Perl <-> Sybase
Message-Id: <34FFF766.775D@etm.ericsson.se>
Hi,
On my question about what module to use for reading from and writing to
a Sybase database, I got a fine answer. i'm now working through the
Manual and FAQ, and was wondering if somenone could show me some working
perl code, so that I know how it exactly works? I like learning by
example, and the manual doesn't provide so much examples.
Thanx!
~Geert
------------------------------
Date: Fri, 6 Mar 1998 15:04:55 GMT
From: joel@wmi0.wmi.com (Joel Coltoff)
Subject: Re: Perl Script count lines of c/c++ code
Message-Id: <6dp3a2$rqn@netaxs.com>
In article <14953E9BAF17D111926800805FA66B710239DA0A@hermes.atos-group.com>,
R. Allen Conway <raconway@atos-group.com> wrote:
>Well, it all depends on what you mean by "lines of ... code". If this does
>not include comments the wc is not going to be enough, and I don't
>think that dropping comments from the calculation is all that trivial.
Sure it is. In fact there are several easy ways to do it.
The perl approach:
Search out dejanews for the many (and some recent) threads
on stripping comments from a C program.
The philistine, heathenistic, non-perl, compiler approach:
gcc -E -nostdinc foo.c | uniq > foo.i
wc -l foo.i
The second approach will be off a bit because of how comments are
stripped. The "uniq" is an attempt to squeeze out multiple blank
lines. The output file has some '#' directives in it. You'd need
a smarter filter here to do this correctly. As a first pass you
could do something like
grep 'a-zA-Z0-9' | grep -v '#' |
If you just want a rough idea of lines this isn't a bad way to go.
--
Joel Coltoff
I'd explain it, but there's a lot of math. -- Calvin
------------------------------
Date: 6 Mar 1998 13:30:18 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: problems with one-liners on the command line
Message-Id: <slrn6fvuja.lkc.Tom.Grydeland@mitra.phys.uit.no>
On 5 Mar 1998 17:55:01 -0500,
Kevin B Cohen <kcohen@julius.ling.ohio-state.edu> wrote:
> i can pull off a substitution (thanks to tchrist) with something like
>
> perl -pi.bak -e s/foo/bar/g; myfile.txt
>
> but i can't manage much else.
You'll need to quote things to stop the shell from splitting it.
> i'm trying to do a little grep-like operation
You should use -n instead of -p then. man perlrun.
> perl -p -e if(m/ea.{1,3}/) {print $_; } lexicon.txt
perl -ne 'print if m/ea.{1,3}/' lexicon.txt
> so, those are my attempts at one-liners. i can't even imagine a
> multi-line attempt; when would it start running??
This is not really a Perl problem, but a shell problem. Perhaps a Unix
FAQ is the place to start?
Good luck,
> kevin
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Fri, 06 Mar 1998 09:11:28 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Quiz
Message-Id: <35000410.570C@min.net>
Ronald J Kimball wrote:
>
> John Porter wrote:
> >
> > If the string had been single-quoted, the \\ would have been passed
> > to tr.
>
> DB<1> print "abc\\def"
> abc\def
> DB<2> print 'abc\\def'
> abc\def
>
> Even in single-quoted strings, some backslash escapes are special.
> Specifically, \' for a single quote, and \\ for a backslash.
Too true! (shame on me.)
John Porter
------------------------------
Date: 6 Mar 1998 15:37:59 GMT
From: "Tom Wouters" <tom.wouters@sd.be>
Subject: Reading BLOBs with DBD:ODBC
Message-Id: <01bd4915$9c7201a0$9504010a@w00409>
I was successfully using on NT4.0 :
perl5.004_04
dbi 0.90
dbd:Oracle 0.47
Now I'm trying to port my application to Informix using DBD:ODBC.
I 've installed DBD:ODBC 0.16.
Before connecting to the Informix database, I'm testing this
DBD:ODBC-connection with my Oracle database
(Microsoft ODBC-driver for Oracle) :
-I can 't read a long-field from the Oracle database anymore.(It worked
fine with DBD:ORACLE 0.47 using blob_read)
-bind_columns doesn't work anymore. I have to use fetchrow_array which
isn't that fast.
So my main question is :
Is it possible to read blobs using DBD:ODBC ? (Maybe it's better to use
DBD:INFORMIX but I didn't succeed in compiling this on my NT4.0 machine)
Tom
------------------------------
Date: Fri, 6 Mar 1998 06:27:55 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: Running a perl script on Windows 95
Message-Id: <6dp132$snp@bgtnsc03.worldnet.att.net>
Unfortunately, Windows doesn't have an equivalent for the hashbang (#!).
ActiveState (and possibly the GS port as well, but I'm not sure about this)
will read any flags you have after the hypothetical name and act on them,
but that's about it. So if you head off your program with
#!/usr/bin/perl -w
as you should, you still get warning messages, but it doesn't help in
finding the Perl executable.
You can associate perl scripts with winperl through the View / Options item
in the My Computer menu (it's in a slightly different spot for Active
Desktop), but the best thing to do is add it to your path. Under NT you can
do this through the System control panel. Under Win95 you need to modify
AUTOEXEC.BAT (or create it if you don't have one). Me, I don't bother with
setting up Perl scripts to run when you double-click. I just open up a
command prompt window to start with.
This is, by the way, a FAQ, but I don't remember the number.
--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl
>I have a Perl script that is running fine on UNIX. I now want to run it
>on Windows 95 but it is not being executed at all. I am suspecting that
>it cannot even find the Windows version Perl interpreter that I
>installed. What is the Windows equivalent of the first line used for
>UNIX (#!/usr/local/bin/perl) that tells where the Perl interpreter is?
>Any other details that I should pay attention to as well? Thanks.
>
------------------------------
Date: Fri, 06 Mar 1998 13:17:41 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: Sort a hash table by it's values
Message-Id: <34fff405.243109272@news.mmc.org>
On Fri, 06 Mar 1998 12:55:04 +0000, Alex Schajer <alexs@online.emap.com> wrote,
wasting bandwidth and time and increasing the noise level even MORE:
>Hi,
>
>I have hash table with numbers in them. I want to order the hash table
>by their values
(snip)
>Thanks,
>Alex
See perlfaq4, "How do I sort a hash (optionally by value instead of key)?". If
you don't know where the FAQs are on your system, go to:
http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html#How_do_I_sort_a_hash_optionaly
Since your X-Mailer header indicates you're a Windows user, and you obviously
didn't read the FAQ, your post has only served to reinforce the terrible image
of Windows users in this forum. Please don't post again until you've done your
homework. It's embarrasing for those of us who are Windows users yet do try to
be good c.l.p.m. citizens.
--
Jeffrey R. Drumm, Systems Integration Specialist
Maine Medical Center - Medical Information Systems Group
drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented!" - me
------------------------------
Date: 6 Mar 1998 07:39:28 -0600
From: jima@MCS.COM (Jim Allenspach)
Subject: Re: Sort a hash table by it's values
Message-Id: <6douag$m0g@Venus.mcs.net>
>I have hash table with numbers in them. I want to order the hash table
>by their values
> [...]
>Any ideas?
Yes! Why don't you check the Perl FAQ? This question is answered
under the heading "How do I sort a hash (optionally by value instead of
key)?"
You can find a link to the FAQ at this URL:
http://language.perl.com/faq/
Don't forget to bookmark it, just in case you have any other questions.
Hope this helps.
jma
--
Jim Allenspach Laziness. Impatience. Hubris.
jima at mcs dot com
Chicago IL It's great to be a Perl programmer.
------------------------------
Date: Fri, 06 Mar 1998 13:57:26 +0000
From: Alex Schajer <alexs@online.emap.com>
Subject: Re: Sort a hash table by it's values
Message-Id: <350000C6.19815D70@online.emap.com>
To all those who replied thanks and sorry for not RTFMimg.
However that FAQ's are so big, and the books so long, all that is
sometimes required is a pointer to where in the FAQs or books to look. I
know it is not an excuse.
Thanks again,
Alex
Alex Schajer wrote:
> Hi,
>
> I have hash table with numbers in them. I want to order the hash table
> by their values
>
> ie
>
> $TEAM{'alex'} = 4
> $TEAM{'perl'} = 2
> $TEAM{'unix'} = 5
>
> I would like to rank these and get the results:
>
> $TEAM{'unix'} = 5
> $TEAM{'alex'} = 4
> $TEAM{'perl'} = 2
>
> or even ordered the other way.
>
> Any ideas?
>
> Thanks,
> Alex
------------------------------
Date: Fri, 6 Mar 1998 14:42:11 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Sort a hash table by it's values
Message-Id: <EpEJIB.F8w@world.std.com>
Alex Schajer <alexs@online.emap.com> writes:
>I have hash table with numbers in them. I want to order the hash table
>by their values
Hashes do not keep any order. The best you can do is to get a list of
keys of the hash with the keys() operator. sort the keys (maybe by
looking up the value associated with the key and returning a sort
order based on that.) and use that sorted list of keys for accessing
the hash in the order you want.
%TEAM = ( alex => 4, perl => 2, unix => 5);
for $team (sort {$TEAM{$a} <=> $TEAM{$b}} keys %TEAM) {
print "$team: $TEAM{$team}\n";
}
See the entries for keys() and sort() in the perlfunc man page.
--
Andrew Langmead
------------------------------
Date: Fri, 06 Mar 1998 08:30:44 -0600
From: cursor@cas.nutecnet.com.br
Subject: Sorting text files
Message-Id: <6dp18v$knh$1@nnrp1.dejanews.com>
Hello
I have a text_database with 7000 lines and growing...
I need to sort this database, I tried `sort file1 > file2`, exec ,
system, etc, in Unix.
Its all returned true and don't perform this operation. I set dirs to
777, but dont work too.
I tried it on DOS too and nothing ..
Are there any way to sort a big text file using Perl commands only ???
Thanks
Fernando Amatte
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 6 Mar 1998 14:47:04 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
To: cursor@cas.nutecnet.com.br
Subject: Re: Sorting text files
Message-Id: <6dp298$hc73@eccws1.dearborn.ford.com>
*************************************************************************
************************** FREE RANDAL **********************************
*************************************************************************
In article <6dp18v$knh$1@nnrp1.dejanews.com>,
cursor@cas.nutecnet.com.br writes:
>Hello
>
>I have a text_database with 7000 lines and growing...
>I need to sort this database, I tried `sort file1 > file2`, exec ,
>system, etc, in Unix.
>Its all returned true and don't perform this operation. I set dirs to
>777, but dont work too.
>I tried it on DOS too and nothing ..
>Are there any way to sort a big text file using Perl commands only ???
Read the Camel.
open, slurp, close, open (write), print sort, close.
If sort will handle it, perl probably will too.
*************************************************************************
************************** FREE RANDAL **********************************
*************************************************************************
--
+------------------------------------------------------------------------+
| Clinton A. Pierce | "If you rush a Miracle Man, | http://www. |
| cpierce1@ford.com | you get rotten miracles" | dcicorp.com/ |
| fubar@ameritech.net |--Miracle Max, The Princess Bride| ~clintp |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*
------------------------------
Date: 6 Mar 1998 14:57:46 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Sorting text files
Message-Id: <6dp2ta$i7d$2@info.uah.edu>
[Posted and mailed]
In article <6dp18v$knh$1@nnrp1.dejanews.com>,
cursor@cas.nutecnet.com.br writes:
: I have a text_database with 7000 lines and growing...
: I need to sort this database, I tried `sort file1 > file2`, exec ,
: system, etc, in Unix.
Good idea.
: Its all returned true and don't perform this operation.
I don't understand what you mean by this.
: Are there any way to sort a big text file using Perl commands only ???
With Perl, There's More Than One Way To Do It. Perhaps if you gave
us an example of your typical input file, we might be able to help you
more.
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Fri, 06 Mar 1998 14:09:36 +0000
From: Alex <alex_nixon@ml.com>
Subject: Sybperl documentation
Message-Id: <350003A0.DA18BE74@ml.com>
does anyone know where I can find comprehensive documentation on Sybperl
(Sybase Perl Libraries)?
------------------------------
Date: Fri, 06 Mar 1998 15:51:54 +0100
From: Geert Roovers <etmgero@etm.ericsson.se>
Subject: Re: Sybperl documentation
Message-Id: <35000D8A.743C@etm.ericsson.se>
Alex wrote:
>
> does anyone know where I can find comprehensive documentation on Sybperl
> (Sybase Perl Libraries)?
If you find it, let me know
------------------------------
Date: 6 Mar 1998 15:23:16 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: Sybperl documentation
Message-Id: <slrn6g05iv.73t.randy@theory.uwinnipeg.ca>
On Fri, 06 Mar 1998 14:09:36 +0000, Alex <alex_nixon@ml.com> wrote:
>does anyone know where I can find comprehensive documentation on Sybperl
>(Sybase Perl Libraries)?
>
Hi,
A copy of the sybperl documentation can be found at
http://theory.uwinnipeg.ca/CPAN/by-name/sybperl.html
Best regards,
Randy Kobes
Physics Department Phone: (204) 786-9399
University of Winnipeg Fax: (204) 774-4134
Winnipeg, Manitoba R3B 2E9 e-mail: randy@theory.uwinnipeg.ca
Canada http://theory.uwinnipeg.ca/
------------------------------
Date: 06 Mar 1998 09:43:27 -0600
From: Quentin Fennessy <quentin@jihad.amd.com>
Subject: Re: Sys::Syslog basics
Message-Id: <ximzpj3esf4.fsf@jihad.amd.com>
jvahn@short.circuit.com (James Vahn) writes:
> Stumped. How do I get perl5 to write to a linux syslog daemon?
>
> openlog('perl', 'pid', 'LOCAL0');
For LOCAL0, try LOG_LOCAL0.
: qf@; egrep LOCAL /usr/include/sys/syslog.h
#define LOG_LOCAL0 (16<<3) /* reserved for local use */
#define LOG_LOCAL1 (17<<3) /* reserved for local use */
...
Make sure to remind your syslogd process of your changes to
/etc/syslogd.conf (if you make any) with a `kill -HUP <PID>'.
--
Quentin Fennessy AMD, Austin Texas
------------------------------
Date: 4 Mar 1998 19:25:43 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: The -w switch (was Re: better way to do this?)
Message-Id: <6dk9rn$enc@news.service.uci.edu>
In article <34fd04fd.77879774@130.228.3.8>,
Lars Gregersen <lg@kt.dtu.dk> wrote:
>> I *highly* disagree this advice for some uses. When left in CGI
>> code, it can be deadly. Why? Because if a perl upgrade causes a
>> new (but likely harmless) warning to be spit out that never was
>> before, it will almost certainly cause a "Server Error" do to
>and how exactly are you going to find out if the change is something
>that you have to worry about when you do not see the warnings? Besides
>putting in new warnings to assist an existing Perl version the
>warnings could be a result of new features and/or bugs that you might
>want to know about - not to mention undetected bugs in your code. This
>is especially important in CGI code.
Testing is what some developers are known to do to software.
It is dumb to mindless change the version of the Perl interpreter on
production code before testing it. The new version may have a new bug
that can affect the code, or (although rare), the code was exploiting a
(unknown) bug. Hence, any new warnings that will occur will come up in
a test environment so they can be evaluated to see if they have any
relevance. Also, the testing will help insure that the new interpreter
does not have any new bugs that will affect the code.
As for the -w issue, I am in the camp to remove it in production code.
The beauty of Perl is that it does not enforce rigorous rules. I know
-w does not enforce rules, but if I know what I'm doing, I do not want
to be nagged when my intention is to have the code the way it is.
I look at -w messages as something to take under advisement. And
if my assessment is to ignore it, then I do not want those warnings
to always show in production environments.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: 4 Mar 1998 21:30:00 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: The -w switch (was Re: better way to do this?)
Message-Id: <6dkh4o$k77@news.service.uci.edu>
In article <6di9ep$kdk$2@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>++ note that the book "effective perl programming" by joseph hall and
>++ randal schwartz says you should probably turn -w off for production
>++ programs. (-w is a speed hit and also you don't want your end users
>++ seeing your warnings.)
>
>I read that too, and I disagree. As for the speed hit, I hardly believe
>the hit is significant (show me extended Benchmark results to prove me
>wrong). And if an insignificant speed hit is important for your users,
>you probably shouldn't write Perl anyway.
-w performance hit will depend on how "well formed" your Perl code is.
On "well formed" code, the benchmarks were basically even if -w was
specified or not. The code I used was fairly basic but the benchmarks
values were practically the same (size of time differences could be
attributed to system loads).
As for not "well formed", I have a large program that has been around
since the v4 days of Perl. I have not bothered to resolve all the -w
messages since it would take considerable time, and the program works
fine regardless of the -w warnings (it ain't broke, why fix it):
As for actual times here goes (from Benchmark executing same code
4 times):
-w NOT set:
33 secs (25.47 usr 0.58 sys + 0.15 cusr 0.07 csys = 26.27 cpu)
-w set to tty:
57 secs (29.85 usr 4.47 sys + 0.18 cusr 0.07 csys = 34.57 cpu)
-w to file:
45 secs (29.80 usr 3.71 sys + 0.24 cusr 0.07 csys = 33.82 cpu)
The time differential will increase as I increase the amount of data
that the program processes. If stderr is redirected to a file,
performance hit is not as bad, but a big file was created. The times
suggest that I/O generated by the -w messages is the culprit to the
slowdown. User time does appear to show a slight difference.
Notes:
o Runs executed on SunOS 5.5.1 Generic sun4u sparc SUNW,Ultra-2.
o Code generates many warning messages. Mainly of the
"Use of uninitialized value" type. The amount of warning data
generated was approx 3 megs. Many warnings were repetitive.
For example, if there is a loop, and Perl thinks the use of a
variable has not been initialized, perl repeats the warning
each time the statement is executed. Hence, one "questionable"
statement can generate alot of messages.
o Perl version: perl5 (5.0 patchlevel 3 subversion 0)
For what it's worth,
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Fri, 06 Mar 1998 08:30:03 -0700
From: "Keith L. Miller" <miller@bigsky.net>
Subject: Two scripts at once?
Message-Id: <3500167A.CA72AACD@bigsky.net>
Okay, I have caught a lot of $%&@ for my last posting because it was
(well a stupid question) and I appologize. But this time I do have a
good one. (At least I think I do.)
Anyway, here it is....I have a form that takes one input from a text
box. I need to run two seperate scripts at the same time on different
servers using the data from the text box. I wan't one scipt loaded in
one frame and the other in another frame. Now, I can do this with
JavaScript, but I was wondering if there is anyway for a perl script to
call another perl script on another server and pass data back and forth
to them without some big communications program.
BTW, I have read the FAQ.
Thanks for any help....
Miller
------------------------------
Date: Fri, 6 Mar 1998 15:12:41 GMT
From: joel@wmi0.wmi.com (Joel Coltoff)
Subject: Re: utime not working
Message-Id: <6dp3ol$sgi@netaxs.com>
In article <6dnqmr$pfo@dfw-ixnews11.ix.netcom.com>,
Kat <kmphillip@spamsuck.hotmail.com> wrote:
snip
>PLEASE HELP OR TELL ME A BETTER WAY TO CHANGE THE FILE MOD DATE!
One way would be to use the function as is intended and not the
way you want it to work. Looking in any book on perl or on-line
docs is a good place to start. I've been known to use it this
way but never, never on a first date.
utime $atime, $mtime, $filename;
--
Joel Coltoff
I'd explain it, but there's a lot of math. -- Calvin
------------------------------
Date: 06 Mar 1998 16:31:31 +0100
From: Matthias Neeracher <neeri@iis.ee.ethz.ch>
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <86ra4fal9o.fsf@gwaihir.ethz.ch>
John Porter <jdporter@min.net> writes:
> Ilya Zakharevich wrote:
> > Perl has no (and will not have in any forseeable future) garbage
> > collection.
a) Reference Counting *is* a form of GC.
b) One book about Garbage Collection whose name eludes me at the moment
mentions that somebody once retrofitted Perl4 with a "real" garbage collector
for experimental purposes.
> Far be it from me to question one who has actually contributed
> to the perl core. So for the sake of discussion, what is your
> view on Larry's "Note on Garbage Collection" in the Camel?
> This states that perl performs a complete mark-and-sweep when
> the interpreter finishes.
I wouldn't quite call it "mark-and-sweep", it's more like "nuke-and-pave"
garbage collection :-)
> It would indicate to me that you are
> both right, in a sense: perl does gc, but at a time when
> it is not useful for most (all?) applications. (Its really
> only meaningful when the interpreter is embedded in another
> app which is not exiting.)
That's a bit of a misunderstanding. The primary use of the GC at interpretewr
shutdown time for "mainstream" Perl applications is to guarantee that
destructors for all objects get called.
Matthias
-----
Matthias Neeracher <neeri@iis.ee.ethz.ch> http://www.iis.ee.ethz.ch/~neeri
"If you expect to find truth here, beware, lest you leave a greater fool
than when you entered" -- Anon. (Andreas Osiander), Introduction to
Nicolaus Copernicus, _De revolutionibus orbium_
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 2041
**************************************