Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why I can't omit the () here?

Tags:

perl

SaveImages @img_sources;

The above will report:

Array found where operator expected 

Why can't I omit the () here?

like image 643
new_perl Avatar asked Jun 29 '11 06:06

new_perl


People also ask

When can we omit that in a sentence?

'That' can be omitted after a verb of attribution (said, stated, announced, disclosed) She said (that) she was tired. She said she was tired. 'That' cannot not be omitted after a verb of attribution, if the words that follow the verb might be mistaken as objects of the verb. In a defining clause, use that.

Can we omit where in relative clauses?

We can leave out "where, when or why"or we can use "that" instead in relative clauses. We cannot leave out " where " and "when " and use "that" in adding or connective clauses.

What are the 5 relative clauses?

We attach relative clauses to independent clauses using relative pronouns or relative adverbs. There are five relative pronouns—that, which, who, whom, and whose—and three relative adverbs—where, when, and why. Deciding when to use “that” and “which” can be puzzling. “That” refers to things and never refers to people.

What are 3 examples of relative pronouns?

Examples of relative pronouns include who, whom, whose, where, when, why, that, which and how.


1 Answers

because your SaveImages subroutine is declared after the call. Parentheses are not necessary if a subroutine is declared before the call.

example:

use strict;
use warnings;
use Data::Dumper;
my @ar = (1, 2);
fn @ar;
sub fn
{
    print Dumper \@_;
}

does not work, while

use strict;
use warnings;
use Data::Dumper;
my @ar = (1, 2);
sub fn
{
    print Dumper \@_;
}
fn @ar;

works.

This is an expected behavior and is pointed out in the camel book.

like image 188
Nylon Smile Avatar answered Nov 15 '22 07:11

Nylon Smile