> # foo.txt.bak => bak
> ($extension) = $name =~ /.*\.([^.]*)/;
> # or
> # ($extension) = $name =~ /\.([^.]*)$/;
It doesn't work if there is no extension in $name.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
On Apr 11, Ahmed Moustafa said:
>> # foo.txt.bak => bak
>> ($extension) = $name =~ /.*\.([^.]*)/;
>> # or
>> # ($extension) = $name =~ /\.([^.]*)$/;
>
>It doesn't work if there is no extension in $name.
Yes, and like I said in the post, if there is NO extension AT ALL (meaning
no . at al
On Apr 9, Ahmed Moustafa said:
>John W. Krahn wrote:
>> Ahmed Moustafa wrote:
>>
>>>Jeff, thanks a lot for your explanation. I really appreciate it.
>>>
>>>Jeff 'Japhy' Pinyan wrote:
>>>
Please use File::Basename. Save us all the headache.
>>>I was thinking that avoiding modules would
On Apr 9, Ahmed Moustafa said:
>Jeff, thanks a lot for your explanation. I really appreciate it.
>
>Jeff 'Japhy' Pinyan wrote:
>> Please use File::Basename. Save us all the headache.
>
>I was thinking that avoiding modules would make the code more portable.
>Am I right?
File::Basename is a STA
John W. Krahn wrote:
> Ahmed Moustafa wrote:
>
>>Jeff, thanks a lot for your explanation. I really appreciate it.
>>
>>Jeff 'Japhy' Pinyan wrote:
>>
>>>Please use File::Basename. Save us all the headache.
>>>
>>I was thinking that avoiding modules would make the code more portable.
>>Am I right?
Ahmed Moustafa wrote:
>
> Jeff, thanks a lot for your explanation. I really appreciate it.
>
> Jeff 'Japhy' Pinyan wrote:
> > Please use File::Basename. Save us all the headache.
>
> I was thinking that avoiding modules would make the code more portable.
> Am I right?
No, _using_ modules woul
Jeff, thanks a lot for your explanation. I really appreciate it.
Jeff 'Japhy' Pinyan wrote:
> Please use File::Basename. Save us all the headache.
I was thinking that avoiding modules would make the code more portable.
Am I right?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional
On Apr 9, Jason Larson said:
> $extension =~ s/(^.+\.?)([^\.]*)$/$2/;
>
>Your regex will fail for a couple of different reasons:
[snip]
Your regex will fail, too. Here's why... assuming $extension is
"foobar.txt", here is how the regex matches:
^ matches the beginning of the string
> -Original Message-
> From: Ahmed Moustafa [mailto:[EMAIL PROTECTED]]
> Subject: regular expression to get a file extension
>
> I had the following regular expression to get the extension
> from a file
> name:
>
>
> $extension = $filename;
> $extension =~ s/(^.+\.)([^\.]+)$/$2/;
>
>
Ahmed Moustafa wrote:
>
> I had the following regular expression to get the extension from a file
> name:
>
>
> $extension = $filename;
> $extension =~ s/(^.+\.)([^\.]+)$/$2/;
>
>
> But it didn't work (in case the $filename didn't have an extension); so
> I had to add the following line:
>
>
10 matches
Mail list logo