[12168] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5768 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 24 23:07:15 1999

Date: Mon, 24 May 99 20:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 24 May 1999     Volume: 8 Number: 5768

Today's topics:
    Re: ANNOUNCE: Champaign-Urbana.pm Meeting Tue May 25 (Ook!)
    Re: conditional regexp matching. Please advise. (Ronald J Kimball)
    Re: date conversion and comparison routines <rra@stanford.edu>
    Re: Dumb questions for Jeremy about s/// (Larry Rosler)
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (Larry Rosler)
    Re: How to get a Listbox Horizontal Scroll Bar <ebohlman@netcom.com>
    Re: jerri rigged forms instead of CGI... bad? (Bob Trieger)
    Re: Mac-specific Perl help requested - The Answer (foll (Ronald J Kimball)
    Re: Mac-specific Perl help requested - The Answer (yet  (Ronald J Kimball)
        Mysql from Perl delay? (Ken Williams)
    Re: need relational database <walton@frontiernet.net>
        Newbie  Perl --> HTML <bgleber1@rochester.rr.com>
    Re: Newbie  Perl --> HTML <lyubovi@usa.net>
    Re: Perl on Win32 - How can I hide the process? <thomas@shurflo.com>
    Re: Perl on Win32 - How can I hide the process? <walton@frontiernet.net>
    Re: PERLFUNC: truncate - shorten a file <emschwar@rmi.net>
        Permission denied <garycarrington@mindspring.com>
        Pigheadedness (was Re: Newbie; Perl/Tk Event models) <ebohlman@netcom.com>
    Re: Problems with a guestbook entry script <abey@cs.ucr.edu>
        problems with perl <root@nl2k.ab.ca>
    Re: Question. (Larry Rosler)
    Re: Resolving variables in text files (Abraham Grief)
    Re: Resolving variables in text files <abey@cs.ucr.edu>
    Re: Resolving variables in text files <abey@cs.ucr.edu>
        Timeout question (My code is included)... <vpadua@home.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 24 May 1999 16:20:45 -0700
From: ookookook@yahoo.com (Ook!)
Subject: Re: ANNOUNCE: Champaign-Urbana.pm Meeting Tue May 25
Message-Id: <ookookook-2405991620460001@ip196.r3.d.pdx.nwlink.com>

In article <slrn7kjdeb.gpj.dbt@pianosa.catch22.org>, dbt@meat.net (dbt) wrote:

 >>Daniel S. Lewart <d-lewart@uiuc.edu> says:
 >>>> Our May meeting will be:
 >>>>      Tue May 25 19:00 CDT
 >>>>      Papa Del's
 >>>>      206 E Green St
 >>>>      Champaign, IL
 >>>
 >>>Special guest guru: Randal Schwartz!
 >>>
 >>>Dan
 >>>http://cmi.pm.org/
 >>
 >>Whoa, _COOL_.  Damn me for being in california....

Yeah, who doesn't love waiting seven hours for your pizza and talking to
an unemployed Unix admin until the damn thing arrives?

You gotta love shampoo-banana.

-- 
"Television: a medium. So called because it is neither rare nor well done."
           - Ernie Kovacs


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

Date: Mon, 24 May 1999 21:22:53 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: conditional regexp matching. Please advise.
Message-Id: <1dsbsk6.1p2pqs013ii41sN@p112.block2.tc1.state.ma.tiac.com>

Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:

> [A complimentary Cc of this posting was sent to Ronald J Kimball
> <rjk@linguist.dartmouth.edu>],
> who wrote in article <1dsa1cj.gnskgl1b1ijxeN@[207.60.170.90]>:
> > > and the hope that it can indeed be done using some manipulation of the
> > > ?! or ?= operations.
> > 
> > It probably could, but I suspect that the result would be ugly and less
> > efficient.
> 
> > I believe that some operations just work better when split among several
> > regexes.
> 
> "Work better"?  It is not clear what you mean here.  I assume "look
> better".  

Also "more efficient", as implied in the previous sentence.  I shouldn't
have used such a vague term though, sorry!


In particular, problems of the type "match this and this and not this",
where each "this" is not necessarily adjacent to the others in the
target string, are best done with separate regexes.

/dog/ and /cat/ and !/bird/

vs.

/^(?=.*dog)(?=.*cat)(?!.*cat)/

I definitely prefer the first in this case.


> Returning to the case in question, the posted solutions indeed look
> better than a possible solution in one REx.  But only because of the
> anchoring and since the thing could be parsed in one way only.
> 
> If backtracking is important to the question at hand, then it is
> usually very hard to "split" the problem into parts, and then the
> "advanced" RExen like
> 
>   (0x)?([\da-fA-F]+)(?(1)|h)
> 
> help a lot.

Oo, that's a nice use of this new regex feature.  Thanks for the
example!

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 24 May 1999 17:15:45 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: date conversion and comparison routines
Message-Id: <ylogja6m32.fsf@windlord.stanford.edu>

Kai Henningsen <kaih=7HUguzFXw-B@khms.westfalen.de> writes:

> (Unidirectional gateway for a single news/mailreader using non-RFC
> format, because the native converter doesn't quite do what I want
> (doesn't handle multiparts in any sane way, tends to cut long lines, and
> so on).  Incidentally, this is making me painfully aware that
> MIME::Parser is *SLOW*! Surely parsing a single mail or article should
> not need something on the order of a second?!)

Guess why I didn't use it for News::Gateway.  On the other hand, it can do
a lot of real MIME handling that I can't yet, so I should probably go work
on it and try to make it faster and feed back the changes.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Sat, 22 May 1999 18:27:33 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Dumb questions for Jeremy about s///
Message-Id: <MPG.11b0f95cefe72894989a47@nntp.hpl.hp.com>

In article <7i6qp0$6q0$1@plonk.apk.net> on Sat, 22 May 1999 14:18:09 -
0400, Jody Fedor <JFedor@datacom-css.com> says...
>     I have a file with Vendor ID & Name in format:
> 
>             100    ALPS
>             110    APPLE
> 
>     etc....  At first I didn't know there was a tab between 0 and A, I
> thought it was spaces.
> 
> I used      $rec =~ s/     /:/;
>     where there were 5 spaces between / and /.  only 2 records where there
> weren't tabs were converted to   100:ALPS etc.
> 
> I modified it to look for multiple spaces
> 
>                 $rec =~ s/\s*/:/;  <-- looking for any number of space and
> replace with :

I'm sure that that regex didn't do what you expected it to do (convert 
'100    ALPS' to '100:ALPS').

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


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

Date: Sat, 22 May 1999 19:22:07 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <MPG.11b1062b8d020d95989a48@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <37474364@cs.colorado.edu> on 22 May 1999 17:53:08 -0700, Tom 
Christiansen <tchrist@mox.perl.com> says...
> Cursed by that miserable piece of crap, Mozilla/4.05 [en] (Win95; I)
> finsol@ts.co.nz writes in comp.lang.perl.misc:
 ...
> :For those of you wanting to know more about the Perl Y2K booby-trap code
> :problem, check out:
> :
> :http://www.y2kinfo.com/journal/features/0499_amona.html
> 
> You expect us to take seriously a document that refers to "CGI" as a
> language and goes on to claim this CGI language's localtime function
> has a problem?  Oh please.

That article hasn't changed since the first time the author foisted it 
on us.  She seems impervious to constructive feedback.  There are so 
many things that are simply laughable.

I'll point out one thing that is not laughable at all.  I consider it to 
be a direct insult to professional programmers as a whole, and to a 
specific subset: the authors of the C Library documentation (I am one of 
the latter!), and (by implication) to the authors of the Perl 
documentation (especially to you, Tom).

<QUOTE>
Other definitions include "the number of years since 1900" and similar 
phrases. Programmers may assume that this is the technical wording for 
"the last two digits of the year", especially since we are accustomed to 
writers of technical manuals giving obscure explanations instead of 
simple answers.
</QUOTE>

Anyone who can promulgate such outrageous and demeaning twaddle deserves 
no further attention here.

[And I thought Uri lost his temper when he responded earlier.  Look at 
me now!  :-]

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


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

Date: Tue, 25 May 1999 01:53:07 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: How to get a Listbox Horizontal Scroll Bar
Message-Id: <ebohlmanFC9MKJ.J00@netcom.com>

hansene3824@my-dejanews.com wrote:
: With the Win32-GUI package, I can get a listbox
: vertical scroll bar with syntax -style =>
: WS_VSCROLL, but I can not get a horizontal scroll
: bar on my list box with WS_HSCROLL. So what is
: the deal?  Can anyone lend a hand?

An MS-Windows listbox won't display a horizontal scrollbar, even with the
WS_HSCROLL style set, unless it receives an LB_SETHORIZONTALEXTENT
message, the parameters of which are documented, but not at all clearly,
in the Win32 API docs. 



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

Date: Mon, 24 May 1999 23:31:49 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: jerri rigged forms instead of CGI... bad?
Message-Id: <7iclva$l22$1@birch.prod.itd.earthlink.net>

[ courtesy cc sent by mail if address not munged ]
     
Jerome O'Neil <jeromeo@atrieva.com> wrote:
>Matt Baker wrote:
>
>> Here is the dillema:
>> 1) Is it bad style or normal practice to have a CGI program spit out raw
>> HTML to the web browser?
>> I generally just do a
>> print >>EOD;
>>    lots of HTML goes here
>> EOD
>
>It's not bad form.  In many cases, it's preferable.

May I suggest you look at his code again.



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

Date: Mon, 24 May 1999 21:22:56 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Mac-specific Perl help requested - The Answer (followup)
Message-Id: <1dsbtr0.tighdj12ikrzbN@p112.block2.tc1.state.ma.tiac.com>

Josh Pointer <josh@bitwell.net> wrote:

> Sure, as long as you translate the linebreaks in every document you read
> in and explicitly set $/. That's not my definition of "properly
> handling." MacPerl does not, by default, respect and properly handle \n
> in UNIX-derived files. It interprets \n as \015. That's not a standard
> line break in UNIX. That's not Perl's default behavior. "Properly
> handling" means respecting compatibility issues, or, at the very least,
> properly documenting one's lack of respect for the same. I would seem to
> me that common sense dictates either \n should mean the same thing in
> all versions of Perl, or the differences should be clearly and
> meaningfully documented (in documentation accompanying the
> distribution). MacPerl fails on either count.

Perl was not written with your definitions of "properly handling" or
"default".  Rather, Perl was written with the correct definitions.

Perl's default behavior is not to respect UNIX-derived files, as you so
naively assert.  Perl's default behavior is to respect _the native
platform's_ files.

"\n" does mean the same thing in all versions of Perl.  It means "the
native platform's definition of newline".


Note that more recent editions of the standard documentation are more
explicit on this issue, so the next release of MacPerl will in any case
satisfy your requirements.


-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Mon, 24 May 1999 21:22:55 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Mac-specific Perl help requested - The Answer (yet another followup)
Message-Id: <1dsbtkj.bnh1461jz8blkN@p112.block2.tc1.state.ma.tiac.com>

Josh Pointer <josh@bitwell.net> wrote:

> Matthias Neeracher wrote:
> > 
> > You have not come up with a compelling reason to do so.
> 
> So that data culled from non-Mac sources will behave as expected without
> silly and unnecessary incantations to "tr///". That is to say, for
> compatibility.

Earth to Josh!

Your suggestion would mean that data from *Mac* sources would require
silly and unnecessary incantations to tr///.  You think it would be
preferable for *Mac*Perl to be unable to handle *Mac*-formatted text
files??

Ridiculous.

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        perl -le 'print "Just another \u$^X hacker"'


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

Date: Tue, 25 May 1999 00:18:12 GMT
From: tekkin@hotmail.com (Ken Williams)
Subject: Mysql from Perl delay?
Message-Id: <3749ec64.0@news.cgocable.net>

I'm trying to get some data from a mysql database using Perl.  It works fine, 
but I noticed theres about a half a second delay to do it under Linux 2.2.7 
with Mysql 3.2.22 and the latest DBI/Mysql.pm stuff.  Under my older 
installation it was instant.  

Any idea?


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

Date: Mon, 24 May 1999 22:11:28 -0400
From: Bob Walton <walton@frontiernet.net>
To: anonymous <quikscor@ix.netcom.com>
Subject: Re: need relational database
Message-Id: <374A06D0.2F93665A@frontiernet.net>

Since you mention FoxPro, I assume you're on Win32.  If so, the following
might get you going (courtesy of the perl2exe folks)...

# ODBC test program

# Seting up an ODBC database

#a) Click Settings/ControlPanel
#b) Click 32-Bit ODBC
#c) Select "System DSN" tab
#d) Click Add, select "Microsoft Access Driver", click Finish
#e) Enter the following properties
#   Data Source Name:  test_dsn  (This is the most important field)
#   Description: Anything
#f) Click on Create... and choose a filename, eg. c:\database\test.mdb
#g) Next time Click on Select ... and choose a filename, eg.
c:\database\test.mdb


use Win32::ODBC;

&insertData;
&getData;


exit(0);


sub insertData {
   $dsn = "test_dsn";

   $db = new Win32::ODBC($dsn);
   die "ERROR: Failed to open database\n" if(!$db);

   $sql = "CREATE TABLE test_table (";
   $sql .= "id char(02), ";
   $sql .= "name char(04), ";
   $sql .= "city char(03) )";

    $db->Sql($sql);
   ($ErrNum, $ErrText, $ErrConn) = $db->Error();

   $sql = "DELETE FROM test_table";
   $db->Sql($sql);

   $sql = "INSERT INTO test_table (id, name, city) VALUES ('01', 'Jack',
'NY')";
   $db->Sql($sql);

   $sql = "INSERT INTO test_table (id, name, city) VALUES ('02', 'John',
'Lon')";
   $db->Sql($sql);

   $sql = "INSERT INTO test_table (id, name, city) VALUES ('03', 'Mike',
