new tasks
This commit is contained in:
parent
2a4d27cea0
commit
80737d5a6a
1194 changed files with 15353 additions and 1 deletions
2
Task/Assertions/Perl/assertions-2.pl
Normal file
2
Task/Assertions/Perl/assertions-2.pl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
use autodie;
|
||||
open my $fh, '<', 'file'; # automatically throws an exception on failure
|
||||
9
Task/Assertions/Perl/assertions-3.pl
Normal file
9
Task/Assertions/Perl/assertions-3.pl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
my $a = 5;
|
||||
#...input or change $a here
|
||||
$a == 42 or die "Error message\n";
|
||||
# or, alternatively:
|
||||
die "Error message\n" unless $a == 42;
|
||||
# or:
|
||||
die "Error message\n" if not $a == 42;
|
||||
# or just:
|
||||
die "Error message\n" if $a != 42;
|
||||
2
Task/Assertions/Perl/assertions-4.pl
Normal file
2
Task/Assertions/Perl/assertions-4.pl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
use Carp::Assert;
|
||||
assert($a == 42);
|
||||
4
Task/Assertions/Perl/assertions-5.pl
Normal file
4
Task/Assertions/Perl/assertions-5.pl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
is $a, 42;
|
||||
ok $a == 42;
|
||||
cmp_ok $a, '==', 42, 'The answer should be 42';
|
||||
# etc.
|
||||
1
Task/Assertions/Perl/assertions.pl
Normal file
1
Task/Assertions/Perl/assertions.pl
Normal file
|
|
@ -0,0 +1 @@
|
|||
open my $fh, '<', 'file' or die "Cannot open file: $!\n"; # $! contains the error message from the last error
|
||||
Loading…
Add table
Add a link
Reference in a new issue