Hi all,
I have this problem when trying to pass an argument to a function. The
following codes suppose to handle continual characters (the one that end up
with character "\" to indicate a new line). That one works using a solution
I found on the web but the problem is when I tried to pass the argument to a
function declared in the same file, the argument somehow became null. If I
run this program, the print statement does not display anything. Thanks in
advance.

The sample of the input file is as followed
----------------------------------------------------
 preprocessor http_inspect_server: server default \
     profile all ports { 80 8080 8180 } oversize_dir_length 500 \
     cubaan \
     test \
     ujian

----------------------------------------
#!/usr/bin/perl

sub sample_function {
    print "go in $_\n";
}

# get the path for snort.conf file
my $snort_file = $ARGV[0];

if (open (INFILE,"$snort_file")) {
    my $index = 0;

    while (defined ($line=<INFILE>)) {
    chomp($line);
    if ($line =~ s/\\$//) {
        $line .= <INFILE>;
        redo unless eof (INFILE);

    }
    if ($line !~ /^[[:space:]]*#.*$/) { # handle lines start with #
        if ($line =~ /\S/) {
        print "$index $line\n";
        sample_function($line);
        $index++;
        }
    }
    }
    close INFILE;
}

Reply via email to