[16719] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4131 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 25 11:10:43 2000

Date: Fri, 25 Aug 2000 08:10:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967216213-v9-i4131@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 25 Aug 2000     Volume: 9 Number: 4131

Today's topics:
    Re: stupid question probably <timewarp@shentel.net>
    Re: stupid question probably <elephant@squirrelgroup.com>
    Re: stupid question probably <info@ezboo.com.xx>
    Re: stupid question probably <Joe.Rocklin@sdrc.com>
    Re: stupid question probably <timewarp@shentel.net>
    Re: stupid question probably (Jon S.)
    Re: trying to pull each string from file to evaluate... <gasper@cis.ohio-state.edu>
    Re: uc problems <o_dehon@my-deja.com>
    Re: uc problems (Keith Calvert Ivey)
    Re: uc problems <elephant@squirrelgroup.com>
    Re: use CGI to remove files vnguyen_1999@my-deja.com
    Re: use CGI to remove files vnguyen_1999@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 25 Aug 2000 09:38:42 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: stupid question probably
Message-Id: <39A676E2.545BD76E@shentel.net>

Does it drink alone as well?

 $Time = scalar localtime(time);

And put $Time in your html where you want the date to appear using
substitution. This will give you a full date string w/ time as well but I
suggest you read the Perl faq on how to parse out the individual internal
components to yield just the date pieces you want and in what order you want
them. Or, maybe someone else here will make it easy for you and write the
entire routine out for you. This is a topic covered in most Perl books for
beginners, i.e. pony up the $$$ for a couple books and you will learn much much
more than you ever thought you would even want to know about Perl.

Albert Dewey

Thierry wrote:

> My Perl script works alone, but
> How the hell can I insert a small Perl script within my existing HTML page.
> For exemple to write date....
>
> Thanks
> Thierry



------------------------------

Date: Fri, 25 Aug 2000 13:53:48 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: stupid question probably
Message-Id: <MPG.141117e2ce95b2f69896ef@localhost>

Thierry <info@ezboo.com.xx> wrote ..
>My Perl script works alone, but
>How the hell can I insert a small Perl script within my existing HTML page.
>For exemple to write date....

although it might seem like this is a Perl question - it's not .. you 
would have the same problem of inserting the output of a program written 
in any language

the meandering guesser has steered you in the right direction .. but 
there is more to it than that .. please ask in a forum relating to your 
web server (or ask the administrator of that web server) for specific 
instructions on how to do this

-- 
  jason -- elephant@squirrelgroup.com --


------------------------------

Date: Fri, 25 Aug 2000 16:17:37 +0200
From: "Thierry" <info@ezboo.com.xx>
Subject: Re: stupid question probably
Message-Id: <8o5vo1$77f$1@reader1.fr.uu.net>

The Time display in Perl is for exemple only.
It could be any kind of Perl script !

My question is: Can we INSERT a Perl script in an existing HTML
or do we have to have the Perl script to create the HTML page (whcih might
be long if HTML is complicated...).

Thierry

Albert Dewey <timewarp@shentel.net> a écrit dans le message :
39A676E2.545BD76E@shentel.net...
> Does it drink alone as well?
>
>  $Time = scalar localtime(time);
>
> And put $Time in your html where you want the date to appear using
> substitution. This will give you a full date string w/ time as well but I
> suggest you read the Perl faq on how to parse out the individual internal
> components to yield just the date pieces you want and in what order you
want
> them. Or, maybe someone else here will make it easy for you and write the
> entire routine out for you. This is a topic covered in most Perl books for
> beginners, i.e. pony up the $$$ for a couple books and you will learn much
much
> more than you ever thought you would even want to know about Perl.
>
> Albert Dewey
>
> Thierry wrote:
>
> > My Perl script works alone, but
> > How the hell can I insert a small Perl script within my existing HTML
page.
> > For exemple to write date....
> >
> > Thanks
> > Thierry
>




------------------------------

Date: Fri, 25 Aug 2000 10:23:36 -0400
From: Joe Rocklin <Joe.Rocklin@sdrc.com>
Subject: Re: stupid question probably
Message-Id: <39A68168.A5BBEF2B@sdrc.com>

If you want to put it into an existing HTML page (not a CGI) than just use
javascript, it's a lot easier than converting to a CGI simply to put the date
in.

--joe

Thierry wrote:

> My Perl script works alone, but
> How the hell can I insert a small Perl script within my existing HTML page.
> For exemple to write date....
>
> Thanks
> Thierry

--
------------------------------------------------------------------------------
Joe Rocklin             joe.rocklin@sdrc.com
"The whole of science is nothing more than a refinement of everyday thinking."
        -- Albert Einstein, Physics and Reality [1936]:





------------------------------

Date: Fri, 25 Aug 2000 10:55:03 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: stupid question probably
Message-Id: <39A688C7.1EEE5CB4@shentel.net>

Thierry -

You would save your html page as a .txt template file. Then you would use Perl
to grab that file and read it into a variable. Then you would use a substitution
drill to replace various markers in the html template with things like the date
or whatever. Okay - I will give you the most basic of examples here. (Flamers -
please offer syntax error corrections or alternate methods in a polite manner,
please.)

