Link to home
Start Free TrialLog in
Avatar of RaghuramOct
RaghuramOct

asked on

how to display anchor tag in perl script?

I have a perl script,I am using print statement to display a lhypertext link.But instead of displaying the hypertext link it is displaying the path of the link.I am attaching the code snippet.Can you give me the code for diaplaying hypertext link using perl other than peint statement.


#!/usr/bin/perl
 
print"content-type : text/html\n\n";
 
print "This is a perl program";
 
print "<a href= 'http://localhost/searchengine.html'>searchengine</a>"
~

Open in new window

Avatar of ozo
ozo
Flag of United States of America image

What do you mean by the path of the link?
Try:
#!/usr/bin/perl
 
print "Content-Type : text/html\n\n";
 
print "This is a perl program";
 
print 'searchengine';
Avatar of RaghuramOct
RaghuramOct

ASKER

Eg :
When you want to display the hyperlink ,it should display the link as searchengine(with blue underline.
But it is displaying the anchor tag as follows

searchengine"


When you want to display the hyperlink ,it should display the link as searchengine(with blue underline.
But it is displaying the anchor tag as follows

Continued in code snipet

<a href="http://localhost/searchengine.html">search</a>
 
when i use the print command as follows in perl.
 
print "<a href= 'http://localhost/searchengine.html'>searchengine</a>"

Open in new window

Try Content-type instead of Content-Type

print "Content-type: text/html\n\n";
I too do not understand what you're trying to achieve, so I'm just guessing.
Version #1 in the code box below displays the pure HTML output (not getting interpreted by the browser) and
Version #2 prints the link destination as link title.

# Version #1
#!/usr/bin/perl
 
print "Content-Type: text/html\n\n";
print "This is a perl program";
print '&lt;a href="http://localhost/searchengine.html"&gt;searchengine&lt;/a&gt;'
 
# Version #2
#!/usr/bin/perl
 
print "Content-Type: text/html\n\n";
print "This is a perl program";
print '<a href="http://localhost/searchengine.html">http://localhost/searchengine</a>'

Open in new window

This is a test page search
This is not what I would call a good explanation.

I've uploaded the code below to my webserver. It can be accessed via: http://tuxx-home.at/cgi-bin/test.pl

Is this the desired output? If so, the script looks good but you might have a configuration problem with your webserver. Could you explain to us what you are seeing instead of the desired result? Screenshots would be fine...
#!/usr/bin/perl
 
print "Content-Type: text/html\n\n";
print "This is a perl program";
print "<a href='http://localhost/searchengine.html'>searchengine</a>";

Open in new window



                          Can you tell me what configuration changes I have to make in my web server so as to make it work, none of the HTML tags are working in my current apache web server.

The result you have shown is what I want, but the output i am getting is as follows  
output: 
This is a test page
<a href="http://localhost/serchengine.html"> search </a>

Open in new window

Then maybe your content type is wrong, but if it were, firefox would have asked you to download the file instead of showing the plaintext contents.

Maybe it's some kind of default configuration in your apache... What platform is the webserver running on? Windows or Linux?
I am using Linux OS creating my perl scripts
ok, then please tell me some things:

1. In what directory is your perl script located?

2. What are it's permissions?

     ls -l /path/to/your/test.pl

3. Show me the object dump of the first few lines:

    head -4 /path/to/your/test.pl | od -chx

4. Show me your apache configuration file (/etc/apache2/apache2.conf) and the default vhost configuration file
    /etc/apache2/sites-available/default
Did you copy and paste this from here:
print "Content-type: text/html\n\n";

make sure there is no space between the "e" and the colon.
Hi,
       Attaching the files you wanted
httpd.doc
Test1.txt
Your Apache server is running as apache user and group:
User apache
Group apache


So change the permissions on your /var/www/cgi-bin/ so tha the directory and everything within it belong to apache, not root. Ultimately once you do the changes you should see:
     ls -l /path/to/your/test.pl     =  -rwxr-xr-x    1 apache     apache
ASKER CERTIFIED SOLUTION
Avatar of FishMonger
FishMonger
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial