[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PERL] Eksisterer en fil eller et katalog?



"Christian Wix" <sslug@sslug> writes:

> Jeg havde forestillet mig noget i retning af:
> if (/^$navn/, readdir DIR) {     (her checker jeg på starten af filnavnet)
>   // de er der!
> }

Når du får navnene fra et readdir, så kan du godt stole på at filerne
er der. Du kan dog ikke gøre helt som ovenstående, men prøv noget
ligende følgende:

map {m/<noget til at matche rigtige filer>/ &&
      {
        &do_stuff $_;
      }
    } readdir DH;

Så bliver do_stuff kaldt med alle filnavne, der matcher. Eller hvis du
hellere vil have en liste med filnavne, der matcher:

@filnavne = grep {m/<noget der matcher de rigtige filer>/} readdir DH;

Så kan du tjekker om @filnavne er tom, hvis du bare er intereseret i
om der findes filer der matcher, eller at der ikke gør.

-- 
Når folk spørger mig, om jeg er nørd, bliver jeg altid ilde til mode
og svarer lidt undskyldende: "Nej, jeg bruger RedHat".
                                -- Allan Olesen på dk.edb.system.unix


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 19:54 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *