- publishing free software manuals
Perl Language Reference Manual
by Larry Wall and others
Paperback (6"x9"), 724 pages
ISBN 9781906966027
RRP £29.95 ($39.95)

Sales of this book support The Perl Foundation! Get a printed copy>>>

7.23 Yada Yada Operator

The yada yada operator (noted ...) is a placeholder for code. Perl parses it without error, but when you try to execute a yada yada, it throws an exception with the text Unimplemented:

sub unimplemented { ... }
eval { unimplemented() };
if( $@ eq 'Unimplemented' ) {
  print "I found the yada yada!\n";

You can only use the yada yada to stand in for a complete statement. These examples of the yada yada work:

{ ... }
sub foo { ... }
eval { ... };
sub foo {
                my( $self ) = shift;
do { my $n; ...; print 'Hurrah!' };

The yada yada cannot stand in for an expression that is part of a larger statement since the ... is also the three-dot version of the range operator (see 7.19). These examples of the yada yada are still syntax errors:

print ...;
open my($fh), '>', '/dev/passwd' or ...;
if( $condition && ... ) { print "Hello\n" };

There are some cases where Perl can't immediately tell the difference between an expression and a statement. For instance, the syntax for a block and an anonymous hash reference constructor look the same unless there's something in the braces that give Perl a hint. The yada yada is a syntax error if Perl doesn't guess that the { ... } is a block. In that case, it doesn't think the ... is the yada yada because it's expecting an expression instead of a statement:

my @transformed = map { ... } @input;  # syntax error

You can use a ; inside your block to denote that the { ... } is a block and not a hash reference constructor. Now the yada yada works:

my @transformed = map {; ... } @input; # ; disambiguates
my @transformed = map { ...; } @input; # ; disambiguates
ISBN 9781906966027Perl Language Reference ManualSee the print edition