Mark Knoop wrote:
> Howard wrote:
>
>>my ($basename) = $_ =~ / ^(.*)\.[^.]+$/;
>>
>
>
> I presume the space ^ there is an error. Even so this does not work on
> 123
>
> $bill wrote:
>
>
>>I'd probably do it the easy way and just remove the ext:
>>
>>(my $file = $_) =~ s/\.[^.]*$//;
>>print "$file\n";
>>____________________
>
>
> I would do it this way too... but I have got a bit sucked in to trying to do
> it using the model that was initially suggested which makes a neat little
> puzzle. I am stumped though! Can anyone find a way using the
>
>
>>$_="123";
>>/(XX)YY/;
>>print "$1\n" ; # result: "123";
>
>
> form?
>
> Or can someone prove that it can't be done?
How about a slight variation :
foreach ('123', '123.', '123.txt', '123.some.txt', '123.some.text.txt') {
/^(?:(.*)\.[^.]+|(.*)\.|([^.]+))$/;
print $1 || $2 || $3, "\n";
}
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs