Array from a string.
From: Richard S Beckett (spikeywan_at_bigfoot.com.delete.this.bit)
Date: 03/31/04
- Next message: Simon: "count files + dirs"
- Previous message: David K. Wall: "Re: multiple lines / success or failure?!"
- Next in thread: A. Sinan Unur: "Re: Array from a string."
- Reply: A. Sinan Unur: "Re: Array from a string."
- Reply: Gunnar Hjalmarsson: "Re: Array from a string."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 31 Mar 2004 15:31:45 +0100
I've written a nice little script, and it gets it's array of data from the
command line arguments.
If you enter something like this: myscript.pl one two "three four" five
then the @ARGV array will contain:
one
two
three four
five
Which is EXACTLY what I want.
Now, as people seem to have an aversion to DOS these days, I've added a GUI
to the script, so that running it with no arguments fires up the gui
version.
I get my aray from an entry box...
my $entrybox = $mw -> Entry(-textvariable => \$array) -> pack();
The problem is I can't use an array for the text variable, so I have to
convert the string $array into @array.
If I do this:
@array = split(' ', $array);
Entering: one two "three four" five
gives @array of:
one
two
"three
four"
five
I was just trying to sort this out, when I realised it's an absolute
nightmare if I loop through @array, and try to if /^\".*\"/ etc.
Is there an easy way to do this?
Thanks,
-- R. GPLRank +79.699
- Next message: Simon: "count files + dirs"
- Previous message: David K. Wall: "Re: multiple lines / success or failure?!"
- Next in thread: A. Sinan Unur: "Re: Array from a string."
- Reply: A. Sinan Unur: "Re: Array from a string."
- Reply: Gunnar Hjalmarsson: "Re: Array from a string."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|