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 :stdNum stdNam stdLoc stdAge stdGrd 43 gorge Brazil 28 A 12 John FL 83 B+ 66 Sam Canada 43 C
give me a funki output and doesn't update the file. thanksmy $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);
In reply to updating Input file by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |