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

Re: subroutine scalar string input

by 2teez (Priest)
on Oct 20, 2012 at 23:51 UTC ( #1000160=note: print w/ replies, xml ) Need Help??


in reply to subroutine scalar string input

Hi robertw,

First of all, what you passed to the subroutrine is a scalar variable named $html not an html doc or html tag related string.
perlsub documentation, then gives a clear explanation of parameters passed to a subroutine as thus:

"The Perl model for function call and return values is simple: all functions are passed as parameters one single flat list of scalars, and all functions likewise return to their caller one single flat list of scalars. Any arrays or hashes in these call and return lists will collapse, losing their identities--but you may always use pass-by-reference instead to avoid this..."

So, within a subroutine the array @_ contains the parameters passed to that subroutine.
Thus this;

my $html = "hello"; routine($html); routine2($html); sub routine { my $greetings = shift @_; print $greetings; ## print hello } #OR sub routine2 { my ($greetings) = @_; print $greetings; ## print hello }
In case however, you intended to parse your imported html,
you may consider using an html parser module like HTML::TokeParser or HTML::TreeBuilder.
Hope this helps.

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me


Comment on Re: subroutine scalar string input
Download Code
Re^2: subroutine scalar string input
by robertw (Sexton) on Oct 21, 2012 at 20:03 UTC
    thank you so much all of you this is very helpful:)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000160]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2014-09-20 16:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls