Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

OeufMayo's scratchpad

by OeufMayo (Curate)
on Jun 03, 2004 at 13:17 UTC ( #360118=scratchpad: print w/ replies, xml ) Need Help??

Text::Balanced

Test:

#!/usr/bin/perl -w use strict; use Text::Balanced qw(extract_codeblock); for ( '{ $h{x} = "}" }', '{ $h{s} = "}" }', '{ $h{s} = 1; print "{oops}" }', '{ $h{m} = "}" }', '{ $h{y} = "}" }', '{ $h{tr} = "}" }', '{ $h{qq} = "}" }', '{ $h{qr} = "}" }', '{ $h{qw} = "}" }', '{ $h{qx} = "}" }', ){ my ($e,$r) = extract_codeblock $_; print "Code: $_\nExtracted: $e\nRemainder: $r\n\$\@: $@\n\n"; }

Output:

Code: { $h{x} = "}" } Extracted: { $h{x} = "}" } Remainder: Code: { $h{s} = "}" } Extracted: Remainder: { $h{s} = "}" } Code: { $h{s} = 1; print "{oops}" } Extracted: Remainder: { $h{s} = 1; print "{oops}" } Code: { $h{m} = "}" } Extracted: Remainder: { $h{m} = "}" } Code: { $h{y} = "}" } Extracted: Remainder: { $h{y} = "}" } Code: { $h{tr} = "}" } Extracted: Remainder: { $h{tr} = "}" }

Parse::RecDescent

Test:

#!/usr/bin/perl -w -s use strict; use Parse::RecDescent; my $parser; $parser = Parse::RecDescent->new(q({my %foo} rule:"foo"{$foo{x}="}";}) +); $parser = Parse::RecDescent->new(q({my %foo} rule:"foo"{$foo{s}="}";}) +); $parser = Parse::RecDescent->new(q({my %foo} rule:"foo"{$foo{y}="}";}) +); $parser = Parse::RecDescent->new(q({my %foo} rule:"foo"{$foo{m}="}";}) +); $parser = Parse::RecDescent->new(q({my %foo} rule:"foo"{$foo{tr}="}";} +));

output with -RD_TRACE

Parse::RecDescent: Treating "{my %foo}" as an action Parse::RecDescent: Treating "rule:" as a rule declaration Parse::RecDescent: Treating ""foo"" as an interpolated literal ter +minal Parse::RecDescent: Treating "{$foo{x}="}";}" as an action printing code (4142) to RD_TRACE Parse::RecDescent: Treating "{my %foo}" as an action Parse::RecDescent: Treating "rule:" as a rule declaration Parse::RecDescent: Treating ""foo"" as an interpolated literal ter +minal printing code (3618) to RD_TRACE Parse::RecDescent: Treating "{my %foo}" as an action Parse::RecDescent: Treating "rule:" as a rule declaration Parse::RecDescent: Treating ""foo"" as an interpolated literal ter +minal printing code (3618) to RD_TRACE Parse::RecDescent: Treating "{my %foo}" as an action Parse::RecDescent: Treating "rule:" as a rule declaration Parse::RecDescent: Treating ""foo"" as an interpolated literal ter +minal printing code (3618) to RD_TRACE Parse::RecDescent: Treating "{my %foo}" as an action Parse::RecDescent: Treating "rule:" as a rule declaration Parse::RecDescent: Treating ""foo"" as an interpolated literal ter +minal printing code (3618) to RD_TRACE

People! Wake Up !

Do you still let lizards to control you ?
Then you are puppets of a big puppet theatre, you are unfree slaves and you do not have any time always because you are driven by money, material world, delights and you do not use love and feelings among each other.

Put yourselves together and show other that you are not empty chess pieces on the chess board of negative extraterrestrial beings of dark powers!

The only way to freedom is the way of love, harmony, feelings and goodness.
Well, wake up from your long "winter" sleep and open your hearts and feelings !

We keep our fingers crossed for you and we love you.

Cosmic People of Light Powers.


pmdev wiki
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 examining the Monastery: (8)
As of 2014-09-03 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (35 votes), past polls