[17363] in Perl-Users-Digest
Perl-Users Digest, Issue: 4785 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 1 14:05:52 2000
Date: Wed, 1 Nov 2000 11:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973105508-v9-i4785@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 1 Nov 2000 Volume: 9 Number: 4785
Today's topics:
Re: Bitreverse an integer (Gary E. Ansok)
Re: CGI file uploading nobull@mail.com
CGI slow, command line fast ? mgrabens@popd.isinet.com
Re: cutting / parsing URLS out of a live HTML document <maartenh@usa.net>
Gtk-Perl & Keyboard <josef.zellner@aon.at>
Hardwood Website <jer550@earthlink.net>
Re: How can Perl on Win32 recognize troublesome Macinto <mischief@velma.motion.net>
how do I pass params to perlis.dll via url? <awright@jwac.osis.gov>
Re: In case you were wondering <jboes@eomonitor.com>
Re: newbie again <dsimonis@fiderus.com>
Re: openssl-0.9.6 perl compilation problems <gregm@netidea.com>
out of memory problem under mod_perl <mahnke@fliegen-ist-schoener.de>
Re: Perl Question <james@NOSPAM.demon.co.uk>
Re: Perl Question (Tad McClellan)
print value (ade t)
Re: print value <madden@cms-stl.com>
Re: Problem Passing Test With Msql-Mysql-modules-1.2215 <npasich@sd.cts.com>
Re: regular expression <james@NOSPAM.demon.co.uk>
Re: regular expression <ren.maddox@tivoli.com>
Re: regular expression (Tad McClellan)
Re: running UNIX utilities in perl (Chris Fedde)
Re: sending webpage form <xzrgpnys@yvtugubhfrovm.pbz>
Re: SMS - text messaging <xzrgpnys@yvtugubhfrovm.pbz>
Sorting an array of arrays zabor@my-deja.com
Re: Sorting an array of arrays <kjetilskotheim@iname.com>
Re: Sorting an array of arrays <ren.maddox@tivoli.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Nov 2000 16:57:48 GMT
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: Bitreverse an integer
Message-Id: <8tpi2c$ris@gap.cco.caltech.edu>
In article <8tod03$8ek$1@provolone.cs.utexas.edu>,
Logan Shaw <logan@cs.utexas.edu> wrote:
>
> n-1
> __
> \ k n
> /_ 2 = 2 - 1
> k=0
>
>So, I thought maybe a similar solution might be possible for the one
>involving 4 to the k, which would make it easy to compute masks like
>01010101 in constant time.
How about:
n-1
__
\ k 2n
/_ 4 = (2 - 1) / 3
k=0
Actually, this works for odd numbers of bits, too, if you int() the result.
-- Gary
------------------------------
Date: 01 Nov 2000 18:11:08 +0000
From: nobull@mail.com
Subject: Re: CGI file uploading
Message-Id: <u9lmv3sgub.fsf@wcl-l.bham.ac.uk>
stupot999@my-deja.com writes:
> i am trying to find out
I find it somewhat hard to believe that you are trying. Would you
care to enumerate exaclty what forms this trying has taken to date?
Have you done a Usenet search? Have you looked in the manual?
> ...how to use cgi to allow people to upload files to my server.
Read the documentation of the CGI module that comes with Perl.
Pay particular attension to the bit that deals with uploading.
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Did you know that Deja is French (and possibly Latin too) for
"already"? Deja.com (formerly "DejaNews") is so called bacause it
allows to see if the question you are about to ask on Usenet has been
asked and answered already.
For anyone to post a question to Usenet without doing a search first
is bad enough, to do it via Deja is simply indefensible.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 01 Nov 2000 17:17:48 GMT
From: mgrabens@popd.isinet.com
Subject: CGI slow, command line fast ?
Message-Id: <8tpj7j$6jg$1@nnrp1.deja.com>
I am having a odd problem. I wrote a simple little subroutine that uses
regular expressions to parse a file. When I hit a particularly large
file it takes the CGI 15-20 seconds to parse it. To look into the
performance issues, I wrote a command line script that uses the library
and parses the same file. The command line version takes between 1.5 and
2 seconds (used Time::HiRes).
I have tested the CGI on both apache and Netscape server, same basic
time results.
Both the CGI and command line are using the same Perl. Run times were
taking one right after another, so system load may have changed, but not
that drastically. Plus the time differences are consistently off by
roughly the same amount. (ie. 1.5 seconds from the command line, CGI 15
seconds, 1.9 seconds from the command line, CGI 19 seconds).
It is definately not a decimal problem (though it appears like that).
I have printed out the information as I parse it with a time stamp and
it shows a natural progression through the file. IOW: the regular
expressions are not getting into some strange loop. (no visible jumps in
seconds between any part of the file, nice and consistant.)
Does the priority level cause this much of a difference ?
Any other ideas ?
I am stumped...
Thanks,
Mike
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 1 Nov 2000 20:42:41 +0100
From: "Maarten" <maartenh@usa.net>
Subject: Re: cutting / parsing URLS out of a live HTML document
Message-Id: <8tpnf5$oqn$1@azure.nl.gxn.net>
Ted,
Thanks a lot. It works as you described. I will also find out what the
LinkExtor module can do for me. Besides the URL's, I want to use other parts
of the code as well, and I am trying to find out the best way to do that.
Now that I can use parts of a live web page I am going to play a bit more
with the perl code. Anyway, I learned a lot of your comments, thanks.
--
gtx, maarten
------------------
maarten@hartsuijker.com
Tad McClellan <tadmc@metronet.com> wrote in message
news:slrn9003lf.a5b.tadmc@magna.metronet.com...
> On Tue, 31 Oct 2000 23:27:53 +0100, Maarten <maartenh@usa.net> wrote:
> >>
> >> print "$1 \n" if ($stuff =~ /"(http.*)">/i);
> >
> >Hey Chris,
> >
> >Thanks a lot for your reply, but it's still not working.
> >tried this one:
> >---------
> >use LWP::Simple;
> >$stuff= get('http://www.hartsuijker.com/2000egypt_ses_index.html');
> >open STUFF, $stuff;
> >while (<STUFF>) {
> >print "$1 \n" if ($_ =~ /"(http.*)">/i);
> >}
> >--------
> >but no cigar :-(
>
>
> You have multiple problems, the largest problem appears to be
> confusion about the distinction between a filename and data.
>
> If you had checked the return value from the open() you would
> have gotten a hint about what you are doing wrong.
>
> You should always, yes *always*, check the return value from open():
>
> open STUFF, $stuff or die "could not open '$stuff' $!";
>
> That is likely to make boatloads of output.
>
> The second argument to open() is a filename. Do you have a
> filename in the $stuff variable? No. You have the _contents_
> of a web page (data) in $stuff.
>
> You are trying to open a file with a ridiculously long name like
>
> <HTML><BODY><P>Hello World</P></BODY></HTML>
>
> That is, you are using the _entire contents_ of the web page
> as if it was simply a filename.
>
>
>
> You *already have* the data you need from the get(). You do
> not need any file I/O at all!
>
>
> use LWP::Simple;
> $stuff= get('http://www.hartsuijker.com/2000egypt_ses_index.html');
> print "$1 \n" if ($stuff =~ /"(http.*)">/i);
>
>
> But that only finds the first one. To find all of them:
>
> print "$1 \n" while $stuff =~ /"(http.*)">/ig;
> ^^^^^ ^
> ^^^^^ ^
>
> Or, if you want to process the web page a-line-at-a-time
> for some reason, break it up into lines:
>
> while ( $stuff =~ /(.*\n)/g ) {
> my $line = $1;
> print "$1 \n" while $line =~ /"(http.*)">/ig;
> }
>
>
> You have yet another problem. Your pattern match will not
> do the Right Thing with:
>
> # one big "line"
> $stuff = '<a href="http://www.perl.com">Perl</a>'
> . ' <a href="http://www.perl.org">Perl Mongers</a>';
>
> .* is greedy and matches as much as it can, which is too much for
> your application.
>
> I suggest you change it to:
>
> print "$1 \n" while $stuff =~ /"(http[^"]*)">/ig;
>
>
> But then there is yet still another problem!
>
> Your code will not do the Right Thing with this perfectly legal HTML:
>
> <a href='http://www.perl.com'>
>
>
> Hopefully by now you realize that what you are trying to do is
> a great deal harder than you might imagine it is.
>
> Use a module that has already handled all of the problems.
>
> The HTML::LinkExtor module's purpose in life is to do what
> you are attempting to do. I'd just use that.
>
>
> --
> Tad McClellan SGML consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Wed, 01 Nov 2000 20:06:19 +0100
From: Josef Zellner <josef.zellner@aon.at>
Subject: Gtk-Perl & Keyboard
Message-Id: <3A0069AB.4BEFA5B8@aon.at>
Hi all!
How can I recognize a keyboard hit in Gtk-Perl?
THX
------------------------------
Date: Wed, 01 Nov 2000 17:42:05 GMT
From: "cfd" <jer550@earthlink.net>
Subject: Hardwood Website
Message-Id: <NBYL5.10042$Pw6.654678@newsread1.prod.itd.earthlink.net>
Hardwood floors and more! See the natural beauty of hardwood flooring =
and hardwood designs at www.classicdistributors.com or =
http://209.35.59.31!
------------------------------
Date: Wed, 01 Nov 2000 18:12:59 -0000
From: <mischief@velma.motion.net>
Subject: Re: How can Perl on Win32 recognize troublesome Macintosh filenames?
Message-Id: <t00n9bq3sds497@corp.supernews.com>
Doug Coppage <dpc3k@virginia.edu> wrote:
> Greetings, Earth Creatures!
> I have put in place a simple Perl script on our department's WinNT server
> that traverses the trees of public directories and deletes all files that
> are more than N days old. It works fine *except* that filenames made by
> sneaky Macintosh users can have characters that are illegal in Windows and
> important in Perl, e.g. "Report 10/04/00". Hmm: those strokes are nasty.
I'd say the most simple solution, albeit an unwieldy one in practice,
would be to set up a policy about how to name files.
> The Perl script finds these files in a loop using readdir (as attested by a
> print statement), but a test like
> if ( -f $filespec )
> returns FALSE. Therefore, calls to find the ages of these files fail, as do
> attempts to rename them or to perform all other file tests or operations.
> So, without some way to get past the funky filename characters, the Perl
> script is powerless.
The -f test isn't the most important one here. If it's a public directory
on an NT box, it can't be a Unix domain socket or Unix device file. If it
shows up in a readdir() call's return value, then the slashes aren't
directory delimiters. The most important call then is stat(). You didn't
mention whether or not stat() worked on these files. If -f doesn't, stat()
probably won't either, but it's worth a shot. You need stat() or -M, -A,
or -C find the age of the file anyway. You might also make sure if you
need to test that you are escaping characters and you might try -e instead
of -f.
> I have manipulated the files using DOS commands and the Windows menus, and
> yes, they are files of the ordinary variety (MS Word docs, TIFFs, etc.),
> only with troublesome chars in the filenames.
Here you mention a smart way to take care of these files, although not
the ideal. If DOS commands give you the right info, you could use DOS
to find the age of the files and to delete them.
@file = `dir /q/ta`; ### this will give you a list of files with
### last-accessed times and who the owner is
### for each file
If you really have a hard time with the long filenames, try:
@file = `dir /x/q/ta`; ### this will put in a field that contains the
### archaic 8.3 interpretation of the file name
### used by DOS apps, which won't contain slashes
This does mean you'll have to split the information out into separate
variables and do some calculations, but it should get around your
difficulties.
> Q: Is there another way to grab these files and manipulate them via Perl?
> Any suggestions would help very much.
> Thanks,
> ---Doug Coppage
> ===========================================
> Douglas P. Coppage, dpc3k@virginia.edu
> Microcomputer Support Specialist
> ITC - Academic Computing for the Health Sciences
> University of Virginia, Charlottesville, VA
> http://www.med.virginia.edu/achs
> ===========================================
Ah, the days of DOS! Never thought you'd be glad to see an 8.3 filename
limit did you? Can't say that I blame you there, but this is actually
a workable if inelegant solution. Thank Larry for making Perl a glue
language before you thank me for RTFM on the NT/2000 dir command.
Sorry I can't offer a better solution. Unfortunately, the /b and /x
arguments for dir seem mutually exclusive. You might check into /a-d
though.
HTH,
Chris
--
Christopher E. Stith
mischief@motion.net
------------------------------
Date: Wed, 01 Nov 2000 18:14:15 GMT
From: PhyloBhetto <awright@jwac.osis.gov>
Subject: how do I pass params to perlis.dll via url?
Message-Id: <8tpmhe$9k2$1@nnrp1.deja.com>
I've a script that (for some reason) won't run under ssl with perl.exe
so I've remapped the dir to use perlis.dll. Now the script runs, but
doesn't get any params I've passed to it!
I used to be able to do something similar to this:
http://blah.com/scriptfile.pl?param1
now, it doesn't recognize "param1"
in my code, I reference "param1" by ARGV[0]
what am I doing wrong?
Thanks for any help.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 01 Nov 2000 14:51:00 -0500
From: Jeff Boes <jboes@eomonitor.com>
Subject: Re: In case you were wondering
Message-Id: <3a0065db$0$35011$44a10c7e@news.net-link.net>
amonotod wrote:
>
> In article <39ff4410.361e$235@news.op.net>,
> mjd@plover.com (Mark-Jason Dominus) wrote:
> >
> > In article <SpGL5.195$v37.180435@news.uswest.net>,
> > Jerome O'Neil <jerome.oneil@360.com> wrote:
> > >mjd@plover.com (Mark-Jason Dominus) elucidates:
> > >
> > >> For the record, the dish I ordered was chicken livers sauteed in
> > >> pomegranate molasses.
> > >
> > >And what was the final verdict?
> >
> > It was tasty, but disappointingly mundane. I would not have had any
> > idea that it had been cooked in pomegranate molasses if I had not been
> > told.
> >
> > Despite his assertion to the contrary, ("I ordered something vaguely
> > meat-like and safe") Nat ordered a dish of braised dandelion greens.
> > I liked them; he didn't.
> >
> And do you now go out into your backyard every summer, killing the
> grass so that the dandelions can thrive? My wife's cousin has
> fermented dandelion wine the last several years...
>
This is related to the subject of c.l.p.m. in what manner, please? And
how is this :less: off-topic than discussions about Perl and Apache,
Perl and CGI, Perl and DBI?
Stones, glass houses, and imparting of horizontal momentum thereto. Take
it to email.
--
Jeff Boes <jboes@eoexchange.com> Tel: (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc. http://www.eoexchange.com/
Search, Monitor, Notify. http://www.eomonitor.com/
------------------------------
Date: Wed, 01 Nov 2000 11:18:14 -0500
From: Drew Simonis <dsimonis@fiderus.com>
Subject: Re: newbie again
Message-Id: <3A004246.46B71FE2@fiderus.com>
[Please use meaningfull subjects. "newbie again" won't catch too many
people's interest]
"vertical.reality" wrote:
>
> I have a write to csv script
> It uses a hidden field in the html form to specify the csv file to write to.
> How can I embed the path to the file into the script, so remove the hidden
> field, as it will be the same file every time
>
> Is it something to do with this section ?
Yes.
>
> $query_string=$ENV{QUERY_STRING};
> if(($query_string=~/^file=([^&\b]+)/i)||($query_string=~/&file=([^&\b]+)/i))
> {
I see you aren't using CGI.pm. Using CGI.pm makes figuring out stuff
like this much easier.
> $CSV_file=$+;
> $CSV_file=~s/%([\dA-Fa-f][\dA-Fa-f])/pack("C",hex($1))/eg;
> $CSV_file=~tr/+/ /;
The above 3 lines are removing the URI encoding from the variable
$CSV_file. You can scrap them since you won't be using this variable
anymore. replace with:
$CSV_file = '/path/to/file'
> @line=&modify_CSV($CSV_file);
This line calls the subroutine with the name of the file as
an argument. This can remain unchanged since we are still using
the $CSV_file variable, just with our own information.
------------------------------
Date: Wed, 01 Nov 2000 09:53:06 -0800
From: Greg Martin <gregm@netidea.com>
Subject: Re: openssl-0.9.6 perl compilation problems
Message-Id: <3A005882.7EBF3080@netidea.com>
Jeff Haferman wrote:
>
> I'm having problems "making" the openssl-0.9.6 perl stuff,
> specifically, make craps out when compiling openssl_digest:
>
> /usr/bin/perl -I/usr/libdata/perl/5.00503/mach -I/usr/libdata/perl/5.00503 /usr/libdata/perl/5.00503/ExtUtils/xsubpp -typemap /usr/libdata/perl/5.00503/ExtUtils/typemap -typemap typemap openssl_digest.xs >xstmp.c && mv xstmp.c openssl_digest.c
> cc -c -I../include -DVERSION=\"0.94\" -DXS_VERSION=\"0.94\" -DPIC -fpic -I/usr/libdata/perl/5.00503/mach/CORE openssl_digest.c
> openssl_digest.xs: In function `XS_OpenSSL__MD_name':
> openssl_digest.xs:48: invalid type argument of `->'
> openssl_digest.xs:48: warning: assignment discards `const' from pointer target type
> openssl_digest.xs: In function `XS_OpenSSL__MD_init':
> openssl_digest.xs:57: warning: passing arg 2 of `EVP_DigestInit' makes pointer from integer without a cast
> *** Error code 1
>
> I tried using gcc also, same problem.
> On FreeBSD 4.0, Perl 5.005_03
>
> Any ideas? Thanks,
You did say any ideas ... it's possible that if the arguments are
returned from functions the declarations aren't in scope. The previous
standard for C (still representred by most compilers I believe) said
that if a declaration isn't in scope the default was to return an
integer. Sometimes the order of headers can cause a problem like this.
If the arguments are return values from functions you might search for
the definitions and make sure they are in scope.
--
Regards,
Greg Martin
gregm@netidea.com
------------------------------
Date: Wed, 1 Nov 2000 19:07:30 -0000
From: "Christian Mahnke" <mahnke@fliegen-ist-schoener.de>
Subject: out of memory problem under mod_perl
Message-Id: <8tplo4$91n$01$1@news.t-online.com>
hello group,
I get the following error under high load. Has anybody seen that before? Do
I need more memory, and if so why does the OS (Linux) doesn`t manage with
the swap? Any help is highly appriciated.
Erroo Log:
Sun Oct 29 15:23:25 2000] [notice] Apache/1.3.9 (Unix) Debian/GNU
mod_perl/1.21_03-dev configured -- resuming normal operations
[Sun Oct 29 15:23:22 2000] [notice] SIGUSR1 received. Doing graceful
restart
[Sun Oct 29 13:48:44 2000] [notice] child pid 14620 exit signal Alarm
clock (14)
Callback called exit.
Out of memory!
Ouch! malloc failed in malloc_block()
Callback called exit.
Out of memory!
Callback called exit.
Out of memory!
Callback called exit.
Out of memory!
[Sun Oct 29 11:47:25 2000] [error] server reached MaxClients setting,
consider raising the MaxClients setting
Callback called exit at /dev/null line 319.
END failed--cleanup aborted at /dev/null line 319.
Callback called exit at /dev/null line 319.
Callback called exit at /dev/null line 319.
END failed--cleanup aborted at /dev/null line 319.
Callback called exit at /dev/null line 319.
END failed--cleanup aborted at /dev/null line 319.
Callback called exit at /dev/null line 319.
Callback called exit at /dev/null line 319.
Out of memory!
Out of memory!
Out of memory!
Callback called exit at /dev/null line 4.
END failed--cleanup aborted at /dev/null line 4.
Callback called exit at /dev/null line 4.
END failed--cleanup aborted at /dev/null line 4.
Callback called exit at /dev/null line 4.
END failed--cleanup aborted at /dev/null line 4.
Callback called exit.
Callback called exit.
Callback called exit.
Out of memory!
Out of memory!
Out of memory!
Ouch! malloc failed in malloc_block()
[Sun Oct 29 06:25:18 2000] [notice] suEXEC mechanism enabled (wrapper:
/usr/lib/apache/suexec)
------------------------------
Date: Wed, 1 Nov 2000 17:32:32 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Perl Question
Message-Id: <ant0117327a1fNdQ@oakseed.demon.co.uk>
In article <slrn9003vu.a5b.tadmc@magna.metronet.com>, Tad McClellan
<URL:mailto:tadmc@metronet.com> wrote:
>
> Nobody reads all the articles posted here (there are just too many).
>
> So they must decide somehow which ones they will read and which
> ones they will skip. Most do this by looking at the Subject.
>
> Many folks will skip an article if they cannot tell what it
> is about from the Subject header.
I agree that Subject: lines should be descriptive of the matter under
discussion where possible, but I'm curious about your suggestion that
people actually skip articles that do not have a descriptive subject.
If I see a subject that I know I won't find interesting then I skip
it, but if the subject tells me nothing there is a small chance that
I'll open it to discover what is being discussed. Hmmm, I think I've
just answered my own question - it really is a *very* small chance. :-)
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Wed, 1 Nov 2000 12:37:37 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl Question
Message-Id: <slrn900l71.be8.tadmc@magna.metronet.com>
On Wed, 1 Nov 2000 17:32:32 +0000, James Taylor
<james@NOSPAM.demon.co.uk> wrote:
>In article <slrn9003vu.a5b.tadmc@magna.metronet.com>, Tad McClellan
><URL:mailto:tadmc@metronet.com> wrote:
>>
>> Nobody reads all the articles posted here (there are just too many).
>>
>> So they must decide somehow which ones they will read and which
>> ones they will skip. Most do this by looking at the Subject.
>>
>> Many folks will skip an article if they cannot tell what it
>> is about from the Subject header.
>
>I agree that Subject: lines should be descriptive of the matter under
>discussion where possible, but I'm curious about your suggestion that
>people actually skip articles that do not have a descriptive subject.
>If I see a subject that I know I won't find interesting then I skip
>it, but if the subject tells me nothing there is a small chance that
>I'll open it to discover what is being discussed. Hmmm, I think I've
>just answered my own question - it really is a *very* small chance. :-)
It also depends on how "hurried" the reader is.
When I'm in a hurry (read as "most of the time"), I read only
those who have an interesting Subject. An unknown Subject is
not interesting and I'm too hurried to open it up and see
what is in there. (and poor Subjects have high correlation
with poor articles in my experience anyway)
But I followed up to one of those here :-)
He just happened to catch me in a rare "not very busy" time.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 01 Nov 2000 18:04:42 GMT
From: ade@linux-junky.karoo.co.uk (ade t)
Subject: print value
Message-Id: <3a005ab6.5957501@news.karoo.co.uk>
$i=0;
open (LOG, "<ips.log") || die "Error: $!\n";
@array = <LOG>;
for (@array)
{ $i++; push (@line_nos, $i) if (/$ip/);
}
close <LOG>;
ok i got this far with a little reading from the book and stuuf but
how would i then print the values i have got from this
@array =log file written into mem
{ $i++; push (@line_nos, $i) if (/$ip/); = lines taken out with
correspodig ip from $ip
any help would be greatfull
------------------------------
Date: Wed, 01 Nov 2000 12:33:35 -0600
From: Michael Madden <madden@cms-stl.com>
Subject: Re: print value
Message-Id: <3A0061FF.9B386CEB@cms-stl.com>
Do something like the following:
foreach (@line_nos)
{
print "$_\n";
}
ade t wrote:
>
> $i=0;
> open (LOG, "<ips.log") || die "Error: $!\n";
> @array = <LOG>;
> for (@array)
> { $i++; push (@line_nos, $i) if (/$ip/);
> }
> close <LOG>;
>
> ok i got this far with a little reading from the book and stuuf but
> how would i then print the values i have got from this
>
> @array =log file written into mem
> { $i++; push (@line_nos, $i) if (/$ip/); = lines taken out with
> correspodig ip from $ip
>
> any help would be greatfull
------------------------------
Date: Wed, 01 Nov 2000 10:04:38 -0800
From: Nick Pasich <npasich@sd.cts.com>
Subject: Re: Problem Passing Test With Msql-Mysql-modules-1.2215
Message-Id: <3A005B36.5C56534B@sd.cts.com>
Yes, to both questions.......
I've even reinstalled Perl from scratch...
I've installed it (Mysql Modules) on 2 other
Linux Boxes without any problems.....
-----( Nick )-----
Yann Ramin wrote:
>
> Is MySQL running?
> Did you provide correct test user info?
>
> Yann
> (Real DB people use Postgres :))
>
> Nick Pasich wrote:
>
> >
> > I've successfully compiled, tested and installed DBI-1.14,
> > Data-ShowTable-3.3 and Msql-Mysql-modules-1.2215 on 2 out
> > of 3 Linux systems.
> >
> > The problem arises when running "make test" on
> > Msql-Mysql-modules-1.2215.
> > I'm using MySql 3.22.32 and Perl v5.6.0.
> >
> > I get the following error message:
> >
> >
> ********************************************************************************
> >
> ********************************************************************************
> >
> ********************************************************************************
> >
> >
> > make[1]: Entering directory
> > `/zSRC/MYSQL/PERL/Msql-Mysql-modules-1.2215/mysql'
> > make[1]: Leaving directory
> > `/zSRC/MYSQL/PERL/Msql-Mysql-modules-1.2215/mysql'
> > make[1]: Entering directory
> > `/zSRC/MYSQL/PERL/Msql-Mysql-modules-1.2215/mysql'
> > PERL_DL_NONLAZY=1 /usr/local/bin/perl -I../blib/arch -I../blib/lib
> > -I/usr/local/lib/perl5/5.6.0/i586-linux -I/usr/local/lib/perl5/5.6.0 -e
> > 'use Test::Harness qw(&runtests $verbose); $verbose=0; runtests @ARGV;'
> > t/*.t
> > t/00base............ok
> > t/10dsnlist.........dubious
> > Test returned status 0 (wstat 11, 0xb)
> > t/20createdrop......dubious
> > Test returned status 0 (wstat 11, 0xb)
> > t/30insertfetch.....dubious
> > Test returned status 0 (wstat 11, 0xb)
> > t/40bindparam.......dubious
> > Test returned status 0 (wstat 11, 0xb)
> > t/40blobs...........dubious
> > Test returned status 0 (wstat 11, 0xb)
> > t/40listfields......dubious
> > Test returned status 0 (wstat 11, 0xb)
> > t/40nulls...........dubious
> > Test returned status 0 (wstat 11, 0xb)
> > t/40numrows.........dubious
> > Test returned status 0 (wstat 11, 0xb)
> > t/50chopblanks......dubious
> > Test returned status 0 (wstat 11, 0xb)
> > t/50commit..........dubious
> > Test returned status 0 (wstat 11, 0xb)
> > t/60leaks...........skipped test on this platform
> > t/ak-dbd............dubious
> > Test returned status 0 (wstat 11, 0xb)
> > DIED. FAILED tests 1-90
> > Failed 90/90 tests, 0.00% okay
> > t/dbdadmin..........dubious
> > Test returned status 0 (wstat 11, 0xb)
> > DIED. FAILED tests 1-20
> > Failed 20/20 tests, 0.00% okay
> > Failed Test Status Wstat Total Fail Failed List of failed
> >
> -------------------------------------------------------------------------------
> >
> -------------------------------------------------------------------------------
> > t/10dsnlist.t 0 11 ?? ?? % ??
> > t/20createdrop. 0 11 ?? ?? % ??
> > t/30insertfetch 0 11 ?? ?? % ??
> > t/40bindparam.t 0 11 ?? ?? % ??
> > t/40blobs.t 0 11 ?? ?? % ??
> > t/40listfields. 0 11 ?? ?? % ??
> > t/40nulls.t 0 11 ?? ?? % ??
> > t/40numrows.t 0 11 ?? ?? % ??
> > t/50chopblanks. 0 11 ?? ?? % ??
> > t/50commit.t 0 11 ?? ?? % ??
> > t/ak-dbd.t 0 11 90 90 100.00% 1-90
> > t/dbdadmin.t 0 11 20 20 100.00% 1-20
> > 1 test skipped.
> > Failed 12/14 test scripts, 14.29% okay. 110/115 subtests failed, 4.35%
> > okay.
> > make[1]: *** [test_dynamic] Error 255
> > make[1]: Leaving directory
> > `/zSRC/MYSQL/PERL/Msql-Mysql-modules-1.2215/mysql'
> > make: *** [test] Error 2
> >
> >
> ********************************************************************************
> >
> ********************************************************************************
> >
> ********************************************************************************
> >
> > Any help would be GREATLY appreciated............
> >
> > -----( Nick Pasich )-----
>
> --
>
> --------------------------------------------------------------------
> Yann Ramin atrus@atrustrivalie.eu.org
> Atrus Trivalie Productions www.redshift.com/~yramin
> AIM oddatrus
> Marina, CA http://profiles.yahoo.com/theatrus
>
> IRM Developer Network Toaster Developer
> SNTS Developer KLevel Developer
> Electronics Hobbyist person who loves toys
>
> Build a man a fire, and he's warm for a day.
> Set a man on fire, and he'll be warm for the rest of his life.
>
> "I'm prepared for all emergencies but totally unprepared for everyday
> life."
> --------------------------------------------------------------------
--
WebSite: http://www.users.cts.com/sd/n/npasich
_ _
_ __ _ __ __ _ ___(_) ___| |__
| '_ \| '_ \ / _` / __| |/ __| '_ \
| | | | |_) | (_| \__ \ | (__| | | |
|_| |_| .__/ \__,_|___/_|\___|_| |_|@sd.cts.com
|_|
------------------------------
Date: Wed, 1 Nov 2000 17:36:50 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: regular expression
Message-Id: <ant011750c72fNdQ@oakseed.demon.co.uk>
In article <MPG.1469c52683197d6498ae89@nntp.hpl.hp.com>, Larry Rosler
<URL:mailto:lr@hpl.hp.com> wrote:
> In article <kovvvs0lfh3hbf6i3vjhctml9mc3o8oi0l@4ax.com>,
> bart.lateur@skynet.be says...
>
> ...
>
> > Be aware the the *contents* of $re must be what you would type between
> > the slashes, so you might need some extra backslashes when typing in the
> > regex.
> >
> > $re = '\\d+';
> > /($re)/o
> >
> > is pretty much the same as
> >
> > /(\d+)/
>
> Yes, it is. But your example doesn't require that the backslash be
> doubled.
>
Are you advocating the use of a single backslash as in $re = '\d+';
on the grounds that Perl can see what you mean? If so, this doesn't
seem very maintainable and could easily trip you up later.
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: 01 Nov 2000 11:58:57 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: regular expression
Message-Id: <m3pukf60bi.fsf@dhcp11-177.support.tivoli.com>
James Taylor <james@NOSPAM.demon.co.uk> writes:
> In article <MPG.1469c52683197d6498ae89@nntp.hpl.hp.com>, Larry Rosler
> <URL:mailto:lr@hpl.hp.com> wrote:
> > In article <kovvvs0lfh3hbf6i3vjhctml9mc3o8oi0l@4ax.com>,
> > bart.lateur@skynet.be says...
> >
> > ...
> >
> > > Be aware the the *contents* of $re must be what you would type between
> > > the slashes, so you might need some extra backslashes when typing in the
> > > regex.
> > >
> > > $re = '\\d+';
> > > /($re)/o
> > >
> > > is pretty much the same as
> > >
> > > /(\d+)/
> >
> > Yes, it is. But your example doesn't require that the backslash be
> > doubled.
> >
>
> Are you advocating the use of a single backslash as in $re = '\d+';
> on the grounds that Perl can see what you mean? If so, this doesn't
> seem very maintainable and could easily trip you up later.
Within single quotes, backslash is only special in front of a single
quote or another backslash.
$x = 'you don\'t need a \ for \d or for itself, except to end with \\';
print "$x\n";
__END__
This prints:
you don't need a \ for \d or for itself, except to end with \
Note that even interpolating $x within double-quotes does not affect
the "\d". This is because only one interpolation pass occurs. In a
regex, on the other hand, the \d has meaning after the interpolation.
From perlop(1):
q/STRING/
`'STRING''
A single-quoted, literal string. A backslash
represents a backslash unless followed by the
delimiter or another backslash, in which case the
delimiter or backslash is interpolated.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Wed, 1 Nov 2000 12:45:38 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: regular expression
Message-Id: <slrn900lm2.be8.tadmc@magna.metronet.com>
On Wed, 1 Nov 2000 17:36:50 +0000, James Taylor
<james@NOSPAM.demon.co.uk> wrote:
>In article <MPG.1469c52683197d6498ae89@nntp.hpl.hp.com>, Larry Rosler
><URL:mailto:lr@hpl.hp.com> wrote:
>> In article <kovvvs0lfh3hbf6i3vjhctml9mc3o8oi0l@4ax.com>,
>> bart.lateur@skynet.be says...
>>
>> ...
>>
>> > Be aware the the *contents* of $re must be what you would type between
>> > the slashes, so you might need some extra backslashes when typing in the
>> > regex.
>> >
>> > $re = '\\d+';
>> > /($re)/o
>> >
>> > is pretty much the same as
>> >
>> > /(\d+)/
>>
>> Yes, it is. But your example doesn't require that the backslash be
>> doubled.
>>
>
>Are you advocating the use of a single backslash as in $re = '\d+';
>on the grounds that Perl can see what you mean?
I expect that he is advocating not doing useless things.
Doubling backslashes in single quoted strings is useless,
so why do it? $re gets an identical value whether you
assign '\d+' or '\\d+'.
It slows down maintenance while you mentally
filter out the stuff that is there that does not need to
be there.
>If so, this doesn't
>seem very maintainable
Eh? Including useless stuff that must be "filtered out"
doesn't seem very maintainable :-)
>and could easily trip you up later.
I dunno what "trip you up" cases you might mean. Got an example
of what you mean there?
( double quotes don't count, we were talking about single quotes here)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 01 Nov 2000 17:14:22 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: running UNIX utilities in perl
Message-Id: <ObYL5.86$Bf7.170932224@news.frii.net>
In article <slrn900477.a5b.tadmc@magna.metronet.com>,
Tad McClellan <tadmc@metronet.com> wrote:
>On Wed, 01 Nov 2000 06:02:28 GMT, Chris Fedde
> <cfedde@fedde.littleton.co.us> wrote:
>>In article <39FFADDE.905A38E1@student.murdoch.edu.au>,
>>Ryan Fraser <r.fraser@student.murdoch.edu.au> wrote:
>>>How do I run a "make" for the "C" compiler command in a perl CGI script.
>>>
>>>Fraser
>>>
>>
>>Who was it that was recently asking about morally questionable
>>questions in this news group?
>
>
>What is morally questionable in his question?
>
>
Nothing, really. That's just a technique that was exploited (in a slightly
different context) by the Morris worm. But consider the implications of a
url like the following:
http://fedde.littleton.co.us/runme&cmd=rm&arg=rm&arg=-r&arg=*
With power comes responsibility.
chris
--
This space intentionally left blank
------------------------------
Date: 01 Nov 2000 18:12:21 GMT
From: kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz>
Subject: Re: sending webpage form
Message-Id: <3A005D89.79D1B2C3@yvtugubhfrovm.pbz>
digihoo@hotmail.com wrote:
> hi
> i know how to generate and send the <text> results
> of a form using perl .. but is there any way to send
> the <HTML> (or WYSIWYG) version of the page, as filled
> out by the user?
> there must be a way to do this (?)
> thanks ..
I can't figure out why you would want to do this, but I suppose you
could enclude the name of the file (/home/httpd/html/index.html) as a
hidden field in the form (<input type="hidden" name="Filename"
value="/home/httpd/html/index.html) and then parse it to link up the
user entered text with the form based on the name= parameters. But I
don't know of an environment variable that would returnt the entire HTML
page.
Kevin
--
email: xzrgpnys@yvtugubhfrovm.pbz
Huh? http://www.flactem.com/utils/rot13.html
------------------------------
Date: 01 Nov 2000 18:19:00 GMT
From: kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz>
Subject: Re: SMS - text messaging
Message-Id: <3A005F19.20F171BF@yvtugubhfrovm.pbz>
Steve wrote:
> Can anybody recommend a script that allows a user to
> send text messages from a website to a mobile phone.
> I have searched on deja and quite a few script sites
> without much luck. Recommendations from current users
> would be extremely helpful.
Well, that would most likely depend a great deal on the type of phone.
Did it come with instructions on how to send messages to the phone?
Most companies will automatically send an email that sent to a certain
address to the phone, so if that is how your provider works, look up a
script to send email from a web page.
Kevin
(And I did it all with a straight face too! ;)
--
email: xzrgpnys@yvtugubhfrovm.pbz
Huh? http://www.flactem.com/utils/rot13.html
------------------------------
Date: Wed, 01 Nov 2000 17:28:48 GMT
From: zabor@my-deja.com
Subject: Sorting an array of arrays
Message-Id: <8tpjs5$75i$1@nnrp1.deja.com>
I am reading from a file that lists a bunch of users. Now I need to
sort that list and reprit it. Here is my users data that I have in a
file called data.dat:
Jim|Doe|zabor|6/25/00|16:45:31
Mark|Doed|madman|6/30/00|12:18:00
Ken|Doer|Shoeboota|6/2/00|3:22:55
Hope|Doeg|Arabelle|10/2/00|5:55:30
And here is my script, I have commented where I want to do my sort and
am having problems.
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
$fileData="data.dat";
open(DATA, $fileData);
while (<DATA>) {
chomp $_;
@data = split(/\|/,$_);
push @users, [@data];
}
close(DATA);
for $i ( 0 .. $#users ) {
$aref = $users[$i];
$n = @$aref - 1;
for $j ( 0 .. $n ) {
print "elt ", $i, " ", $j, " is ", $users[$i]
[$j], "<BR>\n";
}
}
print "<A HREF='/cgi-bin/test/sort.cgi?sortby=fname'>Sort by First
Name</A><BR>";
print "<A HREF='/cgi-bin/test/sort.cgi?sortby=lname'>Sort by Last
Name</A><BR>";
print "<A HREF='/cgi-bin/test/sort.cgi?sortby=uname'>Sort by Username
Name</A><BR>";
print "<A HREF='/cgi-bin/test/sort.cgi?sortby=date'>Sort by
Date</A><BR>";
print "<A HREF='/cgi-bin/test/sort.cgi?sortby=time'>Sort by
Time</A><BR>";
$buffer = $ENV{'QUERY_STRING'};
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/"/'/g;
$FORM{$name} = $value;
}
if ($FORM{'sortby'}) {
if ($FORM{'sortby'} eq "fname") {$loc = 0;}
elsif ($FORM{'sortby'} eq "lname") {$loc = 1;}
elsif ($FORM{'sortby'} eq "uname") {$loc = 2;}
elsif ($FORM{'sortby'} eq "date") {$loc = 3;}
elsif ($FORM{'sortby'} eq "time") {$loc = 4;}
# HERE IS WHERE MY PROBLEM IS. I NEED TO SORT THE LIST OF THE
LISTS OF USERS.
@nusers = sort {[$a]->[$loc] cmp [$b]->[$loc]} @users;
print "<P>\n";
print $loc, "<BR>\n";
for $i ( 0 .. $#nusers ) {
$aref = $nusers[$i];
$n = @$aref - 1;
for $j ( 0 .. $n ) {
print "elt ", $i, " ", $j, " is ", $nusers[$i]
[$j], "<BR>\n";
}
}
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 01 Nov 2000 18:05:49 +0100
From: Kjetil Skotheim <kjetilskotheim@iname.com>
To: zabor@my-deja.com
Subject: Re: Sorting an array of arrays
Message-Id: <3A005B7D.5D0CFEF3@iname.com>
zabor@my-deja.com wrote:
>
> I am reading from a file that lists a bunch of users. Now I need to
> sort that list and reprit it. Here is my users data that I have in a
> file called data.dat:
>
> Jim|Doe|zabor|6/25/00|16:45:31
> Mark|Doed|madman|6/30/00|12:18:00
> Ken|Doer|Shoeboota|6/2/00|3:22:55
> Hope|Doeg|Arabelle|10/2/00|5:55:30
>
> if ($FORM{'sortby'} eq "fname") {$loc = 0;}
> elsif ($FORM{'sortby'} eq "lname") {$loc = 1;}
> elsif ($FORM{'sortby'} eq "uname") {$loc = 2;}
> elsif ($FORM{'sortby'} eq "date") {$loc = 3;}
> elsif ($FORM{'sortby'} eq "time") {$loc = 4;}
>
> @nusers = sort {[$a]->[$loc] cmp [$b]->[$loc]} @users;
Try:
$loc={fname=>0,lname=>1,uname=>2,date=>3,time=>4}->{$FORM{sortby}};
@nusers = sort{$$a[$loc] cmp $$b[$loc]} @users;
...but of course it would not work for "date"-sorting.
--
Kjetil Skotheim
kjetilskotheim@iname.com
------------------------------
Date: 01 Nov 2000 11:49:11 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Sorting an array of arrays
Message-Id: <m3u29r60rs.fsf@dhcp11-177.support.tivoli.com>
zabor@my-deja.com writes:
> I am reading from a file that lists a bunch of users. Now I need to
> sort that list and reprit it. Here is my users data that I have in a
> file called data.dat:
>
> Jim|Doe|zabor|6/25/00|16:45:31
> Mark|Doed|madman|6/30/00|12:18:00
> Ken|Doer|Shoeboota|6/2/00|3:22:55
> Hope|Doeg|Arabelle|10/2/00|5:55:30
>
> And here is my script, I have commented where I want to do my sort and
> am having problems.
If you haven't read the FAQ on how to sort, you should. ("perldoc -q
sort" is one way to find it.)
[most of code snipped]
I have a couple of comments general comments. First, you should
really "use strict" and enable warnings. Second, have a look at
CGI.pm ("perldoc CGI").
> @nusers = sort {[$a]->[$loc] cmp [$b]->[$loc]} @users;
It looks like you really want:
@nusers = sort {$a->[$loc] cmp $b->[$loc]} @users;
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4785
**************************************