Array to strings?

Discussion in 'Perl' started by gfs X, Mar 23, 2005.

  1. gfs X

    gfs X Guest

    Hi, Im a complete noob to perl.
    Is there a way to convert array values into a string?

    For example

    @myarr=("Sample","test","Array");
    My desired output: "SampletestArray"
    To then work with as a string.

    I know I could just specify piece by piece but thats just too much and
    very impractical (im using it to generate filenames)

    Much thanks in advance
     
    gfs X, Mar 23, 2005
    #1
    1. Advertising

  2. gfs X

    pingu Guest

    gfs X wrote:
    > Hi, Im a complete noob to perl.
    > Is there a way to convert array values into a string?
    >
    > For example
    >
    > @myarr=("Sample","test","Array");
    > My desired output: "SampletestArray"
    > To then work with as a string.
    >
    > I know I could just specify piece by piece but thats just too much and
    > very impractical (im using it to generate filenames)
    >
    > Much thanks in advance
    >

    see

    perldoc perlfunc
    look for 'join'

    $string = join('',@myarr)

    FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future
    for general Perl questions.
     
    pingu, Mar 23, 2005
    #2
    1. Advertising

  3. gfs X

    gfs X Guest

    On 2005-03-23 05:44:28 -0500, pingu <> said:

    > gfs X wrote:
    >> Hi, Im a complete noob to perl.
    >> Is there a way to convert array values into a string?
    >>
    >> For example
    >>
    >> @myarr=("Sample","test","Array");
    >> My desired output: "SampletestArray"
    >> To then work with as a string.
    >>
    >> I know I could just specify piece by piece but thats just too much and
    >> very impractical (im using it to generate filenames)
    >>
    >> Much thanks in advance
    >>

    > see
    >
    > perldoc perlfunc
    > look for 'join'
    >
    > $string = join('',@myarr)
    >
    > FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future
    > for general Perl questions.


    Pingu, that worked perfectly, Thanks a lot! Ill be sure to move to the
    other group if i have another question.
     
    gfs X, Mar 24, 2005
    #3
    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. Venkat
    Replies:
    4
    Views:
    1,014
    Venkat
    Dec 5, 2003
  2. Kurt Krueckeberg
    Replies:
    2
    Views:
    730
    =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?=
    Nov 17, 2004
  3. Rick

    Comparing strings from within strings

    Rick, Oct 21, 2003, in forum: C Programming
    Replies:
    3
    Views:
    394
    Irrwahn Grausewitz
    Oct 21, 2003
  4. Ben

    Strings, Strings and Damned Strings

    Ben, Jun 22, 2006, in forum: C Programming
    Replies:
    14
    Views:
    810
    Malcolm
    Jun 24, 2006
  5. Amit  Limaye
    Replies:
    4
    Views:
    470
    Phlip
    Apr 10, 2006
Loading...

Share This Page