characters from scalar to en array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Arepi
    New Member
    • Sep 2008
    • 62

    characters from scalar to en array

    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!
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    Edit: see my next post..........

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      Maybe this is what you are trying to do:

      Code:
      my $str = 'somelongword';
      my @array = split(//,$str);
      print "$_\n" for @array;

      Comment

      • Arepi
        New Member
        • Sep 2008
        • 62

        #4
        Originally posted by KevinADC
        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

        Code:
        $calar="Hello";
        I want move it to array @t
        See what I want:

        Code:
        $t[0]="H";
        $t[1]="e";
        $t[2]="l";
        $t[3]="l";
        $t[4]="o";
        Thanks!

        Comment

        • Arepi
          New Member
          • Sep 2008
          • 62

          #5
          Originally posted by KevinADC
          Maybe this is what you are trying to do:

          Code:
          my $str = 'somelongword';
          my @array = split(//,$str);
          print "$_\n" for @array;
          Yes this is what I wanted. Thanks for your help!

          Comment

          Working...