Here is the html page that you would save as a template called date.txt  -
-------------------------------------------------
<html>
<head>
<title>Date Page</title>
</head>
<body>
The current date and time is - $Time.
</body>
</html>
-------------------------------------------------
Notice the $Time place marker. This is what you will be replacing using Perl
with the actual date/time string.
Now for the Perl that you will use to load up this page and send it to the user.
Call this showpage.cgi
-------------------------------------------------
#!/usr/bin/perl
print "Content-type: text/html\n\n";     ## Put htis high up so your error
messages will print to the web page if need be.
use CGI qw/:standard/;
&Show_Page;     ## I always use subroutines even for my simplest Perl scripts.
You should too.
sub Show_Page
    {
    open(FILE,"<date.txt") or print "ERROR: 404<br>Cannot open date.txt because
$!<br>";
    while(<FILE>)
    {
    $WebPage .= $_ if $. >= 0     ## Read the template into a variable so you
can play with it.
    }
    close(FILE);

    $time = scalar localtime(time);
    $WebPage =~ s/\$Time/$time/g;     ## This is the part that actually replaces
the $Time place marker.
    print "$WebPage";     ##Send the web page to the user.
    exit;
    }
-------------------------------------------------
Now to make this thing run, type the following in your browser -

http://www.yourcompany.com/date/showpage.cgi

- assuming that you put these two files in a directory called 'date'. The top
line in the Perl script might have to be adjusted to point to where your Perl is
actually located but you should already know this by now anyway. If you want to
get fancier than this, you will have to read some books on Perl or I can help
you on a per hourly basis but this does answer your question for the time being.

Note - you don't insert Perl into the html - it is not javascripting - you use
perl to load and manipulate the html as in the case above. This is what makes
Perl so powerful - do not confuse with simpler scripting languages. Perl is
capable of incredible things - hell even your cat can write Perl! For example,
to quote Abigail - (hehe)
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_;

By the way - I do feel that this is a Perl related question for those of you who
have expressed doubts.

Enjoy -

Albert Dewey

Thierry wrote:

> The Time display in Perl is for exemple only.
> It could be any kind of Perl script !
>
> My question is: Can we INSERT a Perl script in an existing HTML
> or do we have to have the Perl script to create the HTML page (whcih might
> be long if HTML is complicated...).
>
> Thierry



------------------------------

Date: Fri, 25 Aug 2000 15:01:31 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: stupid question probably
Message-Id: <39a6898b.5862385@news.earthlink.net>

On Fri, 25 Aug 2000 14:23:56 +0200, "Thierry" <info@ezboo.com.xx>
wrote:

>That does not work !
>No error message, just a blank line.
>
>Any other idea ?
>Thanks
>
>Thierry

This isn't really a Perl question, so...
Post to the cgi (comp.www.authoring.infosystems.cgi) group, and you'll
get a better response.  There was just a thread on this. 

www.bignosebird.com (or any of the other tutorial sites) with a search
on SSI tells you how to do it with virtual or exec on Apache, but the
reality is that it depends on what the server lets you do.  You
webhoster might not allow it regardless.  You'll also have to probably
change the file name to something like foo.shtml instead of foo.html.

Best of luck,

Jon


------------------------------

Date: Fri, 25 Aug 2000 10:37:19 -0400
From: "Keith Gasper" <gasper@cis.ohio-state.edu>
Subject: Re: trying to pull each string from file to evaluate...
Message-Id: <8o6099$50g$1@news.cis.ohio-state.edu>

TEC <travis.cox@itron.com> wrote
> I'm not real clear on if you just want to keep evaluating the last line of a file (as it gets written
> to) or if you want to remove the last line and evaluate it....

Well, I'm not trying to just read the last line of the file. I would like to read the last line, remove
it, then read the last line... (this should read the formerly-known-as second to last line since the
former last line is now gone) This way, I keep reading from the bottom up until I find what I'm
looking for. I think I can play with your code and get something to work, though. How would
you delete a line? Or better yet, is there a way to move up just one line? Thanks for your help!
Keith




------------------------------

Date: Fri, 25 Aug 2000 13:29:14 GMT
From: Olivier Dehon <o_dehon@my-deja.com>
Subject: Re: uc problems
Message-Id: <8o5saj$h7s$1@nnrp1.deja.com>

In article <1efxd3j.1bih21e1mbmps0N@[192.168.88.117]>,
  sumus@aut.dk (Jakob Schmidt) wrote:
> Laurent de Lasteyrie <lasteyrie@iname.com> wrote:
>
> >   =~ tr/àâä|éèê|îï|ôö|ùûü/A|E|I|O|U/;
> >   But, it give me back "TRILAZI",
>
> That's because é is fourth char on the left side and I is fourth char
on
> right side. Read perlop and try:
>
> $_ = 'trélazé';
>
> $_ = uc;
> tr/àâäéèêîïôöùûü/ÀÂÄÉÈÊÎÏÔÖÙÛÜ/;
>

That'd be fine for a Canadian-French locale. But in a French locale,
capital letters do not get accented.

