469,357 Members | 1,745 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,357 developers. It's quick & easy.

Dynamic Web PAge Titles using Perl and CGI

1
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 2358
KevinADC
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
Kelicula
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 
  2.  
  3. # Use -T if you are going to be allowing users to submit text.
  4. # another great tool is the "fatals to browser"
  5.  
  6. use CGI:Carp qw(fatalsToBrowser warningsToBrowser);
  7. use CGI qw(:standard);
  8. use strict;
  9. use warnings;
  10.  
  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'});
  15.  
  16.  
The result would be:
[HTML]

Content type
<doctype definition>

<meta char-set def>

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

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
KevinADC
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 zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.