Dan Anderson wrote:
>
> I've got a script that goes through SQL files and returns an array of
> table names.  To find table names I use:
>
> while ($_ = <FILE>) {
>   if ($_ =~ m/CREATE.*TABLE/) {
>     $_ = $';
>     while (not ($_ =~ m/)//)) {  # match last parenthesis
>        $_ .= <FILE>;
>     }
>     my $table_name = $`;
>     $table_name = tr/ \t\n\r//d;
>     return $table_name;
>   }
> }
>
> My Programming Perl book says not to use $' $` and $&.  Is there a
> better way to do this?

Hi Dan.

Your code won't compile, so I'm guessing hard at what you're trying
to do. The best way to present a problem to the group is in plain
English, not in the form of non-funtional Perl that we have to
backtrack to understand what you meant.

I think you're trying to scan an SQL 'CREATE TABLE' statement, and
grab the name of the table and all of the field specifications.
Or something like that.

This isn't hard even without the 'forbidden' $' $` and $& but, even
though my belief is that people who avoid them are phobic, they
don't help here at all!

Explain your problem more clearly, with an example of your data,
and we'll be able to help.

Cheers,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to