home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Book Home Programming PerlSearch this book

31.20. use subs

use subs qw/winken blinken nod/;
@x = winken 3..10;
@x = nod blinken @x

This pragma predeclares as standard subroutines all the names in the argument list. The advantage here is that you may now use those functions without parentheses as list operators, just as if you'd declared them yourself. This is not necessarily as useful as full declarations, because it doesn't allow prototypes or attributes, such as:

sub winken(@);
sub blinken(\@) : locked;
sub nod($) : lvalue;
Because it is based on the standard import mechanism, the use subs pragma is not lexically scoped but package scoped. That is, the declarations are effective for the entire file in which they appear, but only in the current package. You may not rescind such declarations with no subs.

Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.