[23136] in Perl-Users-Digest
Perl-Users Digest, Issue: 5357 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 14 09:10:38 2003
Date: Thu, 14 Aug 2003 06:10:12 -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 Thu, 14 Aug 2003 Volume: 10 Number: 5357
Today's topics:
Re: Problem using Benchmark <abigail@abigail.nl>
Re: Problem using Benchmark <tassilo.parseval@rwth-aachen.de>
Re: Problem using Benchmark <abigail@abigail.nl>
Re: Problem using Benchmark <tassilo.parseval@rwth-aachen.de>
Re: Problem using Benchmark (James E Keenan)
Re: Problem with join and unicode <abuseonly@sgrail.org>
Re: Problem with join and unicode <tassilo.parseval@rwth-aachen.de>
Re: Problem with join and unicode <abuseonly@sgrail.org>
Re: replace space only within quotes with something els <sunil_franklin@hotmail.com>
Re: replace space only within quotes with something els <tassilo.parseval@rwth-aachen.de>
Re: replace space only within quotes with something els <sunil_franklin@hotmail.com>
Re: Simple tr/// script <abigail@abigail.nl>
Re: Simple tr/// script <mikeflan@earthlink.net>
Re: Simple tr/// script <mikeflan@earthlink.net>
Re: Simple tr/// script <mikeflan@earthlink.net>
Re: Suggestions for further perl reading <abigail@abigail.nl>
Re: Two questions about perl <simon.andrews@bbsrc.ac.uk>
Re: using Getopt::Long with option value having spaces <bart.lateur@pandora.be>
Re: using Getopt::Long with option value having spaces <flavell@mail.cern.ch>
Re: Why doesn't this work? <usenet@expires082003.tinita.de>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Aug 2003 09:20:26 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Problem using Benchmark
Message-Id: <slrnbjml2q.3a0.abigail@alexandra.abigail.nl>
Chris Charley (charley@pulsenet.com) wrote on MMMDCXXXV September
MCMXCIII in <URL:news:4f7ed6d.0308131630.37814d3e@posting.google.com>:
## Hi
##
## I hope someone might point out the obvious error in my benchmark tests.
## One test concatenates strings to a string and the other pushes them
## onto an array. I tried the debugger (not Benchmark debug, which is
## probably the right one, but I don't know how to use), and tried to find the
## problem but perl debug won't let me step through the code. It will when
## the code is enclosed in sub blocks (and not as strings to be eval'd?).
## The test for forming arrays gave results (below) that were in the
## millions (joins 1752848/s) but the test using concatenation gave results in
## the thousands (joins 2116/s ). Below are the 2 tests and the resulting
## runs for various input parameters. Note that for the 2 different tests, one
## was run with Benchmark count 4,000 and the other for count of 4,000,000.
## Thanks in advance for any suggestions or help offered. The order of
## command line arguments is:
## my ($count, $size_list, $string_size, $loops) = @ARGV;
##
##
## Chris
##
## ##########################################################################
## ##########################################################################
## #!/usr/bin/perl
## # concat5_ar.pl
## # Benchmark concat vs. join vs. interpolate when returning arrays
## use strict;
## use warnings;
## use Benchmark qw( timethese cmpthese ) ;
##
## # Enter count, size_list string_size and # loops from the command line
## my ($count, $size_list, $string_size, $loops) = @ARGV;
## my $string = "." x $string_size;
## my @strings = ($string) x $size_list;
##
## print "COUNT=$count, LIST_SIZE=$size_list, STRING_SIZE: $string_size, ";
## print "LOOPS=$loops\n";
##
## my $r = cmpthese( $count, {
## joins => q {
## my @join;
## push @join, join(' ', @strings) for 1..$loops;
## },
## concat => q {
## my $concat;
## my @concat;
## for (1..$loops) {
## $concat .= "$_ " for @strings;
## push @concat, $concat;
## }
## },
## interpolate => q {
## my @interp;
## push @interp, "@strings" for 1..$loops;
## },
## } );
You've falled into the first trap I mentioned during by Benchmark
talk on YAPC::NA. Your variables '$loops' and '@strings' are lexical
to your main program. There is *NO* way the Benchmark module could
access them, save playing with source filters. That's the purpose
of lexical variables.
Make them package variables, and try again.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'
------------------------------
Date: 14 Aug 2003 09:49:06 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Problem using Benchmark
Message-Id: <bhflui$hla$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Abigail:
> Chris Charley (charley@pulsenet.com) wrote on MMMDCXXXV September
> MCMXCIII in <URL:news:4f7ed6d.0308131630.37814d3e@posting.google.com>:
> ## ##########################################################################
> ## ##########################################################################
> ## #!/usr/bin/perl
> ## # concat5_ar.pl
> ## # Benchmark concat vs. join vs. interpolate when returning arrays
> ## use strict;
> ## use warnings;
> ## use Benchmark qw( timethese cmpthese ) ;
> ##
> ## # Enter count, size_list string_size and # loops from the command line
> ## my ($count, $size_list, $string_size, $loops) = @ARGV;
> ## my $string = "." x $string_size;
> ## my @strings = ($string) x $size_list;
> ##
> ## print "COUNT=$count, LIST_SIZE=$size_list, STRING_SIZE: $string_size, ";
> ## print "LOOPS=$loops\n";
> ##
> ## my $r = cmpthese( $count, {
> ## joins => q {
> ## my @join;
> ## push @join, join(' ', @strings) for 1..$loops;
> ## },
> ## concat => q {
> ## my $concat;
> ## my @concat;
> ## for (1..$loops) {
> ## $concat .= "$_ " for @strings;
> ## push @concat, $concat;
> ## }
> ## },
> ## interpolate => q {
> ## my @interp;
> ## push @interp, "@strings" for 1..$loops;
> ## },
> ## } );
> You've falled into the first trap I mentioned during by Benchmark
> talk on YAPC::NA. Your variables '$loops' and '@strings' are lexical
> to your main program. There is *NO* way the Benchmark module could
> access them, save playing with source filters. That's the purpose
> of lexical variables.
>
> Make them package variables, and try again.
Rather than that, I'd use code-references instead of strings:
[...]
joins => sub {
my @join;
push @join, join(' ', @strings) for 1..$loops;
},
concat => sub { ...
Actually, I'd never use a string for the code to be benchmarked. AFAIK
it does not provide any additional value over code-references (other
than inserting subtle bugs as shown here).
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 14 Aug 2003 09:59:24 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Problem using Benchmark
Message-Id: <slrnbjmnbs.3s3.abigail@alexandra.abigail.nl>
Tassilo v. Parseval (tassilo.parseval@rwth-aachen.de) wrote on MMMDCXXXV
September MCMXCIII in <URL:news:bhflui$hla$1@nets3.rz.RWTH-Aachen.DE>:
!!
!! Rather than that, I'd use code-references instead of strings:
!!
!! [...]
!! joins => sub {
!! my @join;
!! push @join, join(' ', @strings) for 1..$loops;
!! },
!! concat => sub { ...
!!
!! Actually, I'd never use a string for the code to be benchmarked. AFAIK
!! it does not provide any additional value over code-references (other
!! than inserting subtle bugs as shown here).
I seldomly use code references, as the provide no additional value
over strings. The drawback of using code references is that calling
subs is expensive, and they might cost more than the thing you are
trying to benchmark.
Abigail
--
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/ xor !@ _?
exit print :
print and push @_ => shift and goto &{(caller (0)) [3]}}
split // => "KsvQtbuf fbsodpmu\ni flsI " xor & _
------------------------------
Date: 14 Aug 2003 11:13:38 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Problem using Benchmark
Message-Id: <bhfqt2$md7$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Abigail:
> Tassilo v. Parseval (tassilo.parseval@rwth-aachen.de) wrote on MMMDCXXXV
> September MCMXCIII in <URL:news:bhflui$hla$1@nets3.rz.RWTH-Aachen.DE>:
> !!
> !! Rather than that, I'd use code-references instead of strings:
> !!
> !! [...]
> !! joins => sub {
> !! my @join;
> !! push @join, join(' ', @strings) for 1..$loops;
> !! },
> !! concat => sub { ...
> !!
> !! Actually, I'd never use a string for the code to be benchmarked. AFAIK
> !! it does not provide any additional value over code-references (other
> !! than inserting subtle bugs as shown here).
>
>
> I seldomly use code references, as the provide no additional value
> over strings. The drawback of using code references is that calling
> subs is expensive, and they might cost more than the thing you are
> trying to benchmark.
We are talking about benchmarks here. Benchmark.pm's purpose is not to
provide absolute figures about the performance of a piece of code. It's
used to find out how snippets of code behave in comparison to each
other.
So the only case in which you may get inaccurate results is when the
code you benchmark is so trivial that its execution time is a fraction
of that needed to call a Perl function. And such code is usually not
worth a benchmark at all.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 14 Aug 2003 05:45:17 -0700
From: jkeen@concentric.net (James E Keenan)
Subject: Re: Problem using Benchmark
Message-Id: <b955da04.0308140445.479cb805@posting.google.com>
charley@pulsenet.com (Chris Charley) wrote in message news:<4f7ed6d.0308131630.37814d3e@posting.google.com>...
> Hi
>
> I hope someone might point out the obvious error in my benchmark tests.
I was able to copy-and-paste your code and run it with the arguments
you used. It ran properly. So the error is not "obvious" to me.
What were you expecting to happen?
------------------------------
Date: Thu, 14 Aug 2003 08:55:21 GMT
From: derek / nul <abuseonly@sgrail.org>
Subject: Re: Problem with join and unicode
Message-Id: <8gjmjv0qriagfs17c4st4aiqvjqghnhoht@4ax.com>
On Wed, 13 Aug 2003 21:06:59 -0500, tadmc@augustmail.com (Tad McClellan) wrote:
>
>derek / nul <abuseonly@sgrail.org> wrote:
>> open ENGWAG, "$File::Find::name"
>
>
>See also this Perl FAQ, then lose the double quotes:
>
> What's wrong with always quoting "$vars"?
Tad, I removed the quotes from this line and the program fails to run past the
first line in the eng file??
------------------------------
Date: 14 Aug 2003 09:43:03 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Problem with join and unicode
Message-Id: <bhflj7$ha3$1@nets3.rz.RWTH-Aachen.DE>
Also sprach derek / nul:
> On Wed, 13 Aug 2003 21:06:59 -0500, tadmc@augustmail.com (Tad
> McClellan) wrote:
>>
>>derek / nul <abuseonly@sgrail.org> wrote:
>
>>> open ENGWAG, "$File::Find::name"
>>
>>
>>See also this Perl FAQ, then lose the double quotes:
>>
>> What's wrong with always quoting "$vars"?
>
> Tad, I removed the quotes from this line and the program fails to run past the
> first line in the eng file??
You mean, when you write:
open ENGWAG, $File::Find::name or die $!;
you only get the first line from that file? I promise you that this is
not the case. There must be something else that you changed.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Thu, 14 Aug 2003 10:11:23 GMT
From: derek / nul <abuseonly@sgrail.org>
Subject: Re: Problem with join and unicode
Message-Id: <mvnmjv0coujrdhlci7b9d3hc6dhb4mmu3e@4ax.com>
On 14 Aug 2003 09:43:03 GMT, "Tassilo v. Parseval"
<tassilo.parseval@rwth-aachen.de> wrote:
>Also sprach derek / nul:
>
>> On Wed, 13 Aug 2003 21:06:59 -0500, tadmc@augustmail.com (Tad
>> McClellan) wrote:
>>>
>>>derek / nul <abuseonly@sgrail.org> wrote:
>>
>>>> open ENGWAG, "$File::Find::name"
>>>
>>>
>>>See also this Perl FAQ, then lose the double quotes:
>>>
>>> What's wrong with always quoting "$vars"?
>>
>> Tad, I removed the quotes from this line and the program fails to run past the
>> first line in the eng file??
>
>You mean, when you write:
>
> open ENGWAG, $File::Find::name or die $!;
>
>you only get the first line from that file? I promise you that this is
>not the case. There must be something else that you changed.
About 4 levels down the program, I am reading another file, and that one fails
at the end of the first line, ie where the \n is.
------------------------------
Date: Thu, 14 Aug 2003 13:14:41 +0530
From: "Sunil" <sunil_franklin@hotmail.com>
Subject: Re: replace space only within quotes with something else
Message-Id: <vcH_a.2$1p1.95@news.oracle.com>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnbjki2i.3jt.tadmc@magna.augustmail.com...
> Sunil <sunil_franklin@hotmail.com> wrote:
>
>
> > change all occurrences of space with some other characters, only if they
are
> > within double quotes
>
>
> s{ ( " [^"]* " ) } {
> $a = $1;
> $a =~ tr/ /#/;
> $a
> }xge;
>
Hi,
Sorry, this goes over my head can you give a complete example of how to
change the value in $str if
$str = 'this is my string';
Thanks,
Sunil.
------------------------------
Date: 14 Aug 2003 08:06:17 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: replace space only within quotes with something else
Message-Id: <bhfftp$bip$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Sunil:
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrnbjki2i.3jt.tadmc@magna.augustmail.com...
>> Sunil <sunil_franklin@hotmail.com> wrote:
>>
>>
>> > change all occurrences of space with some other characters, only if
>> > they are within double quotes
>>
>>
>> s{ ( " [^"]* " ) } {
>> $a = $1;
>> $a =~ tr/ /#/;
>> $a
>> }xge;
>>
> Sorry, this goes over my head can you give a complete example of how to
> change the value in $str if
> $str = 'this is my string';
The above is just an ordinary substitution, so you use it as usual:
$str =~ s{ ( " [^"]* " ) } {
$a = $1;
$a =~ tr/ /#/;
$a
}xge;
Tad used different delimiters ( {} ) and the /x modifier only to make it
more readable. If you prefer, you could also write it as:
$str =~ s/("[^"]*")/$a=$1;$=~tr/ /#/;$a/ge;
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Thu, 14 Aug 2003 14:13:29 +0530
From: "Sunil" <sunil_franklin@hotmail.com>
Subject: Re: replace space only within quotes with something else
Message-Id: <B3I_a.5$1p1.37@news.oracle.com>
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message
news:bhfftp$bip$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach Sunil:
>
> > "Tad McClellan" <tadmc@augustmail.com> wrote in message
> > news:slrnbjki2i.3jt.tadmc@magna.augustmail.com...
> >> Sunil <sunil_franklin@hotmail.com> wrote:
> >>
> >>
> >> > change all occurrences of space with some other characters, only if
> >> > they are within double quotes
> >>
> >>
> >> s{ ( " [^"]* " ) } {
> >> $a = $1;
> >> $a =~ tr/ /#/;
> >> $a
> >> }xge;
> >>
>
> > Sorry, this goes over my head can you give a complete example of how
to
> > change the value in $str if
> > $str = 'this is my string';
>
> The above is just an ordinary substitution, so you use it as usual:
>
> $str =~ s{ ( " [^"]* " ) } {
> $a = $1;
> $a =~ tr/ /#/;
> $a
> }xge;
>
> Tad used different delimiters ( {} ) and the /x modifier only to make it
> more readable. If you prefer, you could also write it as:
>
> $str =~ s/("[^"]*")/$a=$1;$=~tr/ /#/;$a/ge;
>
> Tassilo
> --
thanks a lot, now it works like a charm...
------------------------------
Date: 14 Aug 2003 09:11:07 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Simple tr/// script
Message-Id: <slrnbjmkhb.92t.abigail@alexandra.abigail.nl>
Bob Walton (bwalton@rochester.rr.com) wrote on MMMDCXXXV September
MCMXCIII in <URL:news:3F3AD310.90806@rochester.rr.com>:
@@ Mike Flannigan wrote:
@@
@@ ...
@@ > 1) The script runs as written, but gives an error after running
@@ > "Use of uninitialized value in transliteration (tr///) . . . at line 12,
@@ > <DATA> line 3." Then there are more errors about
@@ > concatenation at line 13 and 16.
@@ > Can anybody explain these errors for me. I can't figure it out.
@@ > I thought I was smart, but Perl is proving me wrong.
@@
@@
@@ The root of your problem is your two statements (shown here with
@@ commentary):
@@
@@ ...
@@ while (<DATA>) { #read a line from filehandle DATA to default
@@ #variable $_ and execute a block of code
@@ #if not end of file
@@ $ki = <DATA>; #read a line of code and put it in scalar $ki
@@ ...
@@
@@ So you see that you read a line of data, discard it, and read another
@@ line of data which you proceed to process. Then you repeat. So you
@@ process every second line of data. This problem also leads to why it is
@@ doing all the other undesired things you are complaining about.
@@
@@ Recognize that the construct <FILEHANDLE> in scalar context reads a line
@@ from FILEHANDLE, whether it is in a while loop or a scalar assignment,
@@ or anywhere else where a scalar context exists. In a list context, it
@@ will read the whole file in one gulp.
@@
@@ The fix? The second line above should be:
@@
@@ $ki=$_;
Ehm, no. Than you still have an inefficient, non-idiomatic way of
reading in the lines of a file into an array.
my @lines = <DATA>;
No while loop or pushes needed.
Of course, since the program is just processing the lines line-by-line,
there's no need to use an array at all.
while (<DATA>) {
tr /a-zA-Z/n-za-mN-ZA-M/;
print;
}
Abigail
--
print v74.117.115.116.32, v97.110.111.116.104.101.114.32,
v80.101.114.108.32, v72.97.99.107.101.114.10;
------------------------------
Date: Thu, 14 Aug 2003 12:18:32 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Simple tr/// script
Message-Id: <3F3B7EAA.2BCCDFC9@earthlink.net>
Tad McClellan wrote:
> All of the messages that perl might issue are documented in
> the perldiag.pod std doc, you should look up messages
> there as a 1st debugging step.
>
> Or, ask perl to do the looking-up for you by adding
>
> use diagnostics;
>
> near the top of your program, then execute it again.
>
> > $num =~ tr/a-zA-Z\. /n-za-mN-ZA-M\. /;
> ^ ^
> ^ ^ useless backslashes
>
> Why do you want to replace dot with dot and space with space?
>
> Just leave them alone if you do not want them changed.
>
> $num =~ tr/a-zA-Z/n-za-mN-ZA-M/;
Thank you. Very helpful to know that. I guess the warning
was due to the <DATA> read after the file was already at
the end.
------------------------------
Date: Thu, 14 Aug 2003 12:20:16 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Simple tr/// script
Message-Id: <3F3B7F14.1E6DAF55@earthlink.net>
Bob Walton wrote:
> Mike Flannigan wrote:
> The root of your problem is your two statements (shown here with
> commentary):
>
> ...
> while (<DATA>) { #read a line from filehandle DATA to default
> #variable $_ and execute a block of code
> #if not end of file
> $ki = <DATA>; #read a line of code and put it in scalar $ki
Thank you, thank you, thank you.
Thank you all.
So easy, but not if you can't see it. I just need to
think a little more, and copy other people's code a lot less.
Mike
------------------------------
Date: Thu, 14 Aug 2003 12:23:24 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Simple tr/// script
Message-Id: <3F3B7FCE.8CABABF8@earthlink.net>
Abigail wrote:
> while (<DATA>) {
> tr /a-zA-Z/n-za-mN-ZA-M/;
> print;
> }
>
> Abigail
That is so cool.
------------------------------
Date: 14 Aug 2003 08:50:46 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Suggestions for further perl reading
Message-Id: <slrnbjmjb6.92t.abigail@alexandra.abigail.nl>
Chad (chussung@operamail.com) wrote on MMMDCXXXV September MCMXCIII in
<URL:news:97a530bb.0308131640.60c0b7c8@posting.google.com>:
`' Ok I have finished the Llama book and am now creating simple scripts.
`'
`' My question is what should I read to further myself at this. is the
`' camel book the way to go or is there something better?
You could start with reading the documentation.
After that, I suggest "Advanced Programming in the UNIX Environment"
by Stevens. It isn't about Perl, but it will make you realize why
many things of Perl are the way they are.
If you want another Perl book, go for the Cookbook.
Abigail
--
my $qr = qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
$qr =~ s/$qr//g;
print $qr, "\n";
------------------------------
Date: Thu, 14 Aug 2003 10:25:46 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Two questions about perl
Message-Id: <3F3B559A.1020809@bbsrc.ac.uk>
Weirong Zhu wrote:
> On linux
>
> 2. It seems change the $ENV{"xxx"} only takes effect in child process.
> How can I set the enviroment variable in the middle of a perl script?
> For example, I want to change the $LANG several times, so that I can
> print different language's time format by using "localtime"
If you want to do this you probably need to use the setlocale function
which is part of the POSIX module.
See perldoc perllocale for details about this.
Simon.
------------------------------
Date: Thu, 14 Aug 2003 12:00:28 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: using Getopt::Long with option value having spaces
Message-Id: <s6umjv83mgvsik2pkrmjqnrtbi1f5l3pvh@4ax.com>
Sunil wrote:
>I have a file which has some metadata, like
>----
>t1.pl -frwk=perl -mode=1 -args=a,b,c -comments="This is comment 1"
>t2.sql -frwk=sql -mode=2 -args=x -comments="This is comment 2"
>----
>
>I need to read this file line by line and parse it to get the values of
>frwk, -mode and comments, so that I can create another string depending on
>the different values for this string and pass it on to the corresponding
>perl api I have which will execute it for me.
>
>I am stuck because I am not able to pass spaces as part of comments. Is
>there a workaround?
Perhaps look at this FAQ entry:
"How can I split a [character] delimited string except when
inside [character]? (Comma-separated files)"
<http://perldoc.com/perl5.8.0/pod/perlfaq4.html#How-can-I-split-a-%5bcharacter%5d-delimited-string-except-when-inside%0a%5bcharacter%5d--(Comma-separated-files)>
(The person responsible for these long URLs should be shot, IMO.)
In your case, you want to split on spaces except when in quotes. So
replace every occurrence of "," in that regex with "\ ". Spaces without
preceding backslash would be stripped from the regex thanks to the /x
modifier.
--
Bart.
------------------------------
Date: Thu, 14 Aug 2003 14:14:12 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: using Getopt::Long with option value having spaces
Message-Id: <Pine.LNX.4.53.0308141412100.14432@lxplus003.cern.ch>
On Thu, Aug 14, Bart Lateur inscribed on the eternal scroll:
> <http://perldoc.com/perl5.8.0/pod/perlfaq4.html#How-can-I-split-a-%5bcharacter%5d-delimited-string-except-when-inside%0a%5bcharacter%5d--(Comma-separated-files)>
>
> (The person responsible for these long URLs should be shot, IMO.)
I'm sure you realise that they're generated by software.
It would presumably need a bit more craft to build a short form
of the fragment name, and to ensure that it's unique within the
document. I'm sure it's do-able, but who's going to volunteer to
implement it?
cheers
------------------------------
Date: 14 Aug 2003 11:42:53 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: Why doesn't this work?
Message-Id: <bhfsjr$8tb3$1@ID-24002.news.uni-berlin.de>
jend wrote:
> See scripts below: I get zero sized files. and an error message in the logs
> like this: readline() on unopened filehandle at upload.cgi
> It seems that the follwing line is failing in my code
> +++ my $upload_filehandle = $query->upload("myfilename");
just another hint:
how does your HTML, especially te form-tag, look like?
does it contain enctype="multipart/form-data"?
hth, tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/ \ \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5357
***************************************