Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ash committed Jan 1, 2017
1 parent d50fede commit 060b2bb
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 2 deletions.
20 changes: 20 additions & 0 deletions classx.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Cafe {
has $.name;
has @!orders;

method order($what) {
@!orders.push($what);
}

method list-orders {
@!orders.sort.join(', ').say;
}
}

my $cafe = Cafe.new(
name => "Paris"
);

$cafe.order('meet');
$cafe.order('fish');
$cafe.list-orders; # fish, meet
8 changes: 8 additions & 0 deletions classy.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class A {
has $.x = 42;
method m {
say "A.m";
}
}
my A $c = A.new(x => 14);
say $c.x; # 14, not 42
16 changes: 16 additions & 0 deletions db2.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use DBIish;

my $dbh = DBIish.connect(
'mysql',
:host<example.com>,
:port(3306),
:database<test>,
:user<test>,
:password<test_password>
);

my $sth = $dbh.prepare("insert into calendar values (?, ?)");
$sth.execute('2017-01-02', 'Wake up');

$sth.finish;
$dbh.dispose;
2 changes: 1 addition & 1 deletion ex14.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"Perl’s Birthday: 18 December 1987" ~~
/(\d+)\s(\D+)\s(\d+)/;
/ (\d+) \s (\D+) \s (\d+) /;
say $/.Str;
say $/[$_] for 0..2;

5 changes: 5 additions & 0 deletions ex15.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
my %month-abbrs =
:jan('January'),
:feb('February'),
:mar('March');
say %month-abbrs<mar>; # prints March
4 changes: 4 additions & 0 deletions ex16.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
my @a = 1, 2, 3, 5, 7, 11;

say @a; # [1 2 3 5 7 11]
say "This is @a: @a[]"; # This is @a: 1 2 3 5 7 11
2 changes: 2 additions & 0 deletions op65.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
say 20 min 10;
say 'three' max 'two';
4 changes: 4 additions & 0 deletions op66.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
my Int $x;
$x = "123".Int; # Now this is OK
say $x.Int;
say $x; # 123
16 changes: 16 additions & 0 deletions promice1.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# $p1 is Kept
my $p1 = start {
my $inf = 1 / 0;
}

# $p2 is Broken
my $p2 = start {
my $inf = 1 / 0;
say $inf;
}


sleep 1; # Wait until the code blocks are done

say $p1.status; # Kept
say $p2.status; # Broken
2 changes: 1 addition & 1 deletion try1.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
try {
say 42/0;
}
say $!;
say $! if $!;

0 comments on commit 060b2bb

Please sign in to comment.