[19989] in Perl-Users-Digest
Perl-Users Digest, Issue: 2184 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 22 14:05:26 2001
Date: Thu, 22 Nov 2001 11:05:06 -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: <1006455906-v10-i2184@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 22 Nov 2001 Volume: 10 Number: 2184
Today's topics:
Re: Creating a Perl app. Help with installation? <mcnuttj@dnps-linux1.telecom.missouri.edu>
Re: eval or not eval <5l259r001@sneakemail.com>
Re: Fastest way to eliminate words < 4 characters long <andrew_harton@agilent.com>
Re: Fastest way to eliminate words < 4 characters long <5l259r001@sneakemail.com>
Re: fork() difference between Win and Linux/Unix <ilya@martynov.org>
Re: fork() difference between Win and Linux/Unix <5l259r001@sneakemail.com>
HELP: deactivating regexp-active chars from string? (Bruno Boettcher)
Re: HELP: deactivating regexp-active chars from string? <kevin@vaildc.net>
Re: HELP: deactivating regexp-active chars from string? (Tad McClellan)
Re: How can you do a safe unlink? <admin@asarian-host.net>
Request: Perl Monger Stories (Peter Lowe)
Re: Script for stripping FONT (HTML) tags <gisle@ActiveState.com>
Re: Using CGI.pm to obtain a list of params <wsegrave@mindspring.com>
Re: Using CGI.pm to obtain a list of params (Jon Bell)
Re: Using CGI.pm to obtain a list of params <flavell@mail.cern.ch>
Re: variable scope <uri@stemsystems.com>
Re: variable scope <admin@asarian-host.net>
Re: variable scope <joe+usenet@sunstarsys.com>
Re: Which ISPs support perl scripts? <pap@sotonians.net>
Re: Which ISPs support perl scripts? (Owain McGuire)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Nov 2001 16:46:10 GMT
From: <mcnuttj@dnps-linux1.telecom.missouri.edu>
Subject: Re: Creating a Perl app. Help with installation?
Message-Id: <9tja4i$bum$1@dipsy.missouri.edu>
Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
> brian d foy wrote in comp.lang.perl.misc:
>>
>> Here are some starting resources:
>>
>> http://www.perldoc.com/perl5.6.1/bin/h2xs.html
>> http://www.perldoc.com/perl5.6.1/lib/ExtUtils/MakeMaker.html
> Also an article "Building Perl projects with MakeMaker" :
> http://www-106.ibm.com/developerworks/linux/library/l-make.html
This last link seems to be the most useful so far, since it pretty
much walks you through building a quick MakeMaker project.
I ran 'h2xs -X' and I've been looking at the documentation for
MakeMaker, but it all seems to revolve around making a *module*,
whereas I'm making an *application* (that happens to contain,
among many other things, some modules).
The documentation to MakeMaker is confusing. First of all, it
refers (over and over) to "extensions" to Perl. At first this
seems synonymous with "modules", but that isn't the case either
because it also refers to creating perl binaries and linking them.
The biggest gripe I have about MakeMaker thus far, though is that
there seesm to be no provision (or at least, no explanation) for a
'make uninstall'. A quick look at ExtUtils::Install shows that it
*is* in there, but there's no reference to it in the MakeMaker man
page nor is there any hint as to how the uninstall function is
intended to be actually used (there's syntax, but no *context*).
And there's still no help on what to do with all of the MIB files.
The whole structure looks pretty cool (and useful), but there are
some gaps that need filling before I'm ready to unleash this on my
coworkers. :-) Particularly, there are some interesting things
that my current Makefile does that I see no provision for in
MakeMaker. 'make uninstall' is one of them. Another is that in
my current Makefile I do this several times:
cp bin/jscan $(BINDIR)/jscan
(cd $(BINDIR) ; ln -s ./jscan ./jscan.cgi)
or something similar to create symlinks to my executables. How
does MakeMaker handle something like that?
--J
------------------------------
Date: Thu, 22 Nov 2001 17:36:50 +0100
From: "Steffen Müller" <5l259r001@sneakemail.com>
Subject: Re: eval or not eval
Message-Id: <9tj9i7$o96$05$1@news.t-online.com>
"felix" <mr.thanquol@gmx.de> schrieb im Newsbeitrag
news:9tj72q$5it$1@crusher.de.colt.net...
| hi,
|
| I finally reached a point where I can't concentrate any more! I'm trying
to
| read stuff from a config-file
| and put it in hashes and scalars...just an example
[DATA]
| what I want is to get the following
[expectations]
| I think about using eval like in a shell script but I didn't found the
| correct combination yet...
Why eval?
#!perl
use strict;
use warnings;
use Data::Dumper;
my %config;
my $category = undef;
while (<DATA>) {
chomp; # remove newline
s/\s+=\s+/=/g; # make '=' surrounded by
# whitespaces just '='
unless ( /\S/ ) { # an empty line if it does not
# contain non-whitespace chars
$category = undef;
next;
}
my @element = split(/=/); # split at '='
if ( @element == 1 ) { # if no split occurred
$category = $element[0]; # change category
next;
}
if ( !defined $category ) { # if no category
# was specified
$config{$element[0]} = $element[1];
next;
}
if ( !exists $config{$category} ||
ref( $config{$category} ) ne 'HASH' ) {
# the hash item denoted by
# category does not exist
# or is no hash ref
$config{$category} = {};
}
$config{$category}{$element[0]} = $element[1];
# add to inner hash
}
print Dumper \%config;
__DATA__
WebSite
apache = http://www.apache.org
perl = http://www.perl.com
OS
solaris = http://www.sun.com/solaris
suse-linux = http://www.suse.com
logfile = /tmp/log.file
This should do the trick.
--
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;$o=$_;push@o,substr($o,$_*8,8) for(0..
24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\r";$i++};print"\n"#stm
------------------------------
Date: Thu, 22 Nov 2001 16:17:20 -0000
From: "Andrew Harton" <andrew_harton@agilent.com>
Subject: Re: Fastest way to eliminate words < 4 characters long except month abbreviations?
Message-Id: <1006445844.971123@cswreg.cos.agilent.com>
> 'push' => sub {
> @words = ($string =~ m/\w{4,}/g);
> push @words,
> 'jan','feb','mar','apr','may',
> 'jun','jul','aug','sep','oct','nov','dec';
> }
Doesn't your 'push' include all of the 3 letter month abbreviations, whether
they appear in the text or not? I don't think that's the right thing to do
here...
Andrew
------------------------------
Date: Thu, 22 Nov 2001 17:54:28 +0100
From: "Steffen Müller" <5l259r001@sneakemail.com>
Subject: Re: Fastest way to eliminate words < 4 characters long except month abbreviations?
Message-Id: <9tjaiq$q27$05$1@news.t-online.com>
"Andrew Harton" <andrew_harton@agilent.com> schrieb im Newsbeitrag
news:1006445844.971123@cswreg.cos.agilent.com...
| > 'push' => sub {
| > @words = ($string =~ m/\w{4,}/g);
| > push @words,
| > 'jan','feb','mar','apr','may',
| > 'jun','jul','aug','sep','oct','nov','dec';
| > }
| Doesn't your 'push' include all of the 3 letter month abbreviations,
whether
| they appear in the text or not? I don't think that's the right thing to
do
| here...
You are right.
What about this?
timethese( $count, {
'your regex, case insensitive' => sub {
@words = ($string =~
m/\w{4,}|\d+|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/gi);
},
'hash_grep, case ins.' => sub {
@words = ($string =~ m/\w{3,}/g);
@words = grep(
( length $_ > 3 || exists($allowed{lc $_}) ),
@words
);
},
'separate, case ins.' => sub {
@words = ($string =~ m/\w{4,}/g);
foreach ( keys %allowed ) {
push @words, $_ if ($string =~ /$_/i);
}
}
} )
Steffen
--
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;$o=$_;push@o,substr($o,$_*8,8) for(0..
24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\r";$i++};print"\n"#stm
------------------------------
Date: 22 Nov 2001 19:07:31 +0300
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: fork() difference between Win and Linux/Unix
Message-Id: <87adxeyekc.fsf@abra.ru>
>>>>> On Thu, 22 Nov 2001 15:30:42 GMT, Zoltan Kandi <zoltan.kandi@tellabs.com> said:
Zoltan> [..skip..]
Zoltan> Apart from the PID there's one more difference, the Win32 run
Zoltan> produced one extra line "no more children". My question: is
Zoltan> the ActiveState Win32 fork() command 100% compatible with the
Zoltan> Unix implementation of fork()?
ActiveState Win32 emulation of fork() is not 100% compatible with the
Unix implementation of fork()? See 'perldoc perlfork'.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) TIV.net (http://tiv.net/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Thu, 22 Nov 2001 18:12:08 +0100
From: "Steffen Müller" <5l259r001@sneakemail.com>
Subject: Re: fork() difference between Win and Linux/Unix
Message-Id: <9tjbjc$uvt$07$1@news.t-online.com>
"Ilya Martynov" <ilya@martynov.org> schrieb im Newsbeitrag
news:87adxeyekc.fsf@abra.ru...
| >>>>> On Thu, 22 Nov 2001 15:30:42 GMT, Zoltan Kandi
<zoltan.kandi@tellabs.com> said:
|
| ActiveState Win32 emulation of fork() is not 100% compatible with the
| Unix implementation of fork()? See 'perldoc perlfork'.
That's a euphemism. :P
Steffen
--
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;$o=$_;push@o,substr($o,$_*8,8) for(0..
24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\r";$i++};print"\n"#stm
------------------------------
Date: 22 Nov 2001 17:16:41 GMT
From: bboett@bboett.dyndns.org (Bruno Boettcher)
Subject: HELP: deactivating regexp-active chars from string?
Message-Id: <9tjbtp$39q$1@wanadoo.fr>
Hello!
me again :D
just wondering if there is allready some availbale func to deactivate
regexp active chars from a string (those are '.[]/()' etc...)
because i test a usergiven entry against some intern data, thus if the
user inserts eg [] into his chain, thos signs get interpreted as a range
delimiter..
now i can make my own function to deactivate those chars in a string,
but i bet someone allready did so ...
--
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
------------------------------
Date: Thu, 22 Nov 2001 12:34:35 -0500
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: HELP: deactivating regexp-active chars from string?
Message-Id: <221120011234353265%kevin@vaildc.net>
In article <9tjbtp$39q$1@wanadoo.fr>, Bruno Boettcher
<bboett@bboett.dyndns.org> wrote:
> just wondering if there is allready some availbale func to deactivate
> regexp active chars from a string (those are '.[]/()' etc...)
>
> because i test a usergiven entry against some intern data, thus if the
> user inserts eg [] into his chain, thos signs get interpreted as a range
> delimiter..
>
> now i can make my own function to deactivate those chars in a string,
> but i bet someone allready did so ...
Yup. Use \Q ... \E around the text you want to protect:
kevin% perl -e 'print "[]\n"'
[]
kevin% perl -e 'print "\Q[]\E\n"'
\[\]
This is in perldoc perlre.
--
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net | blazing high above your head.
. . . . . . . . . | But _in_ you is the presence that
. . . . . . . . . | will be, when all the stars are dead. (Rainer Maria Rilke)
------------------------------
Date: Thu, 22 Nov 2001 18:04:26 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: HELP: deactivating regexp-active chars from string?
Message-Id: <slrn9vqcm0.tnh.tadmc@tadmc26.august.net>
Bruno Boettcher <bboett@bboett.dyndns.org> wrote:
>
>just wondering if there is allready some availbale func to deactivate
>regexp active chars from a string (those are '.[]/()' etc...)
perldoc -f quotemeta
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 22 Nov 2001 16:53:16 GMT
From: "Mark" <admin@asarian-host.net>
Subject: Re: How can you do a safe unlink?
Message-Id: <04aL7.82101$dk.5973666@bin1.nnrp.aus1.giganews.com>
"Mark Jason Dominus" <mjd@plover.com> wrote in message
news:3bfc52ab.5e7a$338@news.op.net...
MJD,
It seems I owe you an apology. Well, that sounds like I feel pressured into
doing so. Not so. Well, that is, I was almost done writing a lengthy
response to Steffen, as I felt an overwhelming urge to call it quits. Simple
matter is: you were right, I was wrong. I stuck my foot in my mouth by
assuming a mysterious file reappearance that did not occur, and then got
pissy about being called on it and look the fool. Point is, it was not you
who made me look like a fool--I did that all by myself.
Hence, I owe you this apology for my rather antagonistic tone today.
Regards,
- Mark
------------------------------
Date: Thu, 22 Nov 2001 18:26:48 GMT
From: pgl@pm.org (Peter Lowe)
Subject: Request: Perl Monger Stories
Message-Id: <slrn9vqgr8.20kv.pgl@armadillo.yoyo.org>
Perl Mongers of the World! www.pm.org would like to compile a collection of
stories from user groups around the world to add to the site, and encourage
others to start their own groups. The sort of thing we're interesting in
includes how your local group started, how it grew, and any memorable meetings
you've had. If you think you can contribute, please email me and we'll add it
to the site.
cheers,
Peter Lowe.
--
This is not the signature you are looking for. Move along.
------------------------------
Date: Thu, 22 Nov 2001 17:48:06 GMT
From: Gisle Aas <gisle@ActiveState.com>
Subject: Re: Script for stripping FONT (HTML) tags
Message-Id: <m3hermu24r.fsf@ActiveState.com>
merlyn@stonehenge.com (Randal L. Schwartz) writes:
> Sasa> I have a bunch of html files placed in several subfolders under root
> Sasa> folder which has to be stripped of FONT tags since they have to be
> Sasa> formatted via CSS.
>
> Not thoroghly tested, but I usually get these things right on the
> first try...
>
> use HTML::Parser;
> HTML::Parser->new(
> default_h => [sub { print $_[0] }, "text"],
> start_h => [sub { print $_[1] if $_[0] ne "font" }, "tagname, text"],
> end_h => [sub { print $_[1] if $_[0] ne "font" }, "tagname, text"],
> )->parse_file(\*DATA) || die $!;
>
> __END__
> <a>foo</a>
> <font size="+3">bar</font>
Recent versions of HTML::Parser has the 'ignore_tags' attribute that
can be used to simplify this into:
use HTML::Parser;
HTML::Parser->new(
default_h => [sub { print $_[0] }, "text"],
ignore_tags => 'font',
)->parse_file(\*DATA) || die $!;
The HTML-Parser distribution also comes with an example program called
'hstrip' (you find it in the 'eg' directory) that shows this feature
as well as how you can edit out selected attributes.
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/libwww-perl/html-parser/eg/hstrip?rev=1.9&content-type=text/vnd.viewcvs-markup
--
Gisle Aas,
ActiveState
------------------------------
Date: Thu, 22 Nov 2001 11:40:28 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Using CGI.pm to obtain a list of params
Message-Id: <9tjdpb$tkc$1@slb4.atl.mindspring.net>
"Jon Bell" <jtbell@presby.edu> wrote in message
news:Gn7Jxz.6v9@presby.edu...
> In article <39e3e00a.0111220700.45faeb44@posting.google.com>,
> Wiliam Stephens <wil@fbagroup.co.uk> wrote:
> >"brian norman" <brian.norman@gecm.com> wrote in message
> >news:<3bfba755$1@pull.gecm.com>...
> >
> >> use CGI;
> >>
> >> my %Hash;
> >> my $cgi=new CGI;
> >> foreach my $V ( $cgi->param()) # without specifying a specific param
it
> >> returns a list of them all
> >> {
> >> $Hash{$V}=$cgi->param($V); # to get them into your personal hash
> >> }
> >
> >Thanks for the sample code. That is what I needed indeed. I now need
> >to assign each param to a specific variable, which I think I should be
> >able to manage.
>
> Of course, if you know the parameter names in advance (as you should,
> either because you created the form yourself, or you read the docs for
> it), you can assign them straight away to specific variables without
> bothering with a hash. For example, if two of the parameters are named
> 'firstname' and 'lastname':
>
> my $FirstName = $cgi->param('firstname');
> my $LastName = $cgi->param('lastname');
>
> etc. So far, I've used the read-into-hash thing only as a debugging
> measure.
>
Suppose you know the parameter names; but there are several hundred of them.
Do you still advocate the approach you stated. If so, why?
Bill Segraves
Auburn, AL
------------------------------
Date: Thu, 22 Nov 2001 18:18:32 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Using CGI.pm to obtain a list of params
Message-Id: <Gn7s6w.GL7@presby.edu>
In article <9tjdpb$tkc$1@slb4.atl.mindspring.net>,
William Alexander Segraves <wsegrave@mindspring.com> wrote:
>"Jon Bell" <jtbell@presby.edu> wrote in message
>news:Gn7Jxz.6v9@presby.edu...
>> In article <39e3e00a.0111220700.45faeb44@posting.google.com>,
>> Wiliam Stephens <wil@fbagroup.co.uk> wrote:
>> >"brian norman" <brian.norman@gecm.com> wrote in message
>> >news:<3bfba755$1@pull.gecm.com>...
>> >
>> >> use CGI;
>> >>
>> >> my %Hash;
>> >> my $cgi=new CGI;
>> >> foreach my $V ( $cgi->param()) # without specifying a specific param
>it
>> >> returns a list of them all
>> >> {
>> >> $Hash{$V}=$cgi->param($V); # to get them into your personal hash
>> >> }
>> >
>> >Thanks for the sample code. That is what I needed indeed. I now need
>> >to assign each param to a specific variable, which I think I should be
>> >able to manage.
>>
>> Of course, if you know the parameter names in advance [...]
>> you can assign them straight away to specific variables without
>> bothering with a hash. For example, if two of the parameters are named
>> 'firstname' and 'lastname':
>>
>> my $FirstName = $cgi->param('firstname');
>> my $LastName = $cgi->param('lastname');
>
>Suppose you know the parameter names; but there are several hundred of them.
>Do you still advocate the approach you stated. If so, why?
The original poster wants to assign each param to a specific variable. If
you have several hundred parameter names, then using my approach, you have
to have several hundred statements of the form given above.
Using an intermediate hash, you first have the loop shown by Brian, then
you have several hundred statements like
my $FirstName = $Hash{'firstname'};
I don't see much difference in terms of programmer convenience.
Now, if I actually had several hundred parameters to deal with, I'd
probably be using a design that didn't involve several hundred individual
variables for them in the first place. For example, I can imagine a
form for inputting a rectangular table of numbers, with parameters named
'row0col0', 'row0col1', etc. Then I could generate parameter names
dynamically as needed, and extract the individual entries using
$cgi->param(). If I needed to use each entry repeatedly, I'd probably
use a loop to extract them into an array of arrays or something similar.
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
------------------------------
Date: Thu, 22 Nov 2001 19:36:58 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Using CGI.pm to obtain a list of params
Message-Id: <Pine.LNX.4.30.0111221933330.9314-100000@lxplus023.cern.ch>
On Nov 22, William Alexander Segraves inscribed on the eternal scroll:
> Suppose you know the parameter names; but there are several hundred of them.
Then I'd conclude I had a user-interface nightmare on my hands, long
before I even get to the point of invoking the CGI interface...
But if you insist:
> Do you still advocate the approach you stated.
Put them in a hash, of course. It's a natural in Perl.
Hangonabit, they already come back from CGI.pm in a hash. So what's
the problem? ;-)
------------------------------
Date: Thu, 22 Nov 2001 16:21:52 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: variable scope
Message-Id: <x7lmgybwrl.fsf@home.sysarch.com>
>>>>> "MG" == Matt Garrish <matthew.garrish@sympatico.ca> writes:
MG> So why not just initialize the variable within the scope of the
MG> loop, rather than within a new block, since it's life only lasts
MG> for as long as the loop? You are obviously content with whatever
MG> the perl overlords dictate, but I haven't heard a single reason
MG> why this is a "good thing". Only that that's the way it is...
you don't get it. the scope of the loop IS THE SCOPE OF ITS BLOCK. they
are the same. you keep acting as if they are different. so the index
variable of a for loop IS DECLARED INSIDE THE LOOP BLOCK. and so it WILL
MASK WITH NO ERROR any outer scoped variable of the SAME NAME. that is
the whole point. you want to be able to name the index variable to
anything and know that you don't CLOBBER OUTER VARIABLES. now masking
and clobbering ARE NOT THE SAME. and MASKING IS LEGAL and NOT AN ERROR.
i think the english there is fine. just read it a few times. you are
mistaken in your beliefs and do not seem to get loop block scoping.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Thu, 22 Nov 2001 17:04:05 GMT
From: "Mark" <admin@asarian-host.net>
Subject: Re: variable scope
Message-Id: <9eaL7.14383$YD.1352394@news2.aus1.giganews.com>
----- Original Message -----
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Newsgroups: comp.lang.perl.misc
Sent: Thursday, November 22, 2001 3:34 PM
Subject: Re: variable scope
Hi Matt,
This is not a flame. :)
> All I wanted was to know how the scoping of a foreach block works, and
> why it wouldn't catch the multiple declarations as an error.
May I ask you, why should it? I am obviously not as skilled as some folks
here, and I should probably not even burn my fingers on this thread. But let
me ask you a serious question here, just out of curiosity; and then I am
outta this thread.
If you want multiple declarations (each within their own scope) to generate
warning errors, are you then not requesting that your perl interpreter
examines your declarations beyond their individual scope to see if they do
not clash? I mean, is not the whole point of scopes that declarations within
that scope remain visible only within their own vista?
Let me put it this way: if you ask your perl interpreter to look at scoped
declarations as if their scope were global, and subsequently ask perl to
warn you about these "multiple declarations," are you then not effectively
asking your interpreter to behave in a "broken" way?
- Mark
------------------------------
Date: 22 Nov 2001 12:26:24 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: variable scope
Message-Id: <m3vgg27m4f.fsf@mumonkan.sunstarsys.com>
"Matt Garrish" <matthew.garrish@sympatico.ca> writes:
> I'm beginning to think I did write my own language, and it's called
> English. Unfortunately no one here seems to know it. I'm tempted to
> go through and count the number of times people have misread my
> original post. I harassed Ilya for the answer I wanted, and I got it
> long ago!
But then you went on to say something silly about strictures
(which are a red herring here) and fictitious 20,000-line
scripts with dozens of massive, nested foreach loops. Sorry,
but programming languages were not designed to handle stupidity
on such a massive scale. The only appropriate action for
such an input is electro-shock therapy.
To be perfectly clear- if you are plagued by this kind of
problem, then you need to adopt a better programming style.
Lots of people have accidentally masked a variable they didn't
intend to (most likely it was $_ or some other built-in
that didn't scope as the programmer expected), but it's
*completely legal* to do so. You should not expect the compiler
to determine your *intent* in every circumstance (even though
perl often tries to make an educated guess about it), otherwise
it wouldn't need you to write the program in the first place :)
> The thread has since descended into something else entirely. All I
> wanted was to know how the scoping of a foreach block works, and why
> it wouldn't catch the multiple declarations as an error.
^^^^^
Grrr- it's *not* an error; rather a "potential" error, or just
"bad style". perl emits a _diagnostic warning_ if you ask it to.
[...]
> Once the variable is masked, it becomes useless within the loop
> (unless you are privy to some wisdom about how to add code in the
> netherworld between the end of the loop and the resumption of the
> body).
Not that you deserve an honest answer, but you might consider
thinking about how a continue {} block works, and its relation
to Perl's C-style for loop.
Now piss off.
--
Joe Schaefer "Don't go around saying the world owes you a living. The world
owes you nothing- it was here first."
--Mark Twain
------------------------------
Date: Thu, 22 Nov 2001 18:49:14 -0000
From: "Pap Taylor" <pap@sotonians.net>
Subject: Re: Which ISPs support perl scripts?
Message-Id: <1006454985.19613.1@iapetus>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9vq1fp.sk5.tadmc@tadmc26.august.net...
> Chris Clarke <mad-biker@couplands-well.freeserve.co.uk> wrote:
<snip - well just about everything actually>
Largely agree with your sentiments Tad, but remember that part of the joy in
programming is seeing what you can do right now.
Writing CGI stuff in Perl is a good way to do that.
I mean, where would we be if Luke Skywalker had waited "until he completed
with his training", instead of making that inspired run on the Death Star?
P.
------------------------------
Date: Thu, 22 Nov 2001 19:05:34 GMT
From: owain@nospam.demon.co.uk (Owain McGuire)
Subject: Re: Which ISPs support perl scripts?
Message-Id: <3bfd4b80.174598719@news.demon.co.uk>
On Thu, 22 Nov 2001 15:32:54 GMT, tadmc@augustmail.com (Tad McClellan)
wrote:
>Chris Clarke <mad-biker@couplands-well.freeserve.co.uk> wrote:
>
>>As an absolute perl beginner... how do I find an ISP which supports perl
>>scripts?
>
>
>I recommend that you don't try to learn both the application area (CGI)
>and the programming language at the same time.
>
>Learn Perl first. When you are comfortable with Perl, then move
>on to whatever application area you wish to apply Perl to.
I learn't both at the same time. Not a problem if you have some
programming experience in anything. Excellent book called CGI
programming in Perl published by O'Reiley.
The thing that took the time was ibuilding a local development
environment i.e. Apache, MySql, DBI and various modules etc. Oh and I
had never used Linux before so I had to install that too.
>
>You can make a great deal of progress learning before you need
>to find an ISP or pay for anything.
>
>
>First install the perl distribution on your local computer and
>learn Perl programming.
>
>Then install a free web server on your local computer, and learn
>how to make Perl communicate following the Common Gateway Interface.
>
>
>Now you can program from both the command line and in a CGI
>environment and learn/debug to your heart's content.
>
>You can develop your code without an ISP, without internet
>access even.
>
>Once you have it running well at your house and you're ready
>to make it "live" on a web server on the 'net, _then_ you need
>to find an ISP.
>
>
>--
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------
Owain McGuire owain@nospam.ofrm.demon.co.uk (Minus the nospam.)
------------------------------
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 2184
***************************************