[19045] in Perl-Users-Digest
Perl-Users Digest, Issue: 1240 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 4 00:06:06 2001
Date: Tue, 3 Jul 2001 21:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <994219510-v10-i1240@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 3 Jul 2001 Volume: 10 Number: 1240
Today's topics:
Automatic docs from commentless code? <william-news-102374@scissor.com>
Re: Changing Content <KEEPYOURgreywolf_pnwSPAM@snotmail.com>
Re: Changing Content (Eric Bohlman)
Re: Changing Content (Tad McClellan)
Re: Chmod Problem <mbudash@sonic.net>
Re: Gtk or Tk or ? <bowman@montana.com>
Re: hideen fields (Eric Bohlman)
Re: How do I make a forwarded variable declarations? <paul@burry.ca>
Re: How do I make a forwarded variable declarations? (Eric Bohlman)
Re: How I came to love Perl... (Eric Bohlman)
Re: How I came to love Perl... <wyzelli@yahoo.com>
Re: How to timeout a socket recv under win32? <tanghh@ha.org.hk>
Is REG_DATE a special type of mysql column? <diane@dmswebsupport.com>
Re: Is there no solution to a malformed header? (Tad McClellan)
Re: Is there no solution to a malformed header? (Eric Bohlman)
Re: mailto module? <bjoern@hoehrmann.de>
Re: mailto module? <flavell@mail.cern.ch>
Re: map/hash question, functional style (Craig Berry)
Re: map/hash question, functional style <godzilla@stomp.stomp.tokyo>
Re: Merging content from two templates (Eric Bohlman)
Re: parallel processes w/perl <carlos@plant.student.utwente.nl>
Re: parallel processes w/perl <magilfix@us.ibm.com>
Re: parsing contents of html form w/net::smtp (Eric Bohlman)
Re: Protected Dowloads (SSI?) <mbudash@sonic.net>
Re: Protected Dowloads (SSI?) <member@dbforums.com>
Re: require user configuration files <somewhere@in.paradise.net>
Retrieving Domain from URL line (Blstone77)
Scripts to Load Image Based on Time <marcusf@telsoft-inc.com>
Re: Scripts to Load Image Based on Time (Craig Berry)
Re: Vapo-Rub (Eric Bohlman)
Re: Vapo-Rub (Tad McClellan)
Re: web fetching (Tad McClellan)
Re: web fetching <somewhere@in.paradise.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 3 Jul 2001 20:42:16 -0700
From: William Pietri <william-news-102374@scissor.com>
Subject: Automatic docs from commentless code?
Message-Id: <tk544pn5hg7g68@corp.supernews.com>
I've recently been handed a lump of perl code, around 20,000 lines and
almost entirely without comments. Are there tools for getting a better grip
on the structure of this?
After a couple of hours rummaging and searching, the closest thing I've
found is the B::Xref module. This is interesting, but not quite what I'm
looking for. I'm also aware of the magic of pod, but since there are no
comments, that doesn't help me yet.
Ideally, I'm after two things. One is something like Java's javadoc, which
takes a mess of source code and produces skeleton documentation, showing
classes, their methods, and some variable usage information. The other
thing is diagrams (or failing that, tables) of who calls what, like those
produced by doxygen.
(For the curious, here are some links. Namely, info and samples for javadoc
and doxygen.
http://java.sun.com/products/jdk/javadoc/index.html
http://java.sun.com/j2se/1.3/docs/api/index.html
http://www.stack.nl/~dimitri/doxygen/
http://www.mpa-garching.mpg.de/~martin/ray++/doc/classdoc/kernel/inherits.html
http://www.mpa-garching.mpg.de/~martin/ray++/doc/classdoc/kernel/class_RAYPP__RAY.html
The last one is a "collaboration diagram", which I find especially useful.)
Now I know perl's flexible nature makes these sorts of things much harder,
and the fact that the code in hand is very much not OO makes it worse. So
I'm willing to take what I can get.
I think with a little swearing and a lot of sweat, I could generate what I
need from the output of B::Xref. But I figure somebody out there has
already solved this problem. Anybody know where that solution is?
Many thanks,
William
------------------------------
Date: Wed, 04 Jul 2001 02:00:46 GMT
From: Greg Wolf <KEEPYOURgreywolf_pnwSPAM@snotmail.com>
Subject: Re: Changing Content
Message-Id: <MPG.15ac18dc18d10ea89898fc@news.earthlink.net>
In article <x71yny7if7.fsf@home.sysarch.com>, uri@sysarch.com says...
> >>>>> "AI" == ACDesigns, Inc <njcops@hotmail.com> writes:
>
> AI> Have constantly changing content like sports, news, weather, stocks,
> AI> or whatever you can think of on your site. Already used by hundreds
> AI> of web sites around the world.
>
> AI> The CGI script is available at:
> AI> http://pageripper.cjb.net
>
> use LWP::Simple.
>
> send me your $9.95.
>
> uri
I'm new here. Please explain LWP::Simple.
--
Greg Wolf
Cement. Mortar. Concrete. In this context, cement is NOT used as a
construction material; it is simply limestone and clay - baked, and
ground. Add sand and water, it becomes mortar - an adhesive for tiles,
bricks, and such. Add sand and gravel, it becomes concrete. Add steel to
reinforce concrete, and it becomes a durable construction material.10-4?
------------------------------
Date: 4 Jul 2001 02:39:03 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Changing Content
Message-Id: <9htvk7$mkb$4@bob.news.rcn.net>
Greg Wolf <KEEPYOURgreywolf_pnwSPAM@snotmail.com> wrote:
> I'm new here. Please explain LWP::Simple.
An extremely handy Perl module that allows you to fetch a resource from
the Web. If you're running ActivePerl, you already have it installed;
otherwise you can get it from CPAN. Once you have it installed, perldoc
LWP::Simple will show you how to use it.
It really is simple:
use LWP::Simple;
my $pagetext=get('http://www.omsdev.com');
will stick the entire contents of my homepage into $pagetext. There are
also functions to fetch a resource and save it to a file, etc.
------------------------------
Date: Tue, 3 Jul 2001 22:15:46 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Changing Content
Message-Id: <slrn9k4v2i.boj.tadmc@tadmc26.august.net>
Greg Wolf <KEEPYOURgreywolf_pnwSPAM@snotmail.com> wrote:
>In article <x71yny7if7.fsf@home.sysarch.com>, uri@sysarch.com says...
>
>> >>>>> "AI" == ACDesigns, Inc <njcops@hotmail.com> writes:
>>
>> AI> Have constantly changing content like sports, news, weather, stocks,
>> AI> or whatever you can think of on your site. Already used by hundreds
>> AI> of web sites around the world.
>>
>> AI> The CGI script is available at:
>> AI> http://pageripper.cjb.net
>>
>> use LWP::Simple.
>>
>> send me your $9.95.
>>
>> uri
>
>I'm new here.
Learn to use 'perldoc'.
Love to use 'perldoc'.
Love to learn to use 'perldoc'.
perldoc perldoc
:-)
>Please explain LWP::Simple.
Please ask perl to explain LWP::Simple first:
perldoc LWP::Simple
then come back if there's still something you don't understand.
--------------------------------
#!/usr/bin/perl -w
use strict;
use LWP::Simple;
my $htmlpage = get 'http://www.perl.org/';
print $htmlpage;
--------------------------------
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 03 Jul 2001 22:59:26 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Chmod Problem
Message-Id: <mbudash-DD292E.15592703072001@news.sonic.net>
In article <1425-3B422335-325@storefull-242.iap.bryant.webtv.net>,
dennis100@webtv.net (BUCK NAKED1) wrote:
> Why isn't this code chmodding all my files and directories under $tmpdir
> to 644?
>
> # chmod all files to 644
> find sub {-f or return;
> if(my $new = $_)
> { chmod 0644, $_; rename $_, $new; } }, $tmpdir ;
>
gee, i don't know, but the system will tell you:
chmod (0644, $_) or die ("Can't chmod: $!");
rename ($_, $new) or die ("Can't rename: $!");
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Tue, 3 Jul 2001 21:41:38 -0600
From: "bowman" <bowman@montana.com>
Subject: Re: Gtk or Tk or ?
Message-Id: <6dw07.26847$N85.8736@newsfeed.slurp.net>
"David Coppit" <newspost@coppit.org> wrote in message
news:Pine.SUN.4.33.0107031004470.2698-100000@mamba.cs.Virginia.EDU...
> Has Gtk's widgets, documentation, and support "caught up" to Tk?
caught up and surpassed. the widgets have a modern look that surpasses Tk.
The Gtk distro comes with a good tutorial and plenty of examples. There are
at least two decent books, one focusing more on Gtk, the other on the entire
Gnome system.
> Also, I see Curses,
A GUI toolkit for the VT100. There are valid reasons for using Curses, I
just can't think of one at the moment.
>Gimp, Gnome, Glade
Sort of related. Gimp is a image manipulation application. Gtk was developed
in aid of Gimp. Gnome takes the Gtk and extends into to more of an
integrated Desktop system. Glade is a GUI design tool that emits Gtk based
code in a number of popular languages.
> QT
Qt is the basis of KDE.
In many ways all of the toolkits are similar. Personal preferences come
into play. For instance, I don't like the little kludge Qt uses to implement
event handling. wxWindows has another scheme that i think is a little
cleaner. Gtk's rather verbose naming conventions take a little getting used
to, but they are at least pretty orthogonal. After spending many happy
moments trying to hit on the right name for some half remembered Xt or Motif
function, I really appreciate something where I can guess a what a function
might be called for a widget I seldom use, and come up right most of the
time.
> CPAN's user interfaces category. Are these other good alternatives, or
> are Tk and Gtk pretty much the best out there?
Tk is a little more portable if you are going across a number of platforms.
If you are staying with Linux, anything but the barest install will at least
have the gtk and qt libs. Both of these are available on Windows, Qt being a
little more polished. Gtk works well, but it is not highly supported. Other
*nixes tend not to have the libs, and not every AIX sysamin will build Gtk
to run your app, though she might already have PerlTk up and running.
------------------------------
Date: 4 Jul 2001 02:01:04 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: hideen fields
Message-Id: <9httd0$mkb$1@bob.news.rcn.net>
Luis <loboaguia@yahoo.com> wrote:
> <td width="50%"><!-- #exec cgi="listaramo.pl"--><span
> id="a1"></span><font color="#0000FF">*</font>
> </td>
> <input type="hidden" name="Ramo" value = "$ramo">
> <input type="hidden" name="Tipo" value = "$tipo">
> This is my problem.
> At the moment my DBI is not working. How can I assign a value to $ramo
> and $tipo to test the <input ...>?
If I understand correctly, you're actually running listaramo.pl as part of
a server-side include, not in response to an HTTP transaction. Unlike
CGI, SSI is rather implementation-dependent, but my understanding is that
it doesn't provide any direct way of sending form-field values to the
called application (since anything but hidden fields wouldn't have any
values at the time the program was run).
I think there's some confusion as to when in the process various pieces of
code are being run. Is the HTML above static or is it dynamically
generated by a Perl program other than listaramo.pl? If the former, then
$ramo and $tipo are just literal strings beginning with dollar signs.
Are you trying to run listaramo.pl as an SSI and then expecting that the
server will interpolate its variables into the HTML following the SSI
call? That's not how SSI works: whatever listaramo.pl writes to its
standard output replaces the <!-- #exec ...--> construct, and then that's
it. The perl interpreter isn't even running afterwards.
------------------------------
Date: Wed, 04 Jul 2001 02:17:49 GMT
From: Paul Burry <paul@burry.ca>
Subject: Re: How do I make a forwarded variable declarations?
Message-Id: <3B427C74.1CD353D1@burry.ca>
Duh!
my @table;
@table = (
[ 'a', 'b', \@table ],
);
Sorry.. Paul
Paul Burry wrote:
>
> I'd like to declare something like:
>
> my @table = (
> [ 'a', 'b', \@table ],
> );
>
> This doesn't work because @table is not defined when @table is declared.
>
> Is there a way to make a forward declaration for a variable?
>
> TIA .. Paul
------------------------------
Date: 4 Jul 2001 02:43:09 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: How do I make a forwarded variable declarations?
Message-Id: <9htvrt$mkb$5@bob.news.rcn.net>
Paul Burry <paul@burry.ca> wrote:
> Duh!
> my @table;
> @table = (
> [ 'a', 'b', \@table ],
> );
Yep, the general rule is that if you have an initializing expression in a
variable declaration, it's evaluated before the declaration takes effect.
------------------------------
Date: 4 Jul 2001 01:47:43 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: How I came to love Perl...
Message-Id: <9htsjv$j2c$1@bob.news.rcn.net>
Lou Moran <lmoran@wtsg.com> wrote:
> --I start my journey with C and recognize a lot of things. I am
> "getting" it... then the modulo (sp?) (read math stuff) starts and I
> tune out and start looking for something I can "grasp". Then I see
> it! When I was learning Perl it was all about text, words, data and
> what I could do with it. Math (the bad thing) wasn't involoved!
> Whenever I opened a programming book there was all this math (which I
> didn't get in high school and avoided in college) that muddied things
> up for me.
> --So inconclusion I fell in love with Perl b/c _for me_ it's all about
> words, text and data with which I am particularly comfortable.
What you were running up against is that introductory treatments of
languages like C start out with mathematical examples rather than
text-processing examples because in such languages, numbers are
first-class objects whereas strings aren't. In order to manipulate text
in C, you need to know about arrays, functions, pointers and memory
management, and in order to understand those, you need to know simple
expressions first (as you do in any language). Therefore, you pretty much
have to start out teaching simple mathematical expressions in order for
the learner to get the hang of expressions, period. Otherwise you're
trying to teach too many different things at once.
In Perl, strings are first-class objects and therefore you can write
meaningful expressions involving strings before you've learned the
data-structures stuff.
In Java, strings are also first-class objects (though not IMHO quite as
easy to work with as in Perl), so I suspect the reason Java textbooks
often start with math examples is just inertia; it's "the way things have
always been done."
------------------------------
Date: Wed, 4 Jul 2001 12:16:27 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: How I came to love Perl...
Message-Id: <Gnv07.27$iM2.983@vic.nntp.telstra.net>
"Lou Moran" <lmoran@wtsg.com> wrote in message
news:27i3kto5maorj6npje5m835gfej2km505i@4ax.com...
> --Quick background...
<SNIP>
> --I start my journey with C and recognize a lot of things. I am
> "getting" it... then the modulo (sp?) (read math stuff) starts and I
> tune out and start looking for something I can "grasp". Then I see
> it! When I was learning Perl it was all about text, words, data and
> what I could do with it. Math (the bad thing) wasn't involoved!
> Whenever I opened a programming book there was all this math (which I
> didn't get in high school and avoided in college) that muddied things
> up for me.
>
> --So inconclusion I fell in love with Perl b/c _for me_ it's all about
> words, text and data with which I am particularly comfortable.
I had a similar experience in learning BASIC at Uni, where the lecturer was
a Maths Professor, and I didn't 'get' half the problems assigne as
assignments. I ended up with a 'Pass Terminal' (we give you a pass but not
good enough to go any further).
I thereafter considered myself a 'hardware dude' and NOT a programmer.
I started with Perl by default after acquiring a Portmaster which used
Radius for running my ISP. A sample Perl script was provided which provided
stats for users.
I had to learn Perl the hard way, and then got some books (yes Perl for
dummies was my starting point) and then started making slow progress.
Learned heaps from this Newsgroup (Larry Rossler, Uri Guttman, Randal
Schwartz and numerous others - too many to mention).
Once I acquired 'Elements of Programming with Perl' by Andrew Johnson a
whole lot of stuff suddenly clicked, and now I can write programs to save my
life. There is still a lot of stuff I don't get (hardly ever use map and
grep or dbi) but I am now understanding OOP (Damian Conway's book is really
good).
I read programming manuals like novels, which makes people look at me rather
strangely, but that whole text vs maths things was the big epiphany for me
too.
Anyway, I still consider myself a 'hardware tech' but can look at programs
without being put off now.
Oh, and I LOVE Perl!
Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: Wed, 04 Jul 2001 11:02:33 +0800
From: Horace <tanghh@ha.org.hk>
Subject: Re: How to timeout a socket recv under win32?
Message-Id: <3B428748.9937AE62@ha.org.hk>
Although I'm still not really clear what each paramter in select() represents and what
they do (excpet the timeout parameter), but by following your code, I've got the timeout
running, Thank you very much.
Horace Tang
Michael Gilfix wrote:
> select and vec are the way to go. The general idiom is to open up the socket,
> do polling on the socket with select and then call recv on the socket only
> when there is input to be read. So assuming that you have a socket already
> open, you'll probably want something like this snippet:
>
> my ($rin, $rout) ;
>
> # Vec sets the bit within a series of bit flags (like an integer).
> # You can think of this line as setting the bit flag in a set of
> # read bits so that select knows to look for data from this
> # socket
> vec ($rin, fileno (MY_SOCKET), 1) = 1;
>
> # This if statement will block until input is seen at
> # the file descriptor. The last argument specifies the
> # timeout. You could supply a number of seconds and
> # the call will return if no data is seen.
> if ( select ($rout = $rin, undef, undef, undef) ) {
>
> my $my_packet = "";
> my $length_to_read = 256;
> my $server = recv (SOCKET, $my_packet, $my_length_to_read, 0);
> # Do more processing
>
> }
>
> That should give you a general idea. You can always do a:
> "perldoc -f select" and "perldoc -f vec" from the command line (in unix, not
> sure about win) for more info.
>
> -- Mike
>
> On Tuesday 03 July 2001 03:34%, Horace wrote:
>
> > Hi everyone,
> > I'm new to perl and sorry if this question has been asked before,
> > that's how to timeout a socket recv under win32 environmnet? I know that
> > under unix, I can use "alarm", but how about win32?
> > I saw some people suggested using "vec" and "select" to implement
> > the timeout, but I don't know how.
> > Please help and thanks in advance!
>
> --
> Michael Gilfix
> Extreme Blue Group - IBM (Austin)
> magilfix@us.ibm.com
------------------------------
Date: Tue, 03 Jul 2001 20:17:11 -0400
From: Diane Strahl <diane@dmswebsupport.com>
Subject: Is REG_DATE a special type of mysql column?
Message-Id: <3B426087.54F835D5@dmswebsupport.com>
Can someone tell me if there's something special about using REG_DATE as
a COLUMN name in a mysql database when updating the database from a perl
script? I have written a perl script that connects to a mysql database
using the DBI module. When the cgi gets to the following lines,
$SQL = "UPDATE REGINFO SET
APPROVAL_CODE=\"$FORM{'approval_code'}\",CHARGE_AMOUNT=\"$FORM{'chargetotal'}\"
WHERE ID=\"$reg_num\"";
$sth = $dbh->prepare($SQL);
$sth->execute || die "Could not execute SQL statement, maybe invalid?";
it is also updating the REG_DATE column. The REG_DATE column is type
TIMESTAMP.
Thanks,
Diane
------------------------------
Date: Tue, 3 Jul 2001 17:21:39 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Is there no solution to a malformed header?
Message-Id: <slrn9k4dr3.b55.tadmc@tadmc26.august.net>
Pape Toure <pape_toure@yahoo.com> wrote:
>I get an error message, saying the I have a malformed
>header in my script....
This is usually because perl hits and error or warning before
it gets to outputting a correct header.
How you fix it is: you go see what it wrote to your server log
(or use a Carp module).
>This is my script:
>
>#!/usr/bin/perl -w
>use CGI qw(:all);
$| = 1; # output the header right away instead of waiting until
# the output buffer is full (perldoc perlvar)
>print header;
>
>$ENV{PATH} = "";
There is no path. So all commands must use absolute paths.
>$shell = "test.sh";
>chomp $shell;
You just put the contents of $shell in there without a newline.
I doubt that the chomp() accomplishes much...
>system ("$shell");
1) and here we have a command that does NOT have an absolute path!
2) those quotes serve no purpose, and so should not be there.
3) you should check the return value and see if system()
executed OK.
!system($shell) or die "could not run system() command";
or
system($shell) and die "could not run system() command";
>I was wondering if anyone could point me in the right direction
It is probably due to output buffering or PATH problems.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 4 Jul 2001 02:27:15 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Is there no solution to a malformed header?
Message-Id: <9htuu3$mkb$3@bob.news.rcn.net>
Pape Toure <pape_toure@yahoo.com> wrote:
> I've recently written a script linked to a webpage and everytime i run
> it from the command line it works fine. But when I run the script from
> the webpage, I get an error message, saying the I have a malformed
> header in my script....
> This is my script:
> #!/usr/bin/perl -w
> use CGI qw(:all);
>
> print header;
>
> $ENV{PATH} = "";
>
> $shell = "test.sh";
>
> chomp $shell;
>
> system ("$shell");
What's most likely happening here is that the header you printed is still
sitting in a buffer at the time you run your shell program, and therefore
doesn't get printed until after the shell program prints its output. As a
result, the body of your response gets sent to your Web server before the
header does, which will naturally result in a complaint about invalid
headers.
Simply set $| to a nonzero value, which will force the buffers to be
flushed every time you print something.
------------------------------
Date: Wed, 04 Jul 2001 00:37:46 +0200
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: mailto module?
Message-Id: <3b4d04e6.25184743@news.bjoern.hoehrmann.de>
* Alan J. Flavell wrote in comp.lang.perl.misc:
> On Jul 3, Scott Yanoff delicately chiselled into the ether:
>
>> This will not work in all web browsers but it might be worth trying:
>>
>> mailto:info@leoraw?body=This is a test
>
>Don't you know that this is a Perl language group? We don't have to
>put ourselves at risk of something that "will not work in all web
>browsers".
I miss your complaint, that the URI is malformed and must be
mailto:info@leoraw?body=This%20is%20a%20test
--
Björn Höhrmann { mailto:bjoern@hoehrmann.de } http://www.bjoernsworld.de
am Badedeich 7 } Telefon: +49(0)4667/981028 { http://bjoern.hoehrmann.de
25899 Dagebüll { PGP Pub. KeyID: 0xA4357E78 } http://www.learn.to/quote/
------------------------------
Date: Wed, 4 Jul 2001 01:29:05 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: mailto module?
Message-Id: <Pine.LNX.4.30.0107040126180.30012-100000@lxplus003.cern.ch>
On Jul 4, Bjoern Hoehrmann delicately chiselled into the ether:
> >> mailto:info@leoraw?body=This is a test
> >
> >Don't you know that this is a Perl language group? We don't have to
> >put ourselves at risk of something that "will not work in all web
> >browsers".
>
> I miss your complaint, that the URI is malformed and must be
> mailto:info@leoraw?body=This%20is%20a%20test
Sorry, I took the view that as I was counselling against using it at
all, there was no point in repairing that detail. And the whole thing
was pretty much off-topic, so I wanted rid of it ASAP.
f'ups suggested
all the best
------------------------------
Date: Tue, 03 Jul 2001 22:45:24 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: map/hash question, functional style
Message-Id: <tk4io41c3h0043@corp.supernews.com>
Uri Guttman (uri@sysarch.com) wrote:
: >>>>> "CB" == Craig Berry <cberry@cinenet.net> writes:
:
: CB> nobull@mail.com wrote:
: CB> : @hash=();
: CB> : @hash{@keys}=@vals;
:
: CB> Not clear how emptying the unrelated array variable @hash has any
: CB> bearing on loading the hash variable %hash. :)
:
: because if that hash had old values they could still be there. and you
: can't use hash slice assignment without first declaring it (you ARE
: using strict?), so that is the equivilent of my %hash.
Okay, humor level reduced: The first line I quoted clears an array named
@hash, *not* the hash named %hash which is slice-assigned in the second
line I quoted.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Magick is the art and science of causing change in conformity
| with Will." - Aleister Crowley
------------------------------
Date: Tue, 03 Jul 2001 16:18:25 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: map/hash question, functional style
Message-Id: <3B4252C1.C63CD0BC@stomp.stomp.tokyo>
Uri Guttman wrote:
> Craig Berry wrote:
> > nobull wrote:
> > > @hash=();
> > > @hash{@keys}=@vals;
> > Not clear how emptying the unrelated array variable @hash has any
> > bearing on loading the hash variable %hash. :)
> because if that hash had old values they could still be there.
This makes no difference. Array @hash can be populated or null
with no effect on Hash %hash. Pay attention Uri.
> and you can't use hash slice assignment without first declaring it
Yes you can.
(you ARE using strict?), so that is the equivilent of my %hash.
Why would you use strict or variable declarations for a simple
four or five line script? Writing simple short test scripts is
not that difficult for you, is it?
Godzilla!
--
TEST SCRIPT:
____________
#!perl
@keys = qw (key1 key2 key3);
@vals = (1, 2, 3);
@hash = qw (a b c);
@hash{@keys} = @vals;
print "Hash: @{[ %hash ]}";
exit;
PRINTED RESULTS:
________________
Hash: key1 1 key2 2 key3 3
------------------------------
Date: 4 Jul 2001 00:51:03 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Merging content from two templates
Message-Id: <9htp9n$3fp$1@bob.news.rcn.net>
Morten Tangerås <morten@tangeraas.com> wrote:
> It's actually no problem to replace eg. (!Name!) with the right text
> from the text file. In that case, I'm using the following perl code
> ($line represent each line in the template file):
> $line =~s/(\!Name\!)/$CONFIG{'Name'}/gis;
> $line =~s/(\!Loaction\!)/$CONFIG{'Loaction'}/gis;
> But in this case, it's not this simple anyway. First of all, there are
> pretty many different text fields, and the name of the fields are also
> different fro template to template.
> Therefor, I would like a function that parsed a given layout template,
> found all text that started with '(!' and ended with '!)', registred the
> text inside the, and replaced it with the equivalent text from
> $CONFIG{'*'}.
> Are there anyone out there who has any suggestions about how this could
> be done?
$line =~ s/\(!([^!]+)!\)/defined ($CONFIG{$1})? $CONFIG{$1}: "(!$1!)"/egi;
Note how this "puts back" any references to undefined variables, which
helps with debugging (misspelled variable names stand out rather than
disappearing). You don't need the "s" modifier on the substitution
because all it does is causes "." to match newlines, and you don't have a
"." in your pattern. You do need the "e" modifier because the replacement
is now an expression rather than just a string.
------------------------------
Date: Wed, 4 Jul 2001 02:24:30 +0200
From: "carlos" <carlos@plant.student.utwente.nl>
Subject: Re: parallel processes w/perl
Message-Id: <9htno0$hc7$1@dinkel.civ.utwente.nl>
the processes _do_ run simultaneously
check out the module Parallel::ForkManager for a simplified interface
--
carlos
"abaxaba" <msanderso@hotmail.com> wrote in message
news:b89e0a91.0107031223.45abaf0e@posting.google.com...
> I'm working on an application being written entirely in perl and
> javascript, with a DB backend. As this app. won't be used by many
> folks simultaneously, I am trying to do some things to make the server
> work quicker. Mod Perl is certainly one direction I'm moving in. But
> I'd also like to run parallel processes. From what I read wrt fork,
> the parent and child don't seem to run simultaneously. I've heard
> about doing a double-fork [ie, fork again from the child pid], but
> can't seem to make this work.
>
> IS there a way in perl to run simultaneous processes, [perhaps via
> threads in v6], or is this beyond the abilities of the language?
>
> TIA!
>
> shawn
------------------------------
Date: Tue, 3 Jul 2001 19:27:50 -0500
From: Michael Gilfix <magilfix@us.ibm.com>
Subject: Re: parallel processes w/perl
Message-Id: <9htnqv$les$1@ausnews.austin.ibm.com>
Forked processes do run in parallel on a unix machine but communication
between them can be difficult. You have to either open up a named socket
(think of it at a special file that serves as a meeting place) or use shared
memory (ugh). However, Perl does have threading support. It started around the
earlier versions of 5. It used to be experimental but I haven't heard any
warnings about it being experimental so it might be worth taking a look. Note
that you'll lose some backwards compatibility though.
To get more info on threads, try visiting:
http://search.cpan.org/search?dist=Thread. Also, check out the threadpool
module which may be of use:
http://search.cpan.org/search?dist=ThreadPool.
-- Mike
On Tuesday 03 July 2001 15:23%, abaxaba wrote:
> I'm working on an application being written entirely in perl and
> javascript, with a DB backend. As this app. won't be used by many
> folks simultaneously, I am trying to do some things to make the server
> work quicker. Mod Perl is certainly one direction I'm moving in. But
> I'd also like to run parallel processes. From what I read wrt fork,
> the parent and child don't seem to run simultaneously. I've heard
> about doing a double-fork [ie, fork again from the child pid], but
> can't seem to make this work.
>
> IS there a way in perl to run simultaneous processes, [perhaps via
> threads in v6], or is this beyond the abilities of the language?
>
> TIA!
>
> shawn
>
--
Michael Gilfix
Extreme Blue Group - IBM (Austin)
magilfix@us.ibm.com
------------------------------
Date: 4 Jul 2001 02:15:45 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: parsing contents of html form w/net::smtp
Message-Id: <9htu8h$mkb$2@bob.news.rcn.net>
Scaramouche <e.quesada@verizon.net> wrote:
> perhaps then net::smtp is not a feasible method to use for what i need to
> accomplish.
> i was afraid of that, it seemed too good to be true.
It's a perfectly fine method of *sending* mail. It's just that sending
mail is only one part of what your program has to do. It also has to get
values from the form (CGI.pm is the best way to do this in most cases) and
compose a mail message to be sent (which, for the most part, you need to
do with your own code, as how to do it depends on your specific
application). You're not going to find a single module that handles
*every* single aspect of what you're trying to do.
------------------------------
Date: Tue, 03 Jul 2001 22:55:19 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Protected Dowloads (SSI?)
Message-Id: <mbudash-1C8A36.15551903072001@news.sonic.net>
In article <pJp07.3306$rK3.229539@news1.onlynews.com>, bartok
<member@dbforums.com> wrote:
> I am trying to create a script that manages the downloading of
> individual files. I don't just want the perl program to forward the user
> to a new location when they meet the correct criteria (password/IP
> address/payment), I want the download to be done from within the script.
> My current best effort locks the folder with the downloads in from all
> but a user on the host computer (ie no direct download via internet).
> The the script then runs on the computer and, after cheacking the
> criteria, accesses and prints the relevant file. eg for pdf's:
>
> print "Content-type: application/pdf\n\n"; open(DOWNLOAD_FILE,
> "<$download_file") or die "Opening: $!"; while(<DOWNLOAD_FILE>){ print
> $_ or die "Printing: $!"; } close(DOWNLOAD_FILE) or die "Closing: $!";
>
> The problem with this is that the file will be called the name of the
> script - and hence will not have the correct suffix (.pl not .pdf).
> Also, it does not force the file to be downloaded - in Nescape it is
> simply displayed by default. Also, there are probably security holes.
> Any thoughts would be appreciated. I've heard there may be a solution
> involving SSI or TK or something ... Thanks!
>
have your script called using a PATH_INFO style, then pick apart the
$ENV{PATH_INFO} variable to get the needed info. since i know this
sentence may not make sense, here's a real-world example:
i just did a site where one of the requirements matched yours. the
download script is called (from a browser or an LWP-user-agent) like
this (example only):
/cgi-bin/download.cgi/1234/5678/AS1234.MID
since the server works its way down the path 'til it finds an
executable, the script (download.cgi) is called, whereupon the PATH_INFO
environment variable contains this:
/1234/5678/AS1234.MID
and is picked apart using this:
($dummy, $customerno, $orderno, $filename)
= split(/\//, $ENV{PATH_INFO});
the script verifies that:
1) the customer is logged in already (by the existence of separate
customer and session cookies),
2) that the order number points to an order owned by this customer (by
db lookup), and
3) that the file is in this order (also by db lookup).
if all that is true, the script pushes the file back to the browser. if
the browser is configured to download the content-type
(application/octet-stream), the download dialog box will be displayed
and the filename will be filled in as - voila! - AS1234.MID. some
browsers (IE for one), seem to figure out that this is a midi file and
try to play it, so the user needs to right-click (Windows) or
click-and-hold (MacOS) to get the download dialog box, but again, the
filename will be filled in as AS1234.MID.
questions?
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Wed, 04 Jul 2001 02:09:57 GMT
From: bartok <member@dbforums.com>
Subject: Re: Protected Dowloads (SSI?)
Message-Id: <VVu07.3470$rK3.244454@news1.onlynews.com>
Thank you - works perfectly! Doubly good because the answer's so simple.
--
Posted via dBforums, http://dbforums.com
------------------------------
Date: Wed, 4 Jul 2001 09:50:48 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: require user configuration files
Message-Id: <zUs07.4$CP5.120951@news.interact.net.au>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9k2908.6vu.tadmc@tadmc26.august.net...
> Jared Johnson <jared.johnson@boeing.com> wrote:
> >Trying to include a file I get an error "Can't locate
> >~username/.include_file in @INC (@INC contains ...)"
> >
> >Using an HP machine I am able to execue the code
> > $include_file = `echo ~userid/.defaults`;
> >and have it return the expanded path to the .defaults file
>
> >We are migrating to the Sun OS and I have found that this no longer
> >works.
>
>
> Sun must have a different /bin/sh then.
It has a true bourne shell (or close to it), whereas HP/UX is a bit like
Linux in that /bin/sh is a link to the korn shell. ISFAIR
------------------------------
Date: 04 Jul 2001 03:33:49 GMT
From: blstone77@aol.com (Blstone77)
Subject: Retrieving Domain from URL line
Message-Id: <20010703233349.05259.00002082@ng-ci1.aol.com>
I have a perl program which creates a file with Referrer URL's one on each line
like so.
http://perlnewbies.com/history/searchit.html
http://excite.com/search.gw?c=web&lk=excite_home_us&s
http://search.msn.co.uk/spbasic.htm?MT=Presidents
http://search.msn.com/results.asp?RS=CHECKED&Armada
http://search.yahoo.com/bin/search?p=%22Perl
http://top.cswap.com/cat/?biblestudies
etc.. As you probably can guess, i would like to count up the times each domain
sends someone
to my page. My question is how would I get Perl to extract just the domain
names (excite.com, perlnewbies.com, msn.com, etc.) from this file. I'm sure
it's probably something simple, but I can't seem to come up with code that
works. Could someone give me an example of extracting the domain from each
line? I would greatly appreciate your help on this one.
PS, I know I could get the domains from an environment variable, but that is
not an option. I need to know how to use wildcards to extract them from this,
perhaps even the search word they used also. Again, any helpor direction is
appreciated.
------------------------------
Date: Tue, 03 Jul 2001 23:31:00 GMT
From: "Marcus T. Franklin" <marcusf@telsoft-inc.com>
Subject: Scripts to Load Image Based on Time
Message-Id: <UAs07.119995$C7.17495274@typhoon.kc.rr.com>
Group,
I would like to know where I can find a script(s) that allows
me to load and display images based on the time of day,
and day of the week. The images could change every half an hour.
If you know of such a script or links to similar scripts,
it would be appreciated.
Thanks for your time.
Marcus
------------------------------
Date: Wed, 04 Jul 2001 00:24:54 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Scripts to Load Image Based on Time
Message-Id: <tk4oimjedbgj25@corp.supernews.com>
Marcus T. Franklin (marcusf@telsoft-inc.com) wrote:
: I would like to know where I can find a script(s) that allows
: me to load and display images based on the time of day,
: and day of the week. The images could change every half an hour.
: If you know of such a script or links to similar scripts,
: it would be appreciated.
I don't know of any scripts per se, but doing this is pretty easy. Name
your time-based images in the form
img_DOW_POD.jpg
where DOW is the day-of-week number (0-6), and POD is the part-of-day
number (0-47, for half-hour divisions). Then use localtime to determine
the current time and the day of the week, and build the image name to load
accordingly:
my ($min, $hour, $wday) = (localtime)[1, 2, 6];
my $dayPart = $hour * 2;
$dayPart++ if $min >= 30;
my $img = "img_${wday}_$dayPart.jpg";
You'll need 336 images (7 * 48), of course.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Magick is the art and science of causing change in conformity
| with Will." - Aleister Crowley
------------------------------
Date: 4 Jul 2001 00:52:52 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Vapo-Rub
Message-Id: <9htpd4$3fp$2@bob.news.rcn.net>
In comp.lang.perl.misc Anonymous <anonymous@anonymous.anonymous> wrote:
> I am thinking of using Vapo-Rub as a lubricant when I do the Wild Thing?
> Anyone know of precautions or tips?
perldoc perlsex
------------------------------
Date: Tue, 3 Jul 2001 21:59:19 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Vapo-Rub
Message-Id: <slrn9k4u3n.boj.tadmc@tadmc26.august.net>
Eric Bohlman <ebohlman@omsdev.com> wrote:
>In comp.lang.perl.misc Anonymous <anonymous@anonymous.anonymous> wrote:
>> I am thinking of using Vapo-Rub as a lubricant when I do the Wild Thing?
>> Anyone know of precautions or tips?
>
>perldoc perlsex
While RTFM still expands as it always does, it seems to take on
a different meaning in the context of this thread...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 3 Jul 2001 17:31:05 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: web fetching
Message-Id: <slrn9k4ecp.b55.tadmc@tadmc26.august.net>
BUCK NAKED1 <dennis100@webtv.net> wrote:
>Problem was that when I went into LWP::Simple, it requires LWP, and
>LWP, in turn needs code from other modules
>Why do this? Because not all servers have LWP.pm or Socket.PM
^^^^^^^^^^^
"servers" are not the only place that Perl runs.
I have written Perl everyday for 7 years, and NONE of it has
run under a "web server".
The "World Wide Web" is not the "World" you know.
"Because not all computers have LWP.pm or Socket.PM"
now you have the attention of the full Perl community, not just
the subset that happens to use Perl for CGI programming.
>I really do think LWP and the other modules it requires to work, SHOULD
>be included in the main distribution.
<invoke the famous AOL quote here>
P.S. Have you tried having the CPAN module chase the dependencies
and build them _for_ you?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 4 Jul 2001 10:23:38 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: web fetching
Message-Id: <lnt07.5$TO5.86101@news.interact.net.au>
"Mark" <njcops2@hotmail.com> wrote in message
news:a3430fbe.0107030106.57a3a6fd@posting.google.com...
> Hi,
>
> Does anyone know of any other web fetching CGI script other than
> PageRipper
> http://pageripper.cjb.net
>
> If not, can you tell me if it's worth the 10 bucks or not?
Certainly not. You don't have to spam every newsgroup you can think of.
>
> I need a CGI script that will grab an external web page and then allow
> me to use it on my own site. PageRipper was the only script I could
> find.
Sure! You somehow missed the hundreds of other *free* scripts that do
exactly what your stuff does? I don't think so.
------------------------------
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 1240
***************************************