'HK')";
   $db->Sql($sql);

   $sql = "INSERT INTO test_table (id, name, city) VALUES ('04', 'Carl',
'LA')";
   $db->Sql($sql);
}


sub getData {

   $sql = "SELECT * from test_table order by id";

   $db->Sql($sql);
   while ($db->FetchRow()) {
      ($id, $name, $city) = $db->Data("id", "name", "city");
      print $id, " - ", $name, " - ", $city, "\n";
   }
   $db->Close();
}


anonymous wrote:

> I'm in the beginning stages of designing a website.  It looks like I'm
> going to need a relational database.  How do you hook up with such a
> resource in Perl?  I've only used FoxPro and have never used databases
> with the other languages I'm familiar with, C++ and Java.
>
> - j



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

Date: Mon, 24 May 1999 21:33:48 -0700
From: "Brian A. Gleber" <bgleber1@rochester.rr.com>
Subject: Newbie  Perl --> HTML
Message-Id: <f8n23.30$H5.1674@newsr1.twcny.rr.com>

Today is my first day trying to pick up perl.  When I call my perl program
from by Web Browser, it shows my code instead of a html document.

BTW, I am running Win98 with Personal Web Server installed.  Here is my
code, what am I doing wrong?

#!C:\perl\bin\perl


print "Content-type: text/html\n\n";


