Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Small adjustment to array

Reply
Thread Tools

Small adjustment to array

 
 
Francois
Guest
Posts: n/a
 
      08-27-2003
I have an array ( @array ) which i want to change to a list of values like
this:

my $data = ["0", "", "", "3", "", "", "6", "", "", "9", "", "", "12"];

(The numbers are the values in the array)
The length of the array is dynamic... so it could be (0,3,6,9,12) but also
(2,4,6,8,10,12,14,16)

What is the easiest way to do this?


 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      08-27-2003
Francois wrote:
> I have an array ...


So, you started in two CGI groups, then you posted the same question
to alt.perl, and now here. Others in this group may be interested in
knowing about the message below:

-------- Original Message --------
Subject: Re: Small adjustment to array
Date: Wed, 27 Aug 2003 10:49:50 +0200
From: Gunnar Hjalmarsson <>
Newsgroups:
alt.perl,comp.infosystems.www.authoring.cgi,de.comp.lang.perl.cgi
Followup-To: alt.perl
References: <3f4c665a$0$28896$>

Francois wrote (to alt.perl):
> I have an array ...


You posted the same question to two CGI groups, and you have already
received some replies there. What you did is called multiposting, and
is considered bad manner on Usenet.

On the other hand, since your question has nothing to do with CGI,
alt.perl is a more appropriate group.

> ... ( @array ) which i want to change to a list of values like
> this:
>
> my $data = ["0", "", "", "3", "", "", "6", "", "", "9", "", "", "12"];
>
> (The numbers are the values in the array)
> The length of the array is dynamic... so it could be (0,3,6,9,12)
> but also (2,4,6,8,10,12,14,16)
>
> What is the easiest way to do this?


Didn't you learn _anything_ from the discussion in the CGI groups,
such as explaining more clearly what it is you want??

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

 
Reply With Quote
 
 
 
 
Francois
Guest
Posts: n/a
 
      08-27-2003
Thanks for giving a normal answer! I appreciate that much.
I'm going to try this...

"Anno Siegel" <> wrote
> > I have an array ( @array ) which i want to change to a list of values

like
> > this:
> >
> > my $data = ["0", "", "", "3", "", "", "6", "", "", "9", "", "", "12"];
> >
> > (The numbers are the values in the array)
> > The length of the array is dynamic... so it could be (0,3,6,9,12) but

also
> > (2,4,6,8,10,12,14,16)
> >
> > What is the easiest way to do this?

>
> my $data = [ map { ( $_, '', '') } @array];
>
> This will have two emtpty strings after the last element too.
>
> Anno



 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      08-27-2003
Francois wrote:
> I have an array ( @array ) which i want to change to a list of values

[...]

You may want to contact a namesake of yours who posted exactly the same
question in alt.perl.
Probably he got some advice already.

jue


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
per-character font base adjustment paramucho HTML 13 08-17-2005 07:34 PM
XP Clock adjustment Franco Computer Support 2 02-17-2005 07:16 PM
213T Monitor adjustment, ATI video card adjustment Ted Digital Photography 0 11-16-2004 06:19 PM
SWING components adjustment in different resolutions - Should show scrollbars less than 800X600 and expand components over this resolution Bluetears76 Java 1 07-01-2004 09:01 PM
JChart Y axis adjustment. djnex Java 1 11-12-2003 04:25 PM



Advertisments
 



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