Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Perlbotics's scratchpad

by Perlbotics (Chancellor)
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?
[stevieb]: cheers beech. twas totally my mistake, and I got bit. When things work for so long without issue, one becomes complacent (ie. replace we/one with I ;) I've been copy/pasting that around for a few years without a hiccup, so when...
[stevieb]: choroba pointed that out, I was just, you know, *sigh*. In effect, I was lucky and fortunate
[stevieb]: Kind of like my regex-fu went out the window, but only while looking at that specific file ;)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2017-07-25 23:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (383 votes). Check out past polls.