print "<HTML><HEAD><TITLE>Hello!</TITLE></HEAD>\n";

print "<BODY><H1>Hello, World!</H></BODY></HTML>\n";




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

Date: Mon, 24 May 1999 22:37:58 -0400
From: "Lyubov Ignatovsky" <lyubovi@usa.net>
Subject: Re: Newbie  Perl --> HTML
Message-Id: <7id211$on2@dfw-ixnews3.ix.netcom.com>

Try #!c:/per/bin\\/perl.exe -w
Lyubov

Brian A. Gleber wrote in message ...
>Today is my first day trying to pick up perl.  When I call my perl program
>from by Web Browser, it shows my code instead of a html document.
>
>BTW, I am running Win98 with Personal Web Server installed.  Here is my
>code, what am I doing wrong?
>
>#!C:\perl\bin\perl
>
>
>print "Content-type: text/html\n\n";
>
>
>print "<HTML><HEAD><TITLE>Hello!</TITLE></HEAD>\n";
>
>print "<BODY><H1>Hello, World!</H></BODY></HTML>\n";
>
>




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

Date: Tue, 25 May 1999 00:36:45 GMT
From: Thomas/Shurflo <thomas@shurflo.com>
Subject: Re: Perl on Win32 - How can I hide the process?
Message-Id: <3749F032.A93E1E41@shurflo.com>

