Search
 
SCRIPT & CODE EXAMPLE
 

PERL

Perl list files and folders in a directory

my $dir = "bla/bla/upload";
opendir DIR,$dir;
my @dir = readdir(DIR);
close DIR;
foreach(@dir){
    if (-f $dir . "/" . $_ ){
        print $_,"   : file
";
    }elsif(-d $dir . "/" . $_){
        print $_,"   : folder
";
    }else{
        print $_,"   : other
";
    }
}
Comment

Perl list files and folders in a directory

opendir my $dir, "/some/path" or die "Cannot open directory: $!";
my @files = readdir $dir;
closedir $dir;
Comment

Perl list files and folders in a directory

use File::Find;

my @content;
find( &wanted, '/some/path');
do_something_with( @content );

exit;

sub wanted {
  push @content, $File::Find::name;
  return;
}
Comment

PREVIOUS NEXT
Code Example
Perl :: perl 
Perl :: Perl (perl 5.28.1) sample 
Perl :: len perl 
Perl :: Perl - Common Conditional Statements 
Pascal :: pascal read 
Pascal :: pascal exception handling 
Pascal :: begin in pascal 
Pascal :: pascal const 
Powershell :: call function powershell 
Gdscript :: godot close game 
Gdscript :: GAScript - Google Sheets - QBO API - Consent Dialogue Box 
Clojure :: folding at home linuxserver.io 
Cobol :: alertDialog with textfield validator flutter 
Assembly :: MOD OPERATOR for register in arm assembly 
Assembly :: dataframe.shape return what? 
Assembly :: 2su.communications.syr.edu]2su.communications.syr.edu 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: map range of numbers to another range 
Javascript :: jest cache clear 
Javascript :: javascript replace spaces with dashes 
Javascript :: import redux thunk 
Javascript :: jquery refresh page 
Javascript :: delete session javascript 
Javascript :: get week day name in javascript 
Javascript :: how to remove checked attribute of checkbox in jquery 
Javascript :: loop array backwards javascript 
Javascript :: generate random whole numbers within a range javascript 
Javascript :: jquery remove and add class 
Javascript :: how to use another port in angular 
Javascript :: How to get current URL with Javascript or React 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =