[31779] in Perl-Users-Digest
Perl-Users Digest, Issue: 3042 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 23 18:09:25 2010
Date: Fri, 23 Jul 2010 15:09:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 23 Jul 2010 Volume: 11 Number: 3042
Today's topics:
Can't locate Unix/Whereis.pm in @INC <kadoudal@gmail.com>
Re: Can't locate Unix/Whereis.pm in @INC <glex_no-spam@qwest-spam-no.invalid>
Confusion about the smart matching operator <jl_post@hotmail.com>
Re: Confusion about the smart matching operator <derykus@gmail.com>
Re: Confusion about the smart matching operator <jl_post@hotmail.com>
Re: Confusion about the smart matching operator (Alan Curry)
exist function in perl 5.12.1 <dilbert1999@gmail.com>
Re: exist function in perl 5.12.1 <jl_post@hotmail.com>
Re: exist function in perl 5.12.1 <dilbert1999@gmail.com>
Re: exist function in perl 5.12.1 <uri@StemSystems.com>
Re: FAQ 5.29 How can I read in an entire file all at on <brian.d.foy@gmail.com>
Re: FAQ 5.29 How can I read in an entire file all at on <uri@StemSystems.com>
Re: FAQ 5.29 How can I read in an entire file all at on <tw@dionic.net>
Re: FAQ 9.14 How do I make sure users can't enter value <brian.d.foy@gmail.com>
Re: FAQ 9.25 How do I fetch/put an FTP file? <brian.d.foy@gmail.com>
Re: Need help/advice to improve script <hjp-usenet2@hjp.at>
Re: Need help/advice to improve script sln@netherlands.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 23 Jul 2010 05:59:31 -0700 (PDT)
From: kadoudal <kadoudal@gmail.com>
Subject: Can't locate Unix/Whereis.pm in @INC
Message-Id: <88307f4b-cb8e-4b14-a34b-f0c259faecfa@q22g2000yqm.googlegroups.com>
Hi
I am new to Perl, and I try to run a Perl script which is giving me an
error on the first line :
use Unix::Whereis; => Can't locate Unix/Whereis.pm in @IN(...
(I believe a module is missing ... I am using the pre-installed Perl
on Mac OSX 10.6 (Snow)
should I need to add anything to my install ? (whereis command is
running welll in the console)
or just to add any path somewhere ?
thanks
[beginning of my Perl script]
----------
#!/usr/bin/perl
use Unix::Whereis;
my $ffmpeg = Unix::Whereis::whereis('ffmpeg', { 'fallback'
=gt; '1' }); # || or die "Could not find ffmpeg!";
....
[log error ]
Can't locate Unix/Whereis.pm in @INC (@INC contains: /Library/Perl/
Updates/5.10.0/darwin-thread-multi-2level /Library/Perl/Updates/
5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/
Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /
Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-
multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /
System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/
Library/Perl/Extras/5.10.0 .)
------------------------------
Date: Fri, 23 Jul 2010 10:16:18 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Can't locate Unix/Whereis.pm in @INC
Message-Id: <4c49b243$0$89391$815e3792@news.qwest.net>
kadoudal wrote:
> Hi
> I am new to Perl, and I try to run a Perl script which is giving me an
> error on the first line :
>
> use Unix::Whereis; => Can't locate Unix/Whereis.pm in @IN(...
I can't locate it anywhere. Where did you see/find the documentation?
>
> (I believe a module is missing ... I am using the pre-installed Perl
> on Mac OSX 10.6 (Snow)
>
> should I need to add anything to my install ? (whereis command is
> running welll in the console)
Hu?
> or just to add any path somewhere ?
>
> thanks
>
> [beginning of my Perl script]
> ----------
> #!/usr/bin/perl
>
> use Unix::Whereis;
> my $ffmpeg = Unix::Whereis::whereis('ffmpeg', { 'fallback'
> =gt; '1' }); # || or die "Could not find ffmpeg!";
------------------------------
Date: Fri, 23 Jul 2010 09:00:20 -0700 (PDT)
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Confusion about the smart matching operator
Message-Id: <a4526931-df5f-4acd-9b48-66e5143f9a09@i31g2000yqm.googlegroups.com>
Hi,
I've been reading up on the smart matching operator ('~~') in
"perldoc perlsyn", and I have to say I'm a little confused on a
certain aspect of it.
Say I have an array like:
my @a = ('cat', 'dog', 55);
If I want to discover if any of its elements contains only digits,
I can use the '~~' operator against a regular expression, like this:
if ( @a ~~ m/^\d+$/ ) # prints "true"
{
print "true";
}
else
{
print "false"
}
In this respect, the smart matching operator behaves like an "any()"
function, returning a true value if any element matches.
But if I wanted to discover if any of its elements looks like a
number with the Scalar::Util::looks_like_number() function in a code
reference, like this:
use Scalar::Util qw(looks_like_number);
if ( @a ~~ sub { looks_like_number($_[0]) } ) # prints "false"
{
print "true";
}
else
{
print "false"
}
the smart matching operator will return a false value. In this case,
the smart matching operator behaves like an "all()" function,
returning a true value only if every element returns true (or there
are no elements that return false).
So "Array ~~ Regex" returns true in any elements evaluate to true,
but "Array ~~ CodeRef" returns true only if all elements evaluate to
true.
I find this a bit counter-intuitive. Is there any logic behind
this behavior? (I'm asking because I find it difficult to remember
which one behaves like any() and which one behaves like all(), since
the distinction seems arbitrary to me.)
I've discovered that if I want "Array ~~ Regex" to behave like an
all() function, I can basically rewrite it by wrapping it in a
CodeRef, like this:
if ( @a ~~ sub { $_[0] =~ m/^\d+$/ } ) # evaluates to false
However, if I want "Array ~~ CodeRef" to behave like an any()
function, I have to resort to using De Morgan's laws and write it like
this:
if (not( @a ~~ sub { not looks_like_number($_[0]) } )) # evaluates
to true
This works, but I find that this makes the code confusing to read (and
to maintain).
Is there a better way to get "Array ~~ CodeRef" to behave like an
any() function? (Without abandoning the '~~' operator, that is.) I'm
aware that I can do this:
if ( grep { looks_like_number($_) } @a ) # evaluates to true
but I know from experience that many seasoned Perl coders are against
this approach. I also know of this approach documented in "perldoc
List::Util :
sub any { looks_like_number($_) && return 1 for @_; 0 }
if ( any(@a) ) # evaluates to true
but I'd rather not write a new subroutine every time I need the any()
behavior.
So basically I'm asking two things:
1.) Why does "Array ~~ Regex" act like any() whereas "Array ~~
CodeRef" act like all()? (In other words, why the discrepancy?)
and:
2.) Is there a simple/elegant way to get "Array ~~ CodeRef" to behave
like an any() function (like "Array ~~ Regex" does)?
Thanks in advance for any advice.
-- Jean-Luc
------------------------------
Date: Fri, 23 Jul 2010 14:00:10 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: Confusion about the smart matching operator
Message-Id: <45c2e7e4-f440-42f0-9ecd-9d0ed25f664f@g6g2000pro.googlegroups.com>
On Jul 23, 9:00=A0am, "jl_p...@hotmail.com" <jl_p...@hotmail.com> wrote:
> Hi,
>
> =A0 =A0I've been reading up on the smart matching operator ('~~') in
> "perldoc perlsyn", and I have to say I'm a little confused on a
> certain aspect of it.
>
> =A0 =A0Say I have an array like:
>
> =A0 =A0my @a =3D ('cat', 'dog', 55);
>
> =A0 =A0If I want to discover if any of its elements contains only digits,
> I can use the '~~' operator against a regular expression, like this:
>
> =A0 =A0if ( @a ~~ m/^\d+$/ ) =A0# prints "true"
> =A0 =A0{
> =A0 =A0 =A0 print "true";
> =A0 =A0}
> =A0 =A0else
> =A0 =A0{
> =A0 =A0 =A0 print "false"
> =A0 =A0}
>
> In this respect, the smart matching operator behaves like an "any()"
> function, returning a true value if any element matches.
>
> =A0 =A0But if I wanted to discover if any of its elements looks like a
> number with the Scalar::Util::looks_like_number() function in a code
> reference, like this:
>
> =A0 =A0use Scalar::Util qw(looks_like_number);
> =A0 =A0if ( @a ~~ sub { looks_like_number($_[0]) } ) =A0# prints "false"
> =A0 =A0{
> =A0 =A0 =A0 print "true";
> =A0 =A0}
> =A0 =A0else
> =A0 =A0{
> =A0 =A0 =A0 print "false"
> =A0 =A0}
>
> the smart matching operator will return a false value. =A0In this case,
> the smart matching operator behaves like an "all()" function,
> returning a true value only if every element returns true (or there
> are no elements that return false).
>
> =A0 =A0So "Array ~~ Regex" returns true in any elements evaluate to true,
> but "Array ~~ CodeRef" returns true only if all elements evaluate to
> true.
>
> =A0 =A0I find this a bit counter-intuitive. =A0Is there any logic behind
> this behavior? =A0(I'm asking because I find it difficult to remember
> which one behaves like any() and which one behaves like all(), since
> the distinction seems arbitrary to me.)
>
> =A0 =A0I've discovered that if I want "Array ~~ Regex" to behave like an
> all() function, I can basically rewrite it by wrapping it in a
> CodeRef, like this:
>
> =A0 =A0if ( @a ~~ sub { $_[0] =3D~ m/^\d+$/ } ) =A0# evaluates to false
>
> =A0 =A0However, if I want "Array ~~ CodeRef" to behave like an any()
> function, I have to resort to using De Morgan's laws and write it like
> this:
>
> =A0 =A0if (not( @a ~~ sub { not looks_like_number($_[0]) } )) =A0# evalua=
tes
> to true
>
> This works, but I find that this makes the code confusing to read (and
> to maintain).
>
> =A0 =A0Is there a better way to get "Array ~~ CodeRef" to behave like an
> any() function? =A0(Without abandoning the '~~' operator, that is.) =A0I'=
m
> aware that I can do this:
>
> =A0 =A0if ( grep { looks_like_number($_) } @a ) =A0# evaluates to true
>
> but I know from experience that many seasoned Perl coders are against
> this approach. =A0I also know of this approach documented in "perldoc
> List::Util :
>
> =A0 =A0sub any { looks_like_number($_) && return 1 for @_; 0 }
> =A0 =A0if ( any(@a) ) =A0# evaluates to true
>
> but I'd rather not write a new subroutine every time I need the any()
> behavior.
>
Wouldn't the short-circuiting List::Util::first or
List::MoreUtils::any fit the bill then...?
if ( List::Util::first { looks_like_number($_) } @a ) {...}
if ( List::MoreUtils::any { looks_like_number($_) } @a {...}
>
> =A0 =A0So basically I'm asking two things:
>
> 1.) =A0Why does "Array ~~ Regex" act like any() whereas "Array ~~
> CodeRef" act like all()? =A0(In other words, why the discrepancy?)
>
> =A0 =A0and:
>
> 2.) =A0Is there a simple/elegant way to get "Array ~~ CodeRef" to behave
> like an any() function (like "Array ~~ Regex" does)?
>
Maybe something such as this:
use feature 'state';
if ( @a ~~ sub{ state $r; $r //=3D
L::U::first {looks_like_number($_)} @a
} )
...
--
Charles DeRykus
------------------------------
Date: Fri, 23 Jul 2010 14:35:28 -0700 (PDT)
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: Confusion about the smart matching operator
Message-Id: <72bd5ca1-eb51-4faf-8954-013395ccdd8a@g35g2000yqa.googlegroups.com>
> On Jul 23, 9:00=A0am, "jl_p...@hotmail.com" <jl_p...@hotmail.com> wrote:
>
> > but I'd rather not write a new subroutine every time I need the any()
> > behavior.
On Jul 23, 3:00=A0pm, "C.DeRykus" <dery...@gmail.com> replied:
>
> Wouldn't the short-circuiting List::Util::first or
> List::MoreUtils::any fit the bill then...?
>
> if ( List::Util::first { looks_like_number($_) } @a ) {...}
>
> if ( List::MoreUtils::any { looks_like_number($_) } @a {...}
Ah, List::MoreUtils is exactly what I'm looking for. Thanks.
Unfortunately, List::MoreUtils doesn't seem to be a standard module
(at least according to http://perldoc.perl.org/index-modules-L.html).
So on platforms where I can only depend on standard modules I
suppose I can use List::Util::first() instead, as long as the set of
values I'm looking for can never be undefined. (Otherwise, I wouldn't
know if I got a proper match, or if no match at all was found.)
(So now I know a nice work-around to getting "Array ~~ CodeRef"
any() behavior, but I still don't know the reason behind the "Array ~~
Regex" and "Array ~~ CodeRef" any/all discrepancy.)
Thanks again for the response, Charles. It was useful.
Cheers,
-- Jean-Luc
------------------------------
Date: Fri, 23 Jul 2010 21:55:25 +0000 (UTC)
From: pacman@kosh.dhis.org (Alan Curry)
Subject: Re: Confusion about the smart matching operator
Message-Id: <i2d34d$big$1@speranza.aioe.org>
In article <a4526931-df5f-4acd-9b48-66e5143f9a09@i31g2000yqm.googlegroups.com>,
jl_post@hotmail.com <jl_post@hotmail.com> wrote:
>
> use Scalar::Util qw(looks_like_number);
> if ( @a ~~ sub { looks_like_number($_[0]) } ) # prints "false"
> {
> print "true";
> }
> else
> {
> print "false"
> }
>
>the smart matching operator will return a false value. In this case,
>the smart matching operator behaves like an "all()" function,
No it doesn't.
Try it with @a=(1,2,3); it's still false.
The coderef is only called once, with \@a as the argument. You passed an
arrayref to looks_like_number, which is going to be false no matter what.
You're right about one thing at least: it's not easy to predict what ~~ will
do based on the documentation.
--
Alan Curry
------------------------------
Date: Fri, 23 Jul 2010 09:40:06 -0700 (PDT)
From: Dilbert <dilbert1999@gmail.com>
Subject: exist function in perl 5.12.1
Message-Id: <3c91c2e6-1554-4d7b-a35b-29f57a99d4a6@t10g2000yqg.googlegroups.com>
In perl 5.12.1, with reference to the exist function "perldoc -f
exist" ( see also http://perldoc.perl.org/functions/exists.html ) it
says
>> [...]
>> Although the mostly deeply nested array or hash will
>> not spring into existence just because its existence
>> was tested, any intervening ones will. Thus $ref->{"A"}
>> and $ref->{"A"}->{"B"} will spring into existence due to
>> the existence test for the $key element above.
>> [...]
>> This surprising autovivification in what does not at first
>> --or even second-- glance appear to be an lvalue context
>> may be fixed in a future release.
Has this particular case of surprising autovivification always
existed, even in perl 5.10 or 5.8 ?
------------------------------
Date: Fri, 23 Jul 2010 10:04:59 -0700 (PDT)
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: exist function in perl 5.12.1
Message-Id: <e6dbbdc4-2ef1-43a2-a4d1-49827cc82759@g19g2000yqc.googlegroups.com>
On Jul 23, 10:40=A0am, Dilbert <dilbert1...@gmail.com> wrote:
> In perl 5.12.1, with reference to the exist function "perldoc -f
> exist" ( see alsohttp://perldoc.perl.org/functions/exists.html) it
> says
>
> >> [...]
> >> Although the mostly deeply nested array or hash will
> >> not spring into existence just because its existence
> >> was tested, any intervening ones will. Thus $ref->{"A"}
> >> and $ref->{"A"}->{"B"} =A0will spring into existence due to
> >> the existence test for the $key element above.
> >> [...]
> >> This surprising autovivification in what does not at first
> >> --or even second-- glance appear to be an lvalue context
> >> may be fixed in a future release.
>
> Has this particular case of surprising autovivification always
> existed, even in perl 5.10 or 5.8 ?
I believe so, yes. Ever since autovivification existed, this has
always been a caveat to watch out for. And I think autovivification
has been around for all of Perl 5. (But if I'm mistaken, feel free to
correct me.)
Cheers,
-- Jean-Luc
------------------------------
Date: Fri, 23 Jul 2010 12:01:14 -0700 (PDT)
From: Dilbert <dilbert1999@gmail.com>
Subject: Re: exist function in perl 5.12.1
Message-Id: <5874e501-b631-4d13-a06c-7428d9a07073@s9g2000yqd.googlegroups.com>
On 23 juil, 19:04, "jl_p...@hotmail.com" <jl_p...@hotmail.com> wrote:
> On Jul 23, 10:40=A0am, Dilbert <dilbert1...@gmail.com> wrote:
> > In perl 5.12.1, with reference to the exist function "perldoc -f
> > exist" ( see alsohttp://perldoc.perl.org/functions/exists.html) it
> > says
>
> > >> [...]
> > >> Although the mostly deeply nested array or hash will
> > >> not spring into existence just because its existence
> > >> was tested, any intervening ones will. Thus $ref->{"A"}
> > >> and $ref->{"A"}->{"B"} =A0will spring into existence due to
> > >> the existence test for the $key element above.
> > >> [...]
> > >> This surprising autovivification in what does not at first
> > >> --or even second-- glance appear to be an lvalue context
> > >> may be fixed in a future release.
>
> > Has this particular case of surprising autovivification always
> > existed, even in perl 5.10 or 5.8 ?
>
> =A0 =A0I believe so, yes. =A0Ever since autovivification existed, this ha=
s
> always been a caveat to watch out for. =A0And I think autovivification
> has been around for all of Perl 5. =A0(But if I'm mistaken, feel free to
> correct me.)
I think you are right.
I managed to dig up perldoc.com for version 5.8.8 and it has exactly
the same description with regards to the exists function:
http://perldoc.perl.org/5.8.8/functions/exists.html
>> This surprising autovivification in what does not at first -- or even
>> second -- glance appear to be an lvalue context may be fixed in
>> a future release.
Let's hope that the surprising autovivification will be fixed in Perl
5.14
------------------------------
Date: Fri, 23 Jul 2010 15:29:49 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: exist function in perl 5.12.1
Message-Id: <87eieuxahe.fsf@quad.sysarch.com>
>>>>> "D" == Dilbert <dilbert1999@gmail.com> writes:
D> Let's hope that the surprising autovivification will be fixed in Perl
D> 5.14
let's hope not! exists was just a function that provided no information
to the hash expression it was checking. the autoviv happens in the hash
lookup no matter what the outer code is doing. changing that could break
existing code which is a bad thing and the p5p people know that. perl 6
is planning on changing that. maybe a future perl could deal with this
but only enabled under a pragma like other new features.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Fri, 23 Jul 2010 13:56:54 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 5.29 How can I read in an entire file all at once?
Message-Id: <230720101356543760%brian.d.foy@gmail.com>
In article <87mxu7j08z.fsf@quad.sysarch.com>, Uri Guttman
<uri@StemSystems.com> wrote:
> i disagree with that last point. mmap always needs virtual ram allocated
> for the entire file to be mapped. it only saves ram if you map part of
> the file into a smaller virtual window.
I haven't found that to be the case for program memory at least. If you
copy parts of the file you have to copy, but
> again, i disagree. you can easily benchmark slurping an array of lines
> and looping vs line by line reading.
Well, the tension there is the trade-off between space and memory. I
could make that more clear I guess.
I will look at some benchmarks, though, and see how that illuminates
the situation.
------------------------------
Date: Fri, 23 Jul 2010 15:27:02 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: FAQ 5.29 How can I read in an entire file all at once?
Message-Id: <87iq46xam1.fsf@quad.sysarch.com>
>>>>> "bdf" == brian d foy <brian.d.foy@gmail.com> writes:
bdf> In article <87mxu7j08z.fsf@quad.sysarch.com>, Uri Guttman
bdf> <uri@StemSystems.com> wrote:
>> i disagree with that last point. mmap always needs virtual ram allocated
>> for the entire file to be mapped. it only saves ram if you map part of
>> the file into a smaller virtual window.
bdf> I haven't found that to be the case for program memory at least. If you
bdf> copy parts of the file you have to copy, but
mmap still needs space in the program. it may be allocated with malloc
or even builtin these days (haven't used it directly in decades! :). now
real ram could be saved but that is true for all virtual memory use. if
you seek into the mmap space and only read/write parts, then the other
sections won't be touched. so the issue comes down to random access vs
processing a whole file. most uses of slurp are for processing a whole
file so i would lean in that direction. someone sophisticated enough to
use mmap directly for random access should know the resource usage issues.
>> again, i disagree. you can easily benchmark slurping an array of lines
>> and looping vs line by line reading.
bdf> Well, the tension there is the trade-off between space and memory. I
bdf> could make that more clear I guess.
classic tradeoff. but again, these days almost all files you need to
slurp are small relative to ram (real and virtual) sizes. a 1 MB file is
nothing on a 1 GB system. but few text files are as big as 1MB. way back
when, reading line by line was almost required due to ram constraints
but ram size has way outgrown file size increases. i just want to change
the prevailing view a bit. and as i have said some things are only
doable when you have the full file in ram vs line by line.
bdf> I will look at some benchmarks, though, and see how that illuminates
bdf> the situation.
a simple one is slurping a simple config file and doing a basic parse on
it to make a hash. i have posted that code before. it would be easy to
compare that to a line by line version of that. the slurp will blow it
away as it does one s/// op and slurps the file. the line by line has to
parse each line individually and also read in each line. more perl code
and more perl guts code.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Fri, 23 Jul 2010 22:47:14 +0100
From: Tim Watts <tw@dionic.net>
Subject: Re: FAQ 5.29 How can I read in an entire file all at once?
Message-Id: <i2d2l4$fei$1@news.eternal-september.org>
Uri Guttman <uri@StemSystems.com>
wibbled on Sunday 04 July 2010 06:15
> i disagree with that last point. mmap always needs virtual ram allocated
> for the entire file to be mapped. it only saves ram if you map part of
> the file into a smaller virtual window. the win of mmap is that it won't
> do the i/o until you touch a section. so if you want random access to
> sections of a file, mmap is a big win. if you are going to just process
> the whole file, there isn't any real win over File::Slurp
I think it is worth some clarification - at least under linux:
mmap requires virtual address space, not RAM per se, for the initial mmap.
Obviously as soon as you try to read any part of the file, those blocks must
be paged in to actual RAM pages.
However, if you then ignore those pages and have not modified them, the LRU
recovery sweeper can just drop those pages.
Compare to if you slurp the file into some virtual RAM that's been malloc'd:
The RAM pages are all dirty (because you copied data into them) - so if the
system needs to reduce the working page set, it will have to page those out
to swap rather than just dropping them - it no longer has the knowledge that
they are in practise backed by the original file.
So mmap is generally more efficient AFAIUI
--
Tim Watts
Managers, politicians and environmentalists: Nature's carbon buffer.
------------------------------
Date: Fri, 23 Jul 2010 13:47:29 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 9.14 How do I make sure users can't enter values into a form that cause my CGI script to do bad things?
Message-Id: <230720101347298957%brian.d.foy@gmail.com>
In article <m14jh7-gav.ln1@zem.masonsmusic.co.uk>, Justin C
<justin.1007@purestblue.com> wrote:
> > 9.14: How do I make sure users can't enter values into a form that cause my
> > CGI script to do bad things?
> > http://www.perl.org/CGI_MetaFAQ.html
>
> That page redirects to:
>
> <URL:http://brian-d-foy.cvs.sourceforge.net/viewvc/brian-d-foy/CGI_MetaFAQ/CGI
> _MetaFAQ.html>
>
> and three out of the five links in the Security section fail to open.
> Two 404s and one server that has gone away - this may be temporary.
I will look into this. Thanks.
------------------------------
Date: Fri, 23 Jul 2010 13:48:00 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 9.25 How do I fetch/put an FTP file?
Message-Id: <230720101348000792%brian.d.foy@gmail.com>
In article <m2630arxqe.fsf@shermpendley.com>, Sherm Pendley
<spamtrap@shermpendley.com> wrote:
> PerlFAQ Server <brian@theperlreview.com> writes:
>
> > 9.25: How do I fetch/put an FTP file?
> >
> > "LWP::Simple" (available from CPAN) can fetch but not put. "Net::FTP"
> > (also available from CPAN) is more complex but can put as well as fetch.
>
> Net::FTP is a core module since at least 5.8.1 - maybe earlier too,
> but that's the oldest version I have at hand to check.
I'll update this. Thanks,
------------------------------
Date: Fri, 23 Jul 2010 17:33:50 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Need help/advice to improve script
Message-Id: <slrni4jdiu.1aj.hjp-usenet2@hrunkner.hjp.at>
On 2010-07-22 18:22, sln@netherlands.com <sln@netherlands.com> wrote:
> $line =~ /^
> ([^:]*)
> : (?<pass> [^:]*)
> : (?<emails> [^:]*)
> :? (?<flag> [^:]*)
> :? (?<pass_change> [^:]*)
> :? (?<flag_change> .*)
> $/x
> and $data->{$1} = {%+};
That's nice. I guess one of these days I should try to get rid of 5.8.x
so that I can finally start to use 5.10 features ...
hp
------------------------------
Date: Fri, 23 Jul 2010 14:39:18 -0700
From: sln@netherlands.com
Subject: Re: Need help/advice to improve script
Message-Id: <2p2k46tsmo287vcqj3vtqifsqfob8kuqgv@4ax.com>
On Fri, 23 Jul 2010 17:33:50 +0200, "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>On 2010-07-22 18:22, sln@netherlands.com <sln@netherlands.com> wrote:
>> $line =~ /^
>> ([^:]*)
>> : (?<pass> [^:]*)
>> : (?<emails> [^:]*)
>> :? (?<flag> [^:]*)
>> :? (?<pass_change> [^:]*)
>> :? (?<flag_change> .*)
>> $/x
>> and $data->{$1} = {%+};
>
>That's nice. I guess one of these days I should try to get rid of 5.8.x
>so that I can finally start to use 5.10 features ...
>
> hp
Named capture buffers are a nice feature, made for this kind of thing.
-sln
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 3042
***************************************