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>

Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.