in reply to need help using split()

Adapted from "Effective Perl Programming" p. 62. Most likely my adaption, adapted good code to bad. :-)

while (<DATA>) { my @tok; while (s/^([A-Z][a-z]?|[0-9])//) { push @tok, $1; } print join('-', @tok), "\n"; } __DATA__ TTh7 MF4 ThF1 Results T-Th-7 M-F-4 Th-F-1

Replies are listed 'Best First'.
Re: Re: need help using split()
by merlyn (Sage) on Mar 22, 2001 at 02:34 UTC
      thanks merlyn it worked.

      anyway I was originally hoping not to constrain the user to one input format.
      I tried modifying your code in a couple different ways but none of them worked.
      Any further help would be appreciated.

      Thanks again.
           -Etan