Professional Web Applications Themes

Sorting in CGI - PERL Beginners

Hi, I am writing a form that will list the name in the file namedata.dat in alphabetical order and display in a web page. #!/usr/bin/perl use strict; use CGI qw(:standard); my namedata; whie (<namedata>){ namedata = split (/\|/,$_); if ($namedata[0] =~name_word){ print"<b> Firstname:$namedata[1]",br()"lastname:$namedata[0]; } } Why do I keep getting errors when I try to test my form? Thanks, Brady --------------------------------- Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software...

  1. #1

    Default Sorting in CGI

    Hi,
    I am writing a form that will list the name in the file namedata.dat in alphabetical order and display in a web page.
    #!/usr/bin/perl
    use strict;
    use CGI qw(:standard);
    my namedata;
    whie (<namedata>){
    namedata = split (/\|/,$_);
    if ($namedata[0] =~name_word){
    print"<b> Firstname:$namedata[1]",br()"lastname:$namedata[0];
    }
    }
    Why do I keep getting errors when I try to test my form?

    Thanks,
    Brady


    ---------------------------------
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site design software
    Brady Jacksan Guest

  2. #2

    Default Re: Sorting in CGI

    Brady Jacksan wrote:
    >
    > Hi,
    Hello,
    > I am writing a form that will list the name in the file namedata.dat
    > in alphabetical order and display in a web page.
    > #!/usr/bin/perl
    > use strict;
    > use CGI qw(:standard);
    > my namedata;
    > whie (<namedata>){
    ^^^^
    Should be 'while'. Where did you open a file with the filehandle
    namedata?

    > namedata = split (/\|/,$_);
    > if ($namedata[0] =~name_word){
    > print"<b> Firstname:$namedata[1]",br()"lastname:$namedata[0];
    > }
    > }
    > Why do I keep getting errors when I try to test my form?
    What errors are you getting?


    To sort the contents of namedata.dat you have to store the complete
    contents in an array (or use an external sort program.)

    open IN, 'namedata.dat' or die "Cannot open namedata.dat: $!";
    chomp( my namedata = sort <IN> );
    close IN;



    John
    --
    use Perl;
    program
    fulfillment
    John W. Krahn Guest

Similar Threads

  1. Sorting array vs sorting paginated array
    By limitedwave777 in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: May 14th, 01:58 PM
  2. sorting
    By John Vinson in forum Macromedia ColdFusion
    Replies: 7
    Last Post: November 16th, 08:56 AM
  3. PHP Sorting
    By J J in forum PHP Development
    Replies: 7
    Last Post: August 29th, 05:06 PM
  4. Help with sorting... please.. :)
    By Sarah in forum ASP Database
    Replies: 1
    Last Post: July 21st, 08:30 AM
  5. Sorting in SQL
    By Jacco Schalkwijk in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: July 9th, 08:11 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139