Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!frankland-river!pem From: pem@frankland-river.aaii.oz.au (Paul E. Maisano) Newsgroups: comp.lang.perl Subject: Are only simple scalars allowed in "do SUBROUTINE (LIST)" ? Message-ID: <1211@frankland-river.aaii.oz.au> Date: 4 Mar 90 11:25:36 GMT Organization: Australian AI Institute Lines: 27 The manual section for "do SUBROUTINE (LIST)" says: SUBROUTINE may be a scalar variable, ... The parentheses are required to avoid confusion with the "do EXPR" form. I always assumed that an array reference could be considered a scalar. In particular I thought the following was allowed. #!/usr/bin/perl sub sub1 {print "1\n";} sub sub2 {print "2\n";} @subs = ('sub1', 'sub2'); do $subs[1](); Unfortunately it gives a syntax error. I think this is a pity. It is a useful thing to be able to do. Allowing an arbitrary EXPR instead of a scalar would be even better :-) Of course, we could always just use eval instead. Not as elegant though (or as efficient, maybe). ------------------ Paul E. Maisano Australian Artificial Intelligence Institute 1 Grattan St. Carlton, Vic. 3053, Australia Ph: +613 663-7922 Fax: +613 663-7937 Email: pem@aaii.oz.au UUCP: {uunet,mcsun,ukc,nttlab}!munnari!aaii.oz.au!pem