Re: Calling subroutines with the & sigil

2011-04-14 Thread Peter Scott
On Thu, 14 Apr 2011 08:49:45 -0700, sono-io wrote: > The only one I was concerned with was a sub called "if", Sounds like a great device for an obfuscated Perl contest entry. That's the only place I want to see it, though. >but it doesn't > look like it's a built-in function. How

Re: Calling subroutines with the & sigil

2011-04-14 Thread C.DeRykus
On Apr 13, 4:07 pm, sono...@fannullone.us wrote: > Hello, > >         I read somewhere that it's bad practice anymore to call a subroutine > like this: > > &subroutine(); > Normally yes but there are a few circumstances where you need the sigil. See: perldoc perlsub >         I've also read wh

Re: Calling subroutines with the & sigil

2011-04-14 Thread sono-io
Thanks to both Peter Scott, and Brian Fraser (who wrote me off-list). Very informative. I'm cleaning up a very old script that uses the &subroutine construct and learning more Perl in the process. > If you're worried about the speed overhead of one vs the other then either > you are w

Re: Calling subroutines with the & sigil

2011-04-13 Thread Peter Scott
On Wed, 13 Apr 2011 16:07:47 -0700, sono-io wrote: > Hello, > > I read somewhere that it's bad practice anymore to call a subroutine > like this: > > &subroutine(); > > I've also read where it's faster to call a sub like this: > &subroutine; > > than it is to call like this:

Re: Calling subroutines from another file

2004-06-09 Thread Daniel Kasak
Charles K. Clarkson wrote: IMO, the easiest thing to do in the log run is to change "stuff.pl" into a module called (perhaps) "stuff.pm". The you can "use" it. You might end up with something like this: package stuff; require Exporter; @ISA = qw(Exporter); @EXPORT_OK = qw( foo ); sub foo { re

RE: Calling subroutines from another file

2004-06-08 Thread Charles K. Clarkson
Daniel Kasak <[EMAIL PROTECTED]> wrote: : I have a main script file, a package in a separate 'package_name.pm' : file and a file 'stuff.pl' that contains functions that both the : main script and the package need to use. : : I've tried adding: : : require "stuff.pl"; : : to both the main script

RE: Calling subroutines...

2002-05-20 Thread Arul, Rex
When you say, Calling_Sub($var1, $var2), Perl automatically fills in the @_ array with the list of elements you are passing. Now subsequently, inside your subroutine, when you say: my $subvar = @_; what you are doing is that you are getting the scalar value of the array. Since you are passing

RE: Calling subroutines...

2002-05-20 Thread Hanson, Robert
There are lots of ways to do this, but this is an easy one to understand... Calling_sub($var1, $var2); sub Calling_sub { my ($subvar1, $subvar2) = @_; print $subvar1; print $subvar2; } Explaination - When you call a sub the parameters are passed via a special array named @_. Perl puts

RE: Calling subroutines...

2002-05-20 Thread Bob Showalter
> -Original Message- > From: Batchelor, Scott [mailto:[EMAIL PROTECTED]] > Sent: Monday, May 20, 2002 4:21 PM > To: '[EMAIL PROTECTED]' > Subject: Calling subroutines... > > > Hi again all. > > I have a question about calling a subroutine in Perl. Here > is what I am > trying: > > Ca