Actually I believe that option is to be used when STARTing another batch
file(other than the calling batch file). And that's not the problem. I'm
looking on how to hide the DOS box that Perl uses when it starts.
Lewis Perin wrote:

> Thomas/Shurflo <thomas@shurflo.com> writes:
>
> > Anyone know how I can hide the process (dos box) that starts when I run
> > a Perl script? It could take a while to run and I don't want users
> > seeing it.
> >
> > I've been through the manuals and the newsgroups.
>
> In a DOS box on the NT or 9X system you use, type
>
>   start /? | more
>
> and you'll see the info you seek.
>
> Cheers, Lew





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

Date: Mon, 24 May 1999 21:45:10 -0400
From: Bob Walton <walton@frontiernet.net>
To: Thomas/Shurflo <thomas@shurflo.com>
Subject: Re: Perl on Win32 - How can I hide the process?
Message-Id: <374A00A6.4B2FF4CC@frontiernet.net>

Hmmm...that's a bummer.  I tried it again, and it works on my system as I
described with Win95, ActiveState perl build 516 and Tk 800.014.  It also works
on my other system with Win95, perl build 509, and Tk 800.011.  Whether it is
executed from a command prompt or by double-clicking in explorer, the associated
command window is minimized after less than a second of display, and stays that
way until the user clicks on the taskbar entry or the program terminates.  If it
terminates successfully and the user doesn't do anything, the command window is
never redisplayed.  If invoked from a double-click, it just goes away; if
invoked from a command prompt, the minimized command window is left sitting at
its command prompt.  I'll check it under NT tomorrow at work (I don't have NT
here at home) to see if it works there (I'm sure it does, as I use Tk a lot a
work, and the console window is always automatically minimized after startup).

