By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,809 Members | 1,999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,809 IT Pros & Developers. It's quick & easy.

characters from scalar to en array

P: 62
Hi!

I have a string in a scalar. How can I move the characters to en array.
(The first character go in the first place of array,second....)

Thanks!
Oct 13 '08 #1
Share this Question
Share on Google+
4 Replies


KevinADC
Expert 2.5K+
P: 4,059
Edit: see my next post..........
Oct 13 '08 #2

KevinADC
Expert 2.5K+
P: 4,059
Maybe this is what you are trying to do:

Expand|Select|Wrap|Line Numbers
  1. my $str = 'somelongword';
  2. my @array = split(//,$str);
  3. print "$_\n" for @array;
Oct 13 '08 #3

P: 62
Your question makes no sense. Post an example of what you are trying to.

Ok I try demonstrate it:

I have a string in a scalar

Expand|Select|Wrap|Line Numbers
  1. $calar="Hello";
I want move it to array @t
See what I want:

Expand|Select|Wrap|Line Numbers
  1. $t[0]="H";
  2. $t[1]="e";
  3. $t[2]="l";
  4. $t[3]="l";
  5. $t[4]="o";
  6.  
Thanks!
Oct 13 '08 #4

P: 62
Maybe this is what you are trying to do:

Expand|Select|Wrap|Line Numbers
  1. my $str = 'somelongword';
  2. my @array = split(//,$str);
  3. print "$_\n" for @array;
Yes this is what I wanted. Thanks for your help!
Oct 13 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.