[32161] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3426 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 27 18:09:25 2011

Date: Mon, 27 Jun 2011 15:09:07 -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           Mon, 27 Jun 2011     Volume: 11 Number: 3426

Today's topics:
        doing fiddly processing on repeated matches <bugbear@trim_papermule.co.uk_trim>
    Re: doing fiddly processing on repeated matches <uri@StemSystems.com>
    Re: doing fiddly processing on repeated matches <bugbear@trim_papermule.co.uk_trim>
    Re: doing fiddly processing on repeated matches <rweikusat@mssgmbh.com>
    Re: doing fiddly processing on repeated matches <tadmc@seesig.invalid>
    Re: doing fiddly processing on repeated matches <jurgenex@hotmail.com>
    Re: Module to check overlap? <tzz@lifelogs.com>
    Re: Module to check overlap? <ela@yantai.org>
    Re: Module to check overlap? <tzz@lifelogs.com>
        N-gram, tf-IDF in perl <persistence911@gmail.com>
    Re: Other half of 'CGI file upload' <tzz@lifelogs.com>
    Re: Perl definition of newline? <tzz@lifelogs.com>
        PS: Module to check overlap? <ela@yantai.org>
        read small file, get array of hashes? [newbie] <georgeryoung@gmail.com>
    Re: read small file, get array of hashes? [newbie] <rweikusat@mssgmbh.com>
    Re: sort scientific notation value after alphabet <bugbear@trim_papermule.co.uk_trim>
        WebOs - Perl Question <edgrsprj@ix.netcom.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 27 Jun 2011 11:47:19 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: doing fiddly processing on repeated matches
Message-Id: <_ZCdnRb6_vgqwpXTnZ2dnUVZ8rOdnZ2d@brightview.co.uk>

I'm trying to come up with an elegant solution, but am falling foul of
my search terms being common.

I am attempting to process some XML, in particular, I want to manipulate each
opening tag.

I have the "obvious" match to apply to my large xml string:

  while($s =~ m@(<\s*[^\?][^>]+>)@gm) {
  }

Inside the loop I have good access to the tag in $1, and can readily
pass it to a subroutine to be beaten up in various "interesting"
ways, resulting in a modified tag.

My question is - how to I get my modified tags put
back into my large string?

Should I keep an array on the fragments (tag and other) as
I go, and "join()" at the end to build up a new large string, or
is there some standard idiom to slot my new tag where the old one was?

The latter sounds like it might well conflict with the while(/g) modified.

All advice/idioms/links welcomed.

  BugBear


------------------------------

Date: Mon, 27 Jun 2011 07:02:36 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: doing fiddly processing on repeated matches
Message-Id: <87r56flepf.fsf@quad.sysarch.com>

>>>>> "b" == bugbear  <bugbear@trim_papermule.co.uk_trim> writes:

  b> I have the "obvious" match to apply to my large xml string:

  b>  while($s =~ m@(<\s*[^\?][^>]+>)@gm) {
  b>  }

you don't need /m there as you don't use any anchors in the regex. also
don't use alternate delimiters when / is not in the regex. it makes it
much harder to read. and if you do need alternate delims choose {} and
not @ which is very odd for that.

  b> My question is - how to I get my modified tags put
  b> back into my large string?