Example code:

use Tk;
sleep(10);

I note that if I run perl in standard input mode, the command window is
minimized as soon as the enter key is pressed after typing "use Tk;" (that is,
type:

perl
use Tk;

at the command prompt, and observe that the window immediately minimizes).  Does
yours do that?  I also note that it seems to work with backtick-style system
calls, and everything else I have tried, including all sorts of complicated Tk
stuff and console input requests.

I recall that Tk didn't function quite correctly in some earlier ActiveState
releases, such as the first Perl Resource Kit version.  But it was fixed shortly
after that.

Thomas/Shurflo wrote:

> That doesn't seem to work I tried it and the DOS screen stays right there.
>
> Bob Walton wrote:
>
> > If you put:
> >
> > use Tk;
> >
> > at the start of your perl program (and, of course, you have the Tk package
> > installed), the console window will be minimized shortly after execution
> > starts.  You don't have to use anything else from Tk.  The user can click
> > on the window in the task bar and bring it back up, so it isn't totally
> > "hidden".  There is undoubtedly some other way of doing this which isn't
> > quite so ugly.  Maybe you can figure out how Tk does it.
> >
> > Thomas/Shurflo wrote:
> >
> > > Anyone know how I can hide the process (dos box) that starts when I run
> > > a Perl script? It could take a while to run and I don't want users
> > > seeing it.
> > >
> > > I've been through the manuals and the newsgroups.



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

