M626
Programmer
- Mar 13, 2002
- 299
I found this code to delete every that is *.tst but how can i can it to delete anything that's ._*.*
unlink qq($dir\\$file) if $file=~/\.tst$/i;
unlink qq($dir\\$file) if $file=~/\.tst$/i;
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]File::Spec::Functions[/green] [red]qw([/red][purple]catfile[/purple][red])[/red][red];[/red]
[black][b]use[/b][/black] [green]strict[/green][red];[/red]
[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [blue]$dir[/blue] = [red]'[/red][purple]foo[/purple][red]'[/red][red];[/red]
[url=http://perldoc.perl.org/functions/opendir.html][black][b]opendir[/b][/black][/url][red]([/red][black][b]my[/b][/black] [blue]$dh[/blue], [blue]$dir[/blue][red])[/red] or [url=http://perldoc.perl.org/functions/die.html][black][b]die[/b][/black][/url] [red]"[/red][purple]Can't open [blue]$dir[/blue]: [blue]$![/blue][/purple][red]"[/red][red];[/red]
[olive][b]foreach[/b][/olive] [black][b]my[/b][/black] [blue]$name[/blue] [red]([/red][url=http://perldoc.perl.org/functions/readdir.html][black][b]readdir[/b][/black][/url][red]([/red][blue]$dh[/blue][red])[/red][red])[/red] [red]{[/red]
[olive][b]next[/b][/olive] [olive][b]if[/b][/olive] [blue]$name[/blue] !~ [red]m{[/red][purple]^[purple][b]\.[/b][/purple]_.*[purple][b]\.[/b][/purple].*$[/purple][red]}[/red][red];[/red]
[black][b]my[/b][/black] [blue]$file[/blue] = [maroon]catfile[/maroon][red]([/red][blue]$dir[/blue], [blue]$name[/blue][red])[/red][red];[/red]
[url=http://perldoc.perl.org/functions/unlink.html][black][b]unlink[/b][/black][/url] [blue]$file[/blue] or [black][b]die[/b][/black] [red]"[/red][purple]Can't unlink [blue]$file[/blue]: [blue]$![/blue][/purple][red]"[/red][red];[/red]
[red]}[/red]
[url=http://perldoc.perl.org/functions/closedir.html][black][b]closedir[/b][/black][/url][red]([/red][blue]$dh[/blue][red])[/red][red];[/red]