[17345] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4767 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 30 18:10:52 2000

Date: Mon, 30 Oct 2000 15:10:23 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972947423-v9-i4767@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 30 Oct 2000     Volume: 9 Number: 4767

Today's topics:
        How Can i reverse the order ? <the_wizards_bullitin_board@barclays.net>
    Re: How Can i reverse the order ? <latsharj@my-deja.com>
    Re: Linked lists (Mark-Jason Dominus)
        LWP::UserAgent & loading images? joekind@my-deja.com
        MSSQL connection wapache@my-deja.com
    Re: OLE array-based properties <tonyschmitt@cs.com>
        parsing a majordomo archive file allym@usa.net
    Re: Pattern Match (Daniel Chetlin)
    Re: pattern matching help ( ~s/// ) <lr@hpl.hp.com>
    Re: Perl message on Linux: Setting locale failed. (Andy Dougherty)
    Re: perl/cgi programmer in Atlanta <ultrak@my-deja.com>
    Re: PerlMagick quality of Annotate in animated GIF <dwilgaREMOVE@mtholyoke.edu>
    Re: Query (Learning perl) fallenang3l@my-deja.com
    Re: Query (Learning perl) (Tad McClellan)
    Re: Query (Learning perl) <adamf@box43.gnet.pl>
    Re: Query (Learning perl) <tim@ipac.caltech.edu>
    Re: Query (Learning perl) <jeff@yoak.com>
    Re: Removing line breaks from a string - HELP! alphazerozero@my-deja.com
    Re: Removing line breaks from a string - HELP! alphazerozero@my-deja.com
    Re: Set path to perl.exe for Win 98 se <lr@hpl.hp.com>
    Re: signal "CTRL-x" <tony_curtis32@yahoo.com>
    Re: Stop the window closing? <camerond@mail.uca.edu>
    Re: Stop the window closing? <camerond@mail.uca.edu>
    Re: Stultiloquent Queries (was: even or odd?) <lr@hpl.hp.com>
    Re: Stultiloquent Queries (was: even or odd?) (Tom Christiansen)
        Unterminated <> operator? what the heck? oarend@my-deja.com
        Using 'format' and 'write' multiple times? <streaking_pyro@my-deja.com>
    Re: What about CGI.pm? (Jon S.)
    Re: What about CGI.pm? fallenang3l@my-deja.com
    Re: What about CGI.pm? <jeff@vpservices.com>
    Re: What about CGI.pm? fallenang3l@my-deja.com
    Re: Working with time <lr@hpl.hp.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 30 Oct 2000 18:48:56 -0000
From: "Newbie" <the_wizards_bullitin_board@barclays.net>
Subject: How Can i reverse the order ?
Message-Id: <39fdc5a1@news.jakinternet.co.uk>

Hi and thanks in advance for any help!!!

I copied this Guestbook .PL file from my ISP.
the problem being that when someone adds a message its printed at the
bottom!
What i would like to know is how to get the latest mesage at the top of the
document?
Ive played around abit and just can't get it to work the way i want it to.

#!/usr/bin/perl
#this script adds a viewer's comments to the end of the guestbook.html file

use CGI; #allows easy reading of form information from the previous html
page

$guestbooklocation = "/examples/guestbook.html"; #this should be the
filename and path of the guestbook.html file
#possible examples are:
# $guestbooklocation ="/guestbook.html"; #if the web address for the
guestbook file is http://www.mydomain.co.uk/guestbook.html
# $guestbooklocation ="/adirectory/guestbook.html"; #if the web address for
the guestbook file is http://www.mydomain.co.uk/adirectory/guestbook.html

$guest = new CGI; #create a new cgi object

$date = `date`; #get the date
chomp($date); #remove the line ending characters from the date string such
as carriage returns and line feeds

#the next 3 lines reads in the form values into strings
$name = $guest->param('name');
$email = $guest->param('email');
$text = $guest->param('comments');

#the next 3 lines change "<" and ">" in any text entered to "&lt;" and
"&gt;", so any html formatting can not be used
$name =~ s/</&lt;/g;
$email =~ s/@/\@/;
$text =~ s/</&lt;/g;

open (BOOK, "+<../htdocs$guestbooklocation") or die "Could not update the
guestbook file."; #open the html file or log an error message on the web
server
seek (BOOK, (-length($guest->end_html) - 2), 2); #find where the last
comment ended
print BOOK "\n"; #print a newline to make the html tidy
print BOOK << "(NEWCODE)"; #print anything below until (NEWCODE) label is
found - any html tags can be used until the (NEWCODE) label
<h3>Comments by <a href="mailto:$email">$name</a> on $date</h3>
<p>
$text
</p>
<hr>
</body>
<html>
(NEWCODE)
close BOOK; #close the html file as we have written the viewers comments to
it

#the next section deals with displaying a "intermediate" html page while the
guestbook page is refreshed
print "Content-type: text/html\n\n"; #so the browser knows how to deal with
text being printed below
print << "(HTML)"; #print any html code below until the (HTML) label is
found - again any html tags can be used here
<html>
<head>
 <title>Guestbook Update</title>
 <meta HTTP-EQUIV="Refresh" CONTENT="1; URL=$guestbooklocation">
</head>
<body bgcolor="#FFFFFF">
Please wait while the guestbook updates...
<br><br>
If it does not update automatically please click <a
href="$guestbooklocation">here</a>
</body>
</html>
(HTML)

exit; #this script


I have the script working and everything just the way its output.
Thanks Mark




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

Date: Mon, 30 Oct 2000 21:40:03 GMT
From: Dick Latshaw <latsharj@my-deja.com>
Subject: Re: How Can i reverse the order ?
Message-Id: <8tkpri$94k$1@nnrp1.deja.com>

In article <39fdc5a1@news.jakinternet.co.uk>,
  "Newbie" <the_wizards_bullitin_board@barclays.net> wrote:
> I copied this Guestbook .PL file from my ISP.
> the problem being that when someone adds a message its printed at the
> bottom! What i would like to know is how to get the latest mesage at
> the top of the document?
>

Perl FAQ 5:
"How do I change one line in a file/delete a line in a file/insert a
line in the middle of a file/append to the beginning of a file?"
--
Regards,
Dick


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


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

Date: Mon, 30 Oct 2000 19:28:00 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Linked lists
Message-Id: <39fdcbbf.1137$308@news.op.net>
Keywords: boatmen, fidelity, in, lurch

In article <x71ywyjgmc.fsf@home.sysarch.com>,
Uri Guttman  <uri@sysarch.com> wrote:
>from Benchmark.pm, under Notes:
>
>	The time of the null loop (a loop with the same number of
>	rounds but empty loop body) is subtracted from the time of
>	the real loop.
>
>it has been disputed how accurate this is. 

I'll say.  When I use Benchmark.pm to benchmark a million iterations
of q{}; it tells me that the elapsed time was -2 wallclock seconds.

That module is way too complicated.  I never trust anything that comes
out of it any more, because I have no idea what it is doing inside.
For all I know it goes off to Lake Waukegan to pick up beer and loose
women after every loop iteration and then tries to adjust the times
afterwards.

These days when I want to benchmark, I use something more like this:

        $LABEL = 'Null loop';
        ($us, $ss) = times;
        for ($i = 0; $i < $N; $i++) 
        {
        }
        ($ue, $se) = times;
        printf "$LABEL:\t%.2f %.2f %.2f\n", $ue-$us, $se-$ss, $ue+$se-$us-$ss;
        
        $LABEL = 'CMYK varying';
        ($us, $ss) = times;
        for ($i = 0; $i < $N; $i++) 
        {
          cmyk($i,$i,$i);
        }
        ($ue, $se) = times;
        printf "$LABEL:\t%.2f %.2f %.2f\n", $ue-$us, $se-$ss, $ue+$se-$us-$ss;

There are probably biases there but if so at least they are apparent.



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

Date: Mon, 30 Oct 2000 19:57:27 GMT
From: joekind@my-deja.com
Subject: LWP::UserAgent & loading images?
Message-Id: <8tkjr0$36t$1@nnrp1.deja.com>

Hi, I have a script that connects to a few sites and just extracts
certain text.  I was wondering if there was a way when using
LWP::UserAgent to connect to the sites and make sure that it does not
load any images in order to speed my script up?
Do I have to add something like:
$response->header('Accept' => 'text/html');

Here is my code:
my $ua = new LWP::UserAgent;
$ua->timeout ($FORM{'timeout'});
$ua->agent("AgentName/0.1 " . $ua->agent);
my $request = new HTTP::Request 'GET', $search;
my $response = $ua->request ($request);
$response_body = $response->content();


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


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

Date: Mon, 30 Oct 2000 22:24:04 GMT
From: wapache@my-deja.com
Subject: MSSQL connection
Message-Id: <8tksdq$bdu$1@nnrp1.deja.com>

Hellow,

I am trying to connect to the MS SQL server (7.0) on my window
2000 by running the cgi on the command line. But I got this
message:
dbiquery.cgi: DBI->connect(MSSQL:test:localhost) failed:
[Microsoft][ODBC Driver Manager] Data source name not found
and no default driver specified
(SQL-IM002)(DBD:bd-login/SQLConnect err=-1) at
dbiquery_ck.cgi line 16
Content-type:text/html
 ...
How do I go from here. Please help!

Here is some more infor; I have Apache server, Perl 5.6 working
fine. I can also connect to MySQL OK. I also have DBD::ODBC
installed.

Zen


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


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

Date: Mon, 30 Oct 2000 15:34:02 -0500
From: Tony Schmitt <tonyschmitt@cs.com>
Subject: Re: OLE array-based properties
Message-Id: <39FDDB39.C5F11D29@cs.com>

I figured it out myself.

To set a property on an OLE object that requires arguments you use
$object->SetProperty('property',@args,$value);

Tony Schmitt wrote:

> I have been using a COM object from Graphics Server under ASP/Vbscript
> for some time.  Recently, I found a need to use this under PERL as
> well.  The problem comes into play when I try to set the array-based
> properties of the graph object.
>
> Here is the native VBScript code...
>
> Set Graph1 = Server.CreateObject("GS.GSPropVB")
> Graph1.Path = Server.MapPath(Graph1.URL)
> Graph1.GraphTitle = "TESTING"
> Graph1.NumSets = 1
> Graph1.NumPoints = 10
> For i = 1 to Graph1.NumSets
>     Graph1.ThisSet = i
>     For x = 1 to Graph1.NumPoints
>         Graph1.Data(x) = i * 20 + x * 5
>     Next
> Next
> FileName = Graph1.DrawGraph
> FileExt = Graph1.Output
> Set Graph1 = Nothing
>
> ... and in PERL...
>
> use strict;
> use Win32::OLE;
> my $graph;
> Win32::OLE::CreateObject("GS.GSPropVB", $graph) || die "CreateObject:
> $!";$graph->{GraphType} = 6;
> $graph->{Path} = ".";
> $graph->{GraphTitle} = "TESTING";
> $graph->{NumSets} = 1;
> $graph->{NumPoints} = 10;
> for (my $i=1;$i<=$graph->{NumSets};$i++)
> {
>     print "set $i\n";
>     $graph->{ThisSet} = $i;
>     for (my $x=1;$x<=$graph->{NumPoints};$x++)
>     {
>         print "point $x = ",($i*20+$x*5),"\n";
>         $graph->{Data($x)} = ($i*20+$x*5); # *** Here is the problem
> line ***
>     }
> }
> my $filename = $graph->DrawGraph();
> my $fileext = $graph->{Output};
> print "Filename = ".$filename.$fileext."\n";
> undef $graph;
>
> On the problem line, perl returns the error "Undefined subroutine
> &main::Data".  I have also tried a few permutations of setting this
> property, such as "$graph->{Data}{$x} =", which does not generate an
> error, but also does not set any data.
>
> The maker of Graphics Server does not have any support information for
> perl, so I've been basing this on other OLE objects in perl, like the MS
> Excel application.  It uses array-based properties too, like this one:
>     $sheet->Cells(1,1)->{Value} = "foo";
> which sets a value to particular cell in a spreadsheet.  However, in
> this case "Value" is part of the property.
>
> Does anyone have a clue how to make this work?
>
> Tony Schmitt
> CompuServe
> tonyschmitt@cs.com



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

Date: Mon, 30 Oct 2000 21:33:25 GMT
From: allym@usa.net
Subject: parsing a majordomo archive file
Message-Id: <8tkpf6$8lm$1@nnrp1.deja.com>

I'm being lazy here, hoping someone else has invented this wheel
already.

With a mailing list I am interested in, I can get a monthly archive of
old posts from the server.  This is one file, typically 2 mb in size,
with 800 or so messages.  I'm interested in about two years worth of
data, so 24 mb and 16000 messages or so.  The mailing list is produced
by majordomo, and I imagine that the archive file I can receive is a
standard feature of majordomo.

I want a script that will take these monolithic monthly messages and
parse them, creating web pages on the fly that will allow me to list
all threads, expand threads to show all the messages, view a message,
view the next message, skip to the next thread etc.

I only have these archive files; I am just a subscriber to the list.  I
have found a web site that allows me to send it my archive files and it
will create the threaded interface; but I want this on my own web
server on my own network, not on the internet (although I have
unmetered internet access here in the UK, it's still slow; I have a
spare machine with acres of disk space waiting for tasks like this, and
I like to be in control ;-).

Seems that someone else might have done this before; has anyone got any
pointers as to where to look?

Thanks in advance,

Ally


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


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

Date: 30 Oct 2000 18:48:59 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: Pattern Match
Message-Id: <8tkfqr129ns@news2.newsguy.com>

On 30 Oct 2000 04:53:58 GMT, DoC <doc@CONSORTIUM.RedBrick.DCU.IE> wrote:
>Tad McClellan said this: 
>>On 30 Oct 2000 01:05:32 GMT, DoC <doc@CONSORTIUM.RedBrick.DCU.IE> wrote:
>>>$string =~ s/(>.*?)6(.*?<)/"$1" . "15$2"/eg;
>>
>>-------------------
>>#!/usr/bin/perl -w
>>use strict;
>>
>>my $string =<<ENDHTML;
>><p>no six here</p> <a href="6pigs.com">Pigs home page</a>
>>
>><img src="pigs.jpg" alt=">>6 pigs<<">
>><!-- <p>6 pigs</p> -->
>>ENDHTML
>>
>>$string =~ s/(>.*?)6(.*?<)/"$1" . "15$2"/eg;
>>#$string =~ s/(>.*?)6(.*?<)/"${1}15$2"/g;   # evals are slow (and dangerous)
>>
>>print $string;
>>-------------------
>
>These are exceptions, where the above regex will break.

Those are only exceptions in the sense that anything which causes your
REx to fail is an exception. They're fully valid HTML. You can't claim
to have something that parses HTML and then when shown good HTML pass it
off as an "exception".

>However, it was a clear improvement on the previous one posted.

Using an exacto knife to cut out pieces of the screen where the `6'
appeared would be a clear improvement on the previous one posted, so
that's not exactly saying much.

>>Parsing HTML with a regex is hopeless.
>>
>>Use a module that parses HTML.
>
>Overhead. Parsing a simple component of a HTML document like described above
>can be done with a regex or multiple regexes.

Overhead? Once you have a fully working suite of RExen that will parse
HTML correctly, then show me benchmarks to prove your point. The major
failings of your first try have already been shown. It is decidedly not
simple, and I suspect that anyone who uses `.*?' like that will not be
able to do it.

-dlc


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

Date: Mon, 30 Oct 2000 12:27:35 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: pattern matching help ( ~s/// )
Message-Id: <MPG.14677995548e988198ae7c@nntp.hpl.hp.com>

In article <8tjuuk$8fd$1@panther.uwo.ca> on Mon, 30 Oct 2000 09:00:50 -
0500, Darryl Olthoff <olthoff@multiboard.com> says...
> "arthur" <star@sonic.net> wrote in message
> news:B61CA1C3.9D19%star@sonic.net...
> > in article 39e3b80f.0@206.30.194.5, jim and lois at kf4dmb@net-magic.net
> > wrote on 10/10/00 4:38 PM:
> >
> > > $string  =  " t:\test/one/jim.txt";
> > > $string  = ~s ///\/ ;
> > >
> > > I get errors . what am I doing wrong ?
> 
> What is it that you are trying to do?  Are you trying to replace / with \?
> If so you will want to do this:
> 
> $string =~ s!/!\\!g;

Obligatory better-choice suggeston:

  $string =~ tr!/!\\!;

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 30 Oct 2000 21:55:56 -0000
From: doughera@maxwell.phys.lafayette.edu (Andy Dougherty)
Subject: Re: Perl message on Linux: Setting locale failed.
Message-Id: <slrn8vrrl7.kej.doughera@maxwell.phys.lafayette.edu>

In article <39FC8A95.DB54F8F6@that.you>, Anastasia wrote:
>I've had this problem for a while.  Some international settings have
>bien corrupted in my Linux box and I'm trying to repair it with no luck.
>
>Here's the message:
>
>perl: warning: Setting locale failed.

Please see the perllocale man page.  It has an extensive discussion
on exactly this issue.  Almost certainly this isn't a perl problem,
and you'll probably get better advice on how to repair your system
in a Linux-specific forum.

-- 
    Andy Dougherty		doughera@lafayette.edu
    Dept. of Physics
    Lafayette College, Easton PA 18042


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

Date: Mon, 30 Oct 2000 20:25:08 GMT
From: Kermit Lowry, III <ultrak@my-deja.com>
Subject: Re: perl/cgi programmer in Atlanta
Message-Id: <8tklep$4of$1@nnrp1.deja.com>

Thank you for the chastisement.  I have found out that I deserve this
and appreciate the subtle tone.  Everyone, please forgive my
inappropriate manner.  It will not happen again.

Thank you.

In article <slrn8vm90e.lt6.tadmc@magna.metronet.com>,
  tadmc@metronet.com (Tad McClellan) wrote:
>
> [ This is not a job newsgroup.
>
>   Advertisements are not welcome here.
>
>   Job newsgroups have "jobs" in the newsgroup name.
>
>   Please stop abusing Usenet with off-topic posts.
>
>   It will cause the most qualified folks to discount you
>   as too clueless to work with.
> ]
>
> On Sat, 28 Oct 2000 15:55:26 GMT, Kermit Lowry, III <ultrak@my-
deja.com> wrote:
>
> > looking for a perl/cgi programmer with 2+yrs with cgi on Win &
Linux.
> >$25-30/hr contract
>
> That is an awfully low rate. You are likely to get what you pay for.
>
> A (1998?) salary survey showed that 66% of Perl contract programmers
> make $50-90 per hour...
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@metronet.com                     Perl programming
>     Fort Worth, Texas
>

--
----------------
"Only you can prevent forest fires!" -Smoky
at kp.org use kermit.lowry

This input does not necessarily reflect the opinion of my employer.


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


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

Date: Mon, 30 Oct 2000 19:07:42 GMT
From: Dan Wilga <dwilgaREMOVE@mtholyoke.edu>
Subject: Re: PerlMagick quality of Annotate in animated GIF
Message-Id: <dwilgaREMOVE-457A0D.14075930102000@news.mtholyoke.edu>

In article <8tk0ac$mif$1@enterprise.cistron.net>, nobody@nobody.com wrote:

> It works, but the quality of the text is very bad (ugly antialiasing), I'm 
> using ImageMagick v4.2.9. Do newer versions produce better
> quality?
> I tried to do a

I haven't used this feature of ImageMagick, but one guess would be that 
perhaps the image has a constrained number of colors in its palette. I seem to 
recall that older versions of it did not create new color palette entries "on 
the fly", so perhaps this is the problem here.

Dan Wilga          dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply  **


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

Date: Mon, 30 Oct 2000 20:54:13 GMT
From: fallenang3l@my-deja.com
Subject: Re: Query (Learning perl)
Message-Id: <8tkn5g$6ff$1@nnrp1.deja.com>

For small to medium files use this:

open FILE "+< abc.xyz" or die "Can't open abc.xyz for reading/writing:
$!";
flock FILE, 2 or die "Can't exclusively flock abc.xyz: $!";
@file_contents = <FILE>; # Read the whole file into memory
pop @file_contents; # dump the last entry
seek FILE, 0, 0 or die "Can't rewind abc.xyz: $!"; # get to the
starting position of the file
print FILE @file_contents; # spit out all contents
truncate FILE, tell or die "Can't truncate abc.xyz: $!";
close FILE or warn "zbc.xyz didn't close nicely: $!";

For big files, use this:
open LOCK, "> abc.lck" or die "Can't open/create abc.lck: $!"; # Create
semaphore locking file
flock LOCK, 2 or die "Can't exclusively flock abc.lck: $!";
open FILE, "abc.xyz" or die "Can't open abc.xyz for reading: $!";
open TEMP, "> $$.tmp" or die "Can't create $$.tmp: $!";
while (<FILE>) {
	last if eof FILE;
	print TEMP;
}
close TEMP or warn "$$.tmp didn't close nicely: $!";
close FILE or warn "abc.xyz didn't close nicely: $!";
rename "abc.xyz", "abc.bak" or die "Can't rename abc.xyz to abc.bak:
$!";
rename "$$.tmp", "abc.xyz" or die "Can't rename $$.tmp to abc.xyz: $!";
close LOCK or warn "abc.lck didn't close nicely: $!"

I'm sorry if the formatting is broke but I can't do anything about it.

In article <8tkfjs$v6u$1@nnrp1.deja.com>,
  v_v_n@my-deja.com wrote:
> Hi ,
>
> I have to delete a string from a file which appears at the end of that
> file ..... can anyone help me out how to do it.
>
> for example :- In a file "abc.xyz" last line contains the string
> "AAAAAA" .I have to delete that line, I am not able to do it in Perl.
> Please help me out.
>
> Thanks in advance.
> v_v_n
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


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


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

Date: Mon, 30 Oct 2000 16:01:00 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Query (Learning perl)
Message-Id: <slrn8vrocc.55h.tadmc@magna.metronet.com>

On Mon, 30 Oct 2000 20:54:13 GMT, fallenang3l@my-deja.com 
   <fallenang3l@my-deja.com> wrote:
>For small to medium files use this:

>flock FILE, 2 or die "Can't exclusively flock abc.xyz: $!";

>For big files, use this:
>open LOCK, "> abc.lck" or die "Can't open/create abc.lck: $!"; # Create
>semaphore locking file
>flock LOCK, 2 or die "Can't exclusively flock abc.lck: $!";


The OP didn't say anything that would require file locking.

You seem to have assumed requirements that were not given.

While shooting a rabbit with a cannon will work, it is a great
deal more than is strictly necessary.


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 30 Oct 2000 22:53:02 +0100
From: Adam <adamf@box43.gnet.pl>
Subject: Re: Query (Learning perl)
Message-Id: <39FDEDBE.4BF3@box43.gnet.pl>

v_v_n@my-deja.com wrote:
> 
> Hi ,
> 
> I have to delete a string from a file which appears at the end of that
> file ..... can anyone help me out how to do it.
> 
> for example :- In a file "abc.xyz" last line contains the string
> "AAAAAA" .I have to delete that line, I am not able to do it in Perl.
> Please help me out.

hm... yes, i know it is out of topic, but try this:
# sed "$,/AAAAAA/d" your_file >edited

--Adam.


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

Date: Mon, 30 Oct 2000 14:21:12 -0800
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Query (Learning perl)
Message-Id: <39FDF458.1A77BE03@ipac.caltech.edu>

v_v_n@my-deja.com wrote:
> I have to delete a string from a file which appears at the end of that
> file ..... can anyone help me out how to do it.
> 
> for example :- In a file "abc.xyz" last line contains the string
> "AAAAAA" .I have to delete that line, I am not able to do it in Perl.
> Please help me out.

I can't figure out what you mean. 1) delete the last line of a file, 2) delete
the last line in a file if it contains a certain pattern, 3) delete the last
line of a file if it is entirely a particular pattern, or 4) delete just a
pattern from within the last line. Why don't you post what you've tried? We're
much more responsive to people who've read the docs and show that they've tried
to solve the problem themselves. 

