[22302] in Perl-Users-Digest
Perl-Users Digest, Issue: 4523 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 6 18:09:39 2003
Date: Thu, 6 Feb 2003 15:07:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 6 Feb 2003 Volume: 10 Number: 4523
Today's topics:
Re: 'Flatten' array of phrases <goldbb2@earthlink.net>
Re: a few newbie questions... <glex_nospam@qwest.net>
Re: a few newbie questions... (Tad McClellan)
Re: a few newbie questions... <nickyboy@4ce.co.uk>
Accessing remote files in NT (flyershistory)
Re: Accessing remote files in NT <me@privacy.net>
Re: Accessing remote files in NT <goldbb2@earthlink.net>
Re: Accessing remote files in NT <usenet@dwall.fastmail.fm>
Can't use an undefined value as an ARRAY reference <nospam@nospam-anon.com.nospam.invalid>
Re: Crossposting (was: Fetchrow Question) Andrew Lee
getting env of another user (Susanne Ruppel)
Re: getting env of another user <glex_nospam@qwest.net>
Re: How do i use pidof (Anno Siegel)
I'm just not getting it... FAQ5 (rab)
Re: Optimizing subroutine (Anno Siegel)
Re: Perl scripts utilizing Openview Omniback commands (Kevin)
Re: Perl Search Engine Script <tylercruz@hotmail.com>
Re: Perl Search Engine Script <tylercruz@hotmail.com>
Perl Template (karmayogi)
ppm install GD (on windows) (---)
Re: pushing elements into multidimensional array (Nataku)
Re: pushing elements into multidimensional array <tassilo.parseval@post.rwth-aachen.de>
Re: Script Problem - PLEASE help <me@privacy.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 06 Feb 2003 15:17:47 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: 'Flatten' array of phrases
Message-Id: <3E42C2EB.7749DAF9@earthlink.net>
"Jacqui or (maybe) Pete" wrote:
>
> I've got a large array of words and phrases. Some of the phrases are
> partially duplicated, and I want to remove the duplications. I've got
> a big clunky loop that does the job, but I figure there must be a
> smarter and more perl-like way of doing it.
>
> Example:
>
> about minutes
> according
> according the
> according the times
> according the times herald
> according the times herald record
> add
> add cooked
> add recipe
> add recipe box
> add salt
> add some
>
> Should be flattened to:
>
> about minutes
> according the times herald record
> add cooked
> add recipe box
> add salt
> add some
Try this:
my %hash;
while( <> ) {
my $r = \\%hash;
$r = \$$r->{$_} for split;
$$r ||= {};
}
sub flatten {
my ($prefix, $key, $val) = @_;
print( $prefix, $key, "\n" ), return unless %$val;
$prefix .= " " if length $prefix;
flatten $prefix.$key, each %$val for 1 .. keys %$val;
}
flatten '', each %hash for 1 .. keys %hash;
__END__
[untested]
--
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"
------------------------------
Date: Thu, 06 Feb 2003 13:49:14 -0600
From: Jeff D Gleixner <glex_nospam@qwest.net>
Subject: Re: a few newbie questions...
Message-Id: <8Zy0a.41$yr3.42172@news.uswest.net>
>>None of the above has anything to do with Perl. It has to do
>>with web server setup, so you should ask that part in a group
>>where such things are discussed, such as:
>
>
> Sorry - I didn't really think it was OT - I've setup the server and I'm
> not asking for help with that. The question was more aimed at perls
> interaction within that type of setup...[...]
As he stated, it's a Web Server issue. Take the advice and try those
groups or the Apache/PHP documentation.
To get you to the right area for Apache, try:
http://httpd.apache.org/docs/suexec.html
See ya
------------------------------
Date: Thu, 6 Feb 2003 14:18:21 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: a few newbie questions...
Message-Id: <slrnb45god.epa.tadmc@magna.augustmail.com>
nickyboy <nickyboy@4ce.co.uk> wrote:
>
>> Have you seen the Posting Guidelines that are posted here frequently?
>
> I haven't seen them no...
http://mail.augustmail.com/~tadmc/clpmisc.shtml
>> > Firstly I want to be able to run a script as a different user from that
>> > assigned to apache,
>> None of the above has anything to do with Perl. It has to do
>> with web server setup, so you should ask that part in a group
>> where such things are discussed, such as:
>
> Sorry - I didn't really think it was OT -
I've helped you overcome that then.
> I've setup the server and I'm
> not asking for help with that.
But you _should_ be.
> The question was more aimed at perls
> interaction within that type of setup...
perl's interactions with that type of setup will be the same
as python's or sh's or any other language.
> I didn't think a webserver setup
> newsgroup would be the best place to ask about perls abilities or how it
> interacts
Your question is not about Perl. It really isn't.
It is about server configuration. It really is.
Which particular language you want to do it with is only
incidental to the server setup that will be required.
> Thanks very much for your help, I think it's got me started...
Not if you still think it is a Perl problem. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 6 Feb 2003 22:09:48 -0000
From: "nickyboy" <nickyboy@4ce.co.uk>
Subject: Re: a few newbie questions...
Message-Id: <G2B0a.14721$RZ.166130@newsfep4-win.server.ntli.net>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnb45god.epa.tadmc@magna.augustmail.com...
> nickyboy <nickyboy@4ce.co.uk> wrote:
>
> perl's interactions with that type of setup will be the same
> as python's or sh's or any other language.
>
ok, my confusion came from knowing that the way php interacts is different,
and that was why I had a problem with php in the first place... hence my
original post, I guess I was misguided... :(
>
>
> Not if you still think it is a Perl problem. :-)
Tehe... ok - I give up, as it happens my questions have very kindly been
answered by those in the perl group...
So thankyou all, you are kind and generous people! ;-)
sure there'll be more soon!
Thanks
Nick
------------------------------
Date: 6 Feb 2003 13:24:56 -0800
From: flyershistory@hockeymail.com (flyershistory)
Subject: Accessing remote files in NT
Message-Id: <d7bdcf6c.0302061324.4537fd3d@posting.google.com>
Hi,
I'm trying to write a script that access remote files using perl on
NT. I've been able to have a script work on unix, but unable to get it
to work on perl.
Before anybody suggests using LWP or any other library routine, I only
use the server and have no access to it. The bozos who loaded perl
won't only more libraries either - so I'm stuck with no extension
libraries whatsoever. I have to try and get this to work as-is, so any
help or suggestions will be appreciated !
I can get the following to say that the socket, bind and connect was
"ok" - but the file doesn't get printed (it does get printed when
running under unix)
#!/usr/bin/perl
print "Content -type: text/html\n\n";
$server_name = 'www.yahoo.com';
$file_name = 'http://www.yahoo.com';
$hostname = '<actual host name here>'
$sockaddr = 'S n a4 x8';
($name,$aliases,$type,$len,$thataddr) = gethostbyname($server_name);
($name,$aliases,$type,$len,$thisaddr) = gethostbyname($hostname);
$this = pack($sockaddr, 2, 0, $thisaddr);
if (!socket (S, 2, 1, 6)) {
print "bad socket\r\n";
die $!;
}
if (bind(S, $this)) {
print "bind ok... ";
}
else {
die "bind failed... \n";
}
$port = 80;
$that = pack($sockaddr, 2, $port, $thataddr);
if (!connect (S, $that)) {
print "bad connect\r\n";
}
else {
print "YESSSSSSSSSSSSSSS ! *********\r\n";
}
select(S);$|=1; select(STDOUT);
print S "GET $file_name\r\n\r\n";
while ($fileline = <S>) {
print "$fileline\r\n";
}
Thanks !
------------------------------
Date: Fri, 7 Feb 2003 09:04:50 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Accessing remote files in NT
Message-Id: <b1um63$176obh$1@ID-172104.news.dfncis.de>
"flyershistory" <flyershistory@hockeymail.com> wrote in message
news:d7bdcf6c.0302061324.4537fd3d@posting.google.com...
> Hi,
>
> I'm trying to write a script that access remote files using perl on
> NT. I've been able to have a script work on unix, but unable to get it
> to work on perl.
>
> Before anybody suggests using LWP or any other library routine, I only
> use the server and have no access to it.
If you have no access to it, how do you manage to run any scripts?
If you do have access, then you can install/run LWP (or a subset).
------------------------------
Date: Thu, 06 Feb 2003 17:26:54 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Accessing remote files in NT
Message-Id: <3E42E12E.AB64CD8F@earthlink.net>
flyershistory wrote:
>
> Hi,
>
> I'm trying to write a script that access remote files using perl on
> NT. I've been able to have a script work on unix, but unable to get it
> to work on perl.
>
> Before anybody suggests using LWP or any other library routine, I only
> use the server and have no access to it. The bozos who loaded perl
> won't only more libraries either - so I'm stuck with no extension
> libraries whatsoever. I have to try and get this to work as-is, so any
> help or suggestions will be appreciated !
Have you read perldoc -q library?
> I can get the following to say that the socket, bind and connect was
> "ok" - but the file doesn't get printed (it does get printed when
> running under unix)
[snip]
> $this = pack($sockaddr, 2, 0, $thisaddr);
>
> if (!socket (S, 2, 1, 6)) {
Where are these magic numbers coming from? They might be right on one
platform [your particular version of unix], but not necessarily on other
platforms.
I would suggest you use the IO::Socket::INET module which comes with
perl, which got the magic numbers from the system's networking header
files at the time that perl was compiled.
#!/usr/bin/perl -w
use strict;
use warnings;
use IO::Socket;
my $sock = IO::Socket::INET->new("www.yahoo.com:80")
or die "Couldn't connect to yahoo: $@";
warn "Connected\n";
($| = 1), select $_ for select $sock;
print $sock
"GET / HTTP/1.0\015\012" .
"Host: www.yahoo.com\015\012" .
"\015\012";
warn "Request sent, waiting for reply\n";
print while sysread $sock, $_, 1024;
__END__
[tested!]
Note that I use "\015\012", which is CRLF, when writing to the socket,
not "\r\n"... even though use "\n" when writing to the console.
This is because perl's "\n" and "\r" characters are *not* always
synonymous with LF and CR.
When perl prints a "\n" to a text-mode filehandle, it will (if
necessary) be transformed into a machine-specific newline sequence. On
unix, "\n" is an LF, and no translation is done on writing. On
Macintosh, "\n" is actually a CR, and no translation is done on writing.
On windows, "\n" is an LF (like unix), but when it's written to a
text-mode filehandle, it gets turned into a CRLF (since that's what
windows wants as it's line terminator).
The HTTP network protocol requires a CRLF, and printing "\r\n" is NOT
guaranteed to produce a CRLF. Only printing "\015\012" is guaranteed to
produce a CRLF.
--
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"
------------------------------
Date: Thu, 06 Feb 2003 22:16:43 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Accessing remote files in NT
Message-Id: <Xns931AAFC4D5D65dkwwashere@216.168.3.30>
flyershistory <flyershistory@hockeymail.com> wrote on 06 Feb 2003:
> Before anybody suggests using LWP or any other library routine, I only
> use the server and have no access to it. The bozos who loaded perl
> won't only more libraries either - so I'm stuck with no extension
> libraries whatsoever. I have to try and get this to work as-is, so any
> help or suggestions will be appreciated !
You could copy the relevant modules to your own file area and, in your
program, push that directory onto the end of @INC, or just say
use lib 'N:/myperlmods';
or something like that, depending on the location of your file area.
If that's not acceptable, you can get a copy of LWP::Simple off the net and
copy-and-paste the _trivial_http_get() function from it. That's a bad way to
do it, but at least you know the code is good. Write your own if you just
want to experiment, but if you want to get some work done, grab existing code
and use it.
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Thu, 06 Feb 2003 22:07:56 +0000
From: JD <nospam@nospam-anon.com.nospam.invalid>
Subject: Can't use an undefined value as an ARRAY reference
Message-Id: <q3n54vgncqetof33cejlhicn7l74qb8p5m@4ax.com>
Lo all,
OS slackware 8.1 and 8.0
I'm running (attempting to) the nntpget script that comes with the
news::scan module. getnews has the same error.
Here's the problem: It doesn't work. Well, strangely enough it works
for one newsgroup (uk.food+drink.sausages) but not for
others, alt.os.linux.slackware or misc.test for example. The sausage
group is newly formed so that may be an issue.
The error:
Getting articles from news.nildram.co.uk...Can't use an undefined
value as an ARRAY reference at /usr/lib/perl5/site_perl/News/Scan.pm
line 554.
the uk.food+drink.sausage downloads all the articles into a directory,
no problem.
misc.test creates a few empty numbered files in the same directory
(all prev files deleted first) then give the above error.
I have tried this with 2 ISP's (nildram and demon) and 2 news servers,
news.nildram.co.uk and news.demon.co.uk
Same error. All the groups tested exist on both servers...
googling throws up no help. :/
Any clue much appreciated.
--
John
arjf @ sghzfu qbg qrzba qbg pb.hx
------------------------------
Date: Thu, 06 Feb 2003 15:33:16 -0500
From: Andrew Lee
Subject: Re: Crossposting (was: Fetchrow Question)
Message-Id: <qjh54v05dijgk4btn2dank2eden7g85pbf@4ax.com>
On Thu, 06 Feb 2003 00:27:05 GMT, "mgarrish" <mgarrish@rogers.com>
wrote:
>
>"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
>news:3E41ABC8.3C406083@earthlink.net...
>>
>> Flaming folks like uri shows just how foolish you are, and decreases the
>> amount of respect you have (had) in the community.
>>
>
>That's almost too funny for words. And how would you rate his childish
>behaviour, since I never flamed anyone until he made the mistake of coming
>after me? But perhaps that thought never occurred to you, so maybe you
>should take a look at the rest of the behaviour in clpm from a less biased
>view.
>
>Matt
*plonk*
------------------------------
Date: 6 Feb 2003 11:12:27 -0800
From: s.ruppel@gedankenpause.de (Susanne Ruppel)
Subject: getting env of another user
Message-Id: <e43f95.0302061112.285f6c9f@posting.google.com>
Hello!
I am running an installation-script as "root", and need to get some of
the environmental variables of user "sybase". After I got those
variables the script should run further in root-context.
Is there a way to do this? I'm looking for a non-interactive solution.
I tried to change uid, gid, euid, egid, but I detected, that my
environment stays the same (set by the shell)...
OS: Sun 5.8 (later on also HP-UX >= 10.20 and AIX 4.3)
Perl: >= 5.005
Thank you!
Susanne
------------------------------
Date: Thu, 06 Feb 2003 14:03:00 -0600
From: Jeff D Gleixner <glex_nospam@qwest.net>
Subject: Re: getting env of another user
Message-Id: <2az0a.44$yr3.43099@news.uswest.net>
Susanne Ruppel wrote:
> Hello!
>
> I am running an installation-script as "root", and need to get some of
> the environmental variables of user "sybase". After I got those
> variables the script should run further in root-context.
> Is there a way to do this? I'm looking for a non-interactive solution.
>
> I tried to change uid, gid, euid, egid, but I detected, that my
> environment stays the same (set by the shell)...
Shell question.. but.. this might give you what you're after.
my (@SYENV)=`/usr/bin/su -l sybase -c env`; #use your path to su
# do whatever ya want with the info..
Depends on your OS. A "man su" should show you the correct options,
if -l anc -c aren't correct.
------------------------------
Date: 6 Feb 2003 19:05:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How do i use pidof
Message-Id: <b1ubmm$7ej$2@mamenchi.zrz.TU-Berlin.DE>
Benjamin Goldberg <goldbb2@earthlink.net> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> [snip]
> > $existent = signal( 0, $pid);
>
> I think you mean:
>
> $existant = kill( 0, $pid );
True about the kill(), but I stand by my spelling of "existence" :)
Anno
------------------------------
Date: 6 Feb 2003 13:31:37 -0800
From: richardbriggs@att.com (rab)
Subject: I'm just not getting it... FAQ5
Message-Id: <900b7105.0302061331.118ec7b2@posting.google.com>
well...perldoc -q "delete a line in a file" was no help
faq5 no help.
I *do* need to delete a line in a file that matches a certain regex
pattern...
example:
I need a script to take a text file that looks like this:
grok-1
grok-1c text text text text
grok-2 text text text text
grok-2a text text text text
grok-2c text text text text
grok-3 text text text text
grok-3a text text text text
grok-3b text text text text
grok-3c text text text text
grok-5 text text text text
grok-9a text text text text
grok-4z text text text text
and change it into a file that looks like this:
grok-1 text text text text
grok-1c text text text text
grok-2 text text text text
grok-2a text text text text
grok-2c text text text text
grok-3 NEW TEXT HERE
grok-5 text text text text
grok-9a text text text text
grok-4z text text text text
I'm hitting a wall on how to match the pattern (grok-3.+) and delete
those lines containing it, while simultaneously replacing those lines
in that same place in the file with the new grok-3 modified single
line.
It would be easy to strip the lines out by opening the file for
reading and
writing all but the matching lines to a temp file (next if /grok-3/;)
It would be easy to open the temp file up and then scan down to the
line before and after I deleted the "grok-3" lines, but the files I'm
working with aren't always in order so grok-3 may be followed by
grok-9 or nothing at all.
It also would be easy if I was replacing the same number of lines
(which I'm not) by using s///
but I have to test if there are any "grok-3" lines... and no matter
how many are in there (0 or more) I need to replace them with only one
grok-3 line.
any ideas?
Richard
------------------------------
Date: 6 Feb 2003 19:47:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Optimizing subroutine
Message-Id: <b1ue3u$a56$1@mamenchi.zrz.TU-Berlin.DE>
Brian McCauley <nobull@mail.com> wrote in comp.lang.perl.misc:
> mauroid@csi.forth.gr (Dimitri) writes:
>
> > Subject: Optimizing subroutine
>
> Forgot to mention before...
>
> Please put the subject of your post in the Subject of your post. If
> in doubt try this simple test. Imagine you had done a search before
> you posted. Next imagine you found a thread with your subject line.
> Would you have been able to recognise it as a related subject?
>
> BTW the word "subroutine" in the subject line contains no information.
>
> A good subject for this thread is really hard to find but a better one
> whould have been:
>
> Subject: Optimizing transformation of string
>
> > About 40% of the time in my program is taken in the following
> > subroutine. I am looking for ways to make it more efficient.
> > Feel free to suggest anything that works faster.
>
> Three of us came up with elegant suggestions that looked like they
> would be significantly faster. However, the benchmark results are
> somewhat supprising to say the least!
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Benchmark;
>
> sub Dimitri {
> my ($data) = @_;
> my ($i);
> my $len = length($data);
> my $out = "";
>
> for ($i = 0; $i < $len; $i += 2) {
> if (ord(substr($data, $i, 1)) < 128) {
> $out .= substr($data, $i, 2);
> } else {
> $out .= sprintf("%02x", ord(substr($data, $i + 1, 1)));
> }
> }
>
> $out;
> }
>
> sub Brian {
> (my $out = shift) =~ s/\G((?:..)*?)[\x80-\xFF](.)/$1 . sprintf '%02x',
> ord $2/eg;
> $out;
> }
>
> sub Salvador {
> (my $out = shift) =~s{(.)(.)}{$1 lt "\x80" ? $1.$2 : sprintf("%02x",
> ord($2)) }ge;
> $out;
> }
>
> sub Anno {
> join '', map ord() < 128 ? $_ : sprintf( '%02x', ord substr( $_, 1)),
> shift() =~ /../g;
> }
>
> my $test= "ab\xE0def\xFFijk" x 30;
>
> timethese 20000, {
> Dimitri => sub { Dimitri($test) },
> Brian => sub { Brian($test) },
> Salvador => sub { Salvador($test) },
> Anno => sub { Anno($test) },
> };
> __END__
> Benchmark: timing 20000 iterations of Anno, Brian, Dimitri, Salvador...
> Anno: 9 wallclock secs ( 8.44 usr + 0.00 sys = 8.44 CPU) @
> 2369.67/s (n=20000)
> Brian: 6 wallclock secs ( 6.38 usr + 0.00 sys = 6.38 CPU) @
> 3134.80/s (n=20000)
> Dimitri: 7 wallclock secs ( 6.97 usr + 0.02 sys = 6.99 CPU) @
> 2861.23/s (n=20000)
> Salvador: 12 wallclock secs (11.44 usr + 0.00 sys = 11.44 CPU) @
> 1748.25/s (n=20000)
I see similar results, though on my machine Dimitri and Anno swap places.
In light of another branch of this thread, I offer
sub Anno {
( my $out = shift) =~ s/[^\0-\200](.)/sprintf '%02x', ord $1/seg;
$out;
}
It doesn't bother to look at even positions only, which is probably
closer to what the OP actually wants. It also gives the same results
for the test data (generally, if no characters > 128 appear in even
positions). With this change (and the number of runs adapted) I
get:
Benchmark: timing 3529 iterations of Anno, Brian, Dimitri, Salvador...
Anno: 3 wallclock secs ( 2.61 usr + 0.00 sys = 2.61 CPU) @ 1352.11/s (n=3529)
Brian: 4 wallclock secs ( 3.84 usr + 0.00 sys = 3.84 CPU) @ 919.01/s (n=3529)
Dimitri: 6 wallclock secs ( 5.48 usr + 0.00 sys = 5.48 CPU) @ 643.98/s (n=3529)
Salvador: 8 wallclock secs ( 7.41 usr + 0.00 sys = 7.41 CPU) @ 476.25/s (n=3529)
I am surprised, too, that Dimitri's original code is so hard to beat.
Anno
------------------------------
Date: 6 Feb 2003 12:51:35 -0800
From: kevin_mudd@adp.com (Kevin)
Subject: Re: Perl scripts utilizing Openview Omniback commands
Message-Id: <bf26a3a6.0302061251.40643fd2@posting.google.com>
tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb451hg.ed3.tadmc@magna.augustmail.com>...
> Kevin <kevin_mudd@adp.com> wrote:
> >
> > I've been assigned the task of incorporating Omniback commands into
> > perl scripts.
>
> > Was wondering if anyone here has done the same and
> > could help me get started.
>
>
> Searching for "Omniback" in the "comp.lang.perl.*" newsgroups at:
>
> http://groups.google.com/advanced_group_search
>
> finds 2 threads about it.
Unfortunately, one of them is mine and the other doesn't have a response.
------------------------------
Date: Thu, 06 Feb 2003 19:46:10 GMT
From: "Tyler Cruz" <tylercruz@hotmail.com>
Subject: Re: Perl Search Engine Script
Message-Id: <6Yy0a.202912$H7.7421189@news2.calgary.shaw.ca>
Thanks Sam,
Yes this worked (with the if statement) - thanks.
I cannot re-learn Perl, as I really don't have time for it anymore, and my
life is extremely busy.. I'd rather pay somebody to do it for me. What do
most Perl programmers cost nowadays? For example if I wanted something small
like this fixed, what would that of costed me?
Tyler
"Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
news:slrnb44hc2.ecr.sholden@flexal.cs.usyd.edu.au...
> On Thu, 06 Feb 2003 07:56:34 GMT, Tyler Cruz <tylercruz@hotmail.com>
wrote:
> >
> > So what I want to do is put an if statement, questioning if the title
begins
> > with "the " and if it does, then just search for everything after it. I
know
> > this is extremely basic, but I haven't done ANY Perl stuff in years -
and
> > could really use the help. Here is the code snipit:
>
> s/^the//i
>
> Though in practice you probably want to use soething more robust.
>
> Why are you writing/editing a perl script to run on a publically
> accessable web site if you haven't done 'ANY' perl in years???
>
> Maybe you should spend some time refreshing your knowledge (after all
> perl has changed a bit :). Or find someone who has the knowledge already.
>
> > { my $grep = $cgi->param("grep");
> > my $searchstring = $cgi->param("searchstring");
> > my $sth;
> > if ($grep eq "Title") {
> > $sth = $dbh->prepare("select title, director, writer, year, movieid
from
> > reviews where title like \"%$searchstring%\" order by 1") || die "Oops";
>
> You really better hope no one enters something like:
>
> blah"; delete from reviews; select * from reviews where title like "
>
> Or something similar (I obviously didn't test :) in that text box...
>
> If the db user doesn't have write permission then even something like:
>
> select * from reviews, reviews, reviews, reviews, reviews
>
> in place of the delete might bring the database to its knees.
> Depending on the database your using of course. Note I might have the
> syntax all wrong, but the point is valid.
>
> Use placeholders (see the DBI docs), or if your database doesn't
> support them, I don't know if any don't though, then at least use
> $dbh->quote().
>
> Never trust user data you got from a web browser across the internet...
>
> --
> Sam Holden
>
------------------------------
Date: Thu, 06 Feb 2003 19:46:29 GMT
From: "Tyler Cruz" <tylercruz@hotmail.com>
Subject: Re: Perl Search Engine Script
Message-Id: <pYy0a.202915$H7.7421381@news2.calgary.shaw.ca>
Thanks!
"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:b1tchg$cd6$2@mamenchi.zrz.TU-Berlin.DE...
> Tyler Cruz <tylercruz@hotmail.com> wrote in comp.lang.perl.misc:
> > Hi,
> >
> > Here is my problem. This is a portion from a search engine for reviews.
The
> > problem is that our title of reviews are in the format: "The Matrix" for
> > example, so when somebody searches for Matrix, they can see Matrix
easily.
> > However if they search for The Matrix, there is no title called The
Matrix.
>
> Huh? You probably wanted to say the titles are in the format "Matrix,
The",
> or similar.
>
> > To try this out, you can go to http://www.movie-vault.com and see for
> > yourself.
> >
> > So what I want to do is put an if statement, questioning if the title
begins
> > with "the " and if it does, then just search for everything after it. I
know
>
> s/^The\s+//;
>
> Anno
------------------------------
Date: 6 Feb 2003 13:49:08 -0800
From: aninmathen@hotmail.com (karmayogi)
Subject: Perl Template
Message-Id: <d8fd9d9a.0302061349.1c414ed2@posting.google.com>
Hi,
I have a very simple question. This might be very easy for you Perl
Wizards out there. How do I include a template say HTML:template in my
perl program, and make sure that a particular version of the template
say 2.3 is picked up. I ask this because the common repository has two
versions of the HTML templates, and I want to make sure my program
picks up the correct version.
Thanks in advance for answering this.
Regards,
Karmayogi
------------------------------
Date: Thu, 6 Feb 2003 17:02:58 -0500
From: Tamas <antal.3(---)@osu.edu>
Subject: ppm install GD (on windows)
Message-Id: <b1um4h$ekn$1@charm.magnus.acs.ohio-state.edu>
Hi,
I've installed ActiveState perl 5.8.0 (Build 804) along with PPM 3.0 and I
am not able to install GD nor Tk::PNG with ppm.
ppm install GD gives: no suitable installation target found for GD.
Is it possible that GD and friends are left out from new the (5.8.0)
packages?
Thanks,
Tamas
------------------------------
Date: 6 Feb 2003 11:34:44 -0800
From: Crapnut566@yahoo.com (Nataku)
Subject: Re: pushing elements into multidimensional array
Message-Id: <7e48fc99.0302061134.64be7bea@posting.google.com>
Perl doesnt come with native support for multidimensional arrays, at
least not to my knowledge. You can create a pseudo ( and limited in
functionality ) multidimensional array by filling an array with array
references that you have defined.
stig <nospam_stigerikson@yahoo.se> wrote in message news:<b1tbp4$ffi$1@oden.abc.se>...
> hi
>
> is it possible to push an element onto an multidomensional array?
> i try:
>
> $Array[0][0] = "hello";
>
> push $Array[0], "test";
>
> by this (or any other method) i would like to accomplish:
> $Array[0][1] = "test";
>
> however perl reports that i must send an array not a slice of an array.
>
> i also tried the method described in perldoc push
> for $value (LIST) {
> $ARRAY[++$#ARRAY] = $value;
> }
>
> in my case i made it look like this:
> $Array[0][++$#Array[0]] = "test";
>
> that did not work since it did not manage to read out the length of the
> current slice, onle reported ARRAY(0x8066030).
>
> using the scalar function on @Array[0] did not help.
>
>
> perhaps i missed something out (i am more novice then expert, so to say)
>
> thanks
> stig
------------------------------
Date: 6 Feb 2003 20:17:01 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: pushing elements into multidimensional array
Message-Id: <b1ufrt$fd$1@nets3.rz.RWTH-Aachen.DE>
[ please do not top-post ]
Also sprach Nataku:
> Perl doesnt come with native support for multidimensional arrays, at
> least not to my knowledge. You can create a pseudo ( and limited in
> functionality ) multidimensional array by filling an array with array
> references that you have defined.
Define 'limited in functionality'. Limited compared to what?
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Fri, 7 Feb 2003 09:00:49 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Script Problem - PLEASE help
Message-Id: <b1uluj$16mtqj$1@ID-172104.news.dfncis.de>
"Babyface" <stuandju@NOSPAMaberhonddu1.fsnet.co.uk> wrote in message
news:b1u0n4$md0$1@news7.svr.pol.co.uk...
> Are there experts who'd be willing to look at a script for me to see what
> the problem is. It's the YABB discussion board script. (they are not much
> help) My web host Technical support have looked through it a number of
> times but can see no reason why it wouldn't work. I have been through all
> the troubleshooting bits and pieces. I havent changed any of the script
> other than what I was instructed to do.
>
> I could if anybody wished attach the .pl file the .cgi file and the latest
> email from tech support on what they think it could be.
>
> It's a big ask I know but I hope one of you might be able to help
Best off asking in alt.comp.perlcgi.freelance
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4523
***************************************