when you turn the strictures on, they give you warnings as long as you don't declare your variables with the "my" keyword, this serves to localize the variables to the current scope. "my" use can be wide-spread but there are other keywords out there ours and local. You can readily find out many discussions involving the conditions each one of these is used under.

So you could have declared the variables "$data", "@svr_raw" by preceding them with the "my" keyword, that would've given you hints that @svr_raw has been declared as an array but then you used a hash ref.

The module Data::Dumper is used to stringify data structures, (i.e it represents the strings that a data structure - when appropriately referenced- would show), hence you can look at the dumped structure and make judgments on how it can best be accessed. I would stress that it is very handy to learn advanced data structures in Perl,

Are some of the resources for you...

"Oh and yea does it make a difference in accessing the data from this text file if i use single quotes and double quotes? "
double quotes and single quotes contexts come into light if you are accessing variables, since interpolation is affected by the way a variable is enclosed, double quotes allow variable interpolation and single quotes do not..
$name = "varun monk"; print "$name\n"; print '$name\n';

Run this code, which does work similar to what you intend
use strict; use warnings; my $data={}; #declare an anonymous hash while(<DATA>){ chomp; my ($key, $val)=split /\s*=\s*/; $data->{$key}=$val; } print "name=>", $data->{name},"\n"; print "ip=>", $data->{ip},"\n"; ##View the data structure## use Data::Dumper; print Dumper($data); __DATA__ name = "varun" ip = "9.12.23.222";

Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.

In reply to Re: Accessing data present in a text file with references... by biohisham
in thread Accessing data present in a text file with references... by VGR

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.