You could try this.
#! perl -sw use strict; use Data::Dumper; my $source = do {local $/; <DATA> }; # Slurp the source # build an array of chunks that look like parms to Lique() my (@parms) = $source =~ m/=\s+(?:new\s+)?CX::Lique(?:->new\s*?)?\((.* +?)\);/gcs; # Processs the array and build a hash from the chunks. for my $parm (@parms) { my %info; $parm =~ s/'?(\w+)'?\s+=>\s+'?([^,')]+)'?,?\n/$info{$1} = $2;/seg; print Dumper(\%info); } __DATA__ my $fun = new CX::Lique( name => 'Test Addon', 'author'=> 'nutshell', email => 'x@x.com', descrip => 'That', version => '1.1', build => 2 ); my $q = CX::Lique->new( name => 'Test', 'author'=> 'yeehaw', 'email' => 'yeehaw@yahoo.com', descrip => 'Fun', version => '1.11', build => 2 );
Which gives this. No guarentees it will work for all the possible ways this could be structured in the source though.
C:\test>202407 $VAR1 = { 'descrip' => 'That', 'build' => '2', 'version' => '1.1', 'email' => 'x@x.com', 'name' => 'Test Addon' }; $VAR1 = { 'descrip' => 'Fun', 'build' => '2', 'version' => '1.11', 'email' => 'yeehaw@yahoo.com', 'name' => 'Test' }; C:\test>
In reply to Re: Processing (from a variable) the 'new' methods hash and storing it to a hash ref
by BrowserUk
in thread Processing (from a variable) the 'new' methods hash and storing it to a hash ref
by nutshell
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |