PerlFunc: file_parts()

Not perfect, but it will return a breakdown of the various parts (path, name, extension) of a given file.

sub file_parts {
    my $file = shift();
    my $ret;

    #print "File: $file\n";

    if ($file =~ /(.*\/)?(.*?)\.(.*)/) {
        $ret->{'path'} = $1;
        $ret->{'name'} = $2;
        $ret->{'ext'} = $3;
    }

    return $ret;
}


Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 3.14.70.203
To prevent spam please submit by clicking the kitten: