Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
31
Task/Sort-three-variables/Perl/sort-three-variables.pl
Normal file
31
Task/Sort-three-variables/Perl/sort-three-variables.pl
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env perl
|
||||
use 5.010_000;
|
||||
|
||||
# Sort strings
|
||||
|
||||
my $x = 'lions, tigers, and';
|
||||
my $y = 'bears, oh my!';
|
||||
my $z = '(from the "Wizard of OZ")';
|
||||
|
||||
# When assigning a list to list, the values are mapped
|
||||
( $x, $y, $z ) = sort ( $x, $y, $z );
|
||||
|
||||
say 'Case 1:';
|
||||
say " x = $x";
|
||||
say " y = $y";
|
||||
say " z = $z";
|
||||
|
||||
# Sort numbers
|
||||
|
||||
$x = 77444;
|
||||
$y = -12;
|
||||
$z = 0;
|
||||
|
||||
# The sort function can take a customizing block parameter.
|
||||
# The spaceship operator creates a by-value numeric sort
|
||||
( $x, $y, $z ) = sort { $a <=> $b } ( $x, $y, $z );
|
||||
|
||||
say 'Case 2:';
|
||||
say " x = $x";
|
||||
say " y = $y";
|
||||
say " z = $z";
|
||||
Loading…
Add table
Add a link
Reference in a new issue