normally a sub can be called like a function - without the & in front as long as you have the ( ) part at the end so the interpreter can figure out it's a subroutine.
The fact is a little bit more complicated.
The ( ) can be omitted as well, as long as the subroutine has already been defined at the point of the call.
will not give any warnings at all. But if you put the sub at the bottom:
The solitary "echo;" will give an error for bareword usage (if you remove the use strict, it will be a warning instead). If you place the & back in, it will now be okay:
So to "&" or not sometimes depends on the order you define and use subroutine and their references. For the other case, see below.
Quote:
Originally Posted by jim mcnamara
you call a subroutine without parameters: ⊂
you call a subroutine by reference &$subref;
Also note that in these two cases the current @_ as a list of params will be passed to the called subroutine. So
⊂
&$subref;
is the same as
sub(@_); OR &sub(@_);
&$subref(@_);
but not the same as
&sub();
&$subref();
respectively.
See perlsub manpage for total treatment of the subject.
How do we pronounciate bdevsw and cdevsw Kernel resources ?
I presume it as block or charcter device software table. Am I Correct in my assumption ?
Thanks in advance. (9 Replies)
hi all,
I wanted to know how we can copy files to dirs, through a routine and when the file and the dir are specified as parameters for that routine and explicitly called?
Eg: suppose i want to copy file1 to /tmp then
myproc()
{
.
.
}
myproc /path/file1 /tmp/
These parameters when... (1 Reply)
hi all,
I wanted to know how we can copy files to dirs, through a routine and when the file and the dir are specified as parameters for that routine and explicitly called?
Eg: suppose i want to copy file1 to /tmp then
myproc()
{
.
.
}
myproc /path/file1 /tmp/
These parameters when... (4 Replies)
Hello experts,
I need some help here..
I've written the following routine to check for existence of files. The routine does the following. It will look for a compressed ( .Z ) file and if it exists, then it will uncompress it, if it is already uncompressed, then it will just diplay a message... (9 Replies)
Hi,
I use awk but not as a programming language. Just generally in piplelines to split things out by fields.
I am trying to accomplish this one thing that I think a short awk routine would do great for, but can't figure it out.
Lets say I have a file that contains database columns. The file... (25 Replies)
Hi all
I have written a simple perl script that has different options i.e. myscript -l -p etc
i have it so when it runs without any switches it runs a subroutine called nvrm_norm
i want to be able to do a -p option and run
pall -w -f and then called the subruotine
pall is... (1 Reply)
hello,
i am new to scripting and would like to know how to return a hash table from a sub routine.
i tried the following,
my %hash_function = ();
hash_function = &return_hash();
sub return_hash
{
my %hash = ();
///populate the hash
return %hash;
}
but it dosent seem to... (1 Reply)
Hi,
Please help me here while passing the paramert to fuction i am facing problem.
i tryied passing 7 PARAMeter in side single quote,double quate even tried tild sign not working.
how can assign it properly .
usage ()
{
typeset -i NumPARAMs=$1
typeset -i PARAM1=$2
typeset PARAM2=$3... (3 Replies)
Hi,
I am an occasional PERL user. I am trying to call a sub routine (passing parameters) in perl module from a driver .pl file. I have been "tinkering" for a while now and have confused myself.
Could someone please look at the code below and spot where I am going wrong.
testPerl.pl
... (0 Replies)
Discussion started by: chris01010
0 Replies
LEARN ABOUT BSD
clospl
PLOT(3F)PLOT(3F)NAME
plot: openpl et al. - f77 library interface to plot(3X) libraries.
SYNOPSIS
subroutine openpl()
subroutine erase()
subroutine label(str)
character str*(*)
subroutine line(ix1, iy1, ix2, iy2)
subroutine box(ix1, iy1, ix2, iy2)
Draw a rectangle and leave the cursor at ( ix2,iy2).
subroutine circle(ix, iy, ir)
subroutine arc(ix, iy, ix0, iy0, ix1, iy1)
subroutine move(ix, iy)
subroutine cont(ix, iy)
subroutine point(ix, iy)
subroutine linemd(str)
character str*(*)
subroutine space(ix0, iy0, ix1, iy1)
subroutine clospl()
DESCRIPTION
These are interface subroutines, in the library -lf77plot, allowing f77 users to call the plot(3X) graphics routines which generate graphic
output in a relatively device-independent manner. The f77 subroutine names are the same as the C function names except that linemod and
closepl have been shortened to linemd and clospl . See plot(5) and plot(3X) for a description of their effect.
Only the first 255 character in string arguments to label and linemd are used.
This library must be specified in the f77(1) command before the device specific graphics library; for example, to compile and load a FOR-
TRAN program in prog.f to run on a Tektronix 4014 terminal:
f77 prog.f -lf77plot -l4014
See plot(3X) for a complete list of device specific plotting libraries.
SEE ALSO plot(5), plot(1G), plot(3X), graph(1G)4.3 Berkeley Distribution April 30, 1986 PLOT(3F)