codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Array within array  foal at 08:24 on Wednesday, June 11, 2008
 

Hi ,

newbie here.

jus a snippet I was trying. I've been coding in ksh/bash, wondering bout the perl alternative.

@arr=(1,2,3);

I declare a variable which contains the value as :

$new=$arr[0]|$arr[1]|$arr[2];
print "$new\";==> $arr[0]|$arr[1]|$arr[2]

now I want to print the result of $new as the values of the original array,i.e. my print output should be like :
1|2|3.

Any suggestions?

Thanks ppl..

  Re: Array within array  mimir at 08:37 on Wednesday, June 11, 2008
 

foreach(@arr)
{
print STDOUT "$_";

#unless we have reached the "3", add a | behind it.
if($_ =~ /3/){next;}
print STDOUT "|";
}

#was this helpful?



  Re: Array within array  foal at 08:49 on Wednesday, June 11, 2008
 

here , the code just prints the array with a "|".

I need something which would print the value of the variable $new, which would inturn print out values of the original array @arr.

Do I need to read the contents of new into an array through 'split' and then print the array ?

Thanks for the update..

  Re: Array within array  mimir at 08:54 on Wednesday, June 11, 2008
 

@arr = (1,2,3);

#just shove that array into the variable...
foreach(@arr)
{
$new .= $_;

if($_ =~ /3/){next;}
$new .= "|";
}

#and then print it out.
print STDOUT "$new";


#otherwise i dont know.











CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Decoding a string in Javascript
•  Re: Array within array
•  Hey all could some 1 help me ?? thanks
•  Re: Checking for a File that Does Not Exist (Yet)
•  mouse trailer
•  Problems in login using WWW::Mechanize
•  using javascript to embed videos
•  Re: really lost my syntax
•  Urgent:- Please help me out with error XML:Parser no element found


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2008