printing array problem

From: Mark Day (soundz_at_techie.com)
Date: 09/28/04


Date: Tue, 28 Sep 2004 00:56:35 -0700

Any tips on what I'm doing wrong here appreciated.

I'm using perl version 5.6.1 on Win98,

and this test script i've written, I was hoping would print each element
of this array, on a new line, then print the array again in reverse order.

What actually output's is the same array twice with all elements printed
on the same line.

What is wrong with my attempt to reverse the array, adn why does each
scalar not print on a new line?

thanks.

--code snippet---

#!C:\perl\bin\perl

@array = qq(1 2 3 4 5 6 7 8 9 10 11 12 baker's dozen);

foreach (@array)

{

print $_;

print "\n";

}

@array = reverse @array;

foreach (@array) {

print $_;

print "\n";

}



Relevant Pages

  • Re: Working with floating point numbers.
    ... mechanism but now need to reverse the situation and convert a double to the ... I have reversed the code but come stuck when I try to assign the array to ... I've tried to Asc) the string but it didn't work and when I ... Dim S As MyStrings ...
    (microsoft.public.access.modulesdaovba)
  • Re: reverse a collection
    ... indirectly you can leverage this method. ... similar methods, then you are correct, looping may be your only option. ... Array has a reverse method. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Cohens paper on byte order
    ... > you changed from a bit sequence to what appears to be ... an array of unsigned char to represent a bit array, ... in the reverse order instead? ... But the user input IS at the beginning a bit array ...
    (sci.crypt)
  • Re: How to open a file from the end and read the last 100 lines
    ... > I agree CPAN is great. ... #read the file - in reverse - into an array ... messages file. ...
    (comp.lang.perl.misc)
  • Re: IComparable.CompareTo not being called on Array.Reverse
    ... Reverse does NOT do a sorted reverse. ... elsewhere I have an array of Item> ... when I want to sort I do this... ...
    (microsoft.public.dotnet.languages.csharp)