One of my favorite things about perl is that long and tedious solutions can
often be replaced by incredibly elegant and concise ones.

I'm writing a sequence generator.  I've got most of it handled, but this
part bugs me.  I want it to take the variable $field containing, e.g.:

4.3:8.3

And turn it into an array:

4.3  5.3  6.3  7.3  8.3

Here's what I've got:

     if ($field =~ /^(\S+(\.(\d*))):(\S+(\2))$/) {
         ($a,$b) = ($1,$4);
         while ($a <= $b) { push @vector, $a++; }
     }

I guess it just feels really sloppy, like I should be able to do the last
two lines in a single map command or something.

Obviously it's not urgent, I just like seeing how the masters do this kind
of thing.  =)

- Bryan




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to