>>>>> I don't claim to be a master, but you can do something along the lines of:
>>>>> 
>>>>> $range = '4.3:8.3';
>>>>> $range =~ /(\d+).(\d+).(\d+).\2/ and print map "$_.$2 ", $1 .. $3;
>>>>> 
>>>>> Since it appears you require that the fractional part be the same for both
>>>>> ends of the range, I'm just capturing the integer parts and using Perl's
>>>>> range operator to build the list to feed to map()
>>>> 
>>>> I do have a question, I notice you use "and" like an if..then.  What if you
>>>> wanted to do two things if that =~ held true?  Is that possible?
>>> 
>>> Yes.
>>> 
>>> if ( $range =~ /(\d+).(\d+).(\d+).\2/ ) {
>>>     print map "$_.$2 ", $1 .. $3;
>>>     # do something else
>>>     }
>> 
>> 
>> 
>> I actually meant doing 2 things using the--
>> 
>> statement 1 and statement 2;
>> 
>> -- syntax.
>> 
>> I thought there was a way to use braces to enclose a set of statements as if
>> it were one, but I could never get it to work in this type of statement...
> 
> Of course. This is Perl:
> 
> condition and do { statement1; statement2... }
> 
> BUT, the way John suggested is "The Right Way" to do it. Complex
> statements are more difficult to interpret by humans, are more prone to
> be buggy, and are difficult to debug.


Ah, that was the missing key!  Thanks, Randy.  I probably won't use this
much, but it might come in handy at some point...

- B




-- 
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