Then, you could use:

tr/àâäéèêîïôöùûü/AAAEEEIIOOUUU/;

-Olivier


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Fri, 25 Aug 2000 13:42:46 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: uc problems
Message-Id: <39b07528.39155443@news.newsguy.com>

lasteyrie@iname.com (Laurent de Lasteyrie) wrote:

>	I have to upcase the word with accents like "trélazé", there
>is 2 accents in this word. I add "use locale;" at the beginning of my
>program, and when i use "uc" it give me  "TRéLAZé". I try with the
>command :
>	=~ tr/àâä|éèê|îï|ôö|ùûü/A|E|I|O|U/;
>	But, it give me back "TRILAZI",
>
>	Does anyone can help me, please...

Read the documentation for tr/// in perlop.  What you're saying
above is that you want 'à' changed to 'A', 'â' changed to '|',
'ä' changed to 'E', '|' changed to '|', 'é' changed to 'I'
(which is what you got), 'è' changed to '|', 'ê' changed to 'O',
'|' changed to '|' (ignored because you've already specified a
translation for '|'), and 'î', 'ï', '|', 'ô', 'ö', '|', 'ù',
'û', and 'ü' all changed to 'U' (though the '|' are ignored
again).  You could use 

    tr/àâäéèêîïôöùûü/AAAEEEIIOOUUU/;

Or you could read perllocale and try to get uc() working the way
you want, though it might take a little doing since you're
venturing into an area that seems to be a bit controversial in
French typography -- whether vowels should lose their
diacritical marks when capitalized.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


------------------------------

Date: Fri, 25 Aug 2000 14:50:34 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: uc problems
Message-Id: <MPG.141125316ce0130d9896f0@localhost>

Laurent de Lasteyrie <lasteyrie@iname.com> wrote ..
>	I have to upcase the word with accents like "trélazé", there
>is 2 accents in this word. I add "use locale;" at the beginning of my
>program, and when i use "uc" it give me  "TRéLAZé". I try with the
>command :
>	=~ tr/àâä|éèê|îï|ôö|ùûü/A|E|I|O|U/;
>	But, it give me back "TRILAZI",
>
>	Does anyone can help me, please...

sounds like your locale is not set correctly .. you can do it manually 
from within Perl

  perldoc perllocale

-- 
  jason -- elephant@squirrelgroup.com --


------------------------------

Date: Fri, 25 Aug 2000 13:15:05 GMT
From: vnguyen_1999@my-deja.com
Subject: Re: use CGI to remove files
Message-Id: <8o5rg7$gcj$1@nnrp1.deja.com>

If you are able to delete directly on system from the command line but
not from browser is because the permission issue. the ownerships
between the web browser and command line are different. To resolve
this, you have to change permission by changing the "read, write" of
the files which you want to delete, or change ownership of the file,
such as "nobody or web-user-account".

Van

In article <8o2qno$55g$1@news.cis.nctu.edu.tw>,
  is83024@cis.nctu.edu.tw (doco) wrote:
> Dear All:
>
> I am writing a CGI PERL program, which is able to delete designed
files I
> chose thru Browser.  The problem I am facing is that I can delete the
files
> on the System, but by going thru Browser, I can not delete the files.
In
> other words, at the System, I can use "$perl kill.pl delete_file" to
delete
> the files.  But by using Browser, I can not use
> http://localhost/cgi/kill.pl?delete_file to delete the files.  The
following
> is my source of the program:
>
> rm_list_file(@ARGV);
> sub rm_list_file
> {
> $a = $_[0];
> if ($a eq "")
> { print 6;}
> else
> { print m $a;}
> print $a;
> }
>
> Thank you very much for your attention.
>
> --
>
>                                                 *
>


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Fri, 25 Aug 2000 13:18:04 GMT
From: vnguyen_1999@my-deja.com
Subject: Re: use CGI to remove files
Message-Id: <8o5rlo$gfi$1@nnrp1.deja.com>

If you are able to delete directly on system from the command line but
not from browser is because the permission issue. the ownerships
between the web browser and command line are different. To resolve
this, you have to change permission by changing the "read, write" of
the files which you want to delete, or change ownership of the file,
such as "nobody or web-user-account".

Van

In article <8o2qno$55g$1@news.cis.nctu.edu.tw>,
  is83024@cis.nctu.edu.tw (doco) wrote:
> Dear All:
>
> I am writing a CGI PERL program, which is able to delete designed
files I
> chose thru Browser.  The problem I am facing is that I can delete the
files
> on the System, but by going thru Browser, I can not delete the files.
In
> other words, at the System, I can use "$perl kill.pl delete_file" to
delete
> the files.  But by using Browser, I can not use
> http://localhost/cgi/kill.pl?delete_file to delete the files.  The
following
> is my source of the program:
>
> rm_list_file(@ARGV);
> sub rm_list_file
> {
> $a = $_[0];
> if ($a eq "")
> { print 6;}
> else
> { print m $a;}
> print $a;
> }
>
> Thank you very much for your attention.
>
> --
>
>                                                 *
>


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 4131
**************************************


home help back first fref pref prev next nref lref last post