Date: 24 May 1999 17:21:34 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: PERLFUNC: truncate - shorten a file
Message-Id: <xkfd7zqgikh.fsf@valdemar.col.hp.com>

lr@hpl.hp.com (Larry Rosler) writes:
> Last week, someone asked how to create a file of length 10 Mbytes.  
> Except for me, those who answered suggested writing 10 Mbytes to the 
> file.  I verified that truncate() would *grow* a file to arbitrary 
> length, on HP-UX and Windows NT at least.

I just verified it on Linux (Debian 2.1, to be precise).  The manpages
for the system in question don't reflect this behaviour either.  Perhaps
perl's documentation suffers from that of the *nix it was developed on?

> Would it add value to include in this documentation the notion that 
> 'truncate' really means "set file size", even if it means growing the 
> file?

I believe it would, but I have a feeling that truncate is just a shell on
the OS truncate call, which may or may not always work that way.  Some
research is probably in order?

<snip proposed changes>

-=Eric


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

Date: Mon, 24 May 1999 21:46:08 -0400
From: "Gary L. Carrington" <garycarrington@mindspring.com>
Subject: Permission denied
Message-Id: <374A00E0.A2C987AD@mindspring.com>

I am haveing problems creating a file under a scratch directory.  I
chmod the directory to 0666, changed the group ownership to nobody, and
I still cannot create a file under the directory.  I get the error
message stating Permission denied.  How would I correct this problem.

--
Gary L. Carrington
garycarrington@mindspring.com
919-598-6585




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

Date: Tue, 25 May 1999 02:08:30 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Pigheadedness (was Re: Newbie; Perl/Tk Event models)
Message-Id: <ebohlmanFC9nA6.KwH@netcom.com>

Collin Starkweather <collin.starkweather@colorado.edu> wrote:
: my $update = sub {

: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
: $day=(Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday)[$wday];
: $month=(January,February,March,April,May,June,July,August,September,
: 	October,November,December)[$mon];

: $century = $year - 99 ? 20 : 19;
: $string = sprintf <<"eop", $year, $hour, $min, $sec;
: It is $day, $month $mday, $century%02d %02d:%02d:%02d
: eop

: };

It is obvious that the person who wrote this code read the documentation
for localtime(), as he's obviously learned that the year field will
contain a value greater than 99 in the next century.  But why didn't he
make the obvious connection and simply add 1900 to the year rather than
trying to simulate a Fortran arithmetic IF statement?  I can only guess 
that he had a presupposition that century-handling *had* to be more 
complex than it really is, and dutifully wrote needlessly complicated code.




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

Date: Mon, 24 May 1999 17:49:48 -0700
From: Abraham Grief <abey@cs.ucr.edu>
To: Tim Shapcott <tim.shapcott@NOSPAMvirgin.net>
Subject: Re: Problems with a guestbook entry script
Message-Id: <Pine.LNX.4.05.9905241745390.31712-100000@hill.cs.ucr.edu>



On Mon, 24 May 1999, Tim Shapcott wrote:

> Hi
> 
> I am treading very carefully here, because i tried to ask the same question
> a few days ago, but made the mistake of posting the script as an attachment.
> I hope i haven't offended anyone so much that they won't help me!
> 
> Anyway, my problem is, that whenever i try to call the script, i get an
> internal server error mesage. It's nothing to do with the server; perl on it
> runs fine on another script i have there. It must be the script.
> 
> The script _should_ take info from a HTML form, and then display a thankyou
> screen if the data is OK, and the relevant screen for an email address error
> etc. The form data should be posted onto a guestbook page.
> 
> The only possible problem i can see is that the script is located on a
> different server to the page the data is supposed to be saved to. It could
> be that there are problems with permissions? If so, how can i get around
> this, using a password or other?
> 
> If anyone could help me, i would be very grateful.
> 
> Thanks
> 
> Tim Shapcott


Well, a big problem is that your script doesn't compile.
Here's your compiler errors:

Backslash found where operator expected at .//foolish line 173, near ""<h1
align=\"center"\"
        (Missing operator before \?)