use @+ and @- to tell you where the start/end points of the match
are. then you can use substr to replace the tags. this may work better
on a copy of the text as the replacement could change the location of
the regex. you can also save that spot with pos and reset it if that is
a problem. another even better solution is to use s/// with /e. have the
replacement expression call your code and pass it $1 and it returns the
changed tag (along with the <>)

	while( $s =~ s/(<\s*[^\?][^>]+>)/ replace_tag( $1 ) /eg {

this doesn't grab the <> and is better for that reason:

	while( $s =~ s/<\s*([^\?][^>]+)>)/ replace_tag( $1 ) /eg {

and finally, munging xml like that is fraught with danger. use a parser
and build a perl tree. then you can scan that tree and mung it to your
heart's content and convert it back to xml.

uri

-- 
Uri Guttman  --  uri AT perlhunter DOT com  ---  http://www.perlhunter.com --
------------  Perl Developer Recruiting and  Placement Services -------------
-----  Perl Code Review, Architecture, Development, Training, Support -------


------------------------------

Date: Mon, 27 Jun 2011 14:12:07 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: doing fiddly processing on repeated matches
Message-Id: <u_-dnZEC95A1HJXTnZ2dnUVZ7rmdnZ2d@brightview.co.uk>

Uri Guttman wrote:
>>>>>> "b" == bugbear<bugbear@trim_papermule.co.uk_trim>  writes:
>
>    b>  I have the "obvious" match to apply to my large xml string:
>
>    b>   while($s =~ m@(<\s*[^\?][^>]+>)@gm) {
>    b>   }
>
> you don't need /m there as you don't use any anchors in the regex. also
> don't use alternate delimiters when / is not in the regex. it makes it
> much harder to read. and if you do need alternate delims choose {} and
> not @ which is very odd for that.

All good info thank you. The perl fragment is from a script which is (unsurprisingly)
doing matches against XML tags, which have "</tag>" sometimes,
so I was using @ consistently throughout my script.

>
>    b>  My question is - how to I get my modified tags put
>    b>  back into my large string?
>
> use @+ and @- to tell you where the start/end points of the match
> are. then you can use substr to replace the tags. this may work better
> on a copy of the text as the replacement could change the location of
> the regex. you can also save that spot with pos and reset it if that is
> a problem. another even better solution is to use s/// with /e. have the
> replacement expression call your code and pass it $1 and it returns the
> changed tag (along with the<>)
>
> 	while( $s =~ s/(<\s*[^\?][^>]+>)/ replace_tag( $1 ) /eg {
>
> this doesn't grab the<>  and is better for that reason:
>
> 	while( $s =~ s/<\s*([^\?][^>]+)>)/ replace_tag( $1 ) /eg {

Yes, I found the 'e' modifier about an hour after posting. It's not one
I've  ever used (or heard of) before, but it fits my requirement
perfectly.

> and finally, munging xml like that is fraught with danger. use a parser
> and build a perl tree. then you can scan that tree and mung it to your
> heart's content and convert it back to xml.

Indeed. However, I'm actually trying to use XML::LibXML for performance
reasons, and it handles namespaces in a way that is MOST inconvenient later in
my code (compared with, say XML::DOM, where the parser can simply be
told to IGNORE namespaces...)

I'm working with Adsml which has lots of namespaces which are simply NOT needed
for disambiguation, since Adsml has deep tag nesting **and** HUGE (and therefore
unique-ish) tag names.

Despite this, my samples files have 4 separate namespaces, and having to get them all
right in long XPaths is both tedious, and results in hard to read XPaths.

    BugBear


------------------------------

Date: Mon, 27 Jun 2011 14:18:05 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: doing fiddly processing on repeated matches
Message-Id: <87wrg7h0qa.fsf@sapphire.mobileactivedefense.com>

bugbear <bugbear@trim_papermule.co.uk_trim> writes:

[...]

> I have the "obvious" match to apply to my large xml string:
>
>  while($s =~ m@(<\s*[^\?][^>]+>)@gm) {
>  }
>
> Inside the loop I have good access to the tag in $1, and can readily
> pass it to a subroutine to be beaten up in various "interesting"
> ways, resulting in a modified tag.
>
> My question is - how to I get my modified tags put
> back into my large string?

You could replace the loop by an s/// expression which would look
roughly like this (uncompiled or -tested)

	$s =~ s/(<\s*[^\?][^>]+>)/modify_tag($1)/gem;

This should replace each occurence of the pattern in the string with
the result returned by the modify_tag subroutine.


------------------------------

Date: Mon, 27 Jun 2011 13:22:46 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: doing fiddly processing on repeated matches
Message-Id: <slrnj0hi6q.p0a.tadmc@tadbox.sbcglobal.net>

bugbear <bugbear@trim_papermule.co.uk_trim> wrote:

> I'm trying to come up with an elegant solution, 


If you attempt to use a regex to "parse" XML,
then you have already given up on an "elegant"
(or even "correct") solution...


> I am attempting to process some XML, in particular, I want to manipulate each
> opening tag.


But your regex will also match *closing* tags...


> I have the "obvious" match to apply to my large xml string:
>
>   while($s =~ m@(<\s*[^\?][^>]+>)@gm) {
>   }


Your regex will also fail to match some *opening* tags, eg:

    $s = 'foo<b>bold</b>bar';

will fail to match "<b>" and will succeed in matching "</b>".

After you fix all of that, try with data like this:

    <!--
        foo<b>bold</b>bar
    -->

where it should FAIL to match since there are no "b" tags there.

After you fix all of that, post your new regex again, and
we'll provide yet another case that will break it.

Lather, rinse, repeat.

We are very likely to be able to keep that up longer than you can...

:-)


> All advice/idioms/links welcomed.


Use a *real parser* for parsing XML.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


------------------------------

Date: Mon, 27 Jun 2011 14:14:18 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: doing fiddly processing on repeated matches
Message-Id: <tfsh0712eavsh9risebj3it3tdq1t3nr6f@4ax.com>

bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
>I'm trying to come up with an elegant solution, but am falling foul of
>my search terms being common.
>
>I am attempting to process some XML, in particular, I want to manipulate each
>opening tag.

Parse the XML, do your manipulation in the syntax tree, and write the
XML back out.

>I have the "obvious" match to apply to my large xml string:
>
>  while($s =~ m@(<\s*[^\?][^>]+>)@gm) {
>  }

"Obvious" as in simple-minded? REs are not powerful enough to parse a
non-regular language like XML. And even if the non-regular enhancements
to Perl's REs make it much more powerful, if is a fool's errand trying
to parse XML with REs.



>My question is - how to I get my modified tags put
>back into my large string?

You just rebuild the XML text from the syntax tree.

jue


------------------------------

Date: Mon, 27 Jun 2011 11:41:01 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Module to check overlap?
Message-Id: <87liwnb52a.fsf@lifelogs.com>

On Mon, 27 Jun 2011 12:37:47 -0700 "ela" <ela@yantai.org> wrote: 

e> "Ted Zlatanov" <tzz@lifelogs.com> wrote in message 
e> news:871uyjv0ej.fsf@lifelogs.com...
>> You can try inversion lists, which are very good for long runs of data.
>> Your set B would become (1 101 139 601 1000 1201) and you can easily
>> find the overlap of two such lists.  Check out
>> http://www.perlmonks.org/?node_id=908453 for more.

e> Ted, you are very correct, http://www.perlmonks.org/?node_id=908453 HAS a 
e> solution, yet, mentions little about how to pass data to use (No 
e> confirmation letter received after registration until now). Would you mind 
e> helping shed some light which part is talking about input data to match 
e> against a database (again, which part)? I could run the codes smoothly but 
e> just don't know how to format my data (and the database) in order to get the 
e> ball rolling!

You mean you want to know how to make an inversion list?  There's an
example in an article I wrote a while ago:

http://www.ibm.com/developerworks/linux/library/l-cpinv/index.html

which uses my Algorithm::InversionList CPAN module.  You just pass a bit
string to the invlist() function (you can generate bit strings with
vec() or literally).  If your sets are in the low millions of members
you should be OK, but if you're in the hundreds of millions or more you
may run out of memory just allocating the memory structures.  Whether
that's necessary depends on your source data set.  What's the source
format right now?

If your bit string would be too big to be created directly, you'll have
to generate the inversion list yourself from the source data.  I showed
how to do it for set B; it's a pretty simple algorithm.

Ted


------------------------------

Date: Tue, 28 Jun 2011 03:49:43 -0700
From: "ela" <ela@yantai.org>
Subject: Re: Module to check overlap?
Message-Id: <iuaj8k$arn$1@ijustice.itsc.cuhk.edu.hk>


"Ted Zlatanov" <tzz@lifelogs.com> wrote in message 
news:87liwnb52a.fsf@lifelogs.com...
> On Mon, 27 Jun 2011 12:37:47 -0700 "ela" <ela@yantai.org> wrote:
>
> You mean you want to know how to make an inversion list?  There's an
> example in an article I wrote a while ago:
>
> http://www.ibm.com/developerworks/linux/library/l-cpinv/index.html
>
> which uses my Algorithm::InversionList CPAN module.  You just pass a bit
> string to the invlist() function (you can generate bit strings with
> vec() or literally).  If your sets are in the low millions of members
> you should be OK, but if you're in the hundreds of millions or more you
> may run out of memory just allocating the memory structures.  Whether
> that's necessary depends on your source data set.  What's the source
> format right now?

The source format for both "query" and "database" files is in tab delimited 
format. e.g.

Database file, 1 million records of

1\t1000
2000\t3000
2500\t3500
 ...


Query file, 10k records
3\t2200
5000\t62344
77778\t132313
 ...

>
> If your bit string would be too big to be created directly, you'll have
> to generate the inversion list yourself from the source data.  I showed
> how to do it for set B; it's a pretty simple algorithm.
>
> Ted

Thanks for your reference, Ted. I shall peruse it first :-) 




------------------------------

Date: Mon, 27 Jun 2011 14:03:50 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Module to check overlap?
Message-Id: <87sjqv85bd.fsf@lifelogs.com>

On Tue, 28 Jun 2011 03:49:43 -0700 "ela" <ela@yantai.org> wrote: 

e> "Ted Zlatanov" <tzz@lifelogs.com> wrote in message 
e> news:87liwnb52a.fsf@lifelogs.com...
>> On Mon, 27 Jun 2011 12:37:47 -0700 "ela" <ela@yantai.org> wrote:
>> 
>> You mean you want to know how to make an inversion list?  There's an
>> example in an article I wrote a while ago:
>> 
>> http://www.ibm.com/developerworks/linux/library/l-cpinv/index.html
>> 
>> which uses my Algorithm::InversionList CPAN module.  You just pass a bit
>> string to the invlist() function (you can generate bit strings with
>> vec() or literally).  If your sets are in the low millions of members
>> you should be OK, but if you're in the hundreds of millions or more you
>> may run out of memory just allocating the memory structures.  Whether
>> that's necessary depends on your source data set.  What's the source
>> format right now?

e> The source format for both "query" and "database" files is in tab delimited 
e> format. e.g.

e> Database file, 1 million records of

e> 1\t1000
e> 2000\t3000
e> 2500\t3500
e> ...

OK, so your in-memory inversion list will be

(1 1001 2000 3001 2500 3501 ...)

Do you see the pattern?  You're saying "from 1 to 1000 is yes, 1001 to
1999 is no, 2000 to 3000 is yes, 3001 to 2499 is no..."

A million integers in memory should not be too bad, less than 20
megabytes I'd guess.  Perl lists don't have a big overhead.  But you can
pack the numbers in a more compact format if memory usage is a problem.
Try it.

e> Query file, 10k records
e> 3\t2200
e> 5000\t62344
e> 77778\t132313
e> ...

Same pattern.

So then the intersection of the two inversion lists (going with
http://www.perlmonks.org/?node_id=908453 since it explains it well) is
just the negation of the union of the individual negations.

Negation, as that page explains, is easy: remove the leading 0 or add a
leading 0 if there isn't one.

Adding a new range to a list (to compute the union) is pretty simple
too; let us know if you have trouble writing it.

Ted


------------------------------

Date: Mon, 27 Jun 2011 09:15:19 -0700 (PDT)
From: Deamon <persistence911@gmail.com>
Subject: N-gram, tf-IDF in perl
Message-Id: <fbf5e1d2-76d2-4bc2-9e6f-4138c232e52b@22g2000yqv.googlegroups.com>

am trying to do some pattern 'mining' in piece of multi word on each
line. I have done the N-gram analysis using the Text::Ngrams module in
perl which give me the frequency of each word . I am however quite
confused about the finding patterns in this text.

The tf-idf finds frequency also I presume but how does this differ
from the Ngram analysis that I did and how does the similarity measure
also help.

Please are there any perl modules or snippets of code I could get to
understand some of this concepts .

Please I am from new at this and have to do some pattern recognizing
so I am a little new to some of these , a good reference on this
topics will be appreciated.


------------------------------

Date: Mon, 27 Jun 2011 11:44:20 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Other half of 'CGI file upload'
Message-Id: <87hb7bb4wr.fsf@lifelogs.com>

On Sat, 25 Jun 2011 15:21:24 +0100 Rainer Weikusat <rweikusat@mssgmbh.com> wrote: 

RW> Rainer Weikusat <rweikusat@mssgmbh.com> writes:
RW> [...]

>> open($fh, '>', '/tmp/out');

RW> Additional warning: This must not be used on a system with untrusted
RW> and possibily maliscious users because it will happily kill whatever a
RW> possibly existing symlink /tmp/out points to provided the user the
RW> script runs as can write to it.

Yes, plus it does no validation of the data or checking of the upload
size (when /tmp fills up it won't be fun).  Any time you take data from
a remote source and blindly write it locally, you have security and DoS
risks.  That's why I suggested any of the million existing file upload
solutions like WebDAV, which have already done the hard work.

Ted


------------------------------

Date: Mon, 27 Jun 2011 11:30:35 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Perl definition of newline?
Message-Id: <87pqlzb5jo.fsf@lifelogs.com>

On Mon, 27 Jun 2011 00:04:56 -0400 "Uri Guttman" <uri@StemSystems.com> wrote: 

>>>>>> "TZ" == Ted Zlatanov <tzz@lifelogs.com> writes:

TZ> I've been pleasantly surprised by `ack': it's fast, reliable, and does
TZ> everything I need.  So maybe it will work for this as well.

UG> it isn't a core thing and i would expect perldoc to be only relying on
UG> core stuff.

Maybe you could sneak it in with the patch ;)

Ted


------------------------------

Date: Mon, 27 Jun 2011 16:38:53 -0700
From: "ela" <ela@yantai.org>
Subject: PS: Module to check overlap?
Message-Id: <iu9buq$s92$1@ijustice.itsc.cuhk.edu.hk>


Let me elaborate about my concern. The codes seem to test hash-based string 
concatenation and array based AoA concatentation. Then, how input data are 
test against for overlap detection? This is the core that I care most.

> use warnings;
> use strict;
>
> use Devel::Size qw/total_size/;
> use Benchmark;
>
> ++$|;
> print ">>Strings:\n";
> my $t0 = Benchmark->new;
> for (10e3, 10e4, 10e5,){
>
> my %r;
> my($i,$l,$g) = (0) x 3;
> for( 1 .. $_ ) {
>    $r{ int( $i / 10e3 ) } .=
>        qq[ $i -@{[ $i + ( $l = 1500 + int( -500 + rand 1000 ) ) ]} ];
>    $i+=$l + 25 + int( rand 25 );
> }
> print "$_ : " . (total_size(\%r) ) . "\n";
> }
> my $t1 = Benchmark->new;
> my $td = timediff($t1, $t0);
> print "String took:",timestr($td),"\n";
>
> print ">>AoA:\n";
> $t0 = Benchmark->new;
> for (10e3, 10e4, 10e5,){
>
> my %r;
> my($i,$l,$g) = (0) x 3;
> for( 1 .. $_ ) {
>    push @{ $r{ int( $i / 10e3 ) } },
>        [ $i, @{[ $i + ( $l = 1500 + int( -500 + rand 1000 ) ) ]} ];
>    $i+=$l + 25 + int( rand 25 );
> }
> print "$_ : " . (total_size(\%r) ) . "\n";
> }
> $t1 = Benchmark->new;
> $td = timediff($t1, $t0);
> print "Array took:",timestr($td),"\n";
>
> print system('perl -v');
>




------------------------------

Date: Mon, 27 Jun 2011 12:07:39 -0700 (PDT)
From: gry <georgeryoung@gmail.com>
Subject: read small file, get array of hashes? [newbie]
Message-Id: <ddbdc213-72f7-403f-9091-cb183dcaff4a@p31g2000vbs.googlegroups.com>

[perl newbie]  I need to read a small flat file like:
  #testname          #dbname             #duration(hours)  #wipe_db
#schema_dir
  backup_restore     backup_restore      6                 no
vbr
  elastic_cluster    elastic_cluster    48                 no
ElasticCluster
  create_delete_seq  create_delete_seq   0.5               yes
ddl_something
  ...

and get some kind of data object so I can:
1) find the next test in sequence after a given test_name (or
indication of end_of_tests)
2) get the dbname, duration, wipe, or schema for a given test_name

I tried:
use warnings;
use strict;
my $test_suites_file = $ENV{'TEST_SUITES_FILE'} || 'test_suites';
sub read_suites_file
{
    die 'wrong number of args' if(@_ != 1);
    my @tests = ();
    my($file_name) = $_[0];

    open my $suites_file, "< $file_name" or die "Can't open stress
suites file \"$file_name\": $!";
    while(<$suites_file>) {
	next if m"^\s*(#|$)";
        chomp;
	my ($test,$dbname,$duration,$wipe_db,$schema_dir) = split;
	push @tests, {test=>$test, dbname=>$dbname, duration=>$duration,
wipe_db=>$wipe_db, schema_dir=>$schema_dir};
    }
    close($suites_file);
    return @tests
    }

my @tests = read_suites_file($test_suites_file);
my %test = $tests[1];
print 'dbname of tests[1]=', $test{'dbname'};

which gives me:
  Reference found where even-sized list expected at ./
manage_stress_tests.pl line 34.

I want this program to be good quality perl, something that's
straightforward and maintainable.
Hints as to the above bug would be appreciated.  Suggestions about a
better approach to the problem, or better style would be even more
appreciated.
There's no need for speed here, just clarity and good perl code.


------------------------------

Date: Mon, 27 Jun 2011 21:20:50 +0100
From: Rainer Weikusat <rweikusat@mssgmbh.com>
Subject: Re: read small file, get array of hashes? [newbie]
Message-Id: <87vcvr58m5.fsf@sapphire.mobileactivedefense.com>

gry <georgeryoung@gmail.com> writes:
> [perl newbie]  I need to read a small flat file like:
>   #testname          #dbname             #duration(hours)  #wipe_db
> #schema_dir
>   backup_restore     backup_restore      6                 no
> vbr
>   elastic_cluster    elastic_cluster    48                 no
> ElasticCluster
>   create_delete_seq  create_delete_seq   0.5               yes
> ddl_something
>   ...
>
> and get some kind of data object so I can:
> 1) find the next test in sequence after a given test_name (or
> indication of end_of_tests)
> 2) get the dbname, duration, wipe, or schema for a given test_name
>
> I tried:
> use warnings;
> use strict;
> my $test_suites_file = $ENV{'TEST_SUITES_FILE'} || 'test_suites';
> sub read_suites_file
> {
>     die 'wrong number of args' if(@_ != 1);
>     my @tests = ();
>     my($file_name) = $_[0];
>
>     open my $suites_file, "< $file_name" or die "Can't open stress
> suites file \"$file_name\": $!";
>     while(<$suites_file>) {
> 	next if m"^\s*(#|$)";
>         chomp;
> 	my ($test,$dbname,$duration,$wipe_db,$schema_dir) = split;
> 	push @tests, {test=>$test, dbname=>$dbname, duration=>$duration,
> wipe_db=>$wipe_db, schema_dir=>$schema_dir};
>     }
>     close($suites_file);
>     return @tests
>     }
>
> my @tests = read_suites_file($test_suites_file);
> my %test = $tests[1];
> print 'dbname of tests[1]=', $test{'dbname'};
>
> which gives me:
>   Reference found where even-sized list expected at ./
> manage_stress_tests.pl line 34.

The error message you get comes from trying to assign a scalar value
(the hash references stored in $test[1]) to a hash (%test): A hash
assignment needs to be composed of a sequence of key => value pairs
(=> is a fancy name for ,). Modification of your code which can
accomplish 1) and 2) [the basic idea is to to use %tests to map test
names to the corresponding array indicies].