Meanwhile, here's a (long) one liner that shows one example of how to solve
problem 2:

perl -i.bak -nwe 'print $prev if defined $prev; $prev=$_;' \
              -e 'END { print $prev if $prev!~/AAAAAA/; }'   abc.xyz

[I'm sure perl golfers can improve on that quite a bit.]

You can look up in the docs what that does, and how.

perldoc perlrun
perldoc perlsyn
perldoc perlop
perldoc perlvar
perldoc perlre

--

-- Tim Conrow         tim@ipac.caltech.edu                           |


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

Date: Mon, 30 Oct 2000 13:46:55 +0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: Query (Learning perl)
Message-Id: <8tkq9p02k3e@news2.newsguy.com>

[posted and emailed]

In article <8tkfjs$v6u$1@nnrp1.deja.com>, v_v_n@my-deja.com wrote:

> Hi ,

Hello.

> I have to delete a string from a file which appears at the end of that
> file ..... can anyone help me out how to do it.
> 
> for example :- In a file "abc.xyz" last line contains the string
> "AAAAAA" .I have to delete that line, I am not able to do it in Perl.
> Please help me out.

If you are sure that the file contains that string as the last line and
that it is a proper UNIX text file, you could:

use strict;

my $string = "AAAAAA\n";

open TEST,"+< abc.xyz" or die "open $!";
truncate TEST, (stat(TEST))[7]-length($string) or die "truncate $!";
close TEST or die "close $!";

If you aren't sure if that is really the last line, you could read the
file in with the mode above, and handle the situation if it isn't and
otherwise truncate.

If this is a file that might be in use by someone else, make sure to
concern yourself with locking the file properly.

Cheers,
Jeff


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

Date: Mon, 30 Oct 2000 19:21:59 GMT
From: alphazerozero@my-deja.com
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <8tkhoe$18o$1@nnrp1.deja.com>

In article <39F9C094.7ADF42AE@stomp.stomp.tokyo>,
  "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:

> Amusing how you insist on displaying both your ignorance
> and illiteracy in myriad ways. Never use " a " and " of "
> with myriad, both are implied by definition of myriad.
> I wouldn't be surprised to discover you are one of those
> who uses " off of " in speech.
>
> Godzilla!

Actually it looks like we are both correct. And you should be careful
what stones you throw, some of them might bounce back and smash you.
(reprinted with kind regards to www.dictionary.com, highlights added)
myr·i·ad (mr-d)
adj.

Constituting a very large, indefinite number; innumerable: the myriad
fish in the ocean.
Composed of numerous diverse elements or facets: the myriad life of the
metropolis.
n.
A vast number: the myriads of bees in the hive.
Archaic. Ten thousand.

------------------------------------------------------------------------
--------
[Greek murias, muriad- ten thousand, from murios, countless.]

Usage Note: Throughout most of its history in English myriad was used
as a noun, as in a myriad of men. In the 19th century it began to be
used as an adjective, as in myriad men; this usage became so well
entrenched that _many_ _people_ _came_ _to_ _consider_ _it_ _as_ _the_
_only_ _correct_ _possibility_. In fact, both uses have not only ample
precedent in English but also etymological justification from Greek,
inasmuch as the Greek word murias from which myriad derives could be
used as either a noun or an adjective. _Both_ _uses_ _may_ _be_
_considered_ _equally_ _acceptable_, as in Samuel Taylor
Coleridge's “Myriad myriads of lives.”


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


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

Date: Mon, 30 Oct 2000 20:24:06 GMT
From: alphazerozero@my-deja.com
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <8tklcq$4nj$1@nnrp1.deja.com>

In article <39F9D6CE.3A65F6A0@stomp.stomp.tokyo>,
  "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:

> "...that that...." ??

Are you sure the double that was incorrect, or are you just pointing it
out as unusual?

> "Being the illiterate I am...."

Hmm, yes.  I missed the the. (Another double word. Whee! What fun!)


> Use "illiterate" a pronoun or as
> a noun, or as an adjective for
> your sentence, not as an adverb.
> As an adverb, it is 'illiterately'
> for correct usage under different
> semantic syntax.

Now this I have problems with.  If 'illiterately' is indeed a word,
(and I make no claim either way) why do I find it omitted from the
standard texts?


> "...incorrect by saying that...."
>
> "...incorrect in saying that...."
>
> Use of "incorrect in" is a better choice
> for rhythmic alliteration. Use of "when"
> is temporally incorrect. You have already
> uttered your words, now, not in the future.

Well, if we really want to get picky then it should be 'typing'
shouldn't it?

> "grammatical, to use a nineteenth century...."
>
> "grammatical, to coin a nineteenth century...."
>
> Use "a" for an indefinite article unless a
> following word begins with a vowel or sounds
> like it begins with a vowel, noting some very
> rare exceptions to this general rule.

Well, a word following the 'a' starts with a vowel. But I suppose you
meant 'the' following word.  However I prefer your use of the word coin
to my original choice.

> Don't use parenthetical statements unless a
> pseudo footnote is to be implied; a moderately
> unrelated topic. Never use 'numbers' in written
> language unless your topic is inherently related
> to numbers, such as statistics, mathematics or
> similar inherently numerical topics. Spell out
> numbers for all other cases and, never mix pure
> numbers with spellings of numbers. Use one or
> the other but not both.

Indeed.  I am a programmer. And if that doesn't make it clear enough, I
will state that I am lazy.  Therefore I will continue to use 3 letters
instead of 10, at least in informal situations.

> Here you are frequently trying to give lessons
> in English under myriad fake names and, you
> cannot write a simple single sentence without
> making myriad grammatical errors, Frank.

Hahaha.  I do not use a myriad of fake names,  I use two.  None of my
names, fake or real, is Frank. And since we are apparently in picky
mode, I fail to see how an email has enough words to have a myriad of
grammatical errors.

> * laughs *

Ah good.  There I was thinking that you were without a sense of humour.

> Godzilla!
>
> Dr. Kiralynne Schilitubi
> Professor of English
> University of California at Riverside

As you are a Professor of English I am slightly surprised at some of
your comments.  In particular the ones that imply that there are
absolute rules in English.  Your rules weren't around 300 years ago and
they will not be around 300 years from now.  I would have thought that
you would have an appreciation of the dynamic, vibrant nature of
English.  A language that needs no high council to determine its rules,
a language that rejects the claims of the so-called experts and defines
itself by its use, a language that long ago was but a creole.

A final point, on the subject of this newsgroup, Larry Wall talks about
this in one of his lectures about perl, where he mentions his belief
that perl should be usable by someone who does not have a grasp of the
whole langauge, in the same way that a child does not speak like the
high school student and where the same student most likely does not
speak as their prof, but all three manage to get stuff done.

TMTOWTDI

Alphazerozero




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


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

Date: Mon, 30 Oct 2000 13:38:30 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Set path to perl.exe for Win 98 se
Message-Id: <MPG.14678a35c2064e3a98ae7d@nntp.hpl.hp.com>

In article <39FC81FD.E75E7ED6@stomp.stomp.tokyo> on Sun, 29 Oct 2000 
12:01:01 -0800, Godzilla! <godzilla@stomp.stomp.tokyo> says...

 ...

> So, thanks for your path statement, Mr. Harris, it does
> work and hopefully I can now repair other problems and
> damage done by Active State's install wizard. With a little
> luck, I might be able to link perl with my apache web server.

Advance warning:

Unlike running perl from the command line, where the path in the first 
line of your file is ignored (though if the word 'perl' is there the run 
flags are honored), when using Apache, the path in the first line must 
be correct.  Forward slashes work fine, and the drive letter, if 
omitted, will be assumed to be that in which Apache resides.  Therefore 
many who like their programs to run in several environments install perl 
in, for example, c:/usr/local/bin/perl (assuming Apache is in C:), and 
make the first lines of their files read:

    #!/usr/local/bin/perl -wT

Though of course, those particular flags won't suit your disposition.  
:-)

