## this is ark_get.pm file
# use strict;
package ark_get;
sub check_sube () {
That's not how you write a subroutine declaration in Perl, unless you really
want to use prototyping. You're telling perl that you don't want any
arguments passed to the subroutine, which is why you get the warning later
when you try to pass the array. You would normally write the above as:
sub check_sube {
or if you really want prototyping and to pass an array of values:
sub check_sube(@) {
my @input = @_;
my @output =()
Missing a semicolon at the end of the line. Please post code that can be
run. The empty parens are also not necessary when declaring an array.
my @ignore = qw(
Init
rimaryipaddress
Init:secondaryipaddress
ATC
rimary_address
);
foreach ( @input ) {
$firstline = $_;
The above variable is not just going to be assigned the first line, so a bad
choice of names. You should also do the assignment when you declare the
loop:
foreach my $line (@input) {
foreach ( @ignore ) {
($fea1, $na1) = split /:/, $_;
$lin =~ s/$fea1:\\BD-.*\\KCSS-.*\\.*={$nam1=.*?}//g;
}
Again, post code that we can run. What is $nam1? What is $lin?
push @output, $lin;
}
return @output;
}
##### my main program
#!/usr/bin/perl
use ark_get;
sub new_output {
## this is the place i got struck
# when i use this way of invocation it gets value from the function
@newChanges = check_sube ark_get(@firstchanges);
Because you can't call subroutines that way, as I alluded to earlier. You
have things reversed, and if you had warnings enabled you would have
discovered this long ago:
Can't locate object method "ark_get" via package "check_sube" (perhaps you
forgo
t to load "check_sube"?) at test.pl line 15.
Always start your scripts with:
use strict;
use warnings;
Especially when you are still learning!
# when i run it this way it throws an error saying too many arguments
..
@newChanges = check_sube::ark_get(@firstChanges);
Again, had you turned on warnings:
Undefined subroutine &main::ark_get called at test.pl line 21.
You specify the function after the package name:
@newChanges = ark_get::check_sube(@firstChanges);
And once again, do not use all lowercase letters for your module names.
ArkGet or even Ark_get are better options.
It would strongly benefit you to read perlmod as I mentioned earlier, and
not just skim it.
Matt