in reply to Re: updating Input file
in thread updating Input file

You need to be careful not to delete the wrong (multiple) students too. For the examples that waswas-fng and pzbagel gave, if you attempt to delete student 12 (John), it will also delete users 120-129. . . You might want to consider using a hash with the student number as the key instead of the arrays to prevent that.

- - arden.

Replies are listed 'Best First'.
Re: Re: Re: updating Input file
by ambrus (Abbot) on Feb 23, 2004 at 22:55 UTC

    Noone yet has answered what the problem is witheyour original script you gave.

    The problem is

    1. it chops newlines but does not write them back. Change print FILECOPY; to print FILECOPY $_,$/;.
    2. You did not chomp $std. This is neccessary as otherwise the regexp wont match.
    3. It would be wise to change s/$_// to next.
    4. Also the filename "/home/stdInfo" may be wrong.

    5. Also arden says:

      For the examples that waswas-fng and pzbagel gave, if you attempt to delete student 12 (John), it will also delete users 120-129. . .

      That is also true for the original script in the question. So change /^$std/ to /^\Q$std\E\b/.

    Apart from these your script is correct.
      thanks much
Re: Re: Re: updating Input file
by ambrus (Abbot) on Feb 23, 2004 at 21:42 UTC

    I belive that my solution is correct in this sense. $a{stdNum}==12 will match only student number 12.

    You only have to make sure that there are no spaces in the stdNam field or change split to split /\s\s+/.

    (Maybe you wanted to post this as a reply to the original question not my post. I'm not sure.)