Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Where is the writing being ordered for within a .html, output file corresponding to the Perl subroutine line "<A NAME=.... HREF=...>...</A>";?

by 2016User1 (Initiate)
on Mar 14, 2016 at 17:02 UTC ( [id://1157688]=perlquestion: print w/replies, xml ) Need Help??

2016User1 has asked for the wisdom of the Perl Monks concerning the following question:

Hi. Other than following somebody else's suggestions for lines of Perl (Practical extraction and reporting language) code to correct, I don't think I have ever written a full script in Perl and don't know much about the Perl interpreter. Currently I have Perl 5.18.2 installed in a 64-bit, openSUSE Leap, 42.1 Linux operating system. A Perl subroutine written by other people and with a name of the form “make_....._href” that begins with the line of code of the form ''sub make_...._href {'' ends with a line of code looking like ''<A NAME=...... HREF=......>...</A>'';}, or text enclosed by a pair of double-quotation marks, as well as a closing semicolon for I suppose the line of code and a closing right brace to complement the opening left brace and complete the enclosure of the subroutine's contents. I suspect that the purpose of such a line of code is to eventually facilitate the writing of at least a portion of a line in a .html (HyperText Markup Language), output file which at least sometimes may include a hyperlink to a different Web page or else to a location on the same Web page. But I don't think the line ''<A NAME=...... HREF=......>...</A>''; all by itself will enable any such writing to be performed in a .html file! Where should I be looking for the explicit command for such writing of that line in the .html, output file? I suspect that a built-in function of Perl might be involved in such writing. Do you, hopefully an experienced Perl programmer, agree with this guess of mine? Is there a built-in Perl subroutine with a name ending in href? And if so, how may I see its lines of code?
  • Comment on Where is the writing being ordered for within a .html, output file corresponding to the Perl subroutine line "<A NAME=.... HREF=...>...</A>";?
  • Select or Download Code

Replies are listed 'Best First'.
Re: Where is the writing being done in a .html, output file corresponding to the Perl subroutine line "<A NAME=.... HREF=...>...</A>";?
by LanX (Saint) on Mar 14, 2016 at 17:07 UTC
    Welcome to the monastery! :)

    > ends with a line of code looking like ''<A NAME=...... HREF=......>...</A>'';}

    Perl subroutines can implicitly return the last value/statement without explicit return statement.

    see perlsub

    If no return is found and if the last statement is an expression, its value is returned. If the last statement is a loop control structure like a foreach or a while , the returned value is unspecified. The empty sub returns the empty list.

    This is done to facilitate functional programming.

    So the writing is done where the function is called.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Re: Where is the writing being ordered for within a .html, output file corresponding to the Perl subroutine line "<A NAME=.... HREF=...>...</A>";?
by Anonymous Monk on Mar 14, 2016 at 17:20 UTC

    As LanX already said, that string ("<A NAME=... HREF=...>...</A>") is likely being returned from the subroutine. So you should look for the place where the subroutine is being called. For example, it may say something similar to print $fh make_href();, in which case the string will be printed to the filehandle $fh, or something like my $var = make_href();, in which case the string is being stored in the variable $var for further processing and probably eventually printing. If you could show some actual code, that would help in answering your question better - see http://sscce.org/

      Thanks, Rolf and Anonymous Monk, for kindly and so quickly posting some information for me. Your postings make a good beginning for me! You seem to be good teachers! The Perl script written by other people that I have been inspecting contains numerous subroutines. And my knowledge of Perl is little. Perhaps I need to learn more about Perl to understand the code I have been inspecting.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1157688]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-19 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found