File: cheap_accessors.pl

package info (click to toggle)
liblist-objects-withutils-perl 2.028003-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,292 kB
  • sloc: perl: 1,957; makefile: 17; sh: 6
file content (15 lines) | stat: -rw-r--r-- 379 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use strict; use warnings;
use 5.10.1;
use Lowu;

my $result = immarray(
  +{ name => 'bob', id => '200' },
  +{ name => 'joe', id => '400' },
  +{ name => 'sam', id => '600' },
  +{ name => 'amy', id => '800' },
)->first(sub {
  $_->{id} > 500
}) or die 'No employees with ID > 500';

my $person = $result->inflate;
say "Employee ".ucfirst($person->name)." has ID ".$person->id;