most of my script using simple perl(i'm not perl one liner) utk senang kefahaman.ada gak dlm javascript and php too. so dont expect too much... mcm bro rizal(founder ittutor.net) ckp, sharing is caring.
mungkin ada sesetengah script/code/function anda telah jumpa di internet or gunakan. so kalau rasa bleh dimanfaatkan.. pakai la...
untuk starter... rasala subroutines perl ini..
kegunaan nya bila kita nak standardkan size number, 1 menjadi 0001 dan seterusnya....
###############
sub pad {
###############
my ($count,$pad_size) = @_;
my $print_count = $count;
my $count_length = length($count);
# Pad the number if it is smaller than $pad_size.
for ($i = $pad_size;$i > $count_length;$i--) {
$print_count = "0$print_count";
}
return ($print_count);
}
cara pengunaannya:
my $newpadnumber = &pad($number,$padsize);
have fun
No comments:
Post a Comment