Input file question

Discussion in 'Perl' started by SL_McManus, Jan 28, 2004.

  1. SL_McManus

    SL_McManus Guest

    Hi;

    What I am trying to do is to read the input file and and pull a
    10 byte section of lines 4 - 6 to a variable. I would take these in
    order and drop the numbers into $x, $y, & $z. I'm not sure if I have
    something mislabled or my logic is incorrect. I commented out two
    sections to try to isolate one variable. Any thoughts are welcomed.




    Input File (6 lines long)

    Initial Check file for auditing


    Initial Input File TC 849
    Greater than 9.99 File TC 847
    Less than/equal to 9.99 File TC 2




    $linecount = 6;
    $lineread=0;
    $value=1;
    $count=0;

    # start output
    my @lines = ( );
    open(AUDTFILE, '>'.$audtfile) || die "Unable to open $audtfile $!\n";
    binmode(AUDTFILE);
    for $line (@lines) {
    # split it up per-line
    for $linecount (split(/\r?\n/, $line)) {
    # this is the line we care about
    if ($linecount == 4) {
    # substr($line, [col to start], [number of char's to go])
    my $x = substr($line, 37, 10);
    }
    #else ($linecount == 5) {
    # my $y = substr($line, 37, 10);
    # }
    #else ($linecount == 6) {
    # my $z = substr($line, 37, 10);
    # }
    }
    }

    close(AUDTFILE);
     
    SL_McManus, Jan 28, 2004
    #1
    1. Advertising

  2. SL_McManus wrote:
    > What I am trying to do is to read the input file and and pull a 10
    > byte section of lines 4 - 6 to a variable. I would take these in
    > order and drop the numbers into $x, $y, & $z. I'm not sure if I
    > have something mislabled or my logic is incorrect.


    Most of it seems to be incorrect.

    http://learn.perl.org/

    Newsgroups do not replace own serious efforts.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Jan 28, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Weng Tianxiang
    Replies:
    12
    Views:
    1,714
  2. ashutosh
    Replies:
    3
    Views:
    9,055
    Andrew Thompson
    Jun 16, 2005
  3. Guy
    Replies:
    5
    Views:
    2,877
    brucie
    Dec 13, 2003
  4. Replies:
    3
    Views:
    418
  5. Tarkeshwar
    Replies:
    2
    Views:
    211
Loading...

Share This Page