window.addEventListener("load", function(){ alert("کانال تلگرام ما : www.telegram.me/PulseLab"); }); Learning Perl - Writing Exploits5-2
جسارت های در باب امنیت اطلاعات و الکترونیک .
Learning Perl - Writing Exploits5-2
یکشنبه دوازدهم شهریور ۱۳۹۱ ساعت 14:56 | نوشته ‌شده به دست سیروس | ( )

این بخش برای کسانی مورد مفهوم است که در مورد پرل از قبل مطالعه داشتند . در زیر کد اصلی این کتاب رو می بینید که در مورد حلقه بحث شده است که کار هر خط در جلوی آن بعد از عملگر # نوشته شده است .

#!/usr/bin/perl -w
#Loop Tutorial
##################################
#                         FULLY Commented                       #
#################################
 
#While Loops
#Format
# while (Comparison) {
# Action }
#While loops will loop while the comparison is true, if it changes to false, it will no longer continue to loop through its set of action(s).
$i = 1;
while($i <= 5) {
print "While:" . $i . "\n";
$i++;
}
 
#For Loops
#Format
# for (init_expr; test_expr; step_expr;) {
#   ACTION  }
##
# Init expression is done first, then the test expression is tested to be true or false then --
#  the step expression is executed.
for($t = 1; $t <= 5; $t++) {
print "For:" . $t . "\n";
}
 
#Until Loops
#Format
# until (Comparison) {
# Action }
##
# An until loop tests the true false comparison, if it is true, it will continue to loop until the comparison changes to a
# false state.
$p = 1;
until($p == 6) { #It's six because when $p becomes = 5, it doesnt go through the set of action sequences; therefore, 5 isn't printed.
print "Until:" . $p . "\n";
$p++;
}
#Foreach Loops
#Used most commonly to loop through lists
#Format
# foreach $num (@array) {
# Action }
$n = 1;
foreach $n (1..5) {
print "Foreach:" . $n . "\n";
$n++;
}

 

این بخش هم ترجمه بالا است ولی با این فرق که خودم قسمت بالا رو بازنویسی کردم و این بخش رو هم می زارم تا خودتون بخونید ، تقریبا همونائی بودند که در بالا تفصیر کردیم ولی با مثالهای واقعی تر . ( البته گفته نویسنده ای اصلی )


 
دیگر موارد