[13273] in Perl-Users-Digest
Perl-Users Digest, Issue: 683 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 30 23:07:24 1999
Date: Mon, 30 Aug 1999 20:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 30 Aug 1999 Volume: 9 Number: 683
Today's topics:
-F/foobar/ on #! line <crdevilb@mtu.edu>
2 Questions <ICEMOUNTAIN@prodigy.net>
Re: A Question Of Modules.... <kperrier@blkbox.com>
Re: Binary to Text <bwalton@rochester.rr.com>
Re: Binary to Text (Larry Rosler)
Building perl <ark@leviathan.soest.ucsd.edu>
Case insensitive SQL query mrbog@my-deja.com
Re: Case insensitive SQL query (elephant)
Re: How to "unoverride" functions? <uri@sysarch.com>
Re: how to open file descriptor by number? (Martien Verbruggen)
I am new to perl jim_p_stew@my-deja.com
Insecure dependency in open while running with -T switc <prfctbt@cris.com>
Re: Insecure dependency in open while running with -T s <makkulka@cisco.com>
Re: Insecure dependency in open while running with -T s (Larry Rosler)
Interrupts and Graphics in Win32 <streaking_pyro@my-deja.com>
Re: is the mtime time between date1 and date2? (Martien Verbruggen)
Re: is the mtime time between date1 and date2? (Larry Rosler)
Re: Oraperl problems <makkulka@cisco.com>
Re: PERL & EXCEL <jbc@shell2.la.best.com>
Re: perl equivalent of a Unix command line sort? (Martien Verbruggen)
Re: perl equivalent of a Unix command line sort? (Larry Rosler)
Re: perl on linux <aqumsieh@matrox.com>
Re: Perl Y2K Bugs on the Internet finsol@ts.co.nz
Queries <ascot@aquafind.com>
Re: Queries <makkulka@cisco.com>
Re: Queries (elephant)
Re: Redirecting STDERR to STDOUT (on NT) (elephant)
Re: Searching with 2 input fields <makkulka@cisco.com>
Re: Searching with 2 input fields <ICEMOUNTAIN@prodigy.net>
Re: Searching with 2 input fields <makkulka@cisco.com>
Re: Searching with 2 input fields <ICEMOUNTAIN@prodigy.net>
Re: STDIN, Arrays and Win32 (elephant)
Re: UNIX or NT ? <aqumsieh@matrox.com>
Re: Want to use PERL to run script on another server. (Michael Budash)
WANTED: Mentor / Collaborative Partner aprmelton@my-deja.com
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 31 Aug 1999 00:16:47 GMT
From: Colin R. DeVilbiss <crdevilb@mtu.edu>
Subject: -F/foobar/ on #! line
Message-Id: <7qf6tf$8v6$1@campus1.mtu.edu>
hi.
I've been trying to get a short script using the -wanF// command line
options on the shebang line to work, but everything after the -F
seems to be swallowed no matter what I try:
#!/usr/bin/perl -wanF/(\s+)/
BEGIN {
#...
}
chomp @F;
#...
__END__
by adding ``d'' to the line noise after the hyphen, I see that the
shebang line is directly translated and its newline is preserved by
the ``preprocessor''. is this the problem?
the error returned is:
syntax error at foo.pl line 3, near BEGIN
commenting the BEGIN {} block just moves the compile error to ``chomp''.
is there some sort of magic way around this that I'm missing?
thanks for any help.
Colin DeVilbiss
ps. I've read perlrun and perlsyn several times, and if I missed the
relevant sections, I'm sorry--a line number reference would be
sufficient. Thank you.
------------------------------
Date: Mon, 30 Aug 1999 22:26:44 -0400
From: <ICEMOUNTAIN@prodigy.net>
Subject: 2 Questions
Message-Id: <7qfep0$4cim$1@newssvr03-int.news.prodigy.com>
I am making a script to search a gallery of pictures. I want only five
images to be displayed on each page to shorten loading time. How would I do
that. And I want one line to have all capitals in "sub find_model". I looked
in the perl FAQ's and it said to put $line = uc($line); I put that and it
didn't work. Thanks for any help in advanced.
you can see the script at http://www.3gc.net/gallerysearch.txt
and the working script at
http://www.3gc.net/cgi-bin/scripts/gallerysearch.cgi
------------------------------
Date: 30 Aug 1999 20:25:31 -0500
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: A Question Of Modules....
Message-Id: <DED4E8D3C6DC1397.3B2C01BF8861C712.4C452450585F7539@lp.airnews.net>
"Rodrigo Cortes" <roco3d@softhome.net> writes:
> How to use a module without it is installed in the server??????
>
If your question is how do you use a module that isn't installed on
your server, then I can answer it. You can't.
Kent
--
Just don't create a file called -rf. :-)
--Larry Wall in <11393@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Mon, 30 Aug 1999 22:01:57 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Binary to Text
Message-Id: <37CB3794.1E1D9781@rochester.rr.com>
Larry Rosler wrote:
> In article <37C9F222.8F5E12BD@rochester.rr.com> on Sun, 29 Aug 1999
> 22:53:23 -0400, Bob Walton <bwalton@rochester.rr.com> says...
> > hamish wrote:
> >
> > > I am new to Perl and am trying to read a binary file and convert it to text.
> ...
> > Hamish, your task of "converting from binary to text" leaves
> > a lot of room for interpretation. If the interpretation you want is
> > hexadecimal, try:
> >
> > map {printf OUTFILE "%02x",ord($_)} split(//,$buffer);
>
> Heavens! There are four Perl functions in that statement, and it gives
> the correct results, so it is valid Perl, but it isn't The Way To Do It
> nevertheless.
>
> Benchmark: timing 256 iterations of Map0, Map1, Unpack...
> Map0: 50 wallclock secs (50.03 usr + 0.00 sys = 50.03 CPU)
> Map1: 38 wallclock secs (37.23 usr + 0.00 sys = 37.23 CPU)
> Unpack: 1 wallclock secs ( 0.77 usr + 0.00 sys = 0.77 CPU)
Excellent point, Larry. But I can never remember if it is pack or unpack, h or H,
etc, and I'm too lazy to look it up each time I need it (perlfunc isn't real clear,
so I have to go to a book). Since laziness is a virtue, I let the computer do the
work. Is there a good handy way of remembering about pack and unpack and all that
goes with them?
>
>
> #!/usr/local/bin/perl -w
> use strict;
> use Benchmark;
>
> my $buffer = 'A' x 8192;
>
> timethese(1 << (shift || 0), {
> Map0 => sub { map {sprintf '%02x', ord} split //, $buffer },
> Map1 => sub {
> sprintf '%02x' x length $buffer, map ord, split //, $buffer },
> Unpack => sub { unpack 'H*' => $buffer },
> });
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
--
Bob Walton
------------------------------
Date: Mon, 30 Aug 1999 19:57:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Binary to Text
Message-Id: <MPG.1234e45ac629a16b989ee9@nntp.hpl.hp.com>
In article <37CB3794.1E1D9781@rochester.rr.com> on Mon, 30 Aug 1999
22:01:57 -0400, Bob Walton <bwalton@rochester.rr.com> says...
> Larry Rosler wrote:
> > In article <37C9F222.8F5E12BD@rochester.rr.com> on Sun, 29 Aug 1999
> > 22:53:23 -0400, Bob Walton <bwalton@rochester.rr.com> says...
...
> > > map {printf OUTFILE "%02x",ord($_)} split(//,$buffer);
> >
> > Heavens! There are four Perl functions in that statement, and it gives
> > the correct results, so it is valid Perl, but it isn't The Way To Do It
> > nevertheless.
> >
> > Benchmark: timing 256 iterations of Map0, Map1, Unpack...
> > Map0: 50 wallclock secs (50.03 usr + 0.00 sys = 50.03 CPU)
> > Map1: 38 wallclock secs (37.23 usr + 0.00 sys = 37.23 CPU)
> > Unpack: 1 wallclock secs ( 0.77 usr + 0.00 sys = 0.77 CPU)
>
> Excellent point, Larry. But I can never remember if it is pack or unpack, h or H,
> etc, and I'm too lazy to look it up each time I need it (perlfunc isn't real clear,
> so I have to go to a book).
I agree that `perlfunc -f pack` is rather sketchy, but are there books
that describe it better?
> Since laziness is a virtue, I let the computer do the
> work.
Lots of work. :-)
> Is there a good handy way of remembering about pack and unpack and all that
> goes with them?
Fo me, the 'good handy way' is known as trial and error. <blush>
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 30 Aug 1999 16:18:19 -1000
From: Andrew Keyes <ark@leviathan.soest.ucsd.edu>
Subject: Building perl
Message-Id: <37CB3B6B.A4C90950@leviathan.soest.ucsd.edu>
I'm trying to build perl on a NeXT machine with an OpenStep 4.2 Mach
setup, the Configure seemed to go fine
but the the make and make test have sucked up 200MB of disk space so far
while pumping thousands of lines like
Next token is 59 (';')
Shifting token 59 (';'), Entering state 781Next token is 59 (';')
Shifting token 59 (';'), Entering state 781
Reducing via rule 302 (line 1589), expr ';' -> stmt
state stack now 0 1 3 29 73 192 323 443 549 345 463 557 621 677 681 714
738 788 819 345 463 557 622 681 714 738 788 819
Entering state 840
Reducing via rule 295 (line 1557), save_filename save_lineno stmt ->
lineno_labeled_stmt
state stack now 0 1 3 29 73 192 323 443 549 345 463 557 621 677 681 714
738 788 819 345 463 557 622 681 714 738
Is this possiblity what it should be doing ? Or did something go wrong
a along the way. I didn't expect it to
take 100's of MB of diskspace to build perl.
Andrew Keyes
Oceanography
University of Hawaii
------------------------------
Date: Tue, 31 Aug 1999 00:47:32 GMT
From: mrbog@my-deja.com
Subject: Case insensitive SQL query
Message-Id: <7qf8n0$kir$1@nnrp1.deja.com>
I'm sure a lot of people have asked this. I can't find the answer in my
mySQL book, so I'm asking it too.
My site uses a mySQL database and I need to do a LIKE query that is
case insensitive. So, for example:
SELECT from dbname where name LIKE "%Joe%";
but that's canse sensitive so it only returns "Joe", "Joeseph", etc..
But what I want is for it to also return "Joe", "joe", "Joeseph",
"joeSePh", etc...
Do any of you know how to do that? (I know this isn't exactly a perl
question, sorry..)
mike@friendsandfoes.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 31 Aug 1999 12:08:28 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Case insensitive SQL query
Message-Id: <MPG.1235e428a5c1d8e2989c9e@news-server>
mrbog@my-deja.com writes ..
<completely irrelevant to Perl question deleted>
>Do any of you know how to do that? (I know this isn't exactly a perl
>question, sorry..)
not "exactly" a Perl question ? .. it's not a Perl question at all -
MySQL has a HEAP of documentation .. and a HEAP of mailing lists for
asking these kinds of questions
you're far more likely to find someone there that'll be able to answer
your question .. we know about Perl - not MySQL .. if I were to take a
wild stab in the dark - I'd say their web page is probably www.mysql.com
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: 30 Aug 1999 19:50:17 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How to "unoverride" functions?
Message-Id: <x7k8qcvneu.fsf@home.sysarch.com>
>>>>> "A" == Abigail <abigail@delanet.com> writes:
A> pgmr (a@b.com) wrote on MMCLXXXVI September MCMXCIII in
A> ~~ had answered my question, I went back and took a look at your reply
A> ~~ once again. My apologies. I missed that line before and thought you
A> ~~ were a newbie who was trying to be helpful, but had misunderstood or
A> Thinking that I'm a newbie. That's cute. You must be new here.
A> ~~ were some netkook - as there are plenty about.
she ain't no newbie, but i am not sure about netkook!
:-)
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Mon, 30 Aug 1999 23:47:26 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: how to open file descriptor by number?
Message-Id: <iKEy3.74$rB5.4025@nsw.nnrp.telstra.net>
In article <7qecjs$pko$1@lublin.zrz.tu-berlin.de>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> So here, the "=" seems to be required. Inconclusive, I love it.
The Perl Cookbook, page 261, states:
\begin{quote}
open(FH, "<&=$FDNUM); # open FH to the descriptor itself
open(FH, "<&$FDNUM); # open FH to a copy of the descriptor
use IO::Handle;
$fh->fdopen($FDNUM, "r"); # open file descriptor 3 for reading
[ed: I suppose that '3' is an erratum, and should read '$FDNUM']
To close by number, either use the POSIX::close function or else first
open it as we did previously.
...
Adding an equal sign to ["<&", ">&" and "+<&"] to make "<&=", ">&=" and
"+<&=" is more parsimonious of file descriptors and nearly always what
you want to do.
\end{quote}
Martien
--
Martien Verbruggen |
Interactive Media Division | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd. | reflects this.
NSW, Australia |
------------------------------
Date: Tue, 31 Aug 1999 02:38:33 GMT
From: jim_p_stew@my-deja.com
Subject: I am new to perl
Message-Id: <7qff78$osm$1@nnrp1.deja.com>
I am new to perl programming. I purchased a book
and starting reading the 1st few chapters. It all
makes perfect sense, but I don't know how to do
this:
I will build the scripts using wordpad. Next, I
want to test them. I don't have an account with
telnet access, So I downloaded perl32 for windows
95, and think I installed it correctly (In the
root dir (C:)).
Next, I want to run the script. I assume my 1st
line would be #/perl5/perl. Now, if I put my
scripts in the bin directory, how do I run
them?? Do I need to create an html page to
execute the script, or is there a way I can run
it directly??
Thanks
Jim
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 30 Aug 1999 16:41:14 +0000
From: Perfect Beat <prfctbt@cris.com>
Subject: Insecure dependency in open while running with -T switch
Message-Id: <37CAB429.517FF477@cris.com>
Can anyone shed light on the following message from the perl debugger:
"Insecure dependency in open while running with -T switch"
------------------------------
Date: Mon, 30 Aug 1999 17:04:08 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Insecure dependency in open while running with -T switch
Message-Id: <37CB1BF8.EE5ACB3B@cisco.com>
[ Perfect Beat wrote:
> Can anyone shed light on the following message from the perl debugger:
> "Insecure dependency in open while running with -T switch"
You might be using a open () call to open a file. You are passing the file
name in a variable like this open ( FOO, ">$foo) but the $foo is
getting
a tainted value ( value from an outside untrusted source).
--
------------------------------
Date: Mon, 30 Aug 1999 19:15:48 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Insecure dependency in open while running with -T switch
Message-Id: <MPG.1234daa3d6d1505e989ee6@nntp.hpl.hp.com>
In article <37CB1BF8.EE5ACB3B@cisco.com> on Mon, 30 Aug 1999 17:04:08 -
0700, Makarand Kulkarni <makkulka@cisco.com> says...
> [ Perfect Beat wrote:
>
> > Can anyone shed light on the following message from the perl debugger:
> > "Insecure dependency in open while running with -T switch"
>
> You might be using a open () call to open a file. You are passing the file
>
> name in a variable like this open ( FOO, ">$foo) but the $foo is
> getting
> a tainted value ( value from an outside untrusted source).
Is there any advantage to your answer over simply referring the
questioner to perldiag?
Also, your newsreader continues to throw in random empty lines and line
fragments.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 31 Aug 1999 01:05:20 GMT
From: R.Joseph <streaking_pyro@my-deja.com>
Subject: Interrupts and Graphics in Win32
Message-Id: <7qf9o9$l3r$1@nnrp1.deja.com>
I doubt I will be able to do this with Perl, but I was wondering if it
is possible to use interrupts like you would in C++ using the int()
function. What my main goal here is to use interrupt 13h to get the
computer into a graphics mode, and then use something like pokeb() to
draw to the screen. Is this impossible?? Thanks!
--
R.Joseph
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 30 Aug 1999 23:52:55 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: is the mtime time between date1 and date2?
Message-Id: <rPEy3.76$rB5.4025@nsw.nnrp.telstra.net>
In article <7qdn6h$f4c$1@nnrp1.deja.com>,
Matthew Forder <matthew_j_forder@notes.seagate.com> writes:
> I'm trying to write a script to do some archiving on my system. What I
> need is a way in perl to say "Does the mtime for this file fall between
> time x and time y?".
# perldoc -f stat
my $mtime = (stat '/path/to/file')[9];
my $x = time - 42; # 42 seconds before now
my $y= time - 2 * 42; # 84 seconds before now
print "yeppers\n", if ( $x < $mtime && $mtime > $y );
Not everything requires modules.
Note that the mtime may not be meaningful or available on your system.
Martien
--
Martien Verbruggen |
Interactive Media Division | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd. | you come to the end; then stop.
NSW, Australia |
------------------------------
Date: Mon, 30 Aug 1999 19:21:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: is the mtime time between date1 and date2?
Message-Id: <MPG.1234dc1462531a19989ee7@nntp.hpl.hp.com>
In article <rPEy3.76$rB5.4025@nsw.nnrp.telstra.net> on Mon, 30 Aug 1999
23:52:55 GMT, Martien Verbruggen <mgjv@comdyn.com.au> says...
> In article <7qdn6h$f4c$1@nnrp1.deja.com>,
> Matthew Forder <matthew_j_forder@notes.seagate.com> writes:
> > I'm trying to write a script to do some archiving on my system. What I
> > need is a way in perl to say "Does the mtime for this file fall between
> > time x and time y?".
>
> # perldoc -f stat
>
> my $mtime = (stat '/path/to/file')[9];
> my $x = time - 42; # 42 seconds before now
> my $y= time - 2 * 42; # 84 seconds before now
>
> print "yeppers\n", if ( $x < $mtime && $mtime > $y );
Small logic fluff in there. :-)
> Not everything requires modules.
You bet, especially the hyper-heavy Date modules!
> Note that the mtime may not be meaningful or available on your system.
Are there any such systems? I know there are issues about ctime, but
mtime?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 30 Aug 1999 16:52:19 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Oraperl problems
Message-Id: <37CB1932.2F58A9D4@cisco.com>
[ Tung Kwong Yeong wrote:
> Hence, I suspect I need to recompile my Oraperl. However, I
> encounter the following problems when I compile my per 4.036 and
> Oraperl ver 2.4p.
>
> The error message is as follows:
error messages all snipped...
> I have a few questions which I hope the Oraperl gurus can help me:
> Do I need to recompile my Oraperl when I upgraded the OS,Oracle
> and Netscape web server?
If depends on whether you are referring to Oraperl or oraperl.
(a)Oraperl is a wrapper around the DBI API available as Oraperl.pm
(b)oraperl was the earlier way to access oracle databases. You took the source code
of Perl and created oraperl by linking the oracle libs. This is no longer supported
and is not a good idea.
The good news is that your scripts using oraperl will all work with the wrapper
I am referring to in (a).
So what you need to do now is get the DBI and the DBD ( for oracle) and
then have Oraperl.pm installed to run your scripts. For more information refer to
the DBI FAQ.
--
------------------------------
Date: 30 Aug 1999 23:41:32 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: PERL & EXCEL
Message-Id: <37cb16ac$0$200@nntp1.ba.best.com>
Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> I might add that if someone wants to experiment with reading Excel
> files on Unix then they might want to try out something called LAOLA
> which is referenced on the Win32 pages at <http://www.perl.com> it
> is an attempt to read OLE storage files directly from Perl. I cant
> vouch any further for it I'm afraid.
I've used this before to extract the text from MS Word files using Perl
under Unix. This was about a year ago, using the program included with
the LAOLA distribution called 'lhalw', v. 0.3.8.1. I needed it to
extract the text of some navigational updates issued by the US Coast
Guard (Local Notices to Mariners for the 11th Coast Guard District),
which for some incredibly annoying reason the USCG sees fit to post to
the Internet only as MS Word documents, rather than as plain text.
I really *hate* it when my tax dollars are spent like that.
Anyway, my recollection is that it worked quite well, letting me grab
the text contained in the Word docs more or less cleanly.
An issue I didn't think about at the time, but which occurred to me
more recently, concerns the fact that some non-MS text-extraction
utilities designed to work with Word apparently give you not only the
plain text normally seen in the Word document, but also deleted text
and editorial comments and so on that are stored along with the current
document text proper. A friend told me a funny story about receiving a
marketing flyer from a modem manufacturer that was sent as an MS Word
document, and when he ran it through some sort of text extractor under
Linux to see what it contained he got all sorts of back and forth
discussion between the marketing people and the tech people at the
company in question, debating whether or not the product could actually
do what the flyer claimed it could do.
Poorly documented, continuously mutating, proprietary document formats
definitely have their downside as an information-delivery medium.
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: Mon, 30 Aug 1999 23:19:23 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: perl equivalent of a Unix command line sort?
Message-Id: <%jEy3.54$rB5.4025@nsw.nnrp.telstra.net>
In article <h67ogfo29ty.fsf@baynetworks.com>,
plussier@baynetworks.com (Paul L. Lussier) writes:
>
> Hi all,
>
> I'm trying sort a lists of ip addresses in a script
This happens to work, for various modes of 'work', useability is left
to the reader.
use Socket;
my @sorted_ips = sort { inet_aton($a) cmp inet_aton($b) } @ips;
Martien
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use being
NSW, Australia | a damn fool about it.
------------------------------
Date: Mon, 30 Aug 1999 19:43:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: perl equivalent of a Unix command line sort?
Message-Id: <MPG.1234e12d95d5d449989ee8@nntp.hpl.hp.com>
In article <%jEy3.54$rB5.4025@nsw.nnrp.telstra.net> on Mon, 30 Aug 1999
23:19:23 GMT, Martien Verbruggen <mgjv@comdyn.com.au> says...
> In article <h67ogfo29ty.fsf@baynetworks.com>,
> plussier@baynetworks.com (Paul L. Lussier) writes:
> > I'm trying sort a lists of ip addresses in a script
>
> This happens to work, for various modes of 'work', useability is left
> to the reader.
>
> use Socket;
> my @sorted_ips = sort { inet_aton($a) cmp inet_aton($b) } @ips;
It 'works' rather better than I expected, in fact.
Benchmark: timing 1 iterations of Naive, Packed...
Naive: 35 wallclock secs (35.26 usr + 0.00 sys = 35.26 CPU)
Packed: 11 wallclock secs (10.88 usr + 0.00 sys = 10.88 CPU)
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
my $in_file = 'e:/sorting/ips.txt'; # 100_000 lines
my $n = 100_000;
my @in; $#in = $n - 1;
my @out; $#out = $n - 1;
open IN, $in_file or die $!;
@in = <IN>;
use Socket;
sub Naive { # multiple comparisons
@out = sort { inet_aton($a) cmp inet_aton($b) } @in;
}
sub Packed { # pack sortkeys and operands, sort, retrieve operands
@out =
map substr($_, 4) =>
sort
map pack('C4' => /(\d+)\.(\d+)\.(\d+)\.(\d+)/) . $_ => @in;
}
timethese(1 << (shift || 0), {
Naive => \&Naive,
Packed => \&Packed,
});
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 30 Aug 1999 17:21:30 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: perl on linux
Message-Id: <x3yd7w5vuat.fsf@tigre.matrox.com>
GoodfriB@jntf.osd.mil (James R. Goodfriend) writes:
>
> In article <x3yemh3rda0.fsf@tigre.matrox.com>, aqumsieh@matrox.com says...
> >
> >
> >GoodfriB@jntf.osd.mil (James R. Goodfriend) writes:
> >
> >> % perl -pie 's/\r//g' script.pl
> >
> >That should really be:
> >
> > % perl -pi -e 'y/\r//' script.pl
> >
> >If there is something after the '-i', perl takes it as the extension
> >of the backup copy it creates. So it doesn't see the '-e'.
>
> Yes, um, I followed up my own post explaining my error, after
> T.Christiansen alerted me to my gaffe. This was like, 3 weeks ago...
Yes. And someone pointed out my mistake too:
perl -pi -e 'y/\r//d' script.pl
And that was also around 3 weeks ago. Either you or I have problems
with our servers (I've had problems before). But the fact that someone
replied to my post suggests that the problem is in your side this
time.
--Ala
------------------------------
Date: Tue, 31 Aug 1999 02:24:19 GMT
From: finsol@ts.co.nz
Subject: Re: Perl Y2K Bugs on the Internet
Message-Id: <7qfec7$o5o$1@nnrp1.deja.com>
In article <MPG.1233c6255975914d989ed2@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) wrote:
> In article <7q4iq8$fk2$1@nnrp1.deja.com> on Thu, 26 Aug 1999 23:32:25
> GMT, finsol@ts.co.nz <finsol@ts.co.nz> says...
> The following was posted to Fun With Perl, but surely should be seen
by
> the members of this newsgroup, who are explicitly maligned by her in
an
> international general-news medium.
>
> This on CNN:
> http://cnn.com/TECH/computing/9908/24/web.y2k.idg/index.html
>
> Y2K "specialist" Joceleyn Amon looked for Y2K problems "on the web";
> here's what she has to say about a certain programming language:
>
> "One of the most vocal programming groups who resent any
> mention of Y2K on their newsgroup are developers using the
> Perl programming language," she said.
>
> Reading between the lines, it appears that Amon may have read
> production Perl code on the web:
>
> "We rarely have our code reviewed by our peers, not even, it
> seems, when it is published on the Web for all to see," she
> says.
>
> Of course, it's hard to understand how you could read the Perl code
> (presumably written for the CGI) on a well-designed webpage. Perhaps
> this has some correlation with her findings regarding the "Y19.1K
> bug".
>
> There is also something called a "booby trap" bug! And many people
> (probably some of them Perl programmers) dispute its existence!!
>
> The only logical solution is not to surf to any Perl-driven web sites
> come 1/1/00; who knows WHAT might happen if you're looking at
> http://www.perl.com/ come midnight!
>
Contrary to what you (and the writer of the item you posted) thought you
may have read, my research had very little to do with the Y2K compliance
of the 'live' code behind web pages. What Y2K bugs they may contain is
anybody's guess as the code is not accessible! My own opinion is that
'live' web code is as riddled with Y2K bugs as the code which is
published on the web as examples or as programming language tutorials.
It is this published code that my article refers to.
Perhaps you could actually read the article before you comment. It is
available at URL:
http://www.y2kinfo.com/journal/features/0899_amon.html
This topic deserves more intelligent thought than you are obviously
prepared to devote to it.
Jocelyn Amon
--
Financial Solutions Limited
http://www.ts.co.nz/~finsol/
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 30 Aug 1999 20:17:29 -0700
From: James Hensinger <ascot@aquafind.com>
Subject: Queries
Message-Id: <37CB4949.5698DB2F@aquafind.com>
I have Linux Red Hat running MySQL and a database with multiple tables.
Is there a command I can use to stop when each page is full like in dos
the /p stopped when each screen page was full. Or where on the net can
I find the different commands?
Cheers,
Jim
------------------------------
Date: Mon, 30 Aug 1999 17:34:41 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Queries
Message-Id: <37CB2320.7FD82296@cisco.com>
[ James Hensinger wrote:
> I have Linux Red Hat running MySQL and a database with multiple tables.
This is not the correct newsgroup for asking questions on Linux/MySQL etc.
> Is there a command I can use to stop when each page is full like in dos
> the /p stopped when each screen page was full. Or where on the net can
> I find the different commands?
You have not mentioned what program or utility is generating these pages --
If these pages were being generated at the SQL prompt as a result
of lengthy query results then you have to refer to that SQL utility
to find the answer. Using SQLPlus on a Oracle system requires
you to use "set pause on" to put the output in paged mode.
If this was a Perl Program or a C program generating these pages
you can pipe your output to 'more' or 'less'.
--
------------------------------
Date: Tue, 31 Aug 1999 11:29:56 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Queries
Message-Id: <MPG.1235d3572a3a55a6989c9c@news-server>
James Hensinger writes ..
>I have Linux Red Hat running MySQL and a database with multiple tables.
>Is there a command I can use to stop when each page is full like in dos
>the /p stopped when each screen page was full. Or where on the net can
>I find the different commands?
did you even look at the newsgroup that you were posting to ? .. or are
you just really good at hiding your Perl question ?
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Tue, 31 Aug 1999 09:22:55 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Redirecting STDERR to STDOUT (on NT)
Message-Id: <MPG.1235bd584b3bf730989c9a@news-server>
Paulius writes ..
>how can I redirect STDERR to STDOUT so die "string" would work
>correctly?
I'll ignore the "so die [...] would work correctly" and just answer the
first part of your question (die works correctly on all the NT systems
I've used it on without any intervention)
redirecting STDERR to STDOUT is done on NT the same as it is done on
UNIX .. see the documentation on open() in the perlfunc documentation
for examples and explanations
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Mon, 30 Aug 1999 16:12:54 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Searching with 2 input fields
Message-Id: <37CB0FF5.3D1CD10E@cisco.com>
ICEMOUNTAIN@prodigy.net wrote:
> ..... and I want to search that with 2 input fields (model and year), I
> cant get it to work though. It works if I search with only one field.
You do..
$searchstr = "$in{'year'}, $in{'model'}";
Just keep these search items separate ..
$searchstr_year = $in{'year'} ;
$searchstr_model = $in{'model'} ;
and then later on instead of
if ($year, $model =~ $searchstr)
{
}
match like this..
if ( ($year eq $searchstr_year) && ($model eq $searchstr_model) ) {}
You may want to have $searchstr_model, $searchstr_year, $model
and $year trimmed of leading and trailing whitespace.
--
------------------------------
Date: Mon, 30 Aug 1999 19:49:19 -0400
From: <ICEMOUNTAIN@prodigy.net>
Subject: Re: Searching with 2 input fields
Message-Id: <7qf5gs$24ki$1@newssvr03-int.news.prodigy.com>
Thanks it worked. Shouldn't I change @results too? I didn't understand
"You may want to have $searchstr_model, $searchstr_year, $model
and $year trimmed of leading and trailing whitespace."
though.
------------------------------
Date: Mon, 30 Aug 1999 17:25:54 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Searching with 2 input fields
Message-Id: <37CB2111.9E8C7B7C@cisco.com>
[ ICEMOUNTAIN@prodigy.net wrote:
> Shouldn't I change @results too? I didn't understand
Yes. You no longer need @results. Just open the datafile and
read each line to see if this line has information for that
year and model.
--
open(INF,$datafile) ||die "cannot open datafile..." ;
# read each line from the file and find
# if this line has the information for that model and year..
while ( $mydata = <INF> )
{
$found = 0;
($year,$model,$num,$width) = split(/\|/, $mydata );
if (($year eq $searchstr_year) && ( $model eq $searchstr_model ))
{
# your 2 print statements to emit HTML go here.
$found =1 ; # atleast on line with information found..
}
}# end while
close (INF) ;
#next statement will be <<botHTML ..
--Hope this minor modification will help.
------------------------------
Date: Mon, 30 Aug 1999 22:19:32 -0400
From: <ICEMOUNTAIN@prodigy.net>
Subject: Re: Searching with 2 input fields
Message-Id: <7qfeg9$51um$1@newssvr03-int.news.prodigy.com>
thanks for the help.
------------------------------
Date: Tue, 31 Aug 1999 09:13:03 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: STDIN, Arrays and Win32
Message-Id: <MPG.1235bb0cb5a0299c989c99@news-server>
[ item posted to comp.lang.perl.misc and CCed to Philip M. Cohen ]
Philip M. Cohen writes ..
>elephant wrote:
>
>> C:\>copy con x.pl
>> #!perl -w
>> use strict;
>>
>> my @a = <STDIN>;
>>
>> print ":: $_" for @a;
>> __END__
>> ^Z
>> 1 file(s) copied.
>>
>> C:\>perl x.pl
>> abc
>> def
>> ghi
>> ^Z
>> :: abc
>> :: def
>> :: ghi
>>
>> C:\>
>
>When I try this, the control-Z works as stated for creation of x.pl (have
>to press
>Enter afterward), but when I run x.pl, control-Z immediately terminates
>input (no
>Enter needed, or even possible). And the output is different. The first
>time:
>
>C:\>perl x.pl
>abc
>def
>ghi
>:: abc
>:: def
>:: ghi
>
>C:\>
>
>And thereafter, the first output line after control-Z disappears:
>
>C:\>perl x.pl
>abc
>def
>ghi
>:: def
>:: ghi
>
>C:\>
>
>This happens regardless of what I print as the first line after control-Z.
>
>Every once in a while :: abc (or whatever) will reappear and then go away
>again, but ^Z never shows up.
>
>This happens on both my home and work Win95 systems, using ActiveState's
>build 519 of Perl 5.005_03.
thanks for taking the time to post this information Philip ..
unfortunately the problem seems so bizarre that it serves only to
further justify people's choice of WinNT over Win95 .. I can't even
guess why it would be doing what you say
other people have said that ^D is actually the EOF character on Win95 ..
if you're in the experimentation mood - perhaps you could try using ^D
as the termination character in both the "copy con" and in the STDIN
input to perl
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Mon, 30 Aug 1999 17:24:45 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: UNIX or NT ?
Message-Id: <x3ybtbpvu5f.fsf@tigre.matrox.com>
Mandeep Singh <singh_mandeep@jpmorgan.com> writes:
> Is there a way to know which operating system you are on from inside
> perl script?
Yes. Read the documentation. From perlfaq8:
How do I find out which operating system I'm running under?
--Ala
------------------------------
Date: Mon, 30 Aug 1999 19:25:07 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Want to use PERL to run script on another server.
Message-Id: <mbudash-3008991925070001@adsl-216-103-91-123.dsl.snfc21.pacbell.net>
In article <37CACE5A.EB1CFB70@bridge.bellsouth.com>, Mark Conlin
<Mark.Conlin@bridge.bellsouth.com> wrote:
>Mark Conlin wrote:
>>
>> I would like to use PERL to run another PERL script on a different
>> server.
>>
>> Is there a way to access the script as if I had hit it with a web
>> browser, from
>> inside a different script on a different server ?
>>
>> thanks
>>
>
>I thought I would answer my own question, what I was looking
>for really was a UNIX command and not a Perl command.
>
>rsh, allows you to get to another server, if you have a login
>there and you can run a command.
>
>So, I am going to use that to get to the other server
>and hit the script.
>
>Mark
>
i think you'll find using LWP::Simple is the way...
--
| Michael Budash Consulting | 707-252-7670 voice |
| Perl, Javascript, PHP, MySQL | 603-250-8679 fax |
| Official Extropia Developer | mbudash@sonic.net |
------------------------------
Date: Tue, 31 Aug 1999 02:43:02 GMT
From: aprmelton@my-deja.com
To: datandomains@datandomains.com
Subject: WANTED: Mentor / Collaborative Partner
Message-Id: <7qfffk$ovn$1@nnrp1.deja.com>
Wanted:
Experienced programmer to act as a mentor and help make minor
modifications to pre-existing scripts. Mostly in need of someone to help
troubleshoot errors I have made. Pay negotiable and/or additional
commissions on future sales resulting from programs.
Requirements:
CGI/Perl with a Unix background. Examples of past work.
--
Sincerely,
April Melton
------------------------
Owner
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 683
*************************************