> Thank you again. Your efforts are appreciated. At least
> you didn't ask me to pay you two-hundred smackers for
> an answer like Active State would.

I won't ask either, especially as my answer is volunteered, not 
requested.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 30 Oct 2000 13:12:02 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: signal "CTRL-x"
Message-Id: <87lmv6kut9.fsf@limey.hpcc.uh.edu>

>> On Tue, 31 Oct 2000 01:15:25 +0800,
>> Beggar <cpegbeggar@mail.com> said:

> Hi all, How to capture the signal "CTRL-x" in perl?
> Actually, is it considered as a signal ?

C-x is a key stroke (combination).  It is not normally
associated with a signal (maybe under DOS?).  Do you mean
C-z or C-c by any chance?

Perhaps if you explain what you actually want your
application to do at a higher level, it will be easier to
see how to help...

In the meantime, "perldoc perlipc"

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Mon, 30 Oct 2000 15:51:39 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Stop the window closing?
Message-Id: <39FDED6B.5D53861F@mail.uca.edu>

Ah, who cares? Let the lizard talk to itself. You know, the posts are
just like those 50's Japanese movies: repetitious, klunky, devoid of any
factual accuracy, and don't even inspire any good fantasy. Only a good
excuse to get up from your chair and get a Coke and some popcorn. It
doesn't even matter if you miss the rest of the movie. Which I will.

