[30732] in Perl-Users-Digest
Perl-Users Digest, Issue: 1977 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 11 18:09:49 2008
Date: Tue, 11 Nov 2008 15:09:14 -0800 (PST)
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, 11 Nov 2008 Volume: 11 Number: 1977
Today's topics:
Re: Comparing audio files <kieranocall@gmail.com>
Re: determine when to change to or from daylight saving <r.ted.byers@gmail.com>
Help: getMaxAnnotationWidthForFont Problem <openlinuxsource@gmail.com>
Re: Help: getMaxAnnotationWidthForFont Problem <kkeller-usenet@wombat.san-francisco.ca.us>
How to extract a value from all the hashes in a list of <mrstevegross@gmail.com>
Re: How to extract a value from all the hashes in a lis <jurgenex@hotmail.com>
Re: How to extract a value from all the hashes in a lis <mrstevegross@gmail.com>
Re: How to extract a value from all the hashes in a lis <tadmc@seesig.invalid>
Re: Huge files manipulation <bik.mido@tiscalinet.it>
Re: SUBSTR() with replacement or lvalue performance iss <bik.mido@tiscalinet.it>
Re: SUBSTR() with replacement or lvalue performance iss xhoster@gmail.com
Re: SUBSTR() with replacement or lvalue performance iss sln@netherlands.com
Re: SUBSTR() with replacement or lvalue performance iss <nospam-abuse@ilyaz.org>
Re: SUBSTR() with replacement or lvalue performance iss <nospam-abuse@ilyaz.org>
Re: SUBSTR() with replacement or lvalue performance iss xhoster@gmail.com
Re: SUBSTR() with replacement or lvalue performance iss sln@netherlands.com
Re: SUBSTR() with replacement or lvalue performance iss xhoster@gmail.com
Re: SUBSTR() with replacement or lvalue performance iss xhoster@gmail.com
Syntax to retrieve $# from de-referenced array sjcampbl@gmail.com
Re: Syntax to retrieve $# from de-referenced array <1usa@llenroc.ude.invalid>
Re: Syntax to retrieve $# from de-referenced array <jurgenex@hotmail.com>
Re: Syntax to retrieve $# from de-referenced array <tadmc@seesig.invalid>
Why does the following statement work ? <toralf.foerster@gmx.de>
Re: Why does the following statement work ? <joost@zeekat.nl>
Re: Why does the following statement work ? xhoster@gmail.com
Re: {JOB} Calling all Perl Monks - My client has been l <dha@panix.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 11 Nov 2008 08:49:05 -0800 (PST)
From: kieran <kieranocall@gmail.com>
Subject: Re: Comparing audio files
Message-Id: <76a7411f-1157-43e4-a594-2ce7ca185180@k36g2000pri.googlegroups.com>
On Oct 22, 3:58 pm, kieran <kieranoc...@gmail.com> wrote:
> On Oct 16, 9:56 pm, rc <christian.ramse...@gmail.com> wrote:
>
>
>
> > On Oct 8, 4:39 pm, kieran <kieranoc...@gmail.com> wrote:
>
> > > Hello,
> > > I am trying to compare two similar audio files (WAV). From what i have
> > > read i need tosampleboth audio files at certain frequencies and run
> > > these through a FFT and then compare the results. Can anyone advise me
> > > if this is the correct approach and also describe the steps i need to
> > > take to get to the stage where I can compare the files.
>
> > While this can certainly be done in Perl, a nice environment for
> > prototyping this kind of applications is GNU Octave or Matlab (given
> > you are rich or a student). Reading some files from wav,down/
> > upsampling them, applying filters and perform an fft is just a few
> > lines of code in both of these tools.
>
> > Once you have a working solution, you can still collect all modules
> > you need to do it in Perl from CPAN or just continue to use Octave via
> > Inline::Octave.
>
> > Now for what to do exactly, this heavily depends on what your input
> > and your goals are. To get help with this, maybe asking in a group
> > about audio processing or algorithms would be better.
>
> > Good luck
>
> > Christian
>
> > --
> > rc at networkz dot ch
>
> Hi Christian,
> Thanks for your reply, the approach you describe will certainly help,
> I have requested a trial version of Octave so I will begin using that
> for protoyyping once I get access.
>
> A couple of things you might be able to help me with, I have been
> looking for some modules to use for downsampling, filtering etc... The
> module I found for resampling audio called Audio::Mad::Resample would
> not install on my machine, i got some errors that i could not resolve.
> Are there any modules you can recomend for down/up sampling?
> Also for creating a low-pass filter i have been looking at PDL::Audio,
> there are many types of filter available in this module, I am not sure
> which is best for low-pass filters.
> Thanks,
> Kieran
Hello,
I have done some of the work in prototyping the wav file comparison in
MATLAB and I have begun translating this into perl. I am experiencing
some problems when I read the data from the wave file in perl, the
values I am getting seem very large and seem to be 3,000(aprox.) times
larger than the values i get when i imported the wav file data into
Matlab. When I graph both sets of values the resulting graphs look the
same as the wave form.
In matlab i am using the wavread function to read the samples from my
wav file. I get 49617 samples of very low numbers, lots of zero values
and plenty of very low and negative values. I have followed a few
tutorials in Matlab and these reading look correct.
However when i attempt to do the same in perl i get the smae ammount
of samples but the numbers are very large and with few if any zero
readings. I have been uing the Audio::Analyzer Audio::Wav::Read
modules.
Can you explain why I am getting such a large difference between
Matlab nad perl? I would expect the results to match.
If you require any more information please let me know.
Regards,
Kieran
------------------------------
Date: Tue, 11 Nov 2008 13:47:58 -0800 (PST)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: determine when to change to or from daylight savings time
Message-Id: <601adfb6-d921-49e2-89e2-5a8ac3491a23@e1g2000pra.googlegroups.com>
On Nov 9, 5:27=A0am, "Dr.Ruud" <rvtol+n...@isolution.nl> wrote:
> Ted Byers schreef:
>
> > Dr.Ruud:
> >> Peter Wyzl:
> >>> but is there some 'authorative source' of what all the different
> >>> timezones are and the daylight times for those zones and when they
> >>> switch back and forth?
>
> >> I use DateTime::TimeZone which uses Olson. Good enough for
> >> me.http://search.cpan.org/search?query=3Dtimezone&mode=3Dmodule
>
> > I have downloaded the Olson timezone data, and executed the script
> > "parse-olson.pl". =A0It created a directory called lib that contains th=
e
> > timezone data transformed into *.pm files in a number of directories.
> > I have perl installed in C:\Perl. =A0Do I just copy the files and
> > folders created by parse_olson.pl into C:\Perl\site, over-writing
> > what's already there?
>
> I have no clue what you are trying to achieve, or rather mess up, so I
> can't anwer that question.
> But if you want to install specific Perl modules on a Windows system in
> a clean way, just use the latest ActiveState or the Vanilla Perl tools.
>
> --
> Affijn, Ruud
>
> "Gewoon is een tijger."
All I'm after is to make sure the timezone data I have is up to date.
I routinely use ActiveState's PPM to install packages, and I use CPAN
as a fallback option when the package I'm after isn't in a PPM
repository. The documentation for DateTime::TimeZone doesn't say
which version of the Olson data it uses, so I can't be sure it uses
the current Olson data unless someone can confirm that.
Thanks
Ted
------------------------------
Date: Tue, 11 Nov 2008 23:20:59 +0800
From: Amy Lee <openlinuxsource@gmail.com>
Subject: Help: getMaxAnnotationWidthForFont Problem
Message-Id: <pan.2008.11.11.15.20.53.772711@gmail.com>
Hello,
I install a platform for bioinformatics research and that needs GD module.
When I after GD I find that I encountered an error with following message.
Can't call method "getMaxAnnotationWidthForFont" on an undefined value at
/usr/lib/perl5/site_perl/5.8.3/Bio/GMOD/Blast/Graph.pm line 379.
I check out the line 379 at this Graph.pm. It indicates the functions of
GD so I wonder that whether I miss some other GD modules.
My problem is whether "getMaxAnnotationWidthForFont" belongs to a GD
module or other module.
Thank you very much.
Regards,
Amy Lee
------------------------------
Date: Tue, 11 Nov 2008 10:07:11 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Help: getMaxAnnotationWidthForFont Problem
Message-Id: <h7uou5xh3e.ln2@goaway.wombat.san-francisco.ca.us>
On 2008-11-11, Amy Lee <openlinuxsource@gmail.com> wrote:
>
> I install a platform for bioinformatics research and that needs GD module.
> When I after GD I find that I encountered an error with following message.
>
> Can't call method "getMaxAnnotationWidthForFont" on an undefined value at
^^^^^^^^^^^^^^^^^^^^^
> /usr/lib/perl5/site_perl/5.8.3/Bio/GMOD/Blast/Graph.pm line 379.
>
> I check out the line 379 at this Graph.pm. It indicates the functions of
> GD so I wonder that whether I miss some other GD modules.
The problem is not with Graph.pm, but with whatever object on which
you're trying to call call getMaxAnnotationWidthForFont. Find out why
that variable (I'm guessing it's a variable, but as you posted no code
who knows?) is undefined and fix that problem.
If you need help fixing the problem, post a *short* and *complete*
script that replicates the problem, as the posting guidelines recommend.
--keith
--
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information
------------------------------
Date: Tue, 11 Nov 2008 12:22:03 -0800 (PST)
From: mrstevegross <mrstevegross@gmail.com>
Subject: How to extract a value from all the hashes in a list of hashes?
Message-Id: <5901baa1-d229-4def-984c-cac54a48635c@q26g2000prq.googlegroups.com>
I have a list of hashes that looks like this:
my @list = (
{ Name => 'Foo', X => Y },
{ Name => 'Bar', X => Y },
{ Name => 'Baz', X => Y },
);
I would like to iterate across the list-of-hashes and extract just the
values of the 'Name' key as a list. I had hoped that the following
code would do the trick:
my @names = grep { $_->{Name} } @list;
But it doesn't, because the grep simply matches the hash reference but
doesn't return the value of the named attribute. Is there a quick way
to make this work, other than iterating across the list with a
foreach() statement?
Thanks,
--Steve
------------------------------
Date: Tue, 11 Nov 2008 12:41:11 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: How to extract a value from all the hashes in a list of hashes?
Message-Id: <tdrjh4555cathvh5gmgbpi7mqs1nnharvl@4ax.com>
mrstevegross <mrstevegross@gmail.com> wrote:
>I have a list of hashes that looks like this:
>
>my @list = (
> { Name => 'Foo', X => Y },
> { Name => 'Bar', X => Y },
> { Name => 'Baz', X => Y },
>);
>
>I would like to iterate across the list-of-hashes and extract just the
>values of the 'Name' key as a list. I had hoped that the following
>code would do the trick:
>
>my @names = grep { $_->{Name} } @list;
>
>But it doesn't, because the grep simply matches the hash reference but
>doesn't return the value of the named attribute. Is there a quick way
>to make this work, other than iterating across the list with a
>foreach() statement?
my @names = map $_ -> {Name}, @list;
jue
------------------------------
Date: Tue, 11 Nov 2008 13:12:35 -0800 (PST)
From: mrstevegross <mrstevegross@gmail.com>
Subject: Re: How to extract a value from all the hashes in a list of hashes?
Message-Id: <49fc5401-00de-4768-b5ad-7c85f0b60f91@w39g2000prb.googlegroups.com>
> my @names = map $_ -> {Name}, @list;
Thanks--it works great!
--Steve
------------------------------
Date: Tue, 11 Nov 2008 15:57:07 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: How to extract a value from all the hashes in a list of hashes?
Message-Id: <slrnghjvtj.1vh.tadmc@tadmc30.sbcglobal.net>
mrstevegross <mrstevegross@gmail.com> wrote:
>> my @names = map $_ -> {Name}, @list;
>
> Thanks--it works great!
If you had paid close attention when you read the documentation
for the function you were using, you could have discovered this
on your own:
perldoc -f grep
...
See also L</map> for a list composed of the results of the BLOCK or EXPR.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Tue, 11 Nov 2008 13:11:49 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Huge files manipulation
Message-Id: <0htih4tuvd74qepmfchpj8umhrhmpgll6i@4ax.com>
On Mon, 10 Nov 2008 02:24:53 -0800 (PST), klashxx <klashxx@gmail.com>
wrote:
>Hi , i need a fast way to delete duplicates entrys from very huge
>files ( >2 Gbs ) , these files are in plain text.
[cut]
>Any advice will be very well come.
>
>Thank you in advance.
Wouldn't have been nice of you to mention that you asked the very same
question elsewhere? <http://perlmonks.org/?node_id=722634> Did they
help you there? How did they fail to do so?
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Tue, 11 Nov 2008 13:50:57 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: SUBSTR() with replacement or lvalue performance issues
Message-Id: <4tvih4hqm5b737i9josos8dtu2td58aqjd@4ax.com>
On Mon, 10 Nov 2008 23:44:51 +0000 (UTC), Ilya Zakharevich
<nospam-abuse@ilyaz.org> wrote:
>> See: <http://perlmonks.org/?node_id=498434>
>
>Simple experiments show that it is still buggy with 5.8.8: code below returns
>
> the quick brown fox jumps over the laxy dog
> the quick brown fox jumps over the lazy dog
Same with 5.10 here.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 11 Nov 2008 17:14:06 GMT
From: xhoster@gmail.com
Subject: Re: SUBSTR() with replacement or lvalue performance issues
Message-Id: <20081111121442.793$YY@newsreader.com>
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> [A complimentary Cc of this posting was NOT [per weedlist] sent to
> Michele Dondi
> <bik.mido@tiscalinet.it>], who wrote in article
> <bs38h49bu6oanughiuvgdgr8rfen2v8fh0@4ax.com>:
> > ISTR that the lvaluedness of substr()'s return value, as long as the
> > fact that you can EVEN take references of it and modify the string
> > with a sort of action-at-distance was put there specifically for
> > performance issues. At some point there were problems with
> > substitutions having a lenght larger than the substituted IalsoIRC,
> > but they should be solved in recent enough perls.
> >
> > See: <http://perlmonks.org/?node_id=498434>
>
> Simple experiments show that it is still buggy with 5.8.8: code below
> returns
>
...
>
>
> change_nth 7, 'lazy', map{ substr $bigScalar, $_->[0], $_->[1] }
> [0,3], [4,5], [10,5], [16,3], [20,5], [26,4], [31,3], [35,4], [40,3];
> print "$bigScalar\n";
I don't see this as a bug with substr. "Map" doesn't alias the values
it returns, it copies them. So the magic is no longer there, just as it
isn't present in $x if you do:
my $x=substr $bigScalar, 1, 4;
So if it's a bug, it is a bug with map, not substr.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Tue, 11 Nov 2008 18:45:16 GMT
From: sln@netherlands.com
Subject: Re: SUBSTR() with replacement or lvalue performance issues
Message-Id: <gikjh45j2uq9c0ke9aif9shahuir9kijbn@4ax.com>
On 11 Nov 2008 17:14:06 GMT, xhoster@gmail.com wrote:
>Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
>> [A complimentary Cc of this posting was NOT [per weedlist] sent to
>> Michele Dondi
>> <bik.mido@tiscalinet.it>], who wrote in article
>> <bs38h49bu6oanughiuvgdgr8rfen2v8fh0@4ax.com>:
>> > ISTR that the lvaluedness of substr()'s return value, as long as the
>> > fact that you can EVEN take references of it and modify the string
>> > with a sort of action-at-distance was put there specifically for
>> > performance issues. At some point there were problems with
>> > substitutions having a lenght larger than the substituted IalsoIRC,
>> > but they should be solved in recent enough perls.
>> >
>> > See: <http://perlmonks.org/?node_id=498434>
>>
>> Simple experiments show that it is still buggy with 5.8.8: code below
>> returns
>>
>...
>>
>>
>> change_nth 7, 'lazy', map{ substr $bigScalar, $_->[0], $_->[1] }
^
\
>> [0,3], [4,5], [10,5], [16,3], [20,5], [26,4], [31,3], [35,4], [40,3];
>> print "$bigScalar\n";
>
>I don't see this as a bug with substr. "Map" doesn't alias the values
>it returns, it copies them. So the magic is no longer there, just as it
>isn't present in $x if you do:
>my $x=substr $bigScalar, 1, 4;
>
>So if it's a bug, it is a bug with map, not substr.
>
>Xho
------------------------------
Date: Tue, 11 Nov 2008 21:25:13 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: SUBSTR() with replacement or lvalue performance issues
Message-Id: <gfct7p$1lqi$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
<sln@netherlands.com>], who wrote in article <gikjh45j2uq9c0ke9aif9shahuir9kijbn@4ax.com>:
> >> Simple experiments show that it is still buggy with 5.8.8: code below
> >> returns
> >> change_nth 7, 'lazy', map{ substr $bigScalar, $_->[0], $_->[1] }
> ^
> \
Nope.
Hope this helps,
Ilya
------------------------------
Date: Tue, 11 Nov 2008 21:31:52 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: SUBSTR() with replacement or lvalue performance issues
Message-Id: <gfctk8$1lrp$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
<xhoster@gmail.com>], who wrote in article <20081111121442.793$YY@newsreader.com>:
> > Simple experiments show that it is still buggy with 5.8.8: code below
> > returns
> > change_nth 7, 'lazy', map{ substr $bigScalar, $_->[0], $_->[1] }
> > [0,3], [4,5], [10,5], [16,3], [20,5], [26,4], [31,3], [35,4], [40,3];
> > print "$bigScalar\n";
> I don't see this as a bug with substr.
It is a bug, and it involves substr. ;-)
> "Map" doesn't alias the values it returns, it copies them.
What for? Why this should not work:
perl -wle "@a=(10..15); sub z2{$_[2]=0}; z2 map $_, @a; print for @a"
Thanks,
Ilya
------------------------------
Date: 11 Nov 2008 21:55:20 GMT
From: xhoster@gmail.com
Subject: Re: SUBSTR() with replacement or lvalue performance issues
Message-Id: <20081111165556.884$HL@newsreader.com>
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> [A complimentary Cc of this posting was sent to
> <sln@netherlands.com>], who wrote in article
> <gikjh45j2uq9c0ke9aif9shahuir9kijbn@4ax.com>:
> > >> Simple experiments show that it is still buggy with 5.8.8: code
> > >> below returns
>
> > >> change_nth 7, 'lazy', map{ substr $bigScalar, $_->[0], $_->[1] }
> > ^
> > \
>
> Nope.
It will work provided you make the obvious change to change_nth to do the
dereference.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Tue, 11 Nov 2008 22:23:13 GMT
From: sln@netherlands.com
Subject: Re: SUBSTR() with replacement or lvalue performance issues
Message-Id: <e71kh4tj4ardq4b549ea42dagpc1pgakeo@4ax.com>
On Fri, 07 Nov 2008 11:41:21 +0100, Michele Dondi <bik.mido@tiscalinet.it> wrote:
>On Fri, 07 Nov 2008 02:17:58 GMT, sln@netherlands.com wrote:
>
>>Apart from like, copy from the start of a matched position, to a
>>file (as opposed to another buffer), then catenating the modification
>>to the file, then continue on with the next match, is the substr
>>(lvalue or replacement) a viable option?
>>
>>I have to consider performance on such large operations.
>
>ISTR that the lvaluedness of substr()'s return value, as long as the
>fact that you can EVEN take references of it and modify the string
>with a sort of action-at-distance was put there specifically for
>performance issues. At some point there were problems with
>substitutions having a lenght larger than the substituted IalsoIRC,
>but they should be solved in recent enough perls.
>
>See: <http://perlmonks.org/?node_id=498434>
>
>
>Michele
5.8.6 has problems:
use strict;
use warnings;
my $cnt;
printf "\nPerl Version: %vd\n", $^V;
my @fldvals = split( ' ', "one two three four five");
## Initalize references on dummy record
## -------------------------------------
print "\nInit \@lvrefs to 5 char fields x 7 fields/record\n",'-'x30,"\n";
my $bigscalar = "+++++-----+++++-----+++++-----+++++";
my @lvrefs = map{ \substr $bigscalar, $_->[0], $_->[1] }
[0,5], [5,5], [10,5], [15,5], [20,5], [25,5], [30,5];
print "\nrecord: <".$bigscalar.">\n\n";
$cnt = 1;
print " field ".$cnt++." \t<".$$_.">\n" for @lvrefs;
## Change record, print $$lvrefs
## -------------------------------------
print "\nChange record, print \$\$lvrefs\n",'-'x30,"\n";
# Set bigscalar to 6 char width fields, use @lvrefs to print
$bigscalar = sprintf ("%-6s"x5, @fldvals);
print "\n(\%-6s) record: <".$bigscalar.">\n\n";
$cnt = 1;
print " field ".$cnt++." \t<".$$_.">\n" for @lvrefs;
# Set bigscalar to 5 char width fields, use @lvrefs to print
$bigscalar = sprintf ("%-5s"x5, @fldvals);
print "\n(\%-5s) record: <".$bigscalar.">\n\n";
$cnt = 1;
print " field ".$cnt++." \t<".$$_.">\n" for @lvrefs;
## Assign to $$lvrefs, print record
## -------------------------------------
print "\nAssign to \$\$lvrefs, print record\n",'-'x30,"\n";
# Assign $$lvref to 10 char value's
print "\n(\%-10s) \$\$lvrefs\n\n";
$cnt = 0;
for (@fldvals)
{ ${$lvrefs[$cnt++]} = sprintf "%-10s", $_; }
$cnt = 1;
print " field ".$cnt++." \t<".$$_.">\n" for @lvrefs;
print "\nrecord: <".$bigscalar.">\n";
# Assign $$lvref to 5 char value's
print "\n(\%-5s) \$\$lvrefs\n\n";
$cnt = 0;
for (@fldvals)
{ ${$lvrefs[$cnt++]} = sprintf "%-5s", $_; }
$cnt = 1;
print " field ".$cnt++." \t<".$$_.">\n" for @lvrefs;
print "\nrecord: <".$bigscalar.">\n";
# Assign $$lvref to 2 char value's
print "\n(\%-2d, 1..7) \$\$lvrefs\n\n";
$cnt = 0;
for (1..7)
{ ${$lvrefs[$cnt++]} = sprintf "%-2d", $_; }
$cnt = 1;
print " field ".$cnt++." \t<".$$_.">\n" for @lvrefs;
print "\nrecord: <".$bigscalar.">\n";
__END__
Perl Version: 5.8.6
Init @lvrefs to 5 char fields x 7 fields/record
------------------------------
record: <+++++-----+++++-----+++++-----+++++>
field 1 <+++++>
field 2 <----->
field 3 <+++++>
field 4 <----->
field 5 <+++++>
field 6 <----->
field 7 <+++++>
Change record, print $$lvrefs
------------------------------
(%-6s) record: <one two three four five >
field 1 <one >
field 2 < two >
field 3 < thr>
field 4 <ee fo>
field 5 <ur f>
field 6 <ive >
field 7 <>
(%-5s) record: <one two threefour five >
field 1 <one >
field 2 <two >
field 3 <three>
field 4 <four >
field 5 <five >
field 6 <>
field 7 <>
Assign to $$lvrefs, print record
------------------------------
(%-10s) $$lvrefs
field 1 <one >
field 2 <two >
field 3 <three>
field 4 <four >
field 5 <five >
field 6 < >
field 7 <two >
record: <one two threefour five two threefour five >
(%-5s) $$lvrefs
field 1 <one >
field 2 <two >
field 3 <three>
field 4 <four >
field 5 <five >
field 6 < >
field 7 <two >
record: <one two threefour five two threefour five >
(%-2d, 1..7) $$lvrefs
field 1 <1 two>
field 2 <2 eef>
field 3 <3 ive>
field 4 <4 tw>
field 5 <5 ree>
field 6 <6 fiv>
field 7 <7 >
record: <1 two2 eef3 ive4 tw5 ree6 fiv7 >
------------------------------
Date: 11 Nov 2008 22:28:39 GMT
From: xhoster@gmail.com
Subject: Re: SUBSTR() with replacement or lvalue performance issues
Message-Id: <20081111172915.373$UB@newsreader.com>
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> [A complimentary Cc of this posting was sent to
>
> > "Map" doesn't alias the values it returns, it copies them.
>
> What for? Why this should not work:
>
> perl -wle "@a=(10..15); sub z2{$_[2]=0}; z2 map $_, @a; print for @a"
It does work. It just doesn't do what you want :)
I think the current behavior is reasonable, although it would be nice to
have the other as an option (maybe Array::Splice could have a map_alias,
even though it is getting a bit far afield of the name-space).
The current behavior is consistent with what other things that conceptually
*could* keep aliasing, but don't. Like push. Or subroutines.
perl -le ' my @x=1..10; sub foo { $_[0]}; foreach (@x) {
$_="x" foreach foo($_)}; print "@x"'
1 2 3 4 5 6 7 8 9 10
Well, subroutines that have not been declared :lvalue, anyway.
On the other hand, reverse does preserve aliasing.
a do block also preserves aliasing, but for some odd reason I'm not
allowed to assign to one directly.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: 11 Nov 2008 22:55:11 GMT
From: xhoster@gmail.com
Subject: Re: SUBSTR() with replacement or lvalue performance issues
Message-Id: <20081111175547.178$zG@newsreader.com>
sln@netherlands.com wrote:
> On Fri, 07 Nov 2008 11:41:21 +0100, Michele Dondi
> <bik.mido@tiscalinet.it> wrote:
>
> >On Fri, 07 Nov 2008 02:17:58 GMT, sln@netherlands.com wrote:
> >
> >>Apart from like, copy from the start of a matched position, to a
> >>file (as opposed to another buffer), then catenating the modification
> >>to the file, then continue on with the next match, is the substr
> >>(lvalue or replacement) a viable option?
> >>
> >>I have to consider performance on such large operations.
> >
> >ISTR that the lvaluedness of substr()'s return value, as long as the
> >fact that you can EVEN take references of it and modify the string
> >with a sort of action-at-distance was put there specifically for
> >performance issues. At some point there were problems with
> >substitutions having a lenght larger than the substituted IalsoIRC,
> >but they should be solved in recent enough perls.
> >
> >See: <http://perlmonks.org/?node_id=498434>
> >
> >
> >Michele
>
> 5.8.6 has problems:
I think it is your expectations that have problems. But you haven't
described what your expectations are, so it is hard to tell.
The lvals remember the offset and length. If the main string gets
rearranged, the lval doesn't try to change the offset and length in an
attempt to trace that rearrangement. Can you imagine the morass if they
did? Instead, it keeps the "window" the same and lets characters move
around beneath it.
Also, if you assign to the lval with a string of a different length,
the lval still remembers it's length to be the originally created one, not
the length of the string just assigned to it. So you can assign and
then immediately read and get a different thing than what you just
assigned. But I don't know that the alternative would be any less odd.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Tue, 11 Nov 2008 12:58:19 -0800 (PST)
From: sjcampbl@gmail.com
Subject: Syntax to retrieve $# from de-referenced array
Message-Id: <d35182ae-6fb3-408f-8bae-f8ae88d2f0e5@s1g2000prg.googlegroups.com>
I understand to retrieve the highest array subscript I use the
syntax...
$#MyArray
However, what if the array is a reference held within a greater hash
structure...
%MyHash{MyHashKey} holds a reference to an array
How do I retrieve $# on this?
$#{MyHash{MyHashKey}} doesn't seem to work.
------------------------------
Date: Tue, 11 Nov 2008 21:25:09 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Syntax to retrieve $# from de-referenced array
Message-Id: <Xns9B53A701FBD7Casu1cornelledu@127.0.0.1>
sjcampbl@gmail.com wrote in news:d35182ae-6fb3-408f-8bae-f8ae88d2f0e5
@s1g2000prg.googlegroups.com:
> I understand to retrieve the highest array subscript I use the
> syntax...
>
> $#MyArray
>
> However, what if the array is a reference held within a greater hash
> structure...
>
> %MyHash{MyHashKey} holds a reference to an array
>
> How do I retrieve $# on this?
>
> $#{MyHash{MyHashKey}} doesn't seem to work.
#!/usr/bin/perl
use strict;
use warnings;
my %MyHash = ( MyHashKey => [1, 2, 3] );
print $#{$MyHash{MyHashKey}}, "\n";
__END__
C:\Temp> h
2
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Tue, 11 Nov 2008 13:29:32 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Syntax to retrieve $# from de-referenced array
Message-Id: <s5ujh4l7ue0s3kpgcjtb5nvs52jpc8fmut@4ax.com>
sjcampbl@gmail.com wrote:
>I understand to retrieve the highest array subscript I use the
>syntax...
>
>$#MyArray
Actually $MyArray[-1] maybe more perlish.
>However, what if the array is a reference held within a greater hash
>structure...
You can still use ....[-1] :-)
>%MyHash{MyHashKey} holds a reference to an array
>
>How do I retrieve $# on this?
See 'perldoc perlretut' and follow rule 1 in "Using references".
jue
------------------------------
Date: Tue, 11 Nov 2008 15:59:22 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Syntax to retrieve $# from de-referenced array
Message-Id: <slrnghk01q.1vh.tadmc@tadmc30.sbcglobal.net>
Jürgen Exner <jurgenex@hotmail.com> wrote:
> sjcampbl@gmail.com wrote:
>>I understand to retrieve the highest array subscript I use the
>>syntax...
>>
>>$#MyArray
>
> Actually $MyArray[-1] maybe more perlish.
Except that it does something completely different. :-)
What is wanted is the subscript, not the value.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Tue, 11 Nov 2008 14:23:03 +0000 (UTC)
From: toralf <toralf.foerster@gmx.de>
Subject: Why does the following statement work ?
Message-Id: <gfc4g7$pvp$1@registered.motzarella.org>
I'm asking , b/c the 2nd "}" is not matched and the 2nd "{" too :
echo -e "A\nB\nA\n" |\
perl -wne ' $h{$_}++; }; foreach $s (keys %h) { print "$h{$s}\t$s" '
--
MfG/Sincerely
Toralf Förster
pgp finger print: 7B1A 07F4 EC82 0F90 D4C2 8936 872A E508 7DB6 9DA3
------------------------------
Date: Tue, 11 Nov 2008 15:27:33 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Why does the following statement work ?
Message-Id: <87zlk6qqwa.fsf@zeekat.nl>
toralf <toralf.foerster@gmx.de> writes:
> I'm asking , b/c the 2nd "}" is not matched and the 2nd "{" too :
>
> echo -e "A\nB\nA\n" |\
> perl -wne ' $h{$_}++; }; foreach $s (keys %h) { print "$h{$s}\t$s" '
Because of the wrapping implied by the -n switch. See perldoc perlrun
or use B::Deparse:
$ perl -MO=Deparse -wne ' $h{$_}++; }; foreach $s (keys %h) { print \
"$h{$s}\t$s" '
BEGIN { $^W = 1; }
LINE: while (defined($_ = <ARGV>)) {
++$h{$_};
}
foreach $s (keys %h) {
print "$h{$s}\t$s";
}
-e syntax OK
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: 11 Nov 2008 17:31:56 GMT
From: xhoster@gmail.com
Subject: Re: Why does the following statement work ?
Message-Id: <20081111123232.775$Wh@newsreader.com>
toralf <toralf.foerster@gmx.de> wrote:
> I'm asking , b/c the 2nd "}" is not matched and the 2nd "{" too :
>
> echo -e "A\nB\nA\n" |\
> perl -wne ' $h{$_}++; }; foreach $s (keys %h) { print "$h{$s}\t$s" '
from perldoc perlrun:
-n causes Perl to assume the following loop around your program,
which
makes it iterate over filename arguments somewhat like sed -n or
awk:
LINE:
while (<>) {
... # your program goes here
}
And it means this quite literally. "Your program" is not something that
gets executed as the block inside the while loop. Is it text that gets
wrapped up in the implicit text and compiled. So "your program" is
perfectly free to use a "}" to close the implicitly opened "while (<>) {",
but of course that means it needs to provide a unbalanced "{" to for the
implicit "}" to close.
I tend not to use this trick, and would usually write it more like:
perl -wne ' $h{$_}++; END {foreach $s(keys %h){print "$h{$s}\t$s"}}'
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Tue, 11 Nov 2008 21:12:22 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: {JOB} Calling all Perl Monks - My client has been looking for you...
Message-Id: <slrnghjt9n.6b.dha@panix2.panix.com>
On 2008-11-10, plarge10 <patricklarge@gmail.com> wrote:
> My client is very simply looking for the best and brightest perl
> developers in New York City.
You have posted a job posting or a resume in a technical group.
Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.
Had you read and understood the Usenet user manual posted frequently to
"news.announce.newusers", you might have already known this. :) (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Another good source of information on how Usenet functions is
news.newusers.questions (information from which is also available at
http://www.geocities.com/nnqweb/).
Please do not explain your posting by saying "but I saw other job
postings here". Just because one person jumps off a bridge, doesn't
mean everyone does. Those postings are also in error, and I've
probably already notified them as well.
If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.
http://jobs.perl.org may be of more use to you
Yours for a better usenet,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
It was when a cow-orker proudly showed me his Java Ring that I finally
realised that Java was nothing more than a huge April Fool joke that had
got out of hand. - Andy Wardley
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 1977
***************************************