What do you mean by "just wiped everything out"? One or the other of the example should have worked, unless there is something else wrong.
Tracy Dryden
tracy@bydisn.com
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
Actually, what happened when you used split(//,$string) is that it split the string apart at EACH CHARACTER, which is obviously not what you wanted. When the perlfunc manpage said "If PATTERN is also omitted..." it didn't say HOW to omit the pattern, and I guessed that just using // was the way. I WAS WRONG! :~/ Actually, you apparently can't omit the pattern unless you omit everything! Since the default variable to split is $_, you can assign your string to that before splitting. I tried the following and it worked like a charm:
Code:
$_ = $string;
@DATA = split;
It strips off leading and trailing spaces, then splits on whitespace. It's probably more efficient than the other way.
Tracy Dryden
tracy@bydisn.com
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.