Help for this page

Select Code to Download


  1. or download this
    my $dir = '/path/of/dir';
    opendir my $dh, $dir or die "Can't opendir '$dir': $!\n";
    unlink grep s{^(.*$mypattern)}{$dir/$1}i, readdir $dh;
    
  2. or download this
    # opendir as above
    foreach my $file ( grep /$mypattern/i, readdir $dh ) {
        my $path = "$dir/$file";
        unlink $path or die "Can't unlink '$path': $!\n";
    }