But, thanks for setting the record straight. I really don't know when I
first posted to clpm, but that might be right (I thought it would have
been earlier).

Cameron

"I yam who I yam, and that's all that I yam." - Popeye, the Sailor Man
(toot, toot!)

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu


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

Date: Mon, 30 Oct 2000 16:21:57 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Stop the window closing?
Message-Id: <39FDF485.556F637A@mail.uca.edu>

Sorry, my non-English-literature-major background is showing. I'm
misquoting:

> "I yam who I yam, and that's all that I yam." - Popeye, the Sailor Man
> (toot, toot!)

should be "I yam what's I yam, and that's all that I yam."

Cameron

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu


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

Date: Mon, 30 Oct 2000 14:11:51 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Stultiloquent Queries (was: even or odd?)
Message-Id: <MPG.14679202611391ef98ae7e@nntp.hpl.hp.com>

In article <39fc65a5@cs.colorado.edu> on 29 Oct 2000 11:00:05 -0700, Tom 
Christiansen <tchrist@perl.com> says...
> In article <39fc1359.100122189@news.easynet.be>,

 ...

>     sub is_even { abs int shift =~ /[60284]$/ }
>     sub is_odd  { abs int shift =~ /[53197]$/ }

Unnecessary use of abs().  And probably in some of the other methods 
too, though I'm too lazy to test each one.

