[22204] in Perl-Users-Digest
Perl-Users Digest, Issue: 4425 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 18 11:05:49 2003
Date: Sat, 18 Jan 2003 08:05:09 -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 Sat, 18 Jan 2003 Volume: 10 Number: 4425
Today's topics:
Re: A Good Perl Developing Enviroment (Tony L. Svanstrom)
Re: Append a text at the top an existing file <mpapec@yahoo.com>
Re: Arrays. What don't I get? <wkrempa@erols.com>
compare variable with next variable in a loop (FMAS)
Re: compare variable with next variable in a loop <mpapec@yahoo.com>
Re: compare variable with next variable in a loop <mpapec@yahoo.com>
Re: compare variable with next variable in a loop (Tad McClellan)
Re: compare variable with next variable in a loop (Tad McClellan)
Re: compare variable with next variable in a loop <bigj@kamelfreund.de>
Re: compare variable with next variable in a loop <usenet@tinita.de>
Data Form to Email Changes (Grayson Bathgate)
Re: Data Form to Email Changes <tassilo.parseval@post.rwth-aachen.de>
Day of the month redirection - revised (Ralph)
Re: Day of the month redirection - revised (Tad McClellan)
hard (KT)
Re: hard <abigail@abigail.nl>
Re: How do I calculate today minus any given number <usenet@tinita.de>
Re: How to execute a perl script from within a perl scr <torvill@trolldata.no>
Re: How to execute a perl script from within a perl scr (Tad McClellan)
Link of the day <trond@bwsnett.no>
Re: Most efficient way to do this DBI thing? <Jeff@aetherweb.co.uk>
Re: Most efficient way to do this DBI thing? (Tad McClellan)
Newbie: Testing for undef, blank line, or white space <chrishedrick@sbcglobal.net>
Re: Newbie: Testing for undef, blank line, or white spa (Jay Tilton)
Re: Newbie: Testing for undef, blank line, or white spa <chrishedrick@sbcglobal.net>
Re: Newbie: Testing for undef, blank line, or white spa (Tad McClellan)
perl installation question (Philip George)
Re: perl installation question <abigail@abigail.nl>
Re: poe and CloseEvent <troc@netrus.net>
Using domain.com/?query+string and domain.com/index.cgi (krakle)
Re: Using domain.com/?query+string and domain.com/index (Tad McClellan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 18 Jan 2003 10:23:22 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: A Good Perl Developing Enviroment
Message-Id: <1fozbm2.1j2p6ck14hcvrwN%tony@svanstrom.com>
A. Fuentes <alvarof2@hotmail.com> wrote:
> Fellow Perl Netters:
>
> I have a newbie question:
>
> What would be a good Perl Developing Enviroment for
> managing and developing Perl projects?
My favorite is Pico. =)
> (Visual Developer Studio-like)
>
> Any suggestions will be appreciated.
>
> Thanks in advance,
>
> A. Fuentes
> 512-297-9937
--
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #
perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'
------------------------------
Date: Sat, 18 Jan 2003 15:13:10 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: Append a text at the top an existing file
Message-Id: <lvni2vot9vfg15rg3aerh9v5anef9g2gdb@4ax.com>
X-Ftn-To: Jürgen Exner
"Jürgen Exner" <jurgenex@hotmail.com> wrote:
>> Is it another character than ">>" I could us in order to have the
>> appending happening at the top of the file ?
>
>Which part of PerlFAQ5 "How do I change one line in a file/delete a line in
>a file/insert a line in the middle of a file/append to the beginning of a
>file?" is unclear and needs improvement?
Did you ever get any feedback on this famous question? :)
--
Matija
------------------------------
Date: Sat, 18 Jan 2003 10:50:01 -0500
From: wrk <wkrempa@erols.com>
To: Tina Mueller <usenet@tinita.de>
Subject: Re: Arrays. What don't I get?
Message-Id: <3E2977A8.8CABFAF0@erols.com>
Tina,
This seemed likea bug to me until I read this in the "Perl Cook Book"
The foreach looping construct has another feature: each time through the loop,
the iterator variable becomes not a copy of but rather an alias for the current
element. This means that when you change that iterator variable, you really
change each element in the list:
@array = (1,2,3);
foreach $item (@array) {
$item--;
}
print "@array\n";
0 1 2
# multiply everything in @a and @b by seven
@a = ( .5, 3 ); @b =( 0, 1 );
foreach $item (@a, @b) {
$item *= 7;
}
print "@a @b\n";
3.5 21 0 7
This aliasing means that using a foreach loop to modify list values is both
more readable and faster than the equivalent code using a three-part for loop
and explicit
indexing would be. This behavior is a feature, not a bug, that was introduced
by design. If you didn't know about it, you might accidentally change
something. Now
you know about it.
Tina Mueller wrote:
> Graham Wood <Graham.T.Wood@oracle.com> wrote:
> > Richard S Beckett wrote:
> >> I start with
> >> $one = 1; $two = 2; $three = 3; $four = 4;
> >> and want to end with
> >> $one = 2; $two = 4; $three = 6; $four = 8;
>
> >> foreach $value (@values) {
> >> $value *= 2;
> >> }
>
> > This is where you are going astray.
>
> > foreach $value (@values)
>
> > will take each element in your @values array and assign it's value to
> > $value.
>
> right so far. but i wouldn't call it "assign".
>
> > Whatever changes you make to $value after the initial assignment
> > will not affect the value in the array element.
>
> it will, because $value is an alias to the array element.
>
> > The value in $value does
> > not get copied back to the array after you have doubled it. If you print
> > "$value" after the *=2 in your first loop you will see the numbers have
> > been doubled but after this loop completes you still haven't made changes
> > to @values.
>
> well, if i try it out, it prints 2, 4, 6 and 8.
>
> > Changing the values in @values will also not affect the values in $one,
> > $two, $three and $four. The connection between them ends with the
> > assignment of the values in $one .. $four into the array.
>
> that's correct, though.
>
> regards, tina
>
> --
> http://www.tinita.de/ \ enter__| |__the___ _ _ ___
> http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
> http://PerlQuotes.tinita.de/ \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: 18 Jan 2003 04:47:49 -0800
From: massion@gmx.de (FMAS)
Subject: compare variable with next variable in a loop
Message-Id: <f0b3f4c9.0301180447.3d72081f@posting.google.com>
Hi folks,
I have read a file into an array,
This file contains a word list: 1 word = 1 line like :
house
houses
farm
farms
The list is alphabetically sorted and I wand to reduce this list to
the basic form of a word (house, farm)
My problem is to find a way to compare a string with the next
string(s)in the loop. This should happen as long as there is a string
matching the pattern.
$i = 1;
while ($word = <FH>) {
chomp;
$nextword = $word[$i];
next if ($word =~ m/\b$nextword+e?s?\b/i);
push (@reducedlist, $word);
$i++;
}
foreach (@reducedlist) {
print STDOUT "$_\n";
}
Any help would be appreciated!
------------------------------
Date: Sat, 18 Jan 2003 14:52:47 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: compare variable with next variable in a loop
Message-Id: <e7mi2vstejbdl71ugubfrrrsei0vvb3nr0@4ax.com>
X-Ftn-To: FMAS
massion@gmx.de (FMAS) wrote:
>the basic form of a word (house, farm)
>
>My problem is to find a way to compare a string with the next
>string(s)in the loop. This should happen as long as there is a string
>matching the pattern.
>
>$i = 1;
>
>while ($word = <FH>) {
> chomp;
You're chomping $_ here, not $word.
> $nextword = $word[$i];
$word[$i] here is value from @word array(which is empty).
If you want use while loop, you can try something like:
$word = <FH>;
push @reducedlist, $word;
while ($nextword = <FH>) {
next if $word =~ m/\b$nextword+e?s?\b/i;
push @reducedlist, $word;
}
continue {
$word = $nextword;
}
--
Matija
------------------------------
Date: Sat, 18 Jan 2003 15:05:05 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: compare variable with next variable in a loop
Message-Id: <5cni2v4c1fjkto6d9b2rlnafeghlll4mnv@4ax.com>
Matija Papec <mpapec@yahoo.com> wrote:
>$word[$i] here is value from @word array(which is empty).
>
>If you want use while loop, you can try something like:
>
>$word = <FH>;
>push @reducedlist, $word;
>
>while ($nextword = <FH>) {
> next if $word =~ m/\b$nextword+e?s?\b/i;
> push @reducedlist, $word;
>}
>continue {
> $word = $nextword;
>}
or:
while ($nextword = <FH>) {
next if $word =~ m/\b$nextword+e?s?\b/i;
push @reducedlist, $word;
$word = $nextword;
}
in which case $word is changing only when your match failed.
--
Matija
------------------------------
Date: Sat, 18 Jan 2003 08:08:54 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: compare variable with next variable in a loop
Message-Id: <slrnb2invm.7f1.tadmc@magna.augustmail.com>
FMAS <massion@gmx.de> wrote:
> I have read a file into an array,
Your code does not read a file into an array!
> This file contains a word list: 1 word = 1 line like :
> house
> houses
> farm
> farms
> The list is alphabetically sorted and I wand to reduce this list to
> the basic form of a word (house, farm)
That is not simple pattern matching, that is natural language
processing, a Much Harder thing to do.
I get the feeling that this is an "XY problem" or that you haven't
thought out the possibities very thouroughly.
In this followup, I'll try to restrict myself to just answering
the question that was asked.
I'll make a separate followup to explore the possibility that
you really needed to ask some _other_ question.
> My problem is to find a way to compare a string with the next
> string(s)in the loop.
Must you be able to handle things such as:
data
datum
property
properties
??
"unpluralizing" is much too hard for me to answer, so I'll change
the question into something that I _can_ answer. :-)
How can I detect common prefixes?
--------------------------------
#!/usr/bin/perl
use strict;
use warnings;
chomp(my $prev = <DATA>);
my @reducedlist = $prev;
while ( <DATA> ) {
chomp;
push @reducedlist, $_ unless /^$prev/;
$prev = $_;
}
print "$_\n" for @reducedlist;
__DATA__
house
houses
farm
farms
--------------------------------
That works for the data you gave, but I can easily think of
cases where it will fail horribly:
unacceptable
unaccountable
unaccustomed
gets reduced to "unacc".
> $nextword = $word[$i];
^^^^^^^^^
There is no @word array anywhere else in your program...
> next if ($word =~ m/\b$nextword+e?s?\b/i);
^^^^
That[1] would allow an extra "e" _without_ an "s", eg:
rat
rate
rates
would be reduced to "rat". I doubt you want to allow that.
Perhaps you should think more carefully about what it is that you
are really trying to accomplish, and how you could be tripped up...
[1] assuming it was put into valid Perl syntax
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 18 Jan 2003 08:14:52 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: compare variable with next variable in a loop
Message-Id: <slrnb2ioas.7f1.tadmc@magna.augustmail.com>
FMAS <massion@gmx.de> wrote:
> This file contains a word list: 1 word = 1 line like :
> house
> houses
> farm
> farms
>
> The list is alphabetically sorted and I wand to reduce this list to
> the basic form of a word (house, farm)
I'm not sure if you are restricting the problem to recognizing
"plural" forms of the same word or not.
If so, you've missed some possibilities (possibility :-),
as I mentioned in my other followup.
If recognizing plurals is your ultimate goal, I'd consider using
the Lingua::EN::Inflect module to pluralize the "root" word,
then eliminate things that matched the pluralized form.
Do you want
farm
farms
farming
farmed
To be reduced to "farm"?
That is called "stemming". There is a module that will do
stemming for you: Lingua::Stem
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 18 Jan 2003 14:53:16 +0100
From: Janek Schleicher <bigj@kamelfreund.de>
Subject: Re: compare variable with next variable in a loop
Message-Id: <pan.2003.01.18.13.39.25.151857.5897@kamelfreund.de>
On Sat, 18 Jan 2003 13:47:49 +0100, FMAS wrote:
> I have read a file into an array,
> This file contains a word list: 1 word = 1 line like :
> house
> houses
> farm
> farms
>
> The list is alphabetically sorted and I wand to reduce this list to
> the basic form of a word (house, farm)
>
> My problem is to find a way to compare a string with the next
> string(s)in the loop. This should happen as long as there is a string
> matching the pattern.
>
> $i = 1;
It's very rare that you need to count for yourself the number of
elements of a list.
scalar @reducedList stands for the size of the list
$#reducedList is the index of the last element
$reducedList[-1] is the last element of the list
>
> while ($word = <FH>) {
> chomp;
Just like Matija already said you chomp $_ instead of $word.
> $nextword = $word[$i];
> next if ($word =~ m/\b$nextword+e?s?\b/i);
^^^^^
I don't understand what the word boundaries are useful for.
More important, the detection of derived forms seems to be strange.
The + indicates that the baseform could be repeated several times. (If
you simply wanted to seperate the variable of the following 'e', it's
better to use ${nextword}e).
The e?s? stands for either '', 'e', 's', 'es'. E.g. 'mat' would be a
baseform of 'mate' :-)
> push (@reducedlist, $word);
> $i++;
> }
>
> foreach (@reducedlist) {
> print STDOUT "$_\n";
> }
I'd like to suggest the following snippet:
my $last_base = ""; # I hope the first word is not an 'e' or an 'es'.
while (<FH>) {
next if /^${last_base}e?s/i;
# The ^ indicated that the baseform has to start the derived form
print;
chomp( $last_base = $_ );
}
Greetings,
Janek
------------------------------
Date: 18 Jan 2003 15:56:54 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: compare variable with next variable in a loop
Message-Id: <tinh8x2pr$13q$tina@news01.tinita.de>
FMAS <massion@gmx.de> wrote:
> I have read a file into an array,
> This file contains a word list: 1 word = 1 line like :
> house
> houses
> farm
> farms
> The list is alphabetically sorted and I wand to reduce this list to
> the basic form of a word (house, farm)
somehow this question seems familar...
<f0b3f4c9.0301141051.4f42a18f@posting.google.com>
what was wrong with the answers you got there in dclpm?
do you think you would get different answers by just translating
your post into english, but without considering using
some of the suggestions you got in that thread?
tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/ \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: 18 Jan 2003 05:27:32 -0800
From: gbathgate2000@yahoo.com (Grayson Bathgate)
Subject: Data Form to Email Changes
Message-Id: <e89f00b6.0301180527.175f140b@posting.google.com>
I have a CGI-Bin program that takes the results of a web form and
sends them to a text data form on our server. I just downloaded this
program but I need to modify it so that it will #1 write a different
data form every month so the first one doesn't get too long and #2
send a resulting email response to the person who filled the form out
in the first place.
Can anyone help???
------------------------------
Date: 18 Jan 2003 15:13:21 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Data Form to Email Changes
Message-Id: <b0bquh$gch$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Grayson Bathgate:
> I have a CGI-Bin program that takes the results of a web form and
> sends them to a text data form on our server. I just downloaded this
> program but I need to modify it so that it will #1 write a different
> data form every month so the first one doesn't get too long and #2
> send a resulting email response to the person who filled the form out
> in the first place.
>
> Can anyone help???
Here's a little quiz: What kind of information that we would need to help you
is missing in your posting?
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: 17 Jan 2003 23:57:12 -0800
From: ralph@beseenmg.com (Ralph)
Subject: Day of the month redirection - revised
Message-Id: <58772576.0301172357.b6f81ae@posting.google.com>
Please help - I'm a rookie. I'm searching for a script that will
redirect visitors of my website to a specific page depending on the
day of the month and uses the clock on my server to determine the
date. I found a free javascript that does this but it uses the clock
on the visitor's computer. I've been told javascripts can't be
modified to read from my server and that I need a perl script. I'm
running a Windows 2000 server.
Also, I will have 3 folders: one for 31 day months, one for 30 day
months, & one for Feb. (28 days). The script needs to be able to
recognize if the month has 31, 30 or 28 days and goto the correct
folder and then goto the page for that day (1.html for the 1st, 2.html
for the 2nd etc...)
Can anyone help me please?
Thanks.
------------------------------
Date: Sat, 18 Jan 2003 08:18:09 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Day of the month redirection - revised
Message-Id: <slrnb2ioh1.7f1.tadmc@magna.augustmail.com>
Ralph <ralph@beseenmg.com> wrote:
> I'm searching for a script
If you want to _write_ a program that does that, then this is
the place to discuss it.
On the other hand, if you are searching for an already-written
program, then this is NOT the place to ask.
Use a search engine for searching.
> Also, I will have 3 folders: one for 31 day months, one for 30 day
> months, & one for Feb. (28 days).
^^^^^^^^^^^ ^^
^^^^^^^^^^^ ^^
You will have a problem once every four years...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 18 Jan 2003 00:44:34 -0800
From: kennedyel_5000@yahoo.com (KT)
Subject: hard
Message-Id: <6495f466.0301180044.7fa4eca3@posting.google.com>
hi all
i would like to ask that
assume there are two users.A ,B
is that a way to inform B about A's ip address via B's email address
when A is online
that mean. when A is online. then a program send A's ip address to B's
email account.
( are there any module to perform this function in perl ?)
Thx a lot
------------------------------
Date: 18 Jan 2003 12:10:54 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: hard
Message-Id: <slrnb2ih7s.3u5.abigail@alexandra.abigail.nl>
KT (kennedyel_5000@yahoo.com) wrote on MMMCDXXVII September MCMXCIII in
<URL:news:6495f466.0301180044.7fa4eca3@posting.google.com>:
|| hi all
Please, in the future, pick a better subject line.
|| i would like to ask that
||
|| assume there are two users.A ,B
||
|| is that a way to inform B about A's ip address via B's email address
|| when A is online
What do you mean by A's ip address? My desktop has 2 interface cards,
but four interfaces, and hence 4 IP addresses (one of them of course
being 127.0.0.1).
|| that mean. when A is online. then a program send A's ip address to B's
|| email account.
Well, it depends what you mean by "online". The most logical way is to
modify whatever program brings the computer of A in the state of
"being online" (a script from /etc/init.d, perhaps), and to have it
send a message to B.
|| ( are there any module to perform this function in perl ?)
No. It's isn't at all clear what you mean. Of course, there is modules
in Perl to send out email, and it isn't hard to check interface statusses
from Perl either.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'
------------------------------
Date: 18 Jan 2003 05:49:43 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: How do I calculate today minus any given number
Message-Id: <tinh8wam7$1zn$tina@news01.tinita.de>
Sherman Willden <sherman.willden@hp.com> wrote:
> Problem: Given today minus some number I have to know what that past
> date is. Example: If the user enters 30, what is the date 30 days ago
> from today. Today is 01/17/03 so what is the algorithm to return the
> December 2002 date?
stolen from <aml33n$7c2$03$1@news.t-online.com>:
$past_date = time;
sleep(24*60*60 * $days);
(but see the other posts about the problems with DST etc.)
SCNR =)
tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/ \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Sat, 18 Jan 2003 13:20:38 +0100
From: "Anders Torvill Bjorvand" <torvill@trolldata.no>
Subject: Re: How to execute a perl script from within a perl script and return info
Message-Id: <1042891303.682840@a217-118-32-43.bluecom.no>
"Pete" <falconflyr@snet.net> skrev i melding
news:4ca21189.0301141059.5d946602@posting.google.com...
> In a.cgi, if instead of:
>
> print $content;
>
> . . . you do this:
>
> system("/home/www/myserver/mydir/b.cgi");
But how can I get the printed output from b.cgi into a variable $content in
a.cgi?
Can I simply do:
$content = system("/home/www/myserver/mydir/b.cgi");
Sincerely,
Anders T. B.
>
> . . . b.cgi would get executed from a.cgi and when b.cgi is done
> control
> would be returned to a.cgi for further processing if needed. I call
> other
> Perl scripts from iside Perl scripts like this all the time. You
> could also make b.cgi a subroutine in a.cgi, maybe. Hope this helps.
>
>
> Andras Malatinszky <nobody@dev.null> wrote in message
news:<3E240769.3060305@dev.null>...
> > Anders Torvill Bjorvand wrote:
> >
> > > This is the situation:
> > >
> > > I have two scripts a.cgi and b.cgi residing the following places on
the
> > > server:
> > > /home/www/myserver/a.cgi
> > > /home/www/myserver/mydir/b.cgi
> > >
> > > Both scripts are executable (755).
> > >
> > > This is the simplified code of a.cgi:
> > > ------------
> > > #!/usr/bin/perl
> > > $content = `/home/www/myserver/mydir/b.cgi`;
> > >
> > > print "Content-type:text/html\n\n";
> > > print $content;
> > >
> > > exit;
> > > ------------
> > >
> > > This is the simplified code of b.cgi:
> > > ------------
> > > #!/usr/bin/perl
> > >
> > > print "Content-type:text/html\n\n";
> > > print "This is the output from b";
> > >
> > > exit;
> > > ------------
> > >
> > > When running a.cgi, it should produce the output from b.cgi, but a.cgi
> > > outputs nothing.
> > >
> > > Changing line 2 in a.cgi to:
> > > $content = ` perl /home/www/myserver/mydir/b.cgi`;
> > > does not seem to change anything.
> > >
> > > Why doesn't this work, and how can I get it to work?
> > >
> > > Sincerely,
> > > Anders T. B.
> > >
> >
> > This is just a guess, but check the permissions of mydir. I assume this
> > is all in a CGI context, and the user your a.cgi is running as may not
> > have read permissions to the mydir directory. See if moving b.cgi up one
> > level into the myserver directory changes things.
> >
> > Of course our guesses could be more educated if you asked perl to help
> > you with things like error checking.
------------------------------
Date: Sat, 18 Jan 2003 08:24:06 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to execute a perl script from within a perl script and return info
Message-Id: <slrnb2ios6.7f1.tadmc@magna.augustmail.com>
[ Please quote your followups properly:
http://web.presby.edu/~nnqadmin/nnq/nquote.html
]
Anders Torvill Bjorvand <torvill@trolldata.no> wrote:
> But how can I get the printed output from b.cgi into a variable $content in
> a.cgi?
>
> Can I simply do:
> $content = system("/home/www/myserver/mydir/b.cgi");
have you heard of the really great perl documentation?
If you read the documentation for the function that you are using
there, it will tell you how to do what you have asked.
Please don't ask others to read the docs to you.
perldoc -f system
This is *not* what you want to use to capture the output
from a command, for that you should use merely ...
[ snip TOFU ]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 18 Jan 2003 16:47:26 +0100
From: "TJ" <trond@bwsnett.no>
Subject: Link of the day
Message-Id: <b0bsui$nfgbo$1@ID-175630.news.dfncis.de>
Hi.
I wonder if there are anyone who know about a "link of the day" script that
is free, and doesn't show the link
randomly?
------------------------------
Date: Sat, 18 Jan 2003 09:29:37 -0000
From: "Jeff Snoxell" <Jeff@aetherweb.co.uk>
Subject: Re: Most efficient way to do this DBI thing?
Message-Id: <b0b6pt$jp6$1@newsg3.svr.pol.co.uk>
>
> Do your processing iniside of WHILE loops..
> EXAMPLE:
>
> SNIP
>
> if ($SQL->rows()) {
>
Thanks for that Mr Warrior. You've missed my point a little, but you've been
a great help. I've been struggling with this DBI issue as, unlike my former
database interface, I couldn't seem to find a way to determine if I had any
results, and how many, from an SQL query without actually fetching them. It
wasn't really a big problem but just increased how much I've been having to
tweak my old code, and made it rather ugly. I've been hassling the mysql
mailing list a bit for a way round it, to no avail and then there it is!!!
->rows();!!!!
Where did that come from? And why has nobody mentioned it to me before? It
doesn't seem to be in my manual.
How reliable is the return value as a count of the number of fetchable rows?
THANK YOU!
Jeff
------------------------------
Date: Sat, 18 Jan 2003 08:46:19 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Most efficient way to do this DBI thing?
Message-Id: <slrnb2iq5r.7f1.tadmc@magna.augustmail.com>
Jeff Snoxell <Jeff@aetherweb.co.uk> wrote:
>> if ($SQL->rows()) {
>>
>
> Thanks for that Mr Warrior. You've missed my point a little, but you've been
> a great help.
Perhaps less help than you realize...
> I've been struggling with this DBI issue as, unlike my former
> database interface, I couldn't seem to find a way to determine if I had any
> results, and how many, from an SQL query without actually fetching them. It
> wasn't really a big problem but just increased how much I've been having to
> tweak my old code, and made it rather ugly. I've been hassling the mysql
> mailing list a bit for a way round it, to no avail and then there it is!!!
>
> ->rows();!!!!
>
> Where did that come from?
From the DBI module.
> And why has nobody mentioned it to me before?
The way to find out what functions are available in a module is
to read the documentation for the module.
> It
> doesn't seem to be in my manual.
^^^^^^^^^
What manual is that?
It is included in the DBI manual that is already on your hard disk:
perldoc DBI
> How reliable is the return value as a count of the number of fetchable rows?
If you read the docs for "rows" it will tell you that it is not
reliable at all if you are doing a SELECT query.
Those docs also offer an alternative that _is_ reliable.
Use the docs Luke!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 18 Jan 2003 07:06:18 GMT
From: "Chris Hedrick" <chrishedrick@sbcglobal.net>
Subject: Newbie: Testing for undef, blank line, or white space
Message-Id: <K17W9.800$MA6.300179503@newssvr30.news.prodigy.com>
I know the standard testing is as follows:
if (defined($variable)) {
statements
}
But I want to do a while or until statement and test for undef, blank line,
and white space. If the variable carries any of these characteristics I want
the loop to be started over.
I've tried the following variations:
while (not defined(chomp = <STDIN>)) {
}
until (defined(chomp($variable = <STDIN>))) {
statements
}
until (chomp($variable = <STDIN>)) {
statements
}
do {
chomp ($variable = <STDIN>);
} until (defined($variable));
I could keep going, but it only gets weirder from there.
The problem I keep running into is that even a plain simple <ENTER> is also
considered defined. I'm trying to test for nonexistent information entered
from a prompt. How would I go about doing that? If there isn't any
alphanumeric information to evaluate then it will force the block to loop
again?
------------------------------
Date: Sat, 18 Jan 2003 07:46:49 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Newbie: Testing for undef, blank line, or white space
Message-Id: <3e29024b.86447961@news.erols.com>
"Chris Hedrick" <chrishedrick@sbcglobal.net> wrote:
: But I want to do a while or until statement and test for undef, blank line,
: and white space. If the variable carries any of these characteristics I want
: the loop to be started over.
: I've tried the following variations:
:
: while (not defined(chomp = <STDIN>)) {
: }
That won't even compile.
: until (defined(chomp($variable = <STDIN>))) {
: statements
: }
:
: until (chomp($variable = <STDIN>)) {
: statements
: }
In those, the condition is based on the return from chomp(), not on
the value in $variable.
: do {
: chomp ($variable = <STDIN>);
: } until (defined($variable));
:
: I could keep going, but it only gets weirder from there.
No doubt. :)
: I'm trying to test for nonexistent information entered
: from a prompt. How would I go about doing that?
Invert the test. If the string contains at least one non-whitespace
character, let it pass.
while( <STDIN> ) {
last if /\S/;
print "Invalid input. Try again.\n";
}
# process valid input here
------------------------------
Date: Sat, 18 Jan 2003 09:23:58 GMT
From: "Chris Hedrick" <chrishedrick@sbcglobal.net>
Subject: Re: Newbie: Testing for undef, blank line, or white space
Message-Id: <O29W9.808$Eo2.311050277@newssvr30.news.prodigy.com>
Thank you, didn't think of that. Did I mention I was a newbie at this.
> : while (not defined(chomp = <STDIN>)) {
> : }
>
> That won't even compile.
I know it was a mistake in typing.
> : I'm trying to test for nonexistent information entered
> : from a prompt. How would I go about doing that?
>
> Invert the test. If the string contains at least one non-whitespace
> character, let it pass.
>
> while( <STDIN> ) {
> last if /\S/;
> print "Invalid input. Try again.\n";
> }
> # process valid input here
>
>
------------------------------
Date: Sat, 18 Jan 2003 08:56:00 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Newbie: Testing for undef, blank line, or white space
Message-Id: <slrnb2iqo0.7f1.tadmc@magna.augustmail.com>
Chris Hedrick <chrishedrick@sbcglobal.net> wrote:
> Did I mention I was a newbie at this.
And to this newsgroup too, it would appear, since you've done
at least 3 things that are frowned upon here (and in most other
newsgroups as well):
Carefully choose the contents of your Subject header
You have 40 precious characters of Subject to win out and be one of
the posts that gets read. Don't waste them. Take care while
composing them, they are the key that opens the door to getting an
answer.
Spend them indicating what aspect of Perl others will find if they
should decide to read your article.
Do not spend them indicating "experience level" (guru, newbie...).
Use an effective followup style
When composing a followup, quote only enough text to establish the
context for the comments that you will add. Always indicate who
wrote the quoted material. Never quote an entire article. Never
quote a .signature (unless that is what you are commenting on).
Intersperse your comments *following* the sections of quoted text
that your comments apply to. Failure to do this is called "Jeopardy"
posting because the answer comes before the question.
>> : while (not defined(chomp = <STDIN>)) {
>> : }
>>
>> That won't even compile.
> I know it was a mistake in typing.
Do not re-type Perl code
Use copy/paste or your editor's "import" function rather than
attempting to type in your code. If you make a typo you will get
followups about your typos instead of about the question you are
trying to get answered.
You will get more and better answers here if you do your best to
follow the suggestions in the Posting Guidelines that are posted
here weekly:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 18 Jan 2003 13:55:40 -0000
From: phil@ox.compsoc.net (Philip George)
Subject: perl installation question
Message-Id: <b0bmcs$kno$1@spiffy.ox.compsoc.net>
Can anyone help me with this...?
We have a RedHat 7.3 box with Perl 5.6.1 installed in /usr/bin + /usr/lib.
I have an application that requires Perl 5.005_3 so I have downloaded that.
I wish to keep the existing Perl installation, but install 5.005_3 as well.
I also need to install some modules such as ORBit (amongst many other things).
In the 'sh Configure' stage I am telling it to put perl in /usr/bin/perl5005
with the libraries in /usr/lib/perl5005lib.
My questions:
1. it is asking me to specify whichg #! string should automatically start
Perl. Should I just enter '/usr/bin/perl5005'? Presumably I will then have
to reaplce all the '#!/usr/bin/perl' text at the top of my scripts with
'#!/usr/bin/perl5005' too?
2. In order to run my scripts do I need to modify my $PATH or $PERL5LIB
(or any other environment varialbes) in any way to get perl5005 to work
properly?
3. I want to install external modules such as ORBit, COPE etc into a separate
directory /usr/lib/perl5005_modules. How can I do this? Also, how do I then
tell Perl5.005_3 to look in this directory (just add it to PERL5LIB?)
4. As an aside we already have ORBit, COPE etc installed for Perl5.6.1, in
/usr/lib/perl_modules. Will it work if I just copy all of this directory to
/usr/lib/perl5005_modules? (to save reinstalling all of them).
I haven't been able to find answers to these anywhere, but I am sure they must
be common problems.
Thanks for your help!
phil
------------------------------
Date: 18 Jan 2003 15:46:50 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: perl installation question
Message-Id: <slrnb2itsp.3vd.abigail@alexandra.abigail.nl>
Philip George (phil@ox.compsoc.net) wrote on MMMCDXXVII September
MCMXCIII in <URL:news:b0bmcs$kno$1@spiffy.ox.compsoc.net>:
-- Can anyone help me with this...?
--
-- We have a RedHat 7.3 box with Perl 5.6.1 installed in /usr/bin + /usr/lib.
--
-- I have an application that requires Perl 5.005_3 so I have downloaded that.
-- I wish to keep the existing Perl installation, but install 5.005_3 as well.
Does that application really require Perl 5.005_03, or *at least* 5.005_03?
Unless the application is using a bug that has been fixed in 5.6, there's
no reason the application wouldn't run with 5.6.1.
Did you try running it?
Abigail
--
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";
------------------------------
Date: Sat, 18 Jan 2003 08:02:03 -0000
From: Rocco Caputo <troc@netrus.net>
Subject: Re: poe and CloseEvent
Message-Id: <slrnb2i2bj.vp.troc@eyrie.homenet>
On Fri, 17 Jan 2003 15:27:36 +0100, David Zimmermann wrote:
> I use the POE Module to fork
>
> but when I use the CloseEvent Parameter, i get an errormessage
> unknown parameters in POE::Wheel::Run
[...]
> 0 'CloseEvent'
Your code looks fine. Maybe you're using an older version of POE?
The latest CPAN release is 0.24.
-- Rocco Caputo - troc@pobox.com - http://poe.perl.org/
------------------------------
Date: 17 Jan 2003 22:49:15 -0800
From: krakle@visto.com (krakle)
Subject: Using domain.com/?query+string and domain.com/index.cgi?query+string...
Message-Id: <237aaff8.0301172249.3c1f5573@posting.google.com>
I have an index.cgi script on my site.
When goin to http://domain.com the script is called.
When i use http://domain.com/?query+string the query string is chopped
off as if never existed and in the browser address bar I see
http://domain.com/index.cgi.
On an another server this method works well and index.cgi can read the
query string that was attatched to the directory.
Does anyone know how I can implement this? Possibly HTACCESS?
This is driving my nuts.
ps. Let me appologize a head of time for being off topic. I couldn't
find an apache group. So I figured since i'm dealing with Perl scripts
there is bound to be people here who can help. So I also thank you a
head of time as well. Thank you and I'm sorry.
------------------------------
Date: Sat, 18 Jan 2003 08:58:17 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Using domain.com/?query+string and domain.com/index.cgi?query+string...
Message-Id: <slrnb2iqs9.7f1.tadmc@magna.augustmail.com>
krakle <krakle@visto.com> wrote:
> I couldn't
> find an apache group.
comp.infosystems.www.servers.mac
comp.infosystems.www.servers.misc
comp.infosystems.www.servers.ms-windows
comp.infosystems.www.servers.unix
and
http://xml.apache.org/mail.html
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 4425
***************************************