syntax error at .//foolish line 173, near ""<h1 align=\"center"\"
String found where operator expected at .//foolish line 174, near "print
""
  (Might be a runaway multi-line "" string starting on line 173)
        (Missing semicolon on previous line?)
Bareword found where operator expected at .//foolish line 174, near "print
"You"
        (Do you need to predeclare print?)
String found where operator expected at .//foolish line 176, near "print
""
  (Might be a runaway multi-line "" string starting on line 175)
        (Missing semicolon on previous line?)
Bareword found where operator expected at .//foolish line 176, near "print
"is"
        (Do you need to predeclare print?)
String found where operator expected at .//foolish line 177, near "print
""
  (Might be a runaway multi-line "" string starting on line 176)
        (Missing semicolon on previous line?)
Bareword found where operator expected at .//foolish line 177, near "print
"process"
        (Do you need to predeclare print?)
Backslash found where operator expected at .//foolish line 178, near
"<p>\"
        (Missing operator before \?)
String found where operator expected at .//foolish line 179, near "print
""
  (Might be a runaway multi-line "" string starting on line 178)
        (Missing semicolon on previous line?)
Bareword found where operator expected at .//foolish line 179, near "3
CELLPADDING"
        (Missing operator before CELLPADDING?)
String found where operator expected at .//foolish line 180, near "print
""
  (Might be a runaway multi-line "" string starting on line 179)
        (Missing semicolon on previous line?)
Execution of .//foolish aborted due to compilation errors.




You appear to have a backslash and a quote switched on line 173.

Hope this helps.



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

Date: Mon, 24 May 1999 20:19:00 -0600
From: "System Administrator a.k.a. The Root of the Problem" <root@nl2k.ab.ca>
Subject: problems with perl
Message-Id: <374A0894.74471AAB@nl2k.ab.ca>

This is a multi-part message in MIME format.
--------------28E3D691F3A7ABD4C713380E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I am trying to convert up from perl 5.00502 to perl 5.00503 and am
running into problems.

Here is what is going on:




Any pointers

--------------28E3D691F3A7ABD4C713380E
Content-Type: text/plain; charset=us-ascii;
 name="typescript"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="typescript"

