Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
There's more than one way to do things
 
PerlMonks  

Re: Substitutions Within Substitutions

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

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.