Perl
Inhaltsverzeichnis |
Perl
scripte
downlaod a site and change php endings into html
mklocal.pl
perl exampel
make file lowercase in linux
# perl -e 'for (<*>){ $name = lc($_); system("mv $_ $name"); }'
delete suffux
# perl -e 'for(<*.iso>) { $name = $_; $name =~ s#.iso## ; system ("mv $_ $name") } '
replace suffix
# perl -e 'for(<*.php>) { $name = $_; $name =~ s#.php#.html# ; system ("mv $_ $name") } '
loop über eine ordner
@inhalt = `ls -1 /path/to/folder/`;
foreach(2inhalt){
print $_;
}
rename 3.png, 34.png, 233.png to 0003.png, 0034.png, 0233.png
perl -e 'for(<*>) { $org = $_; $_ =~ s/\D*(\d{1,4})\.{1}.*/$1/g; $_ = "000".$_; $_ =~ s/.*(\d{4}$)/$1/; $com = "mv -v $org screen_$_.png"; print $com ."\n"; `$com`; }'
array loop
1.
@Array = ("one", "two", "three", "four") ;
forech(@Array){
print $_;
}
2.
@Array = ("one", "two", "three", "four") ;
$ending_value = scalar(@Array) ;
# @Array returns a scalar in this context
for($counter=0 ; $counter < $ending_value ; $counter++)
{
print "$Array[$counter] " ;
}
quelle: http://perl.about.com/cs/beginningperl/a/010703.htm
instellation von CPAN modulen
perl -MCPAN -e 'install Text::CSV_PP.pm'
csv
links:
http://www.mathematik.uni-ulm.de/help/perl5/doc/DBD/CSV.html http://search.cpan.org/~jwied/Text-CSV_XS-0.23/CSV_XS.pm
array
http://www.htmlite.com/perl016.php
umleitungen
http://omaha.pm.org/emails/2003/msg00256.html
regex
links:
http://en.wikipedia.org/wiki/Perl_regular_expression_examples