spikey_wan has asked for the wisdom of the Perl Monks concerning the following question:
Hello World!
This question sounds simple, but when you look into it, you'll realise that there's more to it than first appears. If you run a script from the DOS command line with arguments, the arguments go into @ARGV in EXACTLY the right manner for my application.
Example:
my-script.pl one two "three four" five
will give an @ARGV array like this:
one, two, three four, five
I am trying to replicate this with a GUI, getting the information with a TK Entry widget. Unfortunately the widget will not allow me to assign it's data to an array, so I need to convert the data from it's string to an array.
If I use split, like this:my $entry=$mw->Entry(-textvariable=>\$string)->pack();
Then a string of:@array = split (' ', $string);
I did start looking at looping through this incorrect array, and creating a new 'corrected' one, but when I realised what this entails, I found it was getting a little close to my limit, especially when I worked out all the considerations that need making. This is the sort of string it would have to cope with:
one "two three" fo"ur "five si"x seven "eight
Giving an array of:
one, two three, fo, ur , five, si, x seven , eight
Any help would be much appreciated.
S.
Edit by Chady -- added code tags.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Convert a string to an array?
by halley (Prior) on Mar 31, 2004 at 15:49 UTC | |
|
Re: Convert a string to an array?
by Fletch (Bishop) on Mar 31, 2004 at 16:11 UTC | |
|
Re: Convert a string to an array?
by dreadpiratepeter (Priest) on Mar 31, 2004 at 15:50 UTC | |
|
Re: Convert a string to an array?
by Crackers2 (Parson) on Mar 31, 2004 at 16:29 UTC | |
|
Re: Convert a string to an array?
by Roy Johnson (Monsignor) on Mar 31, 2004 at 15:49 UTC |