Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

how do i run this subroutine

by kurtcobain (Novice)
on Oct 10, 2012 at 19:09 UTC ( #998289=perlquestion: print w/replies, xml ) Need Help??
kurtcobain has asked for the wisdom of the Perl Monks concerning the following question:

sub Parse{ my $self = shift; my $html_code = shift; my $te = HTML::TableExtract->new( headers => [qw(Severity Advi +sory Synopsis Date)] ); my @args = (); $te->parse_file($html_code); foreach my $ts($te->tables) { foreach my $row ($ts->rows) { push(@args,("\'".join('\',\'',@$row)."\'\n")); } } return @args; }

Hi Monks, I want to run the above subroutine by passing command line arguments to it. How shd i do that. Plz help

Replies are listed 'Best First'.
Re: how do i run this subroutine
by Corion (Pope) on Oct 10, 2012 at 19:11 UTC

    So, what have you tried? Have you had a look at perlrun already?

      suppose the filename is . I ran the script with the command ./ I need to pass the url as an argument . How do i do that? Thanks
Re: how do i run this subroutine
by NetWallah (Abbot) on Oct 10, 2012 at 19:29 UTC
    Command line arguments are available inside the script as the pre-defined variable @ARGV .

    This array can be passed to the subroutine.

                 I hope life isn't a big joke, because I don't get it.

      I am sorry but i couldnt understand how to pass @ARGV to the subroutine . I started learning perl few days back ..Could you please show me the command to do it .
        Do you know how to pass a variable to a subroutine? @ARGV is a variable. Pass it to the subroutine. Or pass $url as toolic derived above.
        Parse (@ARGV); # Parens are optional.

                     I hope life isn't a big joke, because I don't get it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://998289]
Approved by Corion
[LanX]: fun, last time I was in Britain people had problems with my name, just rarely they said "like the children TV star Rolf Harris?", this time most replied instantly "Rolf? like the pedophile Rolf Harris" ?
LanX is perlophile
[ambrus]: Corion: read https://metacpan. org/pod/release/ MLEHMANN/AnyEvent- 7.13/lib/AnyEvent. pm#SUPPLYING-YOUR- OWN-EVENT-MODEL- INTERFACE in that case

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2016-12-08 12:01 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (141 votes). Check out past polls.