jiaoziren has asked for the wisdom of the Perl Monks concerning the following question:
And this is what the file looks like:#!/usr/bin/perl print "content-type: text/html\n\n "; print "<head><title> DEEEalers </title></head> "; print "<body>\n "; print "<h1> Dealers Listing</h1> "; print "<table border>\n "; print "<tr><th>surname</th> "; print "<th>given</th>" ; print "<th>suburb</th>" ; print "<th>postcode</th></tr> "; open (names,"/var/www/cgi-bin/data/dealers.txt "); while ($aline = <names>) { chomp($aline); @fields = split(/,/,$aline); $surn = @fields[0]; $given = @fields[1]; $suburb = @fields[2]; $pcode = @fields[3]; print "<tr>"; print "<td>$surn </td>"; print "<td>$given </td>"; print "<td>$suburb </td>"; print "<td>$pcode </td>"; print "</tr>" ; } print "</table>\n "; print "</body>\n "; exit;
Now I want to extract only the record of whose surname begins with "B", how can I modify my original code to realize this function?PACKHAM,Staeven,MELBOURNE,3011, JACKSON,Shane,MELBOURNE,3004, PADDLE,Ben,MOONEE PONDS,3053,C RAHIM,Stuart,MELBOURNE,3000,C LAI,Bernard,MELBOURNE,3039, BAIRD,Michael,MELBOURNE,2073, FAIRSERVICE,Daniel,MELBOURNE,3000,N GAKOVIC,D,MELBOURNE,3004, MALCOLM,Raymond,MASCOT,2060,X HALEY,Peter,MIRANDA,2640, WALKER,Richard,MALVERN,3150,N HALL,David,MELBOURNE,3002, VALLAK,Simon,MELBOURNE,3043, BALLANTYNE,Anne,MELBOURNE,3000,C BALLER,Sarah,MELBOURNE,3000,C
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help on String manipulation
by davido (Cardinal) on May 13, 2006 at 05:04 UTC | |
by jiaoziren (Initiate) on May 13, 2006 at 05:09 UTC | |
|
Re: Help on String manipulation
by Zaxo (Archbishop) on May 13, 2006 at 05:07 UTC | |
by jiaoziren (Initiate) on May 13, 2006 at 05:15 UTC | |
by davido (Cardinal) on May 13, 2006 at 05:19 UTC | |
by jiaoziren (Initiate) on May 13, 2006 at 05:30 UTC | |
by duff (Parson) on May 13, 2006 at 05:44 UTC | |
| |
|
Re: Help on String manipulation
by Samy_rio (Vicar) on May 13, 2006 at 05:18 UTC | |
by jiaoziren (Initiate) on May 13, 2006 at 05:23 UTC | |
|
Re: Help on String manipulation
by TedPride (Priest) on May 13, 2006 at 20:26 UTC |