---------------------
use warnings;
use strict;


my $test_suites_file = $ENV{'TEST_SUITES_FILE'} || 'suites';
sub read_suites_file
{
    die 'wrong number of args' if(@_ != 1);
    my @tests = ();
    my($file_name) = $_[0];

    open my $suites_file, "< $file_name" or die "Can't open stress suites file \"$file_name\": $!";
    while (<$suites_file>) {
	next if m"^\s*(#|$)";
        chomp;
	my ($test,$dbname,$duration,$wipe_db,$schema_dir) = split;
	push @tests, {test=>$test, dbname=>$dbname, duration=>$duration,
		      wipe_db=>$wipe_db, schema_dir=>$schema_dir};
    }
    close($suites_file);
    return @tests
}

my @tests = read_suites_file($test_suites_file);

my ($seq, %tests, $test);

$seq = 0;
%tests = map { ($_->{test}, $seq++); } @tests;

$test = $tests[$tests{elastic_cluster} + 1]->{test};

printf("test after elastic_cluster: %s\n", $test);
printf("dbname for %s: %s\n", $test, $tests[$tests{$test}]->{dbname});


------------------------------

Date: Mon, 27 Jun 2011 09:29:10 +0100
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: sort scientific notation value after alphabet
Message-Id: <trOdncsxZfjKopXTnZ2dnUVZ8uWdnZ2d@brightview.co.uk>

