http://www.perlmonks.org?node_id=1002880


in reply to Read Hash reference from File

Back into perlmonks after a long time. :)

Seems interesting. Since you don't want the order to be changed, I think you can try with PPI.

Here is a sample code, which I tried. You can make it better for your use.

use PPI; my $ds = PPI::Document->new('sample_config.pl'); for my $sub ( @{ $ds->find('PPI::Statement::Expression') || [] } ) { my $Tokenizer = PPI::Tokenizer->new( \$sub ); while ( my $Token = $Tokenizer->get_token ) { print "Found token '$Token'\n" if ( $Token =~ /\w+/ ); } print "---------------------------------------------\n" }

Hope it helps. Thanks.