>>>>> "AHA" == Alan Haggai Alavi <alanhag...@alanhaggai.org> writes:

  AHA> split considers the pattern given to it, as a delimiter within the
  AHA> expression. Let us consider the three cases:

  >> my @elems1 = split(/\d/,$var);
  AHA> Digits are the delimiters. Delimiters are stripped out of the string
  AHA> by split. Hence, when digits are stripped out of a numeric expression,
  AHA> the result will be undef.

returned strings from the input to split cannot be undef as the input
itself is defined (split will coerce an undef input to a null
string). as john said, grabbed delims that don't match will return undef
as do regexes outside of split.


  >> my @elems2 = split(/./,$var);
  AHA> Again, anything is considered to be a delimiter due to the '.' (match
  AHA> anything). Thus, again, the result is undef.

huh? . IS the delim which means each char is a delim and only the text
between them (null strings) will be returned in a list context.


  >> my @elems3 = split(//,$var);
  AHA> When the pattern is omitted, split splits on whitespace. Since the
  AHA> string does not contain whitespaces, the string cannot be split and
  AHA> split returns the string as it is.

again, wrong. that will split on the null string which matches between
each pair of chars. so it returns a list of single chars.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to