![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| what these statements means | namishtiwari | UNIX for Dummies Questions & Answers | 1 | 01-17-2008 02:20 AM |
| Automate SQL statements | panchpan | SUN Solaris | 3 | 01-03-2008 02:32 AM |
| Please help on IF statements. | filthymonk | Shell Programming and Scripting | 4 | 07-18-2007 06:59 AM |
| Else in If Statements | chapmana | UNIX for Dummies Questions & Answers | 8 | 11-30-2006 08:07 AM |
| or statements? | Blip | Shell Programming and Scripting | 1 | 01-19-2004 04:08 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I am trying to change this :
Albert Einstein 52 Peter Scott 22 Hilary Smith 48 Joan Bakewell 30 Catherine Maguire 26 into Albert Einstein Pass Peter Scott Fail Hilary Smith Pass Joan Bakewell Fail Catherine Maguire Fail I have to use a if statement that says: if field 3 is greater then 40 then change field 3 to pass else change field 3 to fail endif but i am failing badly can any please help |
|
||||
|
Here is one perl script. Check for errors then have a try.
#!/usr/bin/perl $PassMark = 40; $InputFile = "filename"; $OutPutFile = "results"; open (INPUTFILE, "$InputFile") || die "Error Reason $!"; @DATA=<INPUTFILE>; close(INPUTFILE); open (RESULTFILE, ">$OutPutFile") || die "Error Reason $!"; foreach $Record(@DATA) { chomp($Record); my($Fname, $Sname, $Mark) = split(/ /, $Record); if($Mark >= $PassMark) { print RESULTFILE "$Fname $Sname PASS\n"; $s++; } else { print RESULTFILE "$Fname $Sname FAIL\n"; $f++; } } close(RESULTFILE); print "$f students Passed, $f Failed(don't hate them )\n";exit; GoodLuck..!! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|