Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Don't ask to ask, just ask
 
PerlMonks  

Perlbotics's scratchpad

by Perlbotics (Abbot)
on Jul 17, 2008 at 11:27 UTC ( #698270=scratchpad: print w/ replies, xml ) Need Help??

This snipped doesn't add much to the thread...

use strict; use warnings; use Data::Dumper; $Data::Dumper::Sortkeys = 1; my $string = q{AA(aa),AB(a(b),b),AC(Departament d'Astronomia i Astrofí +sica. Universitat de València. C/Dr. Moliner 50, 46100 Burjassot (Val +ència), Spain),AD(a,c,XX(ignored!)),AE(Neumann,AE(+++)),AF(FAILS in r +are case where value contains next token (here:AG),AG(blah)),AG(last) +}; my $range = join(',', 'A'..'Z'); my %result; for (my $key = 'AA'; $key ne 'AAA'; $key++) { # AA..ZZ last if $string !~ /(?:^|\),)$key\(/; # stop if xx( or ),xx( missin +g my $key2 = $key; $key2++; # match AA(...),BB( if ( $string =~ / $key \( (.*?) \) (?: ,$key2\( | $) /x ) { $result{ $key } = $1; } else { #TODO: Error handling warn "No match for $key(...),$key2!\n"; } } print "Result from '$string':\n", Dumper( \%result ), "\n"; __DATA__ $VAR1 = { 'AA' => 'aa', 'AB' => 'a(b),b', 'AC' => 'Departament d\'Astronomia i Astrofísica. Universita +t de València. C/Dr. Moliner 50, 46100 Burjassot (València), Spain', 'AD' => 'a,c,XX(ignored!)', 'AE' => 'Neumann,AE(+++)', 'AF' => 'FAILS in rare case where value contains next token +(here:AG', 'AG' => 'blah)),AG(last' };


... found in a dusty part of the monasteries scriptorium ...

Into this wilde Abyss,
The Womb of nature and perhaps her Grave,
Of neither Sea, nor Shore, nor Air, nor Fire,
But all these in thir pregnant causes mixt
Confus'dly, and which thus must ever fight,
Unless th' Almighty Maker them ordain
His dark materials to create more Worlds,
Into this wilde Abyss the warie fiend
Stood on the brink of Hell and look'd a while,
Pondering his Voyage ...
Milton / Paradise Lost

Darkly fills an otherwise empty scratchpad - and some books by Philip Pullman.

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2014-04-19 02:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (475 votes), past polls