develooper Front page | perl.beginners | Postings from March 2011

Re: File::Basename problem

Thread Previous | Thread Next
From:
Téssio Fechine
Date:
March 4, 2011 08:48
Subject:
Re: File::Basename problem
Message ID:
256295.9615.qm@web111712.mail.gq1.yahoo.com
Can't I use the hash in list context with something like itsNotRegex(%sufixTable) ?
I use this hash in a program that find related suffix to know if a file has a source ('.o' => '.c').. and keeping the list of suffixes in another is variable is a kind of rework.  
Thanks for the help!

> De: Shawn H Corey <shawnhcorey@gmail.com>
> Assunto: Re: File::Basename problem
> Para: beginners@perl.org
> Data: Sexta-feira, 4 de Março de 2011, 13:22
> On 11-03-04 11:14 AM, Téssio Fechine
> wrote:
> >     my ( $file, $dir, $sufix ) =
> fileparse( $item, %sufixTable );
> 
> I don't think fileparse takes a hash as the final
> arguments.  It would be converted to an array and both
> the keys and the values used.
> 
> Also, from `perldoc File::basename`:
> 
> If @suffixes are given each element is a pattern (either a
> string or a "qr//") matched against the end of the
> $filename.  The matching portion is removed and becomes
> the $suffix.
> 
> That mean all the periods in the hash will match any
> character.
> 
> Try:
> 
> my @sufixTable = ( '\\.div', '\\.tex', '\\.o', '\\.c',
> '\\.a', );
> 
> 
> -- Just my 0.00000002 million dollars worth,
>   Shawn
> 
> Confusion is the first step of understanding.
> 
> Programming is as much about organization and
> communication
> as it is about coding.
> 
> The secret to great software:  Fail early &
> often.
> 
> Eliminate software piracy:  use only FLOSS.
> 
> -- To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
> 
> 
> 




Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About