Script started on Mon May 24 15:32:04 1999
doctor.nl2k.ab.ca//usr/source/MD5-1.7$ amke test         make clean
rm -rf MD5.c ./blib Makefile.aperl blib/arch/auto/MD5/extralibs.all perlmain.c mon.out core so_locations pm_to_blib *~ */*~ */*/*~ *.o *.a perl.exe MD5.bs MD5.bso MD5.def MD5.exp
mv Makefile Makefile.old > /dev/null 2>&1
doctor.nl2k.ab.ca//usr/source/MD5-1.7$ perl5.00503 MAkefile.        akefile.PL
Checking if your kit is complete...
Looks good
Running 'perl -I/usr/libdata/perl5/5.00503 /usr/libdata/perl5/5.00503/ExtUtils/xsubpp -v 2>&1' exits with status 2 at (eval 29) line 17.
Running 'perl /usr/libdata/perl5/5.00503/ExtUtils/xsubpp temp000 2>&1' exits with status 1 at (eval 29) line 43.
Writing Makefile for MD5
doctor.nl2k.ab.ca//usr/source/MD5-1.7$ make
mkdir blib
mkdir blib/lib
Perl lib version (5.00503) doesn't match executable version (5.00502) at /usr/libdata/perl5/5.00503/i386-bsdos/Config.pm line 7.
BEGIN failed--compilation aborted at /usr/libdata/perl5/5.00503/ExtUtils/Install.pm line 8.
BEGIN failed--compilation aborted.
*** Error code 2

Stop.
doctor.nl2k.ab.ca//usr/source/MD5-1.7$ make test
Perl lib version (5.00503) doesn't match executable version (5.00502) at /usr/libdata/perl5/5.00503/i386-bsdos/Config.pm line 7.
BEGIN failed--compilation aborted at /usr/libdata/perl5/5.00503/ExtUtils/Install.pm line 8.
BEGIN failed--compilation aborted.
*** Error code 2

Stop.
doctor.nl2k.ab.ca//usr/source/MD5-1.7$ exit
exit

Script done on Mon May 24 15:32:56 1999

--------------28E3D691F3A7ABD4C713380E--



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

Date: Sun, 23 May 1999 00:38:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Question.
Message-Id: <MPG.11b1503eef7c1866989a49@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7i80ph$pgb$1@cnn.Princeton.EDU> on Sun, 23 May 1999 00:41:29 
-0400, T.Chen <tonychen@princeton.edu> says...
> I am still learning the basics of perl and I apologize if this question has
> been asked already.  I need my script to execute a unique program from the
> unix prompt with certain variables.  I am aware that system commands can be
> done, but can other programs be executed?  If so, how?

Divining that by "execute a unique program from the unix prompt" you 
mean "run a program as if it were executed by the Unix shell".  This is 
essentially what the Perl system() function and qx() operator do.

Their use is not restricted to "system commands" (by which I presume you 
mean programs that are provided with the operating system and are 
located in system-specific directories.  You can use system() or qx() to 
execute any program, provided you specify the name of the program file 
as an absolute pathname or as a name that can be located from your PATH 
variable.

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


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

Date: Mon, 24 May 1999 16:22:14 -0800
From: abey@cs.ucr.edu (Abraham Grief)
Subject: Re: Resolving variables in text files
Message-Id: <A6m23.944$y6.740659@WReNphoon3>

Check out:

http://language.perl.com/newdocs/pod/perlfaq4.html#How_can_I_expand_variables_in_te


Hope this helps.



**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****


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

Date: Mon, 24 May 1999 17:26:13 -0700
From: Abraham Grief <abey@cs.ucr.edu>
To: jzahn@softdisk.com
Subject: Re: Resolving variables in text files
Message-Id: <Pine.LNX.4.05.9905241724190.31712-100000@hill.cs.ucr.edu>



> In comp.lang.perl.misc, "Jason Zahn" <jzahn@softdisk.com> writes:
> :I am trying to figure out how to resolve variable names that may be
> :contained in a text file.


Check out:

http://language.perl.com/newdocs/pod/perlfaq4.html
How can I expand variables in text strings?

Hope this helps.



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

Date: Mon, 24 May 1999 18:22:49 -0700
From: Abraham Grief <abey@cs.ucr.edu>
Subject: Re: Resolving variables in text files
Message-Id: <Pine.LNX.4.05.9905241821190.688-100000@hill.cs.ucr.edu>



On Mon, 24 May 1999, Abraham Grief wrote:

> Check out:
> 
> http://language.perl.com/newdocs/pod/perlfaq4.html#How_can_I_expand_variables_in_te
> 
> 
> Hope this helps.
> 
> 
> 
> **** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****
> 
> 


Sorry to waste even more of everyone's time, but I would like to apologize
for posting this message twice.  RemarQ gave me an error message when I
posted there, so I posted from somewhere else.  Apparently the post still
went through.



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

Date: Tue, 25 May 1999 00:14:24 GMT
From: "Vincent M. Padua" <vpadua@home.com>
Subject: Timeout question (My code is included)...
Message-Id: <37497B99.604846B8@home.com>

What I have here is a script that prompts a user to type hi at a "login"
prompt before they are able to execute commands available to the
script.  Assuming the user types hi (that's what the &hello is checking
for) it then goes into the &loop where &loop is getting the users
input.  What I'm trying to do with the code below is that if the user
gets passed the hi portion, and is sitting at the scripts command line,
time them out after X seconds and return them to the prompt where they
must type hi again.

Any and all help is appreciated,

Mitch.

$SIG{ALRM} = sub { die "timeout" };
eval {
        alarm(10);
&hello;
&loop;
alarm(0);
};
if ($@) {
        if ($@ =~ /timeout/) {
        &print_welcome;
        &loop;
        } else {
                die;
        }
}




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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5768
**************************************

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