Now my file contains these data
.rem ***************************************************************** +***** .rem * + * .rem * deb123.rpt + * .rem ***************************************************************** +***** .rem .rem ------------------------ book_tab variables --------------------- .rem .declare book_no a14 .declare l_code a10 .declare l_book a12 .declare book_date a13
and I need to read this file line by line the file name is deb123.rpt and my code is
use IO::File; my $fh = IO::File->new(); die "File $ARGV[0] is there in the specified location but is of Zero b +ytes" if (-z $ARGV[0]); $ARGV[0] .= ".rpt"; $fh->open($ARGV[0], "r"); local($/); #my $data = $fh->getline; #$fh->close; while(defined($data = $fh->getline)){ if($data =~ /^\.r/){ print "This is a comment $data\n"; } if($data =~ /^\.dec/){ print "This is declared variable $data\n"; } } $fh->close;
but its not giving any output and even its not printing the data at particular line in the file also... Please help me out for the code

In reply to Re^2: Extract the variable by denzil_cactus
in thread Extract the variable by denzil_cactus

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.