[10551] in Perl-Users-Digest
Perl-Users Digest, Issue: 4143 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 3 21:07:25 1998
Date: Tue, 3 Nov 98 18:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 3 Nov 1998 Volume: 8 Number: 4143
Today's topics:
ActivePerl (b 506) & IIS4 cgi keeps browser waiting!! <firmanf@nospam.usa.net>
Re: Array Ref Question (Brand Hilton)
Re: Array Ref Question (Charles DeRykus)
Basic HTTP Authentication <kaarkas@bigpond.com>
Re: CGI, common text question <gellyfish@btinternet.com>
Re: Check this out... (Tad McClellan)
chown function and numeric ... HELP! <pierreluc.bourrel@ic3w.net>
Re: Copy of AutoLoader.pm?? <gellyfish@btinternet.com>
Getting Multiple inputs <support@counter.w-dt.com>
getting output from a cgiscript inside a perl script (pickup)
How to assign a network share in Perl <sorry@nospam.com>
how to pass value to .pl file ? <bhupendra@patel.com>
Re: illegitimate data types ? (Brand Hilton)
Re: illegitimate data types ? (Larry Wall)
London.pm Meeting dave@mag-sol.com
Re: Newbie: files in different directories. <gellyfish@btinternet.com>
Re: Not to start a language war but.. (Andrew M. Langmead)
Re: Not to start a language war but.. <zigron@jps.net>
Re: PERL is TOO flexible (Andrew M. Langmead)
Re: perl modules (Brand Hilton)
Re: perl&cgi question (brian d foy)
PERL/UNIX newbie wants to multiprocess in his first scr <smoore@mdsi.bc.ca>
Re: PERL/UNIX newbie wants to multiprocess in his first (Sam Holden)
POSIX::SigAction and sigaction() <curtw@cup.hp.com>
Re: Reading multiple lines <webmaster@topproducer.com>
Re: Reading multiple lines <gellyfish@btinternet.com>
Replacing chracters in a variable (Nico v Leeuwen)
Win32::NetAdmin schergr@my-dejanews.com
Re: Win32::ODBC - field names <chad@anlon.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 03 Nov 1998 20:40:33 -0500
From: firmanf <firmanf@nospam.usa.net>
Subject: ActivePerl (b 506) & IIS4 cgi keeps browser waiting!!
Message-Id: <363FB091.77C042DA@nospam.usa.net>
I have this annoying problem that I can't figure out.
I am using perlshop to generates html pages, but for
some reason, on certain pages the browser would still
be waiting for the page to finish loading, even though
everything on the page has loaded (images, text).
I have tried it with an older version of perl for
win 32 (by HIP, I think), and didn't have any problem
with it. And I don't have any problem with the
plain 'ol perl either.
Anybody has encountered this before, and have any
solutions, or suggestions?
Thanks in advance.
Ferry
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Remove "nospam." from the e-mail address
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pursuant to US Code Title 47, Ch 5, Subch 2, _227: Unsolicited
commercial Email received at this address is subject to a US$500
download and archival fee.
By Emailing such, you agree to these terms.
------------------------------
Date: 3 Nov 1998 22:30:11 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: Array Ref Question
Message-Id: <71o05j$9qv18@mercury.adc.com>
In article <363F6E54.A5240360@tqs.antispam.com>,
Bill Adams <b-i-lla@tqs.antispam.com> wrote:
>Bug or feature?
>
>Can someone explain what is going on in the following script,
>specifically, why the last version actually assigns the value to the
>array element? Was this an intended "Feature"? And is the explanation
>of this in the man page and did I completely miss it?
It's documented in the "Foreach Loops" section of perlsyn, second
paragraph:
If LIST is an actual array (as opposed to an expression returning a
list value), you can modify each element of the array by modifying
VAR inside the loop.
Out of curiosity... in your program, you have the following line:
my $array_ref = +['1'];
Was that "+" intentional? It appears to be ignored, which surprises
me somewhat. I know a "+" preceding a curly brace disambiguates
anonymous hashes from blocks, but I don't know what, if anything, "+["
does.
--
_____
|/// | Brand Hilton bhilton@adc.com
| ADC| ADC Telecommunications, ATM Transport Division
|_____| Richardson, Texas
------------------------------
Date: Tue, 3 Nov 1998 22:49:54 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Array Ref Question
Message-Id: <F1vBF6.9r@news.boeing.com>
In article <363F6E54.A5240360@tqs.antispam.com>,
Bill Adams <b-i-lla@tqs.antispam.com> wrote:
>Bug or feature?
>
>Can someone explain what is going on in the following script,
>specifically, why the last version actually assigns the value to the
>array element? Was this an intended "Feature"? And is the explanation
>of this in the man page and did I completely miss it?
>
>
>/home/thor/bill/src=>./perlbug.pl
>1 Array Has: 1
>2 Array Has: 1
>3 Array Has: 3
>/home/thor/bill/src=>cat perlbug.pl
>#!/usr/bin/perl -w
>
>use strict;
>my $array_ref = +['1'];
>my $step = 1;
>print $step++, " Array Has: ", join('|', @$array_ref), "\n";
>
>#This does not change the value in the array:
>foreach (@$array_ref) {
> my $value = $_;
> $value = 2}
>print $step++, " Array Has: ", join('|', @$array_ref), "\n";
>
>#This does change the value.
>foreach my $value (@$array_ref) {
> $value = '3'}
>print $step++, " Array Has: ", join('|', @$array_ref), "\n";
>
The loop variable in a foreach is a reference to
the actual list element itself.
So, C<my $value = $_> simply copies the loop variable but
leaves the original list element unchanged; whereas, in
the subsequent case, there's no copy and C<$value = '3'>
does change the actual list element.
hth,
--
Charles DeRykus
------------------------------
Date: Wed, 4 Nov 1998 09:41:04 +1100
From: "Brad McCready" <kaarkas@bigpond.com>
Subject: Basic HTTP Authentication
Message-Id: <363f84d7.0@139.134.5.33>
hi guys,
i have a section on my website that is protected by basic http
authentication. i would like a registered user (once passed authentication)
to be able to edit their own profile. is it possible to do this directly
from the username they entered? how do i retrieve this username into a perl
script?
my .htaccess file is something like
AuthUserFile .htpasswd
AuthGroupFile .htgroup
AuthName "Members Only Section"
AuthType Basic
<Limit GET>
require group my-users
</Limit>
thanks in advance for any help offered
brad mccready
------------------------------
Date: 3 Nov 1998 21:38:38 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: CGI, common text question
Message-Id: <71nt4u$sa$1@gellyfish.btinternet.com>
On Tue, 03 Nov 1998 11:47:55 +0100 Kjetil Svendsberget <kjetil@balder.no> wrote:
> i have now several cgi scripts (perl files) who all do
>
> print $cgi->start_html(-title=>"$title",
> -author=>'Kjetil Svendsberget, kjetil\@balder.no, Balder Dialog AS',
> -BGCOLOR=>'#FFFF80',-TEXT=>'#000000',-LINK=>'#0000FF',
> -ALINK=>'#FF0000',-VLINK=>'#400040');
>
> What i would like to do is to have this text in one place rather than
> copy/paste it for every script that needs it.
>
> I have a TMlib.pm module (who every script do a 'use Tmlib' on), and ive
> tried writing this subroutine there:
>
<snip>
It won't work like that. You could derive a new class from CGI in order to
have your own start_html - something like this :
# file TMLib.pm
package TMLib;
use vars qw(@ISA);
@ISA = qw(CGI);
require CGI;
sub start_html
{
my ($cgi,@stuff) = @_;
return $cgi->SUPER::start_html(-title=>"$title",
-author=>'Kjetil Svendsberget, kjetil\@balder.no, Balder Dialog AS',
-BGCOLOR=>'#FFFF80',-TEXT=>'#000000',-LINK=>'#0000FF',
-ALINK=>'#FF0000',-VLINK=>'#400040');
}
1;
__END__
Which you would use like :
#!/usr/bin/perl
use TMLib;
my $cgi = new TMLib;
print $cgi->header,"\n";
print $cgi->start_html,"\n";
# blah
print $cgi->end_html,"\n";
__END__
Easy :) You probably will want to read manpages for perlmod,perlmodlib,
perlbot.
Of course there will other ways to do this.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Tue, 3 Nov 1998 16:33:02 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Check this out...
Message-Id: <ua0o17.7v9.ln@flash.net>
Andre L. (alecler@cam.org) wrote:
: In article <363F41D5.18FA2C63@nova-creations.com>,
: anthony@nova-creations.com wrote:
: > Hi!
: >
: > Does anyone know how I can reformat an in coming variable by replacing
: > blank spaces with + signs?
: >
: > example: (test1 test2 test3) would become (test1+test2+test3)
: >
: > Thanks!
: Well, check out the documentation, dude.
Since there is so much of it I'll narrow the field somewhat,
the original poster wants to have a look at these two:
perlre - Regualar Expressions
perlop - Operators
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 3 Nov 1998 23:35:48 +0100
From: "plb" <pierreluc.bourrel@ic3w.net>
Subject: chown function and numeric ... HELP!
Message-Id: <71o07r$q4r$1@minus.oleane.net>
Hello,
I have tried for several hours the chown function ... i'm getting
desesperate :
$uid=getpwnam($master);
$gid=getgrnam("domains");
printf("UID=$uid<br>");
printf("GID=$gid<br>");
$file = "/home/cetecn/passwd";
chown($uid,$gid,$file);
Does not work, the script die, no way to see $! var
but it shows the right uid and gid.
$master comes from CGI->param("master");
I tried with :
($login,$pass,$uid,$gid) = getpwnam($master);
Same result...
If i put:
$uid='517';
$gid='110';
printf("UID=$uid<br>");
printf("GID=$gid<br>");
$file = "/home/cetecn/passwd";
chown($uid,$gid,$file);
It works fine.
The chown on perldoc notices that $uid and $gid must be numeric. And the
sample works.
I think about a conversion function but i can't find one in the doc and
getting desesperate.
I am running perl 5.004_04 on Redhat 5.1 (2.0.35)
Please, can someone give me a hand ? i have no more idea !
Thank you in advance,
Regards,
Pierre Luc Bourrel
(can you CC to my email, please, i got several problems to log onto a news
server due to some changes)
------------------------------
Date: 3 Nov 1998 22:46:04 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Copy of AutoLoader.pm??
Message-Id: <71o13c$10l$1@gellyfish.btinternet.com>
On Tue, 03 Nov 1998 18:59:11 GMT burtj@my-dejanews.com wrote:
> For one reason (or another), our AutoLoader.pm file got hosed!
<etc>
And perhaps AnyDBM_File.pm, AutoSplit.pm ...
Of course someone could send you the file but I would suggest that you
will find the problem may well go deeper than that.
Grab the lastest distribution of Perl and reinstall.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Tue, 03 Nov 1998 18:52:51 -0600
From: Mike <support@counter.w-dt.com>
Subject: Getting Multiple inputs
Message-Id: <363FA562.B95A8058@counter.w-dt.com>
How could you make it so you can get an input with multiple values
attached? Like <select name=info multiple>
<option>1
<option>2
</select>
If they select both the values it will only output 1 value. Using the
following code.
$in = $ENV{'QUERY_STRING'};
@pairs = split(/&/, $in);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$value =~ s/\|//g;
$value =~ s/\n//g;
$value =~ tr/ //;
$INPUT{$name} = "$value"; }
If they select both inputs in the form it will make $INPUT{'info'} equal
to 2 but I want it to make it so it is like this $INPUT{'info'} equals
1, 2 because they selected both of them. Thanks for your help.
------------------------------
Date: Tue, 03 Nov 1998 23:06:33 GMT
From: tim@interactive1.easynet.co.uk (pickup)
Subject: getting output from a cgiscript inside a perl script
Message-Id: <363f8b50.995482@news.demon.co.uk>
I'm writing a perl script which returns a page of html, building the
page on the fly. Halfway down the page I need to get the output from
another script embedded into the page, and then finish off writing the
page in perl.
I don't have access to the other CGI script and don't even know what
it is written in.
Calling it from a browser like so
http://mymachine:8001/CgiScript/qmethod=show&docid=1
returns a flat text file to the browser ...for example
"This is the return from the other script"
my perl code stripped down looks like this
#!/usr/bin/perl
print "Content-type:text/html\n\n";
print "<html>\n";
print "<body>\n";
print "<h2>cgi script returns</h2>\n";
$cgi_output ="http://mymachine:8001/CgiScript/qmethod=show&docid=1"
//now I want to print the output from the cgiscript
//i have tried
//open(SHOW, $cgi_output);
//@lines = <SHOW>;
//close(SHOW);
//foreach $line (@lines){
// print $line;
//}
//but nothing was returned
print "</body>\n</html>\n";
exit;
What i want this example to return is the page
<html>
<body>
<h2>cgi script returns</h2>
"This is the return from the other script"
</body>
</html>
I am using perl5.00... downloaded from perl.com on a windows nt4
machine. Browser is ie4.
I have tried to look up this process in the perl help manuals, but
don't know what this process is called so am having difficulty finding
appropriate information.
A friend told me this could involve the exec() command and this would
involve security loopholes, which i'm not too concerned about as this
is running on a small intranet, but i can't see its relevance from the
manuals/faqs.
tia
tim pickup
------------------------------
Date: Tue, 3 Nov 1998 20:06:03 -0500
From: "CLee" <sorry@nospam.com>
Subject: How to assign a network share in Perl
Message-Id: <71o919$pot$1@excalibur.flash.net>
I am very new to Perl and was wondering how possible and what help I could
get to do the following.
1. Get drive free space from a server across a TCP/IP connection
2. Get available WINS addresses from the WINS Server
3. Capture Errors from the event log from the server across the network.
I forgot to mention this is on a NT Network using Activestates interpreter.
I also have started to play with the module Adminmisc and it seems to
address some of my issues.
Thanks in advance.
Leo
NT Admin, MCSE
leo.mcse@softhome.net
------------------------------
Date: Tue, 3 Nov 1998 19:05:43 -0500
From: "M.T." <bhupendra@patel.com>
Subject: how to pass value to .pl file ?
Message-Id: <71o5ka$m6f$1@autumn.news.rcn.net>
How to pass parameter from html file to perl .pl file ?
How to fetch Html file parametrer value from pl.file ?
I tried with
from html
href="http://uma/scripts/temp.pl?param1=1:2:3:4";
Error : when you click on link it says data contail no value; (Under
netscape )
in temp.pl file
Use cgi;
$query =new cgi ':standard';
Value = param('param1');
It doesn't work this way ? So please help me out where I am doing wrong
Thanks
mehul
------------------------------
Date: 3 Nov 1998 22:06:37 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: illegitimate data types ?
Message-Id: <71nupd$9qv17@mercury.adc.com>
In article <71np6v$5ri$1@nnrp1.dejanews.com>,
Patrick Timmins <ptimmins@netserv.unmc.edu> wrote:
>In article <71nef7$ls0$1@nnrp1.dejanews.com>,
> mgrabens@my-dejanews.com wrote:
>
>> In the following code snigglet, does this create an illegitimate data type?
>> $myhash{key1} = 'Person';
>> $myhash{key1}{fname} = 'Mike';
>> $myhash{key1}{lname} = 'Grabenstein';
>> $myhash{key2} = 'Class';
>> ... etc ...
>
>Bastard data types? Never! Both parents are listed on the birth
>certificate under the surname 'perldoc': (Mrs. perlref perldoc and
>Mr. perldsc perldoc).
Are you sure about that? I think what he's referring to is that fact
that he's set $myhash{key1} to a string, and then in the next line he
sets it to a hash reference, and Perl keeps both of them, so that if
you "print $myhash{key1}", you get "Person", and if you
"print $myhash{key1}{fname}" you get "Mike".
Pretty freaky if you ask me. Neither dumpvar.pl nor Data::Dumper
recognize the hash reference... they stop with "Person".
Anybody from p5p wanna give an authoritative reply?
--
_____
|/// | Brand Hilton bhilton@adc.com
| ADC| ADC Telecommunications, ATM Transport Division
|_____| Richardson, Texas
------------------------------
Date: 3 Nov 1998 17:20:05 -0800
From: larry@kiev.wall.org (Larry Wall)
Subject: Re: illegitimate data types ?
Message-Id: <71oa45$n9p@kiev.wall.org>
In article <71nupd$9qv17@mercury.adc.com>,
Brand Hilton <bhilton@tsg.adc.com> wrote:
>In article <71np6v$5ri$1@nnrp1.dejanews.com>,
>Patrick Timmins <ptimmins@netserv.unmc.edu> wrote:
>>In article <71nef7$ls0$1@nnrp1.dejanews.com>,
>> mgrabens@my-dejanews.com wrote:
>>
>>> In the following code snigglet, does this create an illegitimate data type?
>>> $myhash{key1} = 'Person';
>>> $myhash{key1}{fname} = 'Mike';
>>> $myhash{key1}{lname} = 'Grabenstein';
>>> $myhash{key2} = 'Class';
>>> ... etc ...
>>
>>Bastard data types? Never! Both parents are listed on the birth
>>certificate under the surname 'perldoc': (Mrs. perlref perldoc and
>>Mr. perldsc perldoc).
>
>Are you sure about that? I think what he's referring to is that fact
>that he's set $myhash{key1} to a string, and then in the next line he
>sets it to a hash reference, and Perl keeps both of them, so that if
>you "print $myhash{key1}", you get "Person", and if you
>"print $myhash{key1}{fname}" you get "Mike".
>
>Pretty freaky if you ask me. Neither dumpvar.pl nor Data::Dumper
>recognize the hash reference... they stop with "Person".
>
>Anybody from p5p wanna give an authoritative reply?
Try this:
$myhash{key1} = 'Person';
$myhash{key1}{fname} = 'Mike';
print $Person{fname},"\n";
Your second line is equivalent to
"Person"->{fname} = 'Mike';
That is, you're really doing a symbolic reference rather than a hard
reference. Because of "autovivification" (the creation of a thingy
where you expect there to be one), your code just "works". However,
your code will break if two entries in %myhash happen to have the same
value, since they'll point to the same global hash. For this reason,
your code will also break if you put "use strict refs" at the front
of it. :-)
One of the interesting asymmetries of Perl is that, in the method call
Person->new();
Person is used as a package name (used as a class name), but in
Person->{fname}
it's used as the name of a hash, and in
Person->[0]
it's used as the name of an array.
Larry
------------------------------
Date: Tue, 03 Nov 1998 13:33:20 GMT
From: dave@mag-sol.com
Subject: London.pm Meeting
Message-Id: <71n0n0$15m$1@nnrp1.dejanews.com>
The monthly London.pm meeting is this Thursday, 5th November. We'll be at the
Cittie of Yorke on High Holborn from about 6:15pm. We'll be in the Cellar Bar.
Nearest tube is Chancery Lane.
As a further enticement, I have procured 15 Perl Monger T-shirts which will
be on sale at the meeting for a tenner each (well 14 of them will be on sale
- one of them is now mine!) I'll only be selling the shirts until about 7pm
as I need to be elsewhere (blowing up Parliament or something like that)
later that evening.
Anyone who lives, works or will be in London and has anything to do with Perl
will be made most welcome. Full details on the web site
<http://london.pm.org>.
Hope to see you there,
Dave...
p.s. Don't forget that as mentioned in a thread here recently, the Cittie of
Yorke serves very good beer at exceptionally low prices!
--
dave@mag-sol.com
London Perl M[ou]ngers: <http://london.pm.org/>
[Note Changed URL]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 3 Nov 1998 22:36:34 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Newbie: files in different directories.
Message-Id: <71o0hi$102$1@gellyfish.btinternet.com>
On Tue, 03 Nov 1998 19:26:01 GMT Morten Knudsen <mk@control.auc.dk> wrote:
>
> dave@mag-sol.com wrote:
>
>> In article <363EF167.397A3A59@control.auc.dk>,
>> Morten Knudsen <mk@control.auc.dk> wrote:
>> > Here's my problem...
>> >
>>
>> [snipped to the relevant statement]
>>
>> > open (CARTFILE, "<$cart");
>>
>> If your file is in another directory, you need to prepend that directory's
>> name to the file name when opening it. Something like:
>>
>> open(CARTFILE, "<$dir/$cart") or die "Can't open $dir/$cart: $!\n";
>>
>> You should also bear in mind that your web server user (who owns the CGI
>> process) may well only have access to the web documents directory tree. You
>> might need to find out where that is by using $ENV{DOCUMENT_ROOT}.
>>
>
> Thank you for your help, but I'm still at a loss. I've prepended(?) the
> path to the file when defining $cart and I've also chmoded the /carts
> directory to 766, so the user should be able to read/write the cart file.
>
So what is the message you get when the open fails - because you did follow
Dave's advice and check the success of the open didn't you ?
Oh I'll repeat that then.
open(CARTFILE, "<$dir/$cart") or die "Can't open $dir/$cart: $!\n";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
THIS IS VERY IMPORTANT !
In case you are not getting a proper error message when you are running
this on a server you might place something like :
BEGIN
{
$SIG{__DIE__} =
$SIG{__WARN__} = sub { $| = 1;
print "Content-type: text/plain\n\n";
print "@_";
}
}
at the beginning of your code.
Or alternatively:
use CGI::Carp qw(fatalsToBrowser);
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Tue, 3 Nov 1998 22:48:19 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Not to start a language war but..
Message-Id: <F1vBCJ.20t@world.std.com>
Ken Manheimer <klm@cnri.reston.va.us> writes:
>From what i've seen here, at least w.r.t. file io, perl takes a fairly
>lenient approach to exception conditions, requiring the programmer to be
>proactive and check for them. Kinda like a lot of C routines. Python,
>on the other hand, is more demanding - if you don't anticipate an
>exception, then you're gonna get disrupted.
I'd say you are right. Perl is a language which tries to allow
different methods of expression. Some feel the difference are needed
for the language to apply to different problems. (Code one way for a
"-e" command line invocation, a different way for a short hack, and a
third way for bulletproof production code.) Others feel it is so
different programmers can use different aspects of the language based
on the previous experience. (The book "Programming Perl" talks about
Perl having a long, but not very steep learning curve. That you can
learn it "little end first". I guess the little end depends on what
you bring to perl though. The easy parts are the parts that you are
familiar with, and the tough parts are the ones you aren't.)
So a error handling style that leans to, if not requires exception
handling would inforce a certain form of expression would make it
dificult to create programs that would be better written in different
forms of expression.
Sometime checking return codes is tedious, and I wish I could just
deal with exeptional conditions in a more centralized way. In those
cases, I want exception handling. Sometimes there is no way to
generalize the handling the difference possible condtions of each
step. In those cases I want return codes.
At the most basic level, turning return codes into exceptions or vice
versa isn't too tough in perl, and tends to be done frequently.
open FILE, $filename or die "Can't open $filename: $!\n";
or
eval { /$user_supplied_regular_expression/ };
handle_ivalid_regex() if $@;
adding "or die" or "eval {}" onto whatever whateve part of perl is
working the wrong way for you isn't that big of a deal to get the
"impedence match" you need.
And a comment on the "C" comparison. One crucial difference is that C
is a lot more forgiving than C on errors. This allows the program to
avoid dealing with problems that it doesn't care about. In C, if you
you open a file that doesn't exist, and then you try to read from the
NULL file handle that is returned, things just crash. In Perl, it
returns end of file, which is lilely to cause the program to go on to
something else.
--
Andrew Langmead
------------------------------
Date: Tue, 03 Nov 1998 17:25:35 -0800
From: ZigroN <zigron@jps.net>
Subject: Re: Not to start a language war but..
Message-Id: <363FAD0F.5074B0C1@jps.net>
My second post to this thread, reluctant...
John Porter wrote:
(snip)
> You completely misunderstand the notion of "8-bit clean".
> It is not about data structures. By insisting that it is,
> you make a fool of yourself.
(snip)
> I'm sorry, friend, but you clearly do not know whereof you speak.
> You would do well to remain reticent, rather than bring upon yourself
> the shame of words spoken without knowledge.
I'm only responding to the above. You're like, inviting a harsh
response, you keep calling everyone a) a liar, and b) a fool for not
knowing something, or not knowing it as well as you think you do. It's
not nessecary. People are not 'stupid' or 'foolish' for being WRONG
about something. COrrect them. Give them examples, instead of asking
for them yourself, and show your point, and hopefully help them to
learn.
Bah.
--
Stephen Hansen
zigron@jps.net
http:// -- Homepage down temporarily :~(
ICQ: 8391641
"Live ye must, and let to Live"
"An harm ye none; Do as ye will"
!!! KTBSPA !!!
------------------------------
Date: Tue, 3 Nov 1998 23:07:15 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: PERL is TOO flexible
Message-Id: <F1vC83.Bzq@world.std.com>
"PERL ROCKS!" <emills@harris.com> writes:
>What does this add? Maybe Mr. Wall wanted to allow many possible
>syntaxes (syntaces?) so in the event that a programmer "forgot" one, he
>was more likely to "stumble on" to one that worked?
I'm not sure if it was a cause, or a happy accident for some "multiple
forms of expression", but I've noticed that in some cases different
ways of performing the same action in perl sometimes make up for
shortcomings parse-then-execute nature of the perl program.
Take conditionals for example. You have both the "if" compound
statement "if(EXPR) BLOCK" and the statement modifier
"STATEMENT if EXPR". The camel book talks about alowing the "if" to
be a modifier if the STATEMENT should stand out for readability. Its
also the case that entering and leaving blocks have a lot of run time
overhead, and the statement modifier form avoids that overhead. (This
is less true now, the optimizer now removes the block if the contents
of the block is "simple")
So if you have expensive and simple ways of doing certain things, and
the syntax can lean the programmer toward the simple ones when they
are appropriate, then the program tends to be more efficient.
--
Andrew Langmead
------------------------------
Date: 3 Nov 1998 22:33:20 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: perl modules
Message-Id: <71o0bg$9qv19@mercury.adc.com>
In article <71nsti$a5m@news.voyager.net>, J Holden <jholden@voyager.net> wrote:
>am really getting my feet wet with perl modules and encountered this
>error message
>
>Can't locate LWP/Socket.pm in @INC and then some paths
>
>I looked and that Socket.pm is in the path that it specifies, but I am
>not sure how to make it work. Can someone show me or give me
>someplace I can look to get more info?
Well, Socket.pm may be in there, but is LWP/Socket.pm there? IOW,
does one of those directories listed contain a directory named LWP,
which in turn contains Socket.pm?
--
_____
|/// | Brand Hilton bhilton@adc.com
| ADC| ADC Telecommunications, ATM Transport Division
|_____| Richardson, Texas
------------------------------
Date: Tue, 03 Nov 1998 17:55:44 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: perl&cgi question
Message-Id: <comdog-ya02408000R0311981755440001@news.panix.com>
In article <363EC5AF.14E81D60@balder.no>, Kjetil Svendsberget <kjetil@balder.no> posted:
> brian d foy wrote:
> >
> > In article <363DDAE2.A18140AE@corp.home.net>, Justin Harvey <jbharvey@corp.home.net> posted:
> >
> > > You need to change the mime association for .pl extension inside your
> > > browsers so that it will use it as a CGI, and not try to download it.
> >
> > sorry, but it's the server that does what you are thinking about.
>
>
> Sorry for asking this in the wrong newsgroup, but as i said this is NOT
> a web server problem, since both machines acess the same web-server
> (www.balder.no), they even have the same browser. IE 4.0 (v.4.72).
you must be using a PoB system then. that's what you get. it's
not a perl thing.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 4 Nov 1998 01:05:02 GMT
From: "Stephen Moore" <smoore@mdsi.bc.ca>
Subject: PERL/UNIX newbie wants to multiprocess in his first script *LAUGH*
Message-Id: <01be078f$94fbcbc0$7f02a8c0@pc256.mdsi.bc.ca>
I am fairly experienced with C/C++ for the PC environment, but am
completely new to PERL and the UNIX environment.
I am trying to write a PERL script that must execute multiple processes in
the background, each generating a huge array of strings which must be
passed back to the foreground process for processing (each huge array is
timestamped and processed by queue).
I do not want to use files. I want to keep it all in memory. I got fork
and signals working fine but not message queues, shared memory, semaphores,
and cannot really see a straight forward solutions.
In a WIN32 environment I would just spawn multple threads each gathering
the data and then plugging them into shared variables with a few synch
objects to help.
Any way to implement shared variables with a simple fork to assist? I
tried:
$A = 0;
$P = \$A;
if (fork == 0)
{
${$P} = 1;
exit(0);
}
wait();
print $A;
and hoped it would print 1 but it printed 0. :( thought maybe references
were pointers and that they wouldnt be adjusted...
Any help appreciated.
------------------------------
Date: 4 Nov 1998 01:30:10 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: PERL/UNIX newbie wants to multiprocess in his first script *LAUGH*
Message-Id: <slrn73vbh2.nqv.sholden@pgrad.cs.usyd.edu.au>
On 4 Nov 1998 01:05:02 GMT, Stephen Moore <smoore@mdsi.bc.ca> wrote:
>I am trying to write a PERL script that must execute multiple processes in
>the background, each generating a huge array of strings which must be
>passed back to the foreground process for processing (each huge array is
>timestamped and processed by queue).
>
>I do not want to use files. I want to keep it all in memory. I got fork
>and signals working fine but not message queues, shared memory, semaphores,
>and cannot really see a straight forward solutions.
perldoc perlipc
--
Sam
compiling kernels is what I do most, so they do tend to stick to the
cache ;) --Linus Torvalds
------------------------------
Date: Tue, 03 Nov 1998 17:21:14 -0800
From: Curt Wohlgemuth <curtw@cup.hp.com>
Subject: POSIX::SigAction and sigaction()
Message-Id: <363FAC09.5B62DC5@cup.hp.com>
Hi:
I'm a complete Perl newbie. I did look in one or more FAQs, and looked
through the articles on this newsgroup, so I'm hoping someone here can
help me...
I have read that catching signals in Perl is unreliable at present.
Understood. What I'm trying to do is set up a "clean" signal
environment for spawned children. Basically, in a loop:
foreach $i (1..$#sig) {
next if ($i == 9 || $i == 24 || $i == 31 || $i == 32);
POSIX::sigaction($i, $sigaction, $oldaction) or
die "sigaction failed: $!";
}
where $sigaction is a POSIX::SigAction set up with SIG_DFL and the empty
set for the mask.
When I do this, I get some strange behavior. With one program, I get a
hang that seems to correspond to a spawned child. With another program,
I get the diagnostic printed:
SIGCHLD handler "DEFAULT" not defined.
followed by this panic:
panic: leave_scope inconsistency.
I'm assuming that the panic is related to the warning/error about the
SIGCHLD handler.
Is it true that clearing SA_NOCLDSTOP for the Perl program will hose
spawning children??
Thanks for any help,
Curt
------------------------------
Date: Tue, 3 Nov 1998 15:04:22 -0800
From: "Alistair Calder" <webmaster@topproducer.com>
Subject: Re: Reading multiple lines
Message-Id: <71o24a$k68$1@supernews.com>
Okay, I read the perlvar man page, and my dim glimmer of PERL knowledge
tells me that $/ will convert the entire file into one line, am I correct?
If so, then my:
foreach $item(@NEWS){
[read this line and parse it for info]
}
won't work because the whole file is one continuous line. If this is the
case, I'm as far behind as when I started.
When I mentioned earlier that I would like to read the whole chunk of data,
I meant that I want to read the three lines that refer to:
Line 1: The anchor and linked text
Line 2: The by-line, or description of the previous line
Line 3: the <BR><BR> line that delimits each news item.
in a group, not the entire file.
Now, forgive me if I am being naive, but the $/ solution doesn't seem to get
me any further ahead. Am I wrong? Can I treat the whole document as one
line, but still extract the proper 3 lines that I require for my local
document?
Thanks,
Alistair
Tad McClellan wrote in message ...
>Alistair Calder (webmaster@topproducer.com) wrote:
>
>
>: What I would like to do is, instead of reading each line seperately, I'd
>: like to read in the whole chunk of data and deal with it as a group.
>
>: Is this going to be possible?
>
>
>{ local $/; # look up $/ special variable in the 'perlvar' man page
>
> $whole_darned_file = <>;
>}
>
>
>--
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------------------------------
Date: 3 Nov 1998 22:57:45 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Reading multiple lines
Message-Id: <71o1p9$116$1@gellyfish.btinternet.com>
On Tue, 3 Nov 1998 12:59:24 -0800 Alistair Calder <webmaster@topproducer.com>
wrote:
> Matt Knecht wrote in message ...
>
>>Alistair Calder <webmaster@topproducer.com> wrote:
>>>I am trying to parse an HTML document have
>>>tried a number of different ways, but I just can't get it to work properly.
>>>
>>>Is this going to be possible?
>>
>>Quite easily! Just use HTML::Parser. You should be able to find it at
>>
>><URL:http://www.perl.com/CPAN-local/modules/by-module/HTML/>
>>
>>It would proabably be wise to grab the entire libwww bundle.
>>
>
> Er...thanks. I am pretty much a beginning PERL programmer, and I have yet
> to use a module. On top of that, I am not sure what do do with it once I
> have it, I don't own the server my site is on. I wouldn't know what to do
> with the module even if I did download it to my machine.
>
> I have looked at the blue Camel book, but I am still not quite sure how
> modules work or how they are implemented in a script. I guess I'll have to
> pick up that knowledge.
>
Examples of the use of HTML::Parser abound on this newsgroup - just search
DejaNews - I for one have posted several.
As for the installation of modules you should find what you want in perlfaq8.
The suggestions you have received as to reading in the whole file will still
be applicable when you use HTML::Parser.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Wed, 04 Nov 1998 00:29:21 GMT
From: nicovl@hotmail.com (Nico v Leeuwen)
Subject: Replacing chracters in a variable
Message-Id: <363f9f54.1724371@news.nl.net>
I have been puzzeled with a question I have a variable and this
varaible might have some carridge returns in it I want my program to
replace the CRT's in the variable with a HTML tag. What code could I
best use?
------------------------------
Date: Tue, 03 Nov 1998 21:59:30 GMT
From: schergr@my-dejanews.com
Subject: Win32::NetAdmin
Message-Id: <71nuc2$d8k$1@nnrp1.dejanews.com>
Please someone help me.....
given the following code:
use Win32::NetAdmin;
Win32::NetAdmin::UsersExist("XXXXXXXXX", "YYYYYYYY") || die "Error1: ",
Win32::FormatMessage(Win32::GetLastError);
Why do I get the following error "Error1: The system cannot find the file
specified."
I know the following. - the script is running local to my workstation.
- I am a domain admin and a local admin on the workstation being checked.
- All machines are available on the network. - $? does not return a
value it remains 0 no matter what happens before it. In other words if I
assign $?=2 and than execute the call $? should change to 0 or false which it
doesnt. - The NetAdmin.pm is installed on my the machine I am executing the
script from
I am pretty sure that everything else is as it should be. All other LIB calls
seem to work fine. Please respond via email with any help. I am baffled.
Thanks in advance,
Greg
Gregory Scher
Perot Systems Corporation
Distributed Systems / NY
NT Systems Specialist
Email: Greg.Scher@wdr.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 03 Nov 1998 18:21:27 -0600
From: Chad Moston <chad@anlon.com>
To: dfk@my-dejanews.com
Subject: Re: Win32::ODBC - field names
Message-Id: <363F9E07.AD59A6F1@anlon.com>
My simple guess is it doesn't like the ' - ' in your field name. The simplest
solution would be to change the name using underscores. I have delt with a lot of
these situations, but had never used the []'s. If that works, please let me know.
Chad
>
>
> Can anyone tell me what I am doing? I guess that it must have something to do
> with escaping the f-bd-field name.
>
>
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4143
**************************************