Small adjustment to array

Discussion in 'Perl Misc' started by Francois, Aug 27, 2003.

  1. Francois

    Francois Guest

    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?
     
    Francois, Aug 27, 2003
    #1
    1. Advertising

  2. 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
     
    Gunnar Hjalmarsson, Aug 27, 2003
    #2
    1. Advertising

  3. Francois

    Francois Guest

    Thanks for giving a normal answer! I appreciate that much.
    I'm going to try this...

    "Anno Siegel" <-berlin.de> 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
     
    Francois, Aug 27, 2003
    #3
  4. 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
     
    Jürgen Exner, Aug 27, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. djnex

    JChart Y axis adjustment.

    djnex, Nov 12, 2003, in forum: Java
    Replies:
    1
    Views:
    531
    Perica Milosevic
    Nov 12, 2003
  2. Bluetears76
    Replies:
    1
    Views:
    1,024
    Larry Barowski
    Jul 1, 2004
  3. paramucho
    Replies:
    13
    Views:
    604
    Jukka K. Korpela
    Aug 17, 2005
  4. robert
    Replies:
    0
    Views:
    276
    robert
    Dec 10, 2006
  5. John Nagle
    Replies:
    9
    Views:
    259
    Dennis Lee Bieber
    Mar 21, 2007
Loading...

Share This Page