As for int(), is even or odd defined for other than integers?

In any case, amen to your pseudotheosophical maunderings.  :=)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 30 Oct 2000 15:35:00 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Stultiloquent Queries (was: even or odd?)
Message-Id: <39fdf794$1@cs.colorado.edu>

In article <MPG.14679202611391ef98ae7e@nntp.hpl.hp.com>,
>>     sub is_even { abs int shift =~ /[60284]$/ }
>>     sub is_odd  { abs int shift =~ /[53197]$/ }
>
>Unnecessary use of abs().  

True enough.

But I did need to do it on the first version.  Think about it.
I'm doing a parity count down to 0.  You need to make sure 
you're above it to get down to it.

>As for int(), is even or odd defined for other than integers?

No, certainly not.  Nor "fred23" either.  I didn't wish to 
clutter up the examples with *too* much boundary checks. :-)

--tom


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

Date: Mon, 30 Oct 2000 21:08:10 GMT
From: oarend@my-deja.com
Subject: Unterminated <> operator? what the heck?
Message-Id: <8tknvi$75e$1@nnrp1.deja.com>

Hi,

my script gives me the following error report:

> syntax error at searchaw.pl line 118, near "if"
> Unterminated <> operator at searchaw.pl line 118.

Is there a limit to how long a line in Perl can be? (I'm running
ActivePerl 5.something on a Win98 system with OmniHTTPd as server)

