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

Re: regular expression to get the tablename.column_name

by imp (Priest)
on Oct 18, 2006 at 03:51 UTC ( [id://578954]=note: print w/replies, xml ) Need Help??


in reply to regular expression to get the tablename.column_name

Trying to condense the code to a single line is really only useful only for satisfying curiosity, as code that is condensed like that is harder to maintain.

That said, here's one line of perl for it:

perl -ne '/^TABLE;([^;\n]+)/ && ($table = $1) or /^COLUMN;([^;\n]+)/ & +& print "$table.$1\n"' data.txt
And here's an awk solution
awk -F ';' '/^TABLE/ {table=$2} /^COLUMN/ {printf("%s.%s\n",table,$2) + }' data.txt

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-03-29 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found