Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Perl basics
#perl 5.22.1 print "\n"; print "\n"; print "\n"; @jack = qw/jack and jill went up the hill/; @twinkle = qw/twinkle twinkle little star/; print "@jack\n"; print "@twinkle\n"; @rhymes = (@jack,@twinkle); print "@rhymes\n"; print "\n"; @sea = qw/She sells sea shells on the sea shore/; @core = (3,2,5,6,7,5,4,3,6,8,7,6); print "Before : @sea\n"; print "Before : @core\n"; @sea = sort(@sea); @core = sort(@core); print "-+-+-+-+-+-+-+-+-+-+-+\n"; print "After : @sea\n"; print "After : @core\n"; print "\n"; @questions = qw/Them that ask no question never told a lie/; @odds = qw/May the odds be with you/; $qstring = join(' ',@questions); $oddstring = join('*',@odds); print $qstring."\n"; print $oddstring."\n"; print "\n"; $rats = "Rats live on no evil star"; $fox = "A:quick:brown:fox:jumps:over:the:lazy:dog"; @star = split(' ', $rats); @foxy = split(':', $fox); print "$star[4]\n"; print "$foxy[3]\n"; print "\n"; @nums = (1..20); print "Before - @nums\n"; splice(@nums, 10, 3, 21..25); print "After - @nums\n"; print "\n"; @days = qw/Mon Tue Wed Thu Fri Sat Sun/; @weekdays = @days[1,4,0]; print "@weekdays\n"; print "\n"; @circus = qw/Tinker Tailor Soldier Spy/; print "1. \@circus = @circus\n"; push(@circus, "Moneypenny"); print "2. \@circus = @circus\n"; unshift(@circus, "Ilsa Faust"); print "3. \@circus = @circus\n"; pop(@circus); print "4. \@circus = @circus\n"; shift(@circus); print "5. \@circus = @circus\n"; print "\n"; @circus = qw/Tinker Tailor Soldier Spy/; $spies = @circus; @clowns = @circus; print "$spies\n"; print "@clowns\n\n"; print "\n"; @var_10 = (1..10); @var_20 = (10..20); @var_abc = ("a".."z"); print "@var_10\n"; print "@var_20\n"; print "@var_abc\n"; print "\n"; @circus = qw/Tinker Tailor Soldier Spy/; print "$circus[1] is the mole.\n\n"; print "$circus[3] is the mole.\n\n"; print "$circus[-2] is the mole.\n\n"; print "\n"; $var = "This is string scalar!"; $quote = 'Single quote - $var'; $double = "Double quote - $var"; print $var; print "\nThis is quote inside quotes: $quote\n"; print "\nHere we go double : $double\n\n"; print "\n"; $mission = "fast"; $impossible = "furious"; $str = $mission." and ".$impossible; $num = 5 + 3; $mul = 4 * 5; $mix = $str ." ". $num; print "str = $str\n"; print "num = $num\n"; print "mul = $mul\n"; print "mix = $mix\n"; print "\n"; @rhymes = (1, 2, 'Buckle','my','shoe'); @matrix3 = qw/Everything that has a beginning/; print $rhymes[2]."\n"; print $matrix3[4]."\n\n"; print "\n"; %data = ('hunt', 2100, 'benji', 54, 'faust', 13); print "\$data{'hunt'} = $data{'hunt'}\n"; print "\$data{'benji'} = $data{'benji'}\n"; print "\$data{'faust'} = $data{'faust'}\n"; print "\n"; %data = ('hunt',100,'hello',17,'penguin',47); print "\$data{'hunt'}=$data{'hunt'}\n"; print "\n"; @sports = ("tennis","cricket","golf"); print "\$sports[1]=$sports[1]\n"; print "\n"; $var=5; print 'single $var'; print "\ndouble $var"; print "\n"; print "\nHello World\n";
run
|
edit
|
history
|
help
0
Perl logo
Sanjana 101742
each_hash_function
Supriya
version tester
Hash
Attractive Numbers
PWC 059-1
Array_with_shift_function
Array_with_pop_function