Re: split value when there's nothing to split

2010-05-30 Thread Grant
> snip >>        $foo = $string =~ /^([^-])+-/ ? $1 : '' ; >> >> that will grab something from the start to the first - and grab it. if >> it matched it will assign it to $foo, otherwise assign ''. (and '' is >> called the null string, not null. perl has no null things unlike >> databases). > snip

Re: split value when there's nothing to split

2010-05-28 Thread Chas. Owens
On Fri, May 28, 2010 at 14:46, Uri Guttman wrote: >> "CO" == Chas Owens writes: > >  CO> On Fri, May 28, 2010 at 12:44, Uri Guttman wrote: > >  >> the negated char class is usually faster than most similar methods. i >  >> just like it as it says what i really want - a string without any - c

Re: split value when there's nothing to split

2010-05-28 Thread Uri Guttman
> "CO" == Chas Owens writes: CO> On Fri, May 28, 2010 at 12:44, Uri Guttman wrote: >> the negated char class is usually faster than most similar methods. i >> just like it as it says what i really want - a string without any - chars. >> also anchoring helps too in saying this string

Re: split value when there's nothing to split

2010-05-28 Thread Chas. Owens
On Fri, May 28, 2010 at 12:44, Uri Guttman wrote: >> "CO" == Chas Owens writes: > >  CO> On Fri, May 28, 2010 at 01:05, Uri Guttman wrote: >  CO> snip >  >>        $foo = $string =~ /^([^-])+-/ ? $1 : '' ; >  >> >  >> that will grab something from the start to the first - and grab it. if >  

Re: split value when there's nothing to split

2010-05-28 Thread Uri Guttman
> "CO" == Chas Owens writes: CO> On Fri, May 28, 2010 at 01:05, Uri Guttman wrote: CO> snip >>        $foo = $string =~ /^([^-])+-/ ? $1 : '' ; >> >> that will grab something from the start to the first - and grab it. if >> it matched it will assign it to $foo, otherwise assign

Re: split value when there's nothing to split

2010-05-28 Thread Chas. Owens
On Fri, May 28, 2010 at 01:05, Uri Guttman wrote: snip >        $foo = $string =~ /^([^-])+-/ ? $1 : '' ; > > that will grab something from the start to the first - and grab it. if > it matched it will assign it to $foo, otherwise assign ''. (and '' is > called the null string, not null. perl has

Re: split value when there's nothing to split

2010-05-27 Thread Uri Guttman
> "G" == Grant writes: G> The value of $string could include dashes or not. If it is, I'd like G> the value of $foo to be set to the portion of the string to the left G> of the first dash. If not, I'd like the value of $foo to be null. G> I'm doing the following, but $foo is equal

split value when there's nothing to split

2010-05-27 Thread Grant
The value of $string could include dashes or not. If it is, I'd like the value of $foo to be set to the portion of the string to the left of the first dash. If not, I'd like the value of $foo to be null. I'm doing the following, but $foo is equal to "1" if there are no dashes in the string: $fo