Or can you find the mistake in

if (($obj{'frei'} == 1) and ($obj{'zm'} == $param{'zm'}) and ($obj
{'gr'} > $mingr[$param{'gr'}]) and ($obj{'gr'} <= $maxgr[$param{'gr'}])
and ($obj{'pr'} > $minpr[$param{'pr'}]) and ($obj{'pr'} <= $maxpr[$param
{'pr'}]) and (($obj{'ort'} eq $param{'ort1'}) or ($obj{'ort'} eq $param
{'ort2'}) or ($obj{'ort'} eq $param{'ort3'}) or ($obj{'ort'} eq $param
{'ort4'}) or ($obj{'ort'} eq $param{'ort5'})) and (($obj{'jahr'} <
$param{'jahr'}) or (($obj{'jahr'} < $param{'jahr'}) and ($obj{'monat'}
<= $param{'monat'})))

(don't worry about the names of the variables or what the heck this is
doing ;-)

The mistake should be somewhere within the last 3 comparisons, since
that's what I just added and now the script doesn't run anymore...

Thanks for your help,

Oliver


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


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

Date: Mon, 30 Oct 2000 21:57:27 GMT
From: R.Joseph <streaking_pyro@my-deja.com>
Subject: Using 'format' and 'write' multiple times?
Message-Id: <8tkqs2$9t7$1@nnrp1.deja.com>

 Hello!  I am using the FORMAT syntax to format an e-mail message that
is sent from my online shopping cart.  Here is my problem code
(abriged):

format MAIL =
@<<<<<<<<<<< @<<<<<<<<<< @<<<<<<<<<...
$data        $data       $data
 .
write(MAIL);

open (FILE ...);
while(<FILE>) {
format MAIL =
@<<<<<<<<<<< @<<<<<<<<<<
$from_file   $from_file
 .
write(MAIL);
}

__END__

The really odd thing is that I get the output from the while loop -
that works just fine, but all I get from the format above it is a
single carriage return!  Please help, I can't figure this out!  Thanks!


--
R.Joseph


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


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

Date: Mon, 30 Oct 2000 19:42:37 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: What about CGI.pm?
Message-Id: <39fdcf19.20001916@news.earthlink.net>

On Sun, 29 Oct 2000 19:37:23 -0800, Jeff Zucker <jeff@vpservices.com>
wrote:

>fallenang3l@my-deja.com wrote:
>> 
>> So is there a point in loading the entire CGI.pm module if all one
>> needs to do is read the query string and bake cookies? 
>
>AFAIK, the module is fairly smart about which parts of itself it loads
>for which purposes.

I'm just a newbie but... 

 ...can't you preload CGI.pm via mod_perl on Apache so it isn't an
issue?

I thought that was the whole point of mod_perl.

Jon


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

Date: Mon, 30 Oct 2000 20:11:21 GMT
From: fallenang3l@my-deja.com
Subject: Re: What about CGI.pm?
Message-Id: <8tkkl1$43f$1@nnrp1.deja.com>

Well, my own cookie and query string reading functions (plus some other
stuff that's in the common.pl file I made) run at 107.53 runs/sec (P3
773, Win98 SE, ActiveState Perl build 618). Here's the code (could you
please help me pinpoint potential problems?):

