Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Perlbotics's scratchpad

by Perlbotics (Canon)
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?

What's my password?
Create A New User
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2017-01-22 15:40 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (187 votes). Check out past polls.