I've been writing Perl for 17 years and I'm still learning new and better ways to write code. Here's another way based on kcott's excellent answer below.
#!/usr/bin/perl -w use strict; use autodie; my ($user_file, $changed_file) = qw{test.txt test.txt.mod}; open my $in_fh, '<', $user_file; open my $out_fh, '>', $changed_file; print "Which user? "; my $user = <STDIN>; chomp $user; print $out_fh grep !/^$user,/, <$in_fh>;
This one slurps the whole file with the angle brackets, passes it through grep to filter the output which gets printed to the output file. Note the exclamation mark in front of the regex. It's the "not" operator which says you don't want the matching lines in your output.

Keep working at it. From the long list of replies, you've certainly piqued the Monks' interest.

Sometimes I can think of 6 impossible LDAP attributes before breakfast.

In reply to Re^3: problem with deleting a row by Ea
in thread problem with deleting a row by brianMonk

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.