-
Write a program that reads 10 numbers from the user and prints the largest of them
-
Write a program that randomizes 7 numbers and prints their sum. If that sum is divisable by 7, it should also print 'Boom !'. (You can use the % operator that means modulus).
-
Write a program that randomizes a number and calculates the sum total of its digits.
-
Write a program that reads lines from a user. When input ends, the program should print every other line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# show | |
# Hello Mr. Anonymous. You work at UNKNOWN COMPANY | |
# | |
# show -name Mike | |
# Hello Mr. Mike. You work at UNKNOWN COMPANY | |
# | |
# show -job Intel | |
# Hello Mr. Anonymous. You work at Intel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
package RoleMaker; | |
use Moose; | |
use File::Slurp qw/write_file/; | |
has 'name', is => 'ro', required => 1; | |
has 'methods' => ( | |
is => 'rw', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Pet; | |
use Moose; | |
has 'name', is => 'ro', isa => 'Str', default => 'Nemo'; | |
has 'past_owners', is => 'ro', isa => 'ArrayRef[Str]'; | |
package main; | |
my $dog = Pet->new( past_owners => ['James', 'Mike'] ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Pet; | |
use Moose; | |
has 'name', is => 'ro', isa => 'Str', default => 'Nemo'; | |
has 'past_owners', is => 'ro', isa => 'ArrayRef[Str]'; | |
package main; | |
my $dog = Pet->new( past_owners => ['James', 'Mike'] ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Starship; | |
use Moose; | |
has 'captain', is => 'ro', isa => 'Str', required => 1; | |
has 'crew', is => 'rw', isa => 'ArrayRef[Str]', required => 1; | |
package main; | |
# Pass a hash ref to prevent copying | |
my $enterprise = Starship->new( { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Pet; | |
use Moose; | |
has 'name', is => 'ro', isa => 'Str', default => 'Nemo'; | |
has 'past_owners', is => 'ro', isa => 'ArrayRef[Str]'; | |
package main; | |
my $dog = Pet->new( past_owners => ['James', 'Mike'] ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Starship; | |
use Moose; | |
has 'captain', is => 'ro', isa => 'Str', required => 1; | |
has 'crew', is => 'rw', isa => 'ArrayRef[Str]', required => 1; | |
sub BUILD { | |
my $self = shift; | |
if ( $self->captain ~~ $self->crew ) { | |
my $captain = $self->captain; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Foo; | |
use Moose; | |
sub DEMOLISH { warn 'Foo::Demolish' } | |
sub BUILD { warn 'Foo::Build' } | |
package Bar; | |
use Moose; | |
extends 'Foo'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MultipleFileUploader; | |
use Moose::Role; | |
requires 'upload_file'; | |
sub upload_files { | |
my $self = shift; | |
my @success; |