diparun has asked for the wisdom of the Perl Monks concerning the following question:

Ho do I access the array elements of @$columns ? Plzz help..
#!perl "d:\Perl\bin\perl.exe" require 'subroutines.lib'; use strict; use warnings; use SQL::Parser; my $sql = <STDIN>; my $parser = SQL::Parser->new; my $success = $parser->parse( $sql ); die $parser->errstr unless $success; my $structure = $parser->structure; my $command = $structure->{command}; my $tables = $structure->{org_table_names}; my $columns = $structure->{org_column_names}; my $where_cols = $structure->{where_cols}; if ($success) { # DISPLAY RESULTI +NG DATA use Data::Dumper; # STRUCTURE print Dumper $parser->structure; } if ($command eq "CREATE"){ &createfile(@$tables); } #elsif{ # #} print "Command : $command\n"; print "Tables : @$tables\n"; print "Columns : @$columns\n"; print "where : $where_cols\n";

thnx,
diparun

20040421 Edit by Corion: Added code tags

Replies are listed 'Best First'.
Re: accessing @$array elements
by gjb (Vicar) on Apr 21, 2004 at 08:18 UTC

    Since $columns is a reference, you can access the elements with $columns->[0], etc.

    Hope this helps, -gjb-

    Update: you can find more info in Perl's documentation.

      Or a very short references tutorial here.