Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

File extension extraction from filename
How does one extract check for the file extension part or a filename in
Perl?

Thanks

Report this thread to moderator Post Follow-up to this message
Old Post
Deke
10-13-04 01:55 AM


Re: File extension extraction from filename
Deke <Deke@nospam.com> wrote in news:10mojl1hbb74va0@news.supernews.com:

> How does one extract check for the file extension part or a filename in
> Perl?

I assume the filenames you are interested in are in the following format:

name.extension

That is, I am going to require that the extension of

.bashrc

is blank.

We are interested in the string following the last period in the name:

#! /usr/bin/perl

use strict;
use warnings;

my @list = qw(name name.extension .extension);

for (@list) {
my ($ext) = /.+\.(\w+)?$/;
defined $ext or $ext = '';

print "Name: $_\tExtension: $ext\n";
}

__END__

Also, look into File::Basename::fileparse

http://search.cpan.org/~nwclark/per...ile/Basename.pm

Sinan.

Report this thread to moderator Post Follow-up to this message
Old Post
A. Sinan Unur
10-13-04 01:55 AM


Re: File extension extraction from filename
Deke wrote:
> How does one extract check for the file extension part or a filename
> in Perl?

Any particular problems with File::Basename?

jue



Report this thread to moderator Post Follow-up to this message
Old Post
Jürgen Exner
10-13-04 08:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:55 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.