Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Substitutions Within Substitutions

by Anonymous Monk
on May 02, 2006 at 22:48 UTC ( [id://547008]=note: print w/replies, xml ) Need Help??


in reply to Substitutions Within Substitutions

This is slightly easier on (my) eyes...
my $text = <<END; create table foo ( somevar1 sometype, somevar2 sometype null, somevar3 sometype not null, somevar4 sometype(20), somevar5 sometype(20) null, somevar6 sometype(10)) END my $header = qr/create\s+table\s+\w+\s*\(\s*/; my $name = qr/\w+\s*/; my $type = qr/\w+\s*/; my $op_char = qr/(?:\(\d+\)\s*)?/; my $words = qr/(?:\w+\s*)*/; my $decl = qr/$name $type $op_char $words/x; my $comma = qr/,\s*/; my $rest = qr/\)\s*/; $text =~ s{($header) ((?: $decl $comma)* $decl) ($rest)} { $1 . (join ",", map {$_ . (/null\s*$/ ? "" : " NOT NULL")} split(/,/, $2)) . $3 }gex; print $text;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://547008]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2025-06-19 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.