- or download this
$self->foo();
foo($self);
- or download this
package A;
...
object B call to bar():
$self->foo() = B
foo( $self ) = A
- or download this
($x) = foo();
$x = foo();
- or download this
my @foo_subs = ( 'sub { return ( 4, 5, 6 ) }',
'sub { my @x = ( 4, 5, 6 ); return @x; }',
...
foo = sub { wantarray ? ( 7 ) : 8 }
($x) = 7
$y = 8
- or download this
for ( @x ) { foo( $_ ) }
map { foo( $_ ) } @x;
- or download this
sub foo {
my $wa = wantarray;
...
map{foo()} @x:
array
array
- or download this
sub baz { return 11 unless shift }
print 'baz(5): ', baz(5), "\n";
print 'baz(0): ', baz(0), "\n";
- or download this
baz(5): 5
baz(0): 11
- or download this
my $FOO = 'foo';
sub bar { $_[0] = 'bar' }
...
print $FOO, "\n";
print bar( $FOO ), "\n";
print $FOO, "\n";
- or download this
foo
bar
bar
- or download this
for my $s ( qw( a b c ) ) { $s =~ s/$/\n/ && print $s }
- or download this
Modification of a read-only value attempted at interview.pl line