my $buffer;
if ($ENV{'REQUEST_METHOD'} eq "POST") {
	read STDIN, $buffer, $ENV{'CONTENT_LENGTH'}
} else {
	$buffer = $ENV{'QUERY_STRING'}
}
my @pairs = split "&", $buffer;
foreach (@pairs) {
	local($name,$value) = split "=", $_, 2;
	$value =~ tr/+/ /;
	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	$query{$name} = $value
}

sub deleteCookie {
	my $name = shift;
	if (getCookie($name)) {
		print "Set-Cookie: $name=", ($cookie_path) ? ";
path=$cookie_path" : "",
					    ($cookie_domain) ? ";
domain=$cookie_domain" : "",
				            "; expires=Thu, 01-Jan-70
00:00:01 GMT\n";
	}
}

sub getCookie {
	my $cName = shift;
	my @pairs = split "; ", $ENV{'HTTP_COOKIE'};
	foreach (@pairs) {
		local($name,$value) = split "=", $_, 2;
		next if $name ne $cName;
		$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex
($1))/eg; # unescape "forbidden" characters
		return $value
	}
	return undef
}

sub setCookie {
	my ($name,$value,$expires) = @_;
	my @days = qw(Sun Mon Tue Wed Thu Fri Sat);
	my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov
Dec);
	my ($sec,$min,$hour,$date,$month,$year) = gmtime $time-
