Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default Reverse Order?

    I read a text file into HTML for viewing through a webpage, fairly
    straight forward.

    Open (INFILE, "<filename.txt") || die "Error opening
    filename.txt.$!,stopped";
    @array = <INFILE>;
    Close(INFILE);
    Foreach my $rec (@array) {
    chomp($rec);
    ($a,$b) = split(/\|/,$rec);
    print "<i>$a - $b</i><br>\n";
    };

    This code simply reads the text file, and populates it to the screen in
    the line order from the text file. I need to reverse the order from the
    text file to the screen. So that the last entry in the text file appears
    at the top of the HTML page? Can anyone help me out? I'm hoping that I
    can just do this in the display code, and that I don't have to rewrite
    the file writing sequence.

    Sincerely in Christ,
    Mark

    Mark Weisman Guest

  2. Similar Questions and Discussions

    1. sw parameters in reverse order
      We have several shockwave objects built into our learning management application. These objects use ini files to display user relevant learning...
    2. Tab Order always greyed out, need to redefine order but can't
      I had a check box but then i had to delete it and change it to a text field. now my tab order is all out of whack and I can't seem to set the tab...
    3. How can I - Reverse Page Order? Delete all odd pages?
      I have documents that need to be archived, unfortunately the laser printer makes then curl so I can't scan them as simplex through the ADF. I can get...
    4. php/mysql query insert values into enters the records in reverse order
      I'm loading tab delimited lines from a txt file using php and running a query for each line to enter the data into a mysql database. However the...
    5. Reverse Page Order
      I have a 25 page pdf document that is in the wrong order. What is the best way to reverse this order? Thank you.
  3. #2

    Default RE: Reverse Order?

    > try
    >
    > open (INFILE, "<filename.txt") || die "Error opening
    > filename.txt.$!,stopped"; @array = <INFILE>; close(INFILE);
    > foreach my $rec (reverse(@array)) {
    > chomp($rec);
    > ($a,$b) = split(/\|/,$rec);
    Just a litle tip, I think it's not a good idea to use
    $a and $b variables since Perl uses those for sort() and whatever.
    > print "<i>$a - $b</i><br>\n";
    > };
    >
    >
    > -----Original Message-----
    > From: Mark Weisman [mailto:mark@outlander.us]
    > Sent: Tuesday, September 02, 2003 8:53 AM
    > To: [email]beginners@perl.org[/email]
    > Subject: Reverse Order?
    >
    >
    > I read a text file into HTML for viewing through a webpage,
    > fairly straight forward.
    >
    > Open (INFILE, "<filename.txt") || die "Error opening
    > filename.txt.$!,stopped"; @array = <INFILE>; Close(INFILE);
    > Foreach my $rec (@array) {
    > chomp($rec);
    > ($a,$b) = split(/\|/,$rec);
    > print "<i>$a - $b</i><br>\n";
    > };
    >
    > This code simply reads the text file, and populates it to the
    > screen in the line order from the text file. I need to
    > reverse the order from the text file to the screen. So that
    > the last entry in the text file appears at the top of the
    > HTML page? Can anyone help me out? I'm hoping that I can just
    > do this in the display code, and that I don't have to rewrite
    > the file writing sequence.
    >
    > Sincerely in Christ,
    > Mark
    >
    > --
    > To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
    > For additional commands, e-mail: [email]beginners-help@perl.org[/email]
    >
    >
    Dan Muey Guest

  4. #3

    Default RE: Reverse Order?

    Worked like a charm, big time thanks.

    Sincerely in Christ,
    Mark-Nathaniel Weisman
    President / Owner
    Outland Domain Group Consulting
    Anchorage / Washington DC / Bellevue
    [email]mark@outlander.us[/email]


    -----Original Message-----
    From: [email]Marcos.Rebelo@eurocopter.com[/email] [mailto:Marcos.Rebelo@eurocopter.com]

    Sent: Monday, September 01, 2003 10:58 PM
    To: Mark Weisman; [email]beginners@perl.org[/email]
    Subject: RE: Reverse Order?


    try

    open (INFILE, "<filename.txt") || die "Error opening
    filename.txt.$!,stopped"; @array = <INFILE>; close(INFILE); foreach my
    $rec (reverse(@array)) {
    chomp($rec);
    ($a,$b) = split(/\|/,$rec);
    print "<i>$a - $b</i><br>\n";
    };


    -----Original Message-----
    From: Mark Weisman [mailto:mark@outlander.us]
    Sent: Tuesday, September 02, 2003 8:53 AM
    To: [email]beginners@perl.org[/email]
    Subject: Reverse Order?


    I read a text file into HTML for viewing through a webpage, fairly
    straight forward.

    Open (INFILE, "<filename.txt") || die "Error opening
    filename.txt.$!,stopped"; @array = <INFILE>; Close(INFILE); Foreach my
    $rec (@array) {
    chomp($rec);
    ($a,$b) = split(/\|/,$rec);
    print "<i>$a - $b</i><br>\n";
    };

    This code simply reads the text file, and populates it to the screen in
    the line order from the text file. I need to reverse the order from the
    text file to the screen. So that the last entry in the text file appears
    at the top of the HTML page? Can anyone help me out? I'm hoping that I
    can just do this in the display code, and that I don't have to rewrite
    the file writing sequence.

    Sincerely in Christ,
    Mark
    Mark Weisman Guest

Posting Permissions

  • You may not post new threads
  • You may 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