Randal L. Schwartz wrote:
>>>>>> "ela" == ela<ela@yantai.org>  writes:
>
> ela>  I have a very large table (1 million+ records) that has five fields
> ela>  and the first two rows are shown:
>
> Sounds like you could use a *database*!
>
> Unless you have a gazillion bytes of RAM you don't mind wasting.

Judging from his posting history, either "ela"
is taking a very long time to create the
DNA analysis software his employer requires,
or he's on a computational biology course, and trying
to get help with his homework.

   BugBear


------------------------------

Date: Sun, 26 Jun 2011 23:41:30 -0500
From: "E.D.G." <edgrsprj@ix.netcom.com>
Subject: WebOs - Perl Question
Message-Id: <So2dnR4_RpxklJXTnZ2dnUVZ_vCdnZ2d@earthlink.com>

Posted by E.D.G.

Questions:  Can Perl programs using any of the ActiveState versions of Perl 
be written for use on the new HP TouchPad computer that runs the WebOs 3.0 
operating system?

If not, then might some other version of Perl run with WebOs computers?

It is my understanding that WebOs is based in some manner on Linux.

At the present time I am using the ActiveState version of Perl for Windows 
XP and Vista.




------------------------------

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 3426
***************************************


home help back first fref pref prev next nref lref last post