Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Maintenance Archeology 101

by hsmyers (Canon)
on Apr 20, 2003 at 17:26 UTC ( #251848=CUFP: print w/replies, xml ) Need Help??

For those into (voluntarily or otherwise) maintenance of someone else's code---in this case 25 megabytes of C++ written over time by various and sundry hands (of various and sundry talent), here is a script that might be of use. It uses the output of ctags as input (pipe fans out there know what to do...) with the result of a reasonably useful table in mySQL.

#!/perl/bin/perl # # tag2msql.pl -- convert ctags -x output into a mysql table. use strict; use warnings; use diagnostics; use DBI; my $dbh = DBI->connect( 'DBI:mysql:host=localhost;database=blitzen', '', '', { PrintError => 0, RaiseError => 1 } ) or die "Cannot connect to Database\n"; my $theQuery; my ($symbol,$type,$line_number,$file_name,$source); while (<>) { if (/^operator/i) { /(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*)/; ($symbol,$type,$line_number,$file_name,$source) = ("$1 $2",$3, +$4,$5,$6); } else { /(.*?)\s+(.*?)\s+(.*?)\s+(.*?)\s+(.*)/; ($symbol,$type,$line_number,$file_name,$source) = ($1,$2,$3,$4 +,$5); } $symbol = $dbh->quote($symbol); $type = $dbh->quote($type); $line_number = $dbh->quote($line_number); $file_name = $dbh->quote($file_name); $source = $dbh->quote($source); $theQuery = qq{ INSERT symbols(symbol,type,line_number,file_name,source) VALUES($symbol,$type,$line_number,$file_name,$source) }; $dbh->do($theQuery) or warn("Cannot do query\n"); } $dbh->disconnect(); #mysql> describe symbol; #+-------------+--------------+------+-----+---------+-------+ #| Field | Type | Null | Key | Default | Extra | #+-------------+--------------+------+-----+---------+-------+ #| symbol | varchar(250) | | PRI | | | #| type | varchar(250) | | MUL | | | #| line_number | smallint(6) | | PRI | 0 | | #| file_name | varchar(200) | | PRI | | | #| source | varchar(250) | | | | | #+-------------+--------------+------+-----+---------+-------+ #5 rows in set (0.00 sec)

--hsm

"Never try to teach a pig to sing...it wastes your time and it annoys the pig."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://251848]
Approved by benn
Front-paged by diotalevi
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2016-12-03 17:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (56 votes). Check out past polls.