CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
How do I print all the elements of an array, less than last

 



zradu
New User

Jan 6, 2012, 10:09 AM

Post #1 of 2 (1248 views)
How do I print all the elements of an array, less than last Can't Post

my @array = ("xxx aaa","zzz bbb","yyy ccc","aaa xxx","bbb yyy","ccc zzz");

I want to print all elements of an array, less than last.


BillKSmith
Veteran

Jan 6, 2012, 10:24 AM

Post #2 of 2 (1245 views)
Re: [zradu] How do I print all the elements of an array, less than last [In reply to] Can't Post

Use an array slice.


Code
  

use strict;
use warnings;
my @array = ("xxx aaa","zzz bbb","yyy ccc","aaa xxx","bbb yyy","ccc zzz");
print join( "\n",@array[0..$#array-1]);

Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives