http://qs1969.pair.com?node_id=170918

PetaMem has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

I'm humbly asking for explanation of basic perl knowledge. What puzzles me is that I'm having a code like that:

my @lexlist = @_; @lexlist = sort keys %lexicon if(!@lexlist);
which works very well. This is the beginning of a subroutine and all I want is to have in lexlist either a list of elements I gave as arguments to this routine or - if none were given - to create this list from some hash.

My problem is, that me thinks the following should be possible also:

my @lexlist = @_ or sort keys %lexicon;
unfortunatedly this doesn't work at all and I have no clue why. It seems, that @_ is always evaluated to a true value even if it is empty. Why this exceptional behaviour?

I'm sure I'm missing something very very basic...

Bye
 PetaMem