$time_offset+$expires*86400;
	$year += 1900;
	my $exp = sprintf("%s, %02d-%s-%04d %02d:%02d:%02d GMT",
		 	  $days[$wday],$date,$months
[$month],$year,$hour,$min,$sec);
	$value =~ s#\%#\%25#gm; # escape forbidden characters
	$value =~ s# #\%20#gm;
	$value =~ s#;#\%3B#gm;
	$value =~ s#,#\%2C#gm;
	print "Set-Cookie: $name=$value", ($expires) ? ";
expires=$exp" : "",
					  ($cookie_path) ? ";
path=$cookie_path" : "",
					  ($cookie_domain) ? ";
domain=$cookie_domain" : "",
	       "\n";
}


In article <39FCECF3.FC191780@vpservices.com>,
  Jeff Zucker <jeff@vpservices.com> wrote:
> fallenang3l@my-deja.com wrote:
> >
> > So is there a point in loading the entire CGI.pm module if all one
> > needs to do is read the query string and bake cookies?
>
> AFAIK, the module is fairly smart about which parts of itself it loads
> for which purposes.
>
> > I am making a
> > CGI script where performance is an issue and I would like to load
and
> > spit out html as fast as possible. Will loading CGI.pm affect the
load
> > time significantly? That module is over 200 kb in size so I figure
it's
> > a real hog.
>
> I am not sure this is the way to test that but to indicate the order
of
> magnitude of the "problem", this script runs at a rate of 32.57 runs
of
> the subroutine per second on an 800mhz pentium III:
>
>   #!/usr/local/bin/perl
>   use Benchmark;
>   Benchmark::timethis( 100,
>      sub { do 'CGI.pm'; my $q=new CGI; print $q->header; }
>   );
>
> --
> Jeff
>


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


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

Date: Mon, 30 Oct 2000 12:38:49 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: What about CGI.pm?
Message-Id: <39FDDC59.EB15611F@vpservices.com>

fallenang3l@my-deja.com wrote:
> 
> Well, my own cookie and query string reading functions (plus some other
> stuff that's in the common.pl file I made) run at 107.53 runs/sec (P3
> 773, Win98 SE, ActiveState Perl build 618). Here's the code (could you
> please help me pinpoint potential problems?):

Why should I bother looking through your code to save you 0.02 of a
second in a web environement where a gnat sneezing on your user's subnet
would be more noticable than that?  And suppose I did look through your
code, how is that better than the thousands of people who have used and
helped iron out CGI.pm?  And what happens next week when a new security
hazard is announced and Lincoln Stein sees the announcement, but you
don't?

> my $buffer;
> if ($ENV{'REQUEST_METHOD'} eq "POST") {
>         read STDIN, $buffer, $ENV{'CONTENT_LENGTH'}

If you don't know what is wrong with that, then a) you have never read
through the archives of this newsgroup and b) you need CGI.pm more than
I previously thought.

-- 
Jeff


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

Date: Mon, 30 Oct 2000 21:22:35 GMT
From: fallenang3l@my-deja.com
Subject: Re: What about CGI.pm?
Message-Id: <8tkoqg$83g$1@nnrp1.deja.com>

Thank you for your CONSTRUCTIVE criticism... NOT!!!

In article <39FDDC59.EB15611F@vpservices.com>,
  Jeff Zucker <jeff@vpservices.com> wrote:
> fallenang3l@my-deja.com wrote:
> >
> > Well, my own cookie and query string reading functions (plus some
other
> > stuff that's in the common.pl file I made) run at 107.53 runs/sec
(P3
> > 773, Win98 SE, ActiveState Perl build 618). Here's the code (could
you
> > please help me pinpoint potential problems?):
>
> Why should I bother looking through your code to save you 0.02 of a
> second in a web environement where a gnat sneezing on your user's
subnet
> would be more noticable than that?  And suppose I did look through
your
> code, how is that better than the thousands of people who have used
and
> helped iron out CGI.pm?  And what happens next week when a new
security
> hazard is announced and Lincoln Stein sees the announcement, but you
> don't?
>
> > my $buffer;
> > if ($ENV{'REQUEST_METHOD'} eq "POST") {
> >         read STDIN, $buffer, $ENV{'CONTENT_LENGTH'}
>
> If you don't know what is wrong with that, then a) you have never read
> through the archives of this newsgroup and b) you need CGI.pm more
than
> I previously thought.
>
> --
> Jeff
>


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


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

Date: Mon, 30 Oct 2000 14:15:02 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Working with time
Message-Id: <MPG.146792c4bc264d1198ae7f@nntp.hpl.hp.com>

In article <t67L5.7$Bf7.170632704@news.frii.net> on Mon, 30 Oct 2000 
04:50:33 GMT, Chris Fedde <cfedde@fedde.littleton.co.us> says...
> In article <8tij4d$f25$1@nnrp1.deja.com>, Mario  <diab.lito@usa.net> wrote:
> >In article <39fc1449$1@nexus.comcen.com.au>,
> >  "Kiel Stirling" <taboo@comcen.com.au> wrote:
> >> Is there an easy way to subtract time ?
> >>
> >> well what I meen is if I had an end time of 13:59:00 hours
> >> and a period of 02:48:20 hours is there an easy way to get the
> >> start time ??
> >>
> >I don't know of a single command to do this but I am a newbie.I would
> >use something like this.
> 
> Consider what happens when the endtime in Mario's code is set to
> 0:59:00. Beyond this and and a few other idiomatic issues, you
> might also want to have code that understands other odd boundary
> case issues like transitions to and from daylight savings time.
> 
> There are several modules in CPAN to choose from. I've used
> Time::ParseDate, Date::Manip, and the venerable Date::Calc for work
> like this.  There are several other choices that might also be
> worth considering.

Indded.  For example, on might simply read the FAQ.

perlfaq4: "How can I compare two dates and find the difference?"

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

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 4767
**************************************


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