[18185] in Perl-Users-Digest
Perl-Users Digest, Issue: 353 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 25 14:07:10 2001
Date: Sun, 25 Feb 2001 11:05:12 -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: <983127912-v10-i353@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 25 Feb 2001 Volume: 10 Number: 353
Today's topics:
Re: 2 keys for one hash. (John Joseph Trammell)
Active Perl and preinstalled modules... <alok@aloksoft.hypermart.net>
Re: Basic: Arrays, shift, and the mystery element <iltzu@sci.invalid>
Re: Can I use Excel as a data source <ubl@schaffhausen.de>
cgi-bin not excuting perl scripts. what have i done? <abcd@ntlworld.com>
Re: cgi-bin not excuting perl scripts. what have i done <abcd@ntlworld.com>
Driving me mad!. How would you do this?? <abcd@ntlworld.com>
Re: filehandle in subroutine? <joemoore@att.net>
Re: get vs. post (was Re: newbie question) <joemoore@att.net>
Re: get vs. post (was Re: newbie question) <flavell@mail.cern.ch>
How is @INC populated <wbn1@qNowesspamt.net>
Re: How is @INC populated (Martien Verbruggen)
Re: Modules problem. To stupid to understand? <lurvas@excite.com>
Re: Not all HREF's vals getting replaced with my val's <joemoore@att.net>
Optimizing hash slice construct <RAY_electronic_design@t-online.de>
Perl SAS Oracle WWW <knuj2000@hotmail.com>
Prime factors the obfuscated way <ianb@ot.com.au>
question about 'for' loop functionality <NOSPAM4MEdrh@engineer.com>
Re: Reading from __DATA__ <joemoore@att.net>
Script Problems - Please Help <mick.beeby@mjb-is.co.uk>
Re: Search/Crawler Indexing with Perl? (Peter Scott)
Re: SHARE / TRADE costly perl programs (Maggert)
Re: Simple(?) server process <haunaguy@cablespeed.com>
Re: SMTP server <terry_s@northstate.net>
Re: splice question <jdpepin@optonline.net>
timeout connect() with select? <perlCHEESE@CHEESEatlaswebmail.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 25 Feb 2001 05:05:55 GMT
From: trammell@bayazid.hypersloth.net (John Joseph Trammell)
Subject: Re: 2 keys for one hash.
Message-Id: <slrn99h2gi.fun.trammell@bayazid.hypersloth.net>
On Sun, 25 Feb 2001 01:03:23 GMT, Kauser Ali Karim wrote:
> Is it possible to have a hash that has two key values.
> If so, I'd appreciate an example.
I assume you're looking to store more than one value per key.
(that's how I'd say it anyhow). One way is to use array
references:
my %hash;
$hash{somekey} = [];
push @{ $hash{somekey} }, "first value";
push @{ $hash{somekey} }, "second value";
my @values = @{ $hash{somekey} };
print @values;
et cetera...
------------------------------
Date: Sun, 25 Feb 2001 19:40:16 +0100
From: "Alok Menghrajani" <alok@aloksoft.hypermart.net>
Subject: Active Perl and preinstalled modules...
Message-Id: <97bjsh$eqe$1@news1.sunrise.ch>
Hi,
I want to write a program that will fetch a webpage accepting cookies. I was
wondering how to know what modules are already installed on my system (i'm
using activePerl on win98). The problem is that when I try to install the
libwww-perl-5.50.tar I get error messages...
Alok.
------------------------------
Date: 25 Feb 2001 16:50:38 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Basic: Arrays, shift, and the mystery element
Message-Id: <983119653.14982@itz.pp.sci.fi>
In article <mbudash-83844A.13080623022001@news.pacbell.net>, Michael Budash wrote:
>change:
>
>while($arrayref->[0]->{name} =~ /dan|ginger/i){
>
>to:
>
>while ( defined($arrayref->[0]) &&
> $arrayref->[0]->{name} =~ /dan|ginger/i ) {
*ahem*
while (@$arrayref and $arrayref->[0]->{name} =~ /dan|ginger/i) {
Both work identically in this case, but mine IMHO looks nicer, and
could be argued to be more correct -- it's the size of the array that
is the issue, not definedness of the elements.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"..when my grandchildren ask me what I did in the great Gulf War for the
liberation of Kuwait And Other Freedom-Loving Democracies, I'll proudly
respond that 'I shoveled shit in Louisiana.'" -- J. D. Baldwin in SDM
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Sun, 25 Feb 2001 13:29:02 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Can I use Excel as a data source
Message-Id: <3A98FA8E.CD38F266@schaffhausen.de>
Virgin News schrieb:
>
> I have a list of stockists written in an Excel spreadsheet which is
> basically an address book.
> Can I use the spreadsheet as it stands, or will i have to convert it to a
> flat file?
Any Excel document is a flat file or do you have an Excel server?
Look for Spreadsheet::ParseExcel at CPAN. It should do the job.
Bye,
->malte
------------------------------
Date: Sun, 25 Feb 2001 12:27:31 -0000
From: "Chile" <abcd@ntlworld.com>
Subject: cgi-bin not excuting perl scripts. what have i done?
Message-Id: <PC6m6.24588$5n4.493852@news6-win.server.ntlworld.com>
Hi,
i have a linux box with apache on it and it was working fine last night,
running perl scripts from the cgi-bin no prob's but now when i try and
access a scipt i get
Not Found
The requested URL /cgi-bin/counter.pl was not found on this server.
i know the file is there as i can see it in the cgi-bin and can run it perl
counter.pl, witout problems.
whats interesting is if i misspell counter.pl and try and run it i get the
IE file not found page so i don't know what this page error is coming from
or why.
Just to check, i went into the apache settings and changed the default page
from httpd/html to just httpd then i browsed to the cgi-bin and clicked on
the counter.pl but instead of executing it it just printed the file on the
screen like a txt file??
i have changed it back now though.
Any ideas??
Thanks
Scott
------------------------------
Date: Sun, 25 Feb 2001 12:32:27 -0000
From: "Chile" <abcd@ntlworld.com>
Subject: Re: cgi-bin not excuting perl scripts. what have i done?
Message-Id: <qH6m6.24604$5n4.494634@news6-win.server.ntlworld.com>
hi again,
for some reason when i just type in the url like below
http://192.168.1.101/cgi-bin/
i normally get a IE permission denied error but instead now i get file not
found?
Any ideas what i can do
Scott
"Chile" <abcd@ntlworld.com> wrote in message
news:PC6m6.24588$5n4.493852@news6-win.server.ntlworld.com...
> Hi,
>
> i have a linux box with apache on it and it was working fine last night,
> running perl scripts from the cgi-bin no prob's but now when i try and
> access a scipt i get
>
> Not Found
> The requested URL /cgi-bin/counter.pl was not found on this server.
>
>
> i know the file is there as i can see it in the cgi-bin and can run it
perl
> counter.pl, witout problems.
>
> whats interesting is if i misspell counter.pl and try and run it i get the
> IE file not found page so i don't know what this page error is coming from
> or why.
>
>
> Just to check, i went into the apache settings and changed the default
page
> from httpd/html to just httpd then i browsed to the cgi-bin and clicked on
> the counter.pl but instead of executing it it just printed the file on the
> screen like a txt file??
>
> i have changed it back now though.
>
> Any ideas??
>
> Thanks
> Scott
>
>
>
------------------------------
Date: Sun, 25 Feb 2001 16:16:10 -0000
From: "Chile" <abcd@ntlworld.com>
Subject: Driving me mad!. How would you do this??
Message-Id: <bZ9m6.25472$5n4.511614@news6-win.server.ntlworld.com>
Hi,
I would really appreciate it if someone could recommend the best method to
do this and any examples would be appreciated.
Basically i have a MySql db with urls to files that are being stored on
remote servers. These files are important to our buisness and are stored on
clients servers and we need to constantly check that these files are up.
Now i know its easy enough to ping the clients url and check if its
reachable but the way the clients servers are set up the files are stored on
a diffrent server so the site can but clients tend to remove/delete our
files so i have been given the task of writing a script that will loop
through the db with url's to these FILES and test for there reachability.
I have the script that loops through the db and prints out the urls etc..
but i just can't figure out how to write a script that i can pass these urls
to for it to check there reachability then reports back...
I saw in a previous post someone asking the same thing and using this was
suggested.
lynx -head -source http://www.example.com/ | grep "200 OK"
now this works perfect and returns "200 OK" if its found or "Error" if its
not but i don't know how to incorprate this into a script so i can pass a
url to a file and it tells me good or bad.
I hope i have descipbed this well enough for someone to help.
thanks for ANY help,
Chud
------------------------------
Date: Sun, 25 Feb 2001 18:32:00 GMT
From: "Joe Moore" <joemoore@att.net>
Subject: Re: filehandle in subroutine?
Message-Id: <Accm6.4149$gc7.292744@bgtnsc07-news.ops.worldnet.att.net>
"Kurt Stueber" <stueber@mpiz-koeln.mpg.de> wrote in message
news:3A968796.BED643C5@mpiz-koeln.mpg.de...
> Hi,
> Could anyone tell me how to hand over a filehandle to a subroutine?
> I would like to write a sub that produces output for different files
> and would like to give the sub the currently valid filehandle for the
> operation.
>
> The following does NOT work:
>
> sub print_this
> { FILE = $_;
> print FILE "Hello!";
> }
>
> open( OUTFILE, "> myfile.txt")
>
> &print_this( OUTFILE );
>
>
>
What you can do that is somewhat simpler is:
sub print_this {
print "Hello!";
}
open( OUTFILE, "> myfile.txt")
$fh = select(OUTFILE); # select redirects STDOUT to the given filehandle
print_this();
select($fh); # redirects STDOUT to the original filehandle
------------------------------
Date: Sun, 25 Feb 2001 17:48:02 GMT
From: "Joe Moore" <joemoore@att.net>
Subject: Re: get vs. post (was Re: newbie question)
Message-Id: <mzbm6.4122$gc7.290158@bgtnsc07-news.ops.worldnet.att.net>
I agree CGI.pm is the way to go, but reading post data is not so difficult.
It comes in on STDIN.
$get_query = $ENV{'QUERY_STRING'};
$post_query = join("",<>);
<egwong@netcom.com> wrote in message
news:974vbt$7ca4$2@newssvr05-en0.news.prodigy.com...
> Joseph M. Suprenant <laclac@global2000.net> wrote:
> > Thanks!
> > but what do you see is wrong with my code, that is making my program to
not
> > work?
>
> As Damian said, your problem is that you're not using CGI.pm. For
> god's sake, please do use it and save yourself *a lot* of trouble
> and heartache. If it's too big for you, try something like CGI::Lite
> instead. Just about anything you'll ever want to do with CGI can
> be done with CGI.pm.
>
> Now, specifically, *your* script was trying to read $ENV{QUERY_STRING}
> in a POST'ed html form. Unfortunately for you $ENV{QUERY_STRING} refers
> to the stuff after the '?' in the url, so you need to change method='POST'
> to method='GET'. Reading POST'ed data is somewhat more complicated.
>
> As I said before, *please* use CGI.pm. It'll make your life much easier.
> If you want to roll your own, then at the very least, read through the
> CGI specs at
> http://www.w3.org/CGI/
>
> ERic
>
> p.s. If you follow up, put the quoted text at the top and your own
> comments at the bottom. Remember, not everyone has read the
> entire thread.
------------------------------
Date: Sun, 25 Feb 2001 19:05:29 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: get vs. post (was Re: newbie question)
Message-Id: <Pine.LNX.4.30.0102251852460.18109-100000@lxplus003.cern.ch>
On Sun, 25 Feb 2001, Joe Moore jeopardized:
> I agree CGI.pm is the way to go,
Good so far...
> but reading post data is not so difficult.
Of course, but that's not the only thing that CGI,pm does for you.
> It comes in on STDIN.
Sure, the CGI spec tells you that, and the relevant specifications
show how to decode the result.
> $get_query = $ENV{'QUERY_STRING'};
> $post_query = join("",<>);
OK, that's the easy part over. Now how to handle at least two
different form-submission encodings, how to deal with 'charset', what
to do about that security bug in X Netscape, how to offer the user a
convenient debugging facility from the command line... the list just
goes on and on. And when a new problem is found, e.g a new browser
vulnerability, you get the fix by merely updating CGI.pm, without
having to plough through all your scripts looking for the points of
weakness.
What it comes down to basically is that there's just a few people
around here who don't use CGI.pm and _KNOW WHY_ they don't use CGI.pm;
there's a lot who get themselves into difficulties because they won't
use CGI.pm.
As long as they continue to have difficulties and need to ask here,
I'd say the answer for them is CGI.pm: when they understand the
problem well enough to decide for themselves, then maybe they'll
continut to choose CGI.pm, or maybe they won't - but they won't be
needing to ask about their detailed problems with that part of the
solution here.
> > p.s. If you follow up, put the quoted text at the top and your own
> > comments at the bottom. Remember, not everyone has read the
> > entire thread.
Curious the way that jeopardists are happy to quote stuff that they
either didn't read or don't intend to respond to. The scorefile is
seeking fresh applicants...
ttfn
------------------------------
Date: Sun, 25 Feb 2001 01:51:49 -0800
From: "Bruce N. Wheelock" <wbn1@qNowesspamt.net>
Subject: How is @INC populated
Message-Id: <YA4m6.13188$JK2.941459@news.uswest.net>
I suppose this will turn out to be an embarrassingly simple question, but
how is the @INC array populated? The values are retained between sessions,
so the data come from somewhere, but where? I've checked the Camel book and
I've searched online, but I can't find the answer to this.
ActiveSource Perl v5.6.0 running on Windows 2000 Professional.
A minimal amount of derisive laughter gratefully appreciated. ;-)
------------------------------
Date: Sun, 25 Feb 2001 23:24:14 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: How is @INC populated
Message-Id: <slrn99hube.hp7.mgjv@martien.heliotrope.home>
On Sun, 25 Feb 2001 01:51:49 -0800,
Bruce N. Wheelock <wbn1@qNowesspamt.net> wrote:
> I suppose this will turn out to be an embarrassingly simple question, but
> how is the @INC array populated? The values are retained between sessions,
> so the data come from somewhere, but where? I've checked the Camel book and
> I've searched online, but I can't find the answer to this.
>
They're compiled in:
$ strings `which perl` | grep perl/lib
/opt/perl/lib/5.6.0
/opt/perl/lib/5.6.0/i686-linux
/opt/perl/lib/site_perl/5.6.0/i686-linux
/opt/perl/lib/site_perl/5.6.0
/opt/perl/lib/site_perl
After configuring your Perl for compilation, you can find these in
config.h as various defined macros with LIB in their names. You can have
a look at perl.c:S_init_perllib() to see what gets loaded, and how. Look
for occurences of incpush() in the code.
You should also be able to find these directories in ARCHLIB/Config.pm,
where archlib is the 2nd one in the list above.
$ perl -MConfig=config_sh -we 'print config_sh' | grep perl/lib
archlibexp='/opt/perl/lib/5.6.0/i686-linux'
installarchlib='/opt/perl/lib/5.6.0/i686-linux'
installprivlib='/opt/perl/lib/5.6.0'
privlibexp='/opt/perl/lib/5.6.0'
archlib='/opt/perl/lib/5.6.0/i686-linux'
installsitearch='/opt/perl/lib/site_perl/5.6.0/i686-linux'
installsitelib='/opt/perl/lib/site_perl/5.6.0'
privlib='/opt/perl/lib/5.6.0'
sitearch='/opt/perl/lib/site_perl/5.6.0/i686-linux'
sitearchexp='/opt/perl/lib/site_perl/5.6.0/i686-linux'
sitelib='/opt/perl/lib/site_perl/5.6.0'
sitelib_stem='/opt/perl/lib/site_perl'
sitelibexp='/opt/perl/lib/site_perl/5.6.0'
Perl does however also do some clever things to include version specific
libraries of older versions of Perl that may be installed in the same
tree.
> ActiveSource Perl v5.6.0 running on Windows 2000 Professional.
The same should hold for the ActiveState version, even though you
probably didn't compile it up yourself, or got the source code
available.
> A minimal amount of derisive laughter gratefully appreciated. ;-)
I don't see any need for derisive laughter.
Martien
--
Martien Verbruggen | The problem with sharks is that they
Interactive Media Division | are too large to get to the shallow
Commercial Dynamics Pty. Ltd. | end of the gene pool. -- Scott R.
NSW, Australia | Godin
------------------------------
Date: Sun, 25 Feb 2001 11:36:09 +0100
From: Hariga Ben <lurvas@excite.com>
Subject: Re: Modules problem. To stupid to understand?
Message-Id: <01HW.B6BE9EA9001DCAD706169BE0@news.communique.se>
On Fri, 23 Feb 2001 12:50:21 +0100, Lurviga Ben wrote
(in message <lurvas-832E91.12502123022001@news.umu.se>):
Thanks to everyone for your suggestions.
After reading the suggestions, the Perl book and a few more FAQ pages I think
I understand how it works. At least does the modules I've written so far work
8-)
h.B.
--
Håriga Ben
lurvas@excite.com
------------------------------
Date: Sun, 25 Feb 2001 18:08:36 GMT
From: "Joe Moore" <joemoore@att.net>
Subject: Re: Not all HREF's vals getting replaced with my val's in s/[HREF val]/[My val]/g...?
Message-Id: <ESbm6.4134$gc7.291243@bgtnsc07-news.ops.worldnet.att.net>
"Charles K. Clarkson" <c_clarkson@hotmail.com> wrote in message
news:C87EB5F64E5F7C56.7181C8B4F864533A.187C11D0C3719A87@lp.airnews.net...
>
> "}ANGEL{" <angel@reflex-point.com> wrote in message
> news:4pml6.63$eS2.183580@nnrp3.sbc.net...
> : Calling all Saints:
> :
> : In the following code, I read all HREF's in an HTML file and attempt to
> : replace the value of the HREF. In this code, I spit the HREF's out to
> : my browser so I can see that the script is picking up all of the
> : HREF's...and it does this flawlessly. But when I s/[HREF value]/[my
> : value]/g it works on some, but not all HREF's. The code is a bit
> : choppy because I am a little green. Perhaps my explanation of the
> : problem is as well. However, any moderately helpful conjecture is
> : sincerely appreciated. The following the complete script:
> :
> : #!/usr/bin/perl5.004
>
> You should really, really, really, really, use strict
> and warnings. It will really jump start your learning curve.
>
> #!/usr/bin/perl5.004 -w
> use strict;
> use diagnostics;
>
> :
> : use CGI::Carp qw(fatalsToBrowser);
> : require "cgi-lib.pl";
> : &ReadParse;
> : print &PrintHeader;
> :
> : open(NewDbFile,
> : "</home/xpedite-houston/www/upload/Message_Body.htm") ||
> : &ShitBiskits;
> : flock(NewDbFile, 2);
> : my @links = <NewDbFile>;
> : flock(NewDbFile, 8);
> : close(NewDbFile);
> :
> : my $doMe;
> : foreach (@links) {
> : $doMe .= $_;
> : while ($_ =~ m/(href="\S+")/g) { #<-----Get the HREF's
>
> Are you sure all the hrefs use double quotes? HTML allows
> single quotes as well.
>
> HTH,
> Charles K. Clarkson
Also, the "\S+" will match things like <a href="URL"> <img src="file.gif">
</a>
where it grabs everything between the first " and the last " on the line!
ie:
URL"> <img src="file.gif
Use "\S+?", which means grab the fewest \S characters before the quote.
>
> : push(@listOlinks,$1);
> : }
> : }
> :
> : foreach (@listOlinks) {
> : print $_."<BR>\n";
> : $doMe =~ s/$_/href\="\[pull name\=$n.html\]"/; #<---Replace the HREF's
> : open(clickTo,">/home/xpedite-houston/www/upload/$n.html") ||
> : &ShitBiskits;
> : flock(clickTo, 2);
> : print clickTo "<html><head><title>Loading...</title><meta
> : http-equiv=\"REFRESH\" content=\"0; URL=$_\"></head></html>" ;
> : flock(clickTo, 8);
> : close(clickTo);
> : $n++;
> : }
> :
> : open(NewFile,">/home/xpedite-houston/www/upload/newMessage.htm") ||
> : &ShitBiskits;
> : flock(NewFile, 2);
> : print NewFile $doMe;
> : flock(NewFile, 8);
> : close(NewFile);
> :
> : print "All Done!";
> :
> : exit();
> :
> : Sincere & Drowning,
> : ANGEL
> :
> :
> :
>
>
------------------------------
Date: Sun, 25 Feb 2001 16:39:43 +0100
From: "Raymund Hofmann" <RAY_electronic_design@t-online.de>
Subject: Optimizing hash slice construct
Message-Id: <97b8vt$vtc$01$1@news.t-online.com>
i use the following working hash slice construct:
map {$_->[1][2][0][1]} @$cellports{keys %$cellports}
Could i do this hash slice more elegantly without the map ?
something like:
@$cellports{keys %$cellports}->[1][2][0][1]
only gives the first element of the hash slice, not all like the first
construct.
$cellports is a ref to a hash with values that contain references to a more
complicated data structure (refs to hashes and array's).
Pleas note that i do not necessarily want all key's of a hash like in the
example here '@$cellports{keys %$cellports}', but maybe
'@$cellports{('some','keys')}'
Raymund Hofmann
------------------------------
Date: Sun, 25 Feb 2001 10:14:07 -0600
From: "Knuj Liam" <knuj2000@hotmail.com>
Subject: Perl SAS Oracle WWW
Message-Id: <97b8ij$mbc$1@news.utdallas.edu>
I'm a total newbie to Perl so please bear with me. I'd like to know if Perl
is capable of serving as the intermediary in an environment that looks like
this:
- UNIX
- Oracle database
- Many SAS programs
- Desire to web-enable the applications so that users can point and click
launch of SAS programs (batch & interactive).
- Other applications such as OLAP tools and S-PLUS.
Here's what it would look like: User opens browser on intranet page. Enters
data in form that defines parameters for a query. Click- query passed to
Oracle for execution. Records returned and passed to a batch SAS program.
SAS output returned as HTML doc for display in browser. Instead of SAS,
maybe it's an S-PLUS script that returns a postscript file or some other
graphic format. Or maybe the selected records are simply passed to an
interactive SAS or S-PLUS session, both of which would have to be launched
from the shell in some way, preferably automagicly.
I guess what I'm asking is whether Perl is a reasonable choice as a sort of
universal traffic cop for all of these diverse applications. We want
everybody to play well together. Many application vendors web-enable their
products to some degree these days, but even then it's useful to be able to
integrate and customize with CGI, a task that I gather to which Perl is
eminently suited.
Any Perl "tribal" knowledge would be most appreciated. I'm not asking how to
do it, just whether it /can/ be done. If I know that it can be done with
Perl, then I will attempt to learn as much as I can and also to suggest to
management that hiring some Perl experts would be a good idea.
Knuj Liam
* * * * * * * * * * * * * *
Send all prayer requests or other messages for the Cosmos to
knuj2000@hotmail.com as they become One with the Universe
immediately upon arrival.
------------------------------
Date: Sun, 25 Feb 2001 21:13:05 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Prime factors the obfuscated way
Message-Id: <3A98DAB1.270DDE1F@ot.com.au>
Inspired by but not really relevant to thread "Finding multiply of prime
factors":
perl -e
'$n=12345;$_="#".1x$n."\n";1while(s/#(11+?)(\1(?{local$f=$f+1}))*(?{$ff=$f})$/length($1).($ff?"x#1".1x$ff:"");/e);print'
or if you have some kind of perverse attachment to whitespace:
perl -e '$n = 12345; $_ = "#" . 1 x $n . "\n"; 1 while
(s/#(11+?)(\1(?{local $f = $f + 1}))*(?{$ff = $f})$/ length ($1) .
($ff?"x#1" . 1x$ff: "");/e);print'
Bits of this may look familiar.
Regards,
Ian
------------------------------
Date: Sun, 25 Feb 2001 18:03:25 GMT
From: David <NOSPAM4MEdrh@engineer.com>
Subject: question about 'for' loop functionality
Message-Id: <igii9t0qbv7hvvnodc315vo4868uqff46v@4ax.com>
Hello
My apologies if this message appears more than once. I've been having
problems with my isp's news server as of late.
I have a question about 'for' loop functionality.
I understand the following:
for ($count=1 ; $count<10 ; $count++){
#some code...
} # no problem here
And
for (@array){
#some code with $_
} # now problem here either
But what if I want to cycle through all elements of @array as well as
initialize $count then auto increment it:
for ($count=1 ; @array ; $count++){
#some code...
}
This doesn't work. It just tests for existence of elements in @array
creating an endless loop if @array holds anything.
The following doesn't work either:
for ($count=1 ; $element = @array ; $count++){
#some code with $element ...
}
This sets $element with the number of elements in array.
I've built the following kludge to do the trick but I'm sure there's a
more eloquent way of doing this.
$count = 1;
foreach (@array){
#some code with $_
$count++;
}
Can anyone clue me in?
Thanks,
David.
------------------------------
Date: Sun, 25 Feb 2001 17:59:36 GMT
From: "Joe Moore" <joemoore@att.net>
Subject: Re: Reading from __DATA__
Message-Id: <cKbm6.4131$gc7.289429@bgtnsc07-news.ops.worldnet.att.net>
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:8u2d9to2c8h821i1e7peimod2cjfffh3pf@4ax.com...
> Dmitry Epstein wrote:
>
> >> After the seek, do:
> >>
> >> 1 until <> eq "__DATA__\n";
> >>
> >> Abigail
> >
> >OK, I am not a Perl expert, so let me ask a stupid question: doesn't <>
> >read from STDOUT or a file from the parameter list? You obviously meant
> >it to read from the source file.
>
> Not STDOUT, STDIN. But you're right. The code should have read
>
> seek DATA, 0, 0;
> 1 until <DATA> eq "__DATA__\n";
Instead of reading multiple times, why not:
@data = <DATA>;
then, when you want to process the file once or mutiple times, just use:
foreach (@data) {
...
}
>
> --
> Bart.
------------------------------
Date: Sun, 25 Feb 2001 11:24:47 -0000
From: "Mick Beeby" <mick.beeby@mjb-is.co.uk>
Subject: Script Problems - Please Help
Message-Id: <97aq4u$27$1@news5.svr.pol.co.uk>
I have a Perl script which does whois lookup on multiple TLD's. The problem
I have is two fold:-
1) If I name the script with a .pl extension it returns correct information
regarding whether particular domains are available or not but I sometimes
get error messages such as 'Use of uninitialized value in transliteration
(tr///) at f:\mjb-is\mjb-is\cgi-bin\whois.pl line 109. ' and 'Use of
uninitialized value in pattern match (m//) at
f:\mjb-is\mjb-is\cgi-bin\whois.pl line 278.' etc. I get several of the
latter ones. I also get this 'The name specified is not recognized as an
internal or external command, operable program or batch file.' The results
do get printed to the screen and are coreect though.
2) If I name the script with a .cgi extension it works fine without any
errors but returns false information. i.e. all domain are listed as
available even when I know which ones are not.
What are the consequences of using a differnet extension? The scripts are in
the cgi-bin directory. This is getting really annoying as sometimes the .pl
one works fine without generating the error messages. If you submit a second
time it usually is OK.
I would appreciate any tips on this. I am not really a Perl programmer at
heart or though I canpick my way round thigs and work stuff out. I have more
experience with Javascript, VBScript, ASP etc.
If possible, could you cross post any replies to my email address too at
mick.beeby@mjb-is.co.uk
Thanks in advance.
Mick
------------------------------
Date: Sun, 25 Feb 2001 16:27:16 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Search/Crawler Indexing with Perl?
Message-Id: <Enam6.8568$V6.26582@news1.gvcl1.bc.home.com>
In article <georgebailey-D24FD8.19202124022001@news.connect.com.au>,
George Bailey <georgebailey@my-deja.com> writes:
>I'd really appreciate some help with this.
>
>I've been attempting to create a search-engine-type crawler which will
>index a set of files on my site, partly as a useful tool, and also as
>part of the process of learning Perl.
This certainly would be a great learning experience. However, you might
like to know that there's already an Open Source project that's created
such a thing as the successor to the Harvest system that was written
mainly in C. Harvest-NG is written in Perl, and is extremely powerful
and flexible:
http://www.tardis.ed.ac.uk/harvest/ng/
--
Peter Scott
------------------------------
Date: Sun, 25 Feb 2001 18:01:51 GMT
From: perl@imchat.com (Maggert)
Subject: Re: SHARE / TRADE costly perl programs
Message-Id: <3a99472e.568663735@news.ionet.net>
On Sat, 24 Feb 2001 08:12:55 GMT, Lisa Escott <bizygal@earthlink.net>
wrote:
>I have bought many perl / cgi programs in the past, and have also traded
>several... Now I have a collection of 31 professional perl scripts to
>share and trade with you. Have you bought any perl / cgi programs?
>Lets help each other out, no strings. People helping people, the way it
>ought to be. Contact bizygal@hotmail.com or ICQ# 12986879 ...
>Awaiting replies, Lisa
>
And have you contemplated that this is illegal? Do you know
that sharing copywrite material is a violation of the law and you and
your buddies can be prosecuted?
Do you think that programmers are fools that don't deserve to
make any money from their work?
I think I'll join your little group and rat your ass out when
I find out what programs you're trying to trade!! Of course you would
have no way of knowing who I am because even though I'm just a stupid
programmer I do know how to spoof your ass!!
------------------------------
Date: Sun, 25 Feb 2001 10:51:14 -0800
From: "Ben L." <haunaguy@cablespeed.com>
Subject: Re: Simple(?) server process
Message-Id: <3a992c3c$1_1@news2.one.net>
I understand what you're trying to do ... I have done something similar to
this in the past - expect with my code instead of periodically checking a
que, the code waits for the next incoming process(via a socket using
TCP/IP), and when one comes along the code forks itself and runs off to
handle the process, while the main process waits for the next incoming. You
can get some ideas on how to engineer this using fork, if your systems
supports it, from the camel pp 348-355, and also search for the IPC
tutorials/faqs online. I understand you may not plan to use sockets or kind
of network communications, but the examples in the camel will give you a
quick look at how to use fork to do what you want - you could set it up with
some kind of timer to peridocally check a que file, and if there are new
entries fork a process to handle them. Good luck.
Jeffrey Porter <jandkporter@mediaone.net> wrote in message
news:3A986A7A.AABF451A@mediaone.net...
> I have to implement a process that wakes up every couple of seconds,
> tests a request queue and if there is activity, run a seperate process.
> Simple right? Well there are a couple of caveats... 1) There can be
> some long running processes here so i can't wait for the process to end
> before I check the incomming requests again. 2). There can be no more
> that x number of processes running, 2). If a process dies, it must be
> removed from a "processes running queue" so I can service another...
>
> All of this is on a single machine so hopefully that makes it easier. I
> don't need output from the processes I'm spawning, nor do I or need to
> feed the process from the server so I was thinking of setting up a queue
> kicking off background processes but don't know how to effectively deal
> with the background PID's and their returns or failures.
>
> The logistics of the queue are pretty simple... any ideas on how to
> accomplish this would be greatly appreciated
>
------------------------------
Date: Sun, 25 Feb 2001 09:52:30 -0500
From: "Terry" <terry_s@northstate.net>
Subject: Re: SMTP server
Message-Id: <eX8m6.28344$3%5.217882@e420r-sjo3.usenetserver.com>
> If you are using win 98, NT or 2000, there is a very good one here.
> http://www.argosoft.com/applications/mailserver/default.asp
>
> I have used this one on win 98 and 2000 with great results, Be sure to
turn
> on relay or it won't send mail out of your lan. Also your dns server must
> point your mx record to your IP or incoming mail will not get to you.
> Email me if i can help further.
> If you are using linux, I admire you but can't help.
>
> Good Luck
> Terry
PS your reply to address is bouncing your mail. The problem may be GayOL
related.
"The Mosquito ScriptKiddiot" <anotherway83@aol.com> wrote in message
news:20010224004903.03325.00002741@ng-cg1.aol.com...
> hey
>
> sorry if this mite sound off-topic, but i haven't been able to find a
decent
> SMTP server...i've looked all over, meaning i've searched using search
engines,
> and it's true that MANY so-called "valid" hits r returned...sites that
> literally contain lists of what they call "free" smtp servers, but when u
try
> them, they're all fake...the ones that work say stuff like "relaying
> denied"....
>
> i did find one that accepted : chem.boisestate.edu
>
> BUT
>
> it NEVER sent the email to the intended recipient
>
> so now, the $64,000 question is....
>
> WHERE CAN I FIND A FREE GOOD SMTP SERVER?
>
> thanks
> peace
> The Mosquito ScriptKiddiot
> Championing the Cause of Mosquitoes in Technology
------------------------------
Date: Sun, 25 Feb 2001 16:41:22 GMT
From: "Joseph Pepin" <jdpepin@optonline.net>
Subject: Re: splice question
Message-Id: <SAam6.10999$Vj5.2499314@news02.optonline.net>
"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrn99h1d3.pen.mgjv@martien.heliotrope.home...
> [Please, in the future, put your reply _after_ the suitably trimmed text
> you reply to. It's the generally accepted quoting style on this group,
> and Usenet in general]
>
> Looks like it might be worth a bug report. I am not saying that I would
> expect Perl to behave either way, although it should probably behave as
> you expect. But there being a difference in the way these two work is
> not acceptable.
>
> If you don't know how to submit a bug report, let me know, and I'll
> prepare one.
>
> Martien
> --
> Martien Verbruggen |
> Interactive Media Division | Hi, Dave here, what's the root
> Commercial Dynamics Pty. Ltd. | password?
> NSW, Australia |
Martien, why don't you submit a bug report. I'd probably mess it up. Do you
suppose this is crazy enough to rate a "Yikes!" ?
------------------------------
Date: Sun, 25 Feb 2001 20:58:48 +1100
From: "h." <perlCHEESE@CHEESEatlaswebmail.com>
Subject: timeout connect() with select?
Message-Id: <3a98dba7@nexus.comcen.com.au>
Hello,
I need to timeout a Socket connect() to a POP3 server. I know how to do
it using alarm(), but I'd much rather use the more reliable and more widely
supported select() call. I have know idea how select() really works, I've
only
seen examples with File handles and the IO::select methods. I've tried
numerous random ways of calling the select function with Sockets. I finally
settled on one that, if connected, returns immediately, and if not
connected, returns after a specified $timeout instead of whatever timeout
the underlying TCP mechnism sets (75 seconds on my machine).
Here is the subroutine I'm using:
sub timedConnect
{
use Socket;
my $socket_handle=shift;
my $packed_address=shift;
my $timeout=shift;
my ($ein,$eout); #only using $ein though...
vec($ein, fileno($socket_handle), 1) = 1; # set Socket to non
blocking???
while(select(undef,undef,$eout=1,$timeout))
{
# since $eout=1, I always get here
# ( immediately if connected, after $timeout if not)
connect($socket_handle,$packed_address);
my $saved_fh=select($socket_handle);
$|=1; # autoflush
select($saved_fh);
return 1;
}
# If I set $eout=$ein, I always get here..
# if I set $eout=undef, I always get here
return 0;
}
Notice I set $ein=1 in the select call. This is what always forces it to
return 1.
When I set it to $ein=$eout, it would always fail. When I set it to
$ein=undef,
it would always fail too. I have no idea why:)
Unfortunately, since the method always returns 1, I really don't find out
whether it has connected until I try to read from the Socket. This still
prevents me from having to wait 75 seconds to find out if I have a
connection, but not the way I want it to.
I would *really* appreciate it if anyone could explain in detail how select
works and/or how to use it with Sockets. I would also appreciate any
information on how vec() sets Handles to non-blocking.
Thanks in advance,
-homeless
------------------------------
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 V10 Issue 353
**************************************