I'm having a problem splitting a variable and need some help. What I have is
some variables with a name, and then information in parens. A couple examples:
$data = David (man from uncle);
$data = John Doe (The boy down the hall);
What I want to do is split $data into two string
Hi,
Somethig like this should work (untested):
my ( $name, $info ) = split /\(/, $data;
regards, Aim.
[EMAIL PROTECTED] wrote:
I'm having a problem splitting a variable and need some help. What I have is
some variables with a
Jimstone7 wrote at Thu, 27 Mar 2003 06:39:25 -0500:
$data = David (man from uncle);
$data = John Doe (The boy down the hall);
What I want to do is split $data into two string variables, one holding the
$name, and the other holding all the $info that is within the parens. How
would
Janek Schleicher wrote:
Jimstone7 wrote at Thu, 27 Mar 2003 06:39:25 -0500:
$data = David (man from uncle);
$data = John Doe (The boy down the hall);
What I want to do is split $data into two string variables, one holding the
$name, and the other holding all the $info that is
Stefan Lidman wrote at Thu, 27 Mar 2003 13:55:27 +0100:
Janek Schleicher wrote:
I would use a regexp:
my ($name, $info) = $data =~ /(.*?)\w+\((.*)\)/;
I guess you ment:
my ($name, $info) = $data =~ /(.*?)\s*\((.*)\)/;
Yep.
Cheerio,
Janek
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
Rob Dixon wrote at Thu, 27 Mar 2003 12:51:46 +:
Janek Schleicher wrote:
$data = David (man from uncle);
$data = John Doe (The boy down the hall);
What I want to do is split $data into two string variables, one holding the
$name, and the other holding all the $info that is
Janek Schleicher wrote:
Rob Dixon wrote at Thu, 27 Mar 2003 12:51:46 +:
I'm afraid your regex is wrong! It does the following:
Yep, it was a typo and untested.
capture zero or more (as few as possible) of any character
!! match one or more 'word' characters followed by an
What's the problem with my split?
$line = "var=value";
($var, $value) = split(/\s*[=]\s*/, $line);
Looks fine to me.
I experienced that $var and $value contained the first letter of the
var and
the value. Sometimes nothing. Where is the error?
Looks to me like it must be in your
On 8/5/01 9:39 PM, Romek KrisztiƔn wrote:
Hello!
What's the problem with my split?
$line = var=value;
($var, $value) = split(/\s*[=]\s*/, $line);
Krisztian
I experienced that $var and $value contained the first letter of the var and
the value. Sometimes nothing. Where is