Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Reference
#perl 5.22.1 print "Hello World\n"; $a=4;$b=3; OUTER: while ($a>=0){ print "hello \$a: $a\n"; $a-=1; INNER: while ($b>=0){ print "hello\$b: $b\n"; if ($b==1){ print "$b\n"; next OUTER; } print "inner while\n"; $b=$b-1; } } $name = "Nive"; sub Name{ print "$name"; } Name($name); sub Average{ $n = @_;$sum=0; print "\n\$n = $n\n"; print "\@_ = @_\n"; foreach $i (@_){ $sum = $sum+$i; } print $sum; } Average((10,20,30,40)); $a=10; @b=(3,6,9); @c=(5,10,15); sub Test1{ print "\n@_\n"; print "$a\n"; print "@b\n"; print "@c\n"; @c=(1) } print "\n@c\n"; Test1($a,@b); print "@c\n"; print "\n********************\n\n"; sub hash_val{ $sum=0; print "\n\@_: @_\n"; %hash1=@_; @hash_keys = keys %hash1; @hash_values = values %hash1; print "\n\@hash_keys: @hash_keys"; print "\n\@hash_values: @hash_values\n"; foreach $val_1 (@hash_values){ $sum=$sum+$val_1; } print $sum; return $sum; } $ans = hash_val(("a"=>100, "b"=>200, "c"=>300, "d"=>400)); print "\n$ans\n"; print "\n*************\n"; foreach ('hic','d','doc') { print; print "\n"; } exit();
run
|
edit
|
history
|
help
0
base N conversion
G
version check
Perl logo
doctor
Quote code
Basics
Soumya 101758
grid
Perl