Hi monks..I have this script which reads i/p file line by line into variable $p, manipulates in a way it becomes a hash reference.. but when I print the $p it prints the manipulated line not something like HASH(0x1e0e9b8) (means it isn't a hash ref. just a normal variable... below is my script..

$line = "cksjdcdbsdcnusageControlAccum:S551(!{\!reportingGroups\!:[{\! +absoluteAccumulated\!:{\!counters\!:[{\!bidirVolume\!:306490319,\!nam +e\!:\!base\!}],\!expiryDate\!:{\!volume\!:\!24-07-2014T00:00:00\!},\! +previousExpiryDate\!:{\!time\!:\!26-06-2014T00:00:00\!,\!volume\!:\!2 +6-06-2014T00:00:00\!},\!reportingLevel\!:\!totalTraffic\!,\!resetPeri +od\!:{\!volume\!:\!28 days\!}},\!name\!:\!110\!,\!restartInfo\!:\!26- +06-2014T00:00:00\!,\!selected\!:\!yes\!,\!subscriberGroupName\!:\!GJ_ +FUP_3GEXP_125MB_28\!,\!subscriptionDate\!:\!26-06-2014T00:00:00\!,\!v +alidityTime\!:3600}],\!version\!:\!2.1\!}!)"; $line =~s/\\//g; if ( $line =~ /usageControlAccum:(\w+)\(!(.*)!\)/ ) { $p=$2; $p=~s/:\{/ => {/g; $p=~s/:\[/ => [/g; $p=~s/!/\'/g; $p=~s/\':/\'=>/g; } print $p;

ouput of which is

{'reportingGroups' => [{'absoluteAccumulated' => {'counters' => [{'bid +irVolume'=>306490319,'name'=>'base'}],'expiryDate' => {'volume'=>'24- +07-2014T00:00:00'},'previousExpiryDate' => {'time'=>'26-06-2014T00:00 +:00','volume'=>'26-06-2014T00:00:00'},'reportingLevel'=>'totalTraffic +','resetPeriod' => {'volume'=>'28 days'}},'name'=>'110','restartInfo' +=>'26-06-2014T00:00:00','selected'=>'yes','subscriberGroupName'=>'GJ_ +FUP_3GEXP_125MB_28','subscriptionDate'=>'26-06-2014T00:00:00','validi +tyTime'=>3600}],'version'=>'2.1'}

now if I assign the above output value directly to any variable & then print it..it is considering it like a hash ref but not in this case...pls help..thanks


In reply to Not able to assign a hash reference. by Ankur_kuls

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.