Beginner Question #1

S

soup_or_power

Consider the following code. Is there any workaround to calling sub b
from sub a without using the $type. Thanks for your help.

package my::package

sub new ()
{
return self;
}

sub a ()
{
my($type)=shift;
my $par1
&b($type, $par1);
}

sub b()
{
my($type, $param)=@_;
}
 
A

A. Sinan Unur

(e-mail address removed) wrote in @l41g2000cwc.googlegroups.com:
Consider the following code. Is there any workaround to calling sub b
from sub a without using the $type. Thanks for your help.

package my::package

Please post real code.

In addition to the syntax error above, my is probably going to be
confusing.

Other than with pragmas, it use customary to capitalize the first letter
of each component in a package identifier.

So:

package My::package;

use strict;
use warnings;

missing.
sub new ()

Why the prototype?
{
return self;
}

What is self?

Bareword "self" not allowed while "strict subs" in use at t.pl line 9

Why the prototype?
{
my($type)=shift;
my $par1

Syntax error.
&b($type, $par1);
}

sub b()
{
my($type, $param)=@_;
}

You need a good book, and make an effort to help others help you.

Please read the posting guidelines for this group.

I have no idea what you are trying to do here.

#! /usr/bin/perl

use strict;
use warnings;

sub a { print "This is a\n"; }

sub b {
print "This is b\nCalling a ...\n";
a();
}

b();

__END__
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top