Hi Monks, I have an input file which contains a student information as follow:
stdNum stdNam stdLoc stdAge stdGrd 43 gorge Brazil 28 A 12 John FL 83 B+ 66 Sam Canada 43 C
What I need to do is to be able to update this file base on the user information let's say I want to delete student so I should be able to delete the whole line that contains the infromation about the student or if I want to only update somthing let's say the age. I am trying to do it by reading the file making the change and copying to another but don't seem to work for me . I am sure there is a better way to update the file than what I am doing .. Can someoen advice? here is an example of what I am doing :
my $stdInfo="/home/stdInfo"; print " Enter the number of student that you want to delete\n"; my $std = <STDIN>; open(FILE, "$stdInfo") || die "couldn't open $stdInfo\n"; open(FILECOPY, ">std") || die "couldn't open std\n"; while(<FILE>) { chomp; next if ( $_ =~ /^#/ ); if ($_ =~ /^$std/) {s/$_//;} print FILECOPY; } system ( "mv std $stdInfo" ); close(FILECOPY); close(FILE);
give me a funki output and doesn't update the file. thanks

In reply to updating Input file by Anonymous Monk

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.