471,825 Members | 1,316 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,825 software developers and data experts.

Dynamic Web PAge Titles using Perl and CGI

how would I go about creating a dynamic web page title that would grab the first line of text of of my web page, using perl and CGI?
Oct 5 '07 #1
3 2403
4,059 Expert 2GB
is the webpge on the same server as the perl script or on a remote server? Do you know any perl?
Oct 5 '07 #2
176 Expert 100+
You can insert a title, as well as many other attributes to the "head" section through the use of a hash reference:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -T 
  3. # Use -T if you are going to be allowing users to submit text.
  4. # another great tool is the "fatals to browser"
  6. use CGI:Carp qw(fatalsToBrowser warningsToBrowser);
  7. use CGI qw(:standard);
  8. use strict;
  9. use warnings;
  11. print header;
  12. print start_html(-title=>'Whatever title you want', 
  13.            script=>{'src'=>'URL to src of javascript'}, 
  14.            style=>{'src'=>'source of style sheet'});
The result would be:

Content type
<doctype definition>

<meta char-set def>

<title>Whatever title you want</title>
<script type="text/javascript" src="source to javascript file"></script>
<link rel="stylesheet" href="source to stylesheet">

Read more here

How you can capture the first line of the page, and insert it into the title, would have to do with setting a scalar, and substituting it in the start_html function call.

Exactly how is up to you...
Oct 5 '07 #3
4,059 Expert 2GB
You can insert a title, as well as many other attributes to the "head" section through the use of a hash reference:
His webpage appears to already exist so the process is going to be different than for creatig a new webpage.
Oct 5 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Devon | last post: by
1 post views Thread by Steve Gadlin | last post: by
3 posts views Thread by Ben Allen | last post: by
4 posts views Thread by Bass Pro | last post: by
reply views Thread by Vito DeCarlo | last post: by
5 posts views Thread by pittendrigh | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.