Hello Monks
I didn't permissons to download CPAN modules..so I came up with the following code
suggest me if anything is wrong
$config = "C:\\Testing\\file.ini"; # check if file exists and can be read -r $config || die "$config does not exists or is not readable"; open(IN, $config) || die "Cannot open $config for reading: $!"; sub readFile { my $key = ""; my $value = ""; # initialize rule storage my $source_dir = ""; my $target_dir = ""; my @pattern; while(<IN>) # read a line from line into $_ { $line = $_; if ( /^(\s*|\;.*|\#.*)$/i ) { # empty line or comment } elsif ( ($key, $value) = /^\$([A-Z_]+)\=(.+)/ ) { #significant line: $key=$value $value = evalValue($value); #$key = lc($key); # look for file attributes $source_dir=$value if( $key eq "SOURCE_DIR" ); $target_dir=$value if ( $key eq "TARGET_DIR" ); @pattern=$value if ( $key eq "PATTERN" ); } } } sub evalValue { my $value = $_[0]; my $key = ""; my $result = ""; my $rest = ""; $_ = $value; $rest = $value; while( ($key) = /\$([A-Z_]\w*)/) { $key_val{$key} || die "Undefined key: $key $!"; $result = $result . $` . $key_val{$key}; $_ = $'; $rest = $'; } $result = $result . $rest; return $result; }
This way I can read all the values and then process accordingly

Thanks again for suggestions

Sridhar

In reply to Re: Reading a Properties file by mantra2006
in thread Reading a Properties file by mantra2006

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.