Find the answer to your Linux question:
Results 1 to 3 of 3
I am reading a file. I want to find the line containing the string "Scores". I want to add the following 6 lines (as I know they are integers). I ...
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    10

    perl reading file

    I am reading a file. I want to find the line containing the string "Scores". I want to add the following 6 lines (as I know they are integers). I am having trouble finding "Scores". I've done
    open($read, "<List2.txt")or die $!;
    $FINAL = "Maximum points per Lab";
    while(<$read>){
    print $_;
    if($_ =~ m/"Maximum points per Lab"/)
    for($i = 1; $i<=6; $i++)
    $sum = <$read>

    and I've tried replacing =~ with eq $FINAL

    the if statement always evaluates to false

  2. #2
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    Print the exact output.
    I want to know what the value of $_ is.

    Cheers,
    Robin
    New Users, please read this..
    Google first, then ask..

  3. #3
    Just Joined!
    Join Date
    Oct 2009
    Posts
    10
    it turned out the problem was I was giving it the wrong file
    sorry about this, delete the post

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...