JustLikeThat has asked for the wisdom of the Perl Monks concerning the following question:
The following code is a simple example of a larger problem I am having. I am trying to transpose a string of characters from a horizontal scalar to a vertical string of characters.
ie) ABCDEFG to:
A
B
C
D
E etc
The code below almost gives me what I want but there is one error message that appliers with each character: Argument "character" isn't numeric in array element at C\:dir line 8. Any help on this simple problem would be nice!!
Thanks in advance for your help!!#!/usr/bin/perl use strict; use warnings; my $phrase="I like apple pie"; #### set the phrase my @array = split(//, $phrase);### split phrase into individual charac +hters### foreach my $w (@array){ print "$array[$w]\n"; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Transposing an Array
by Arunbear (Prior) on Nov 11, 2004 at 21:57 UTC | |
by rev_1318 (Chaplain) on Nov 11, 2004 at 22:27 UTC | |
|
Re: Transposing an Array
by tachyon (Chancellor) on Nov 11, 2004 at 22:33 UTC | |
|
Re: Transposing an Array
by ikegami (Patriarch) on Nov 11, 2004 at 21:40 UTC | |
|
Re: Transposing an Array
by atcroft (Abbot) on Nov 11, 2004 at 22:02 UTC | |
|
Re: Transposing an Array
by gube (Parson) on Nov 12, 2004 at 10:08 UTC | |
by JustLikeThat (Initiate) on Nov 15, 2004 at 15:24 UTC | |
by Happy-the-monk (Canon) on Nov 15, 2004 at 16:42 UTC | |
|
Re: Transposing an Array
by Anonymous Monk on Nov 12, 2004 at 09:58 UTC | |
|
Re: Transposing an Array
by TedPride (Priest) on Nov 12, 2004 at 07:48 UTC |