[11939] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5539 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 2 03:08:54 1999

Date: Sun, 2 May 99 00:00:23 -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           Sun, 2 May 1999     Volume: 8 Number: 5539

Today's topics:
    Re: "Text file busy" error (Timothy Larson)
    Re: Autmatic form submission in perl script <webmaster@chatbase.com>
    Re: Buffering, autoflush the answer? (Ronald J Kimball)
    Re: checking the existence of a directory <djm@tintagel.net>
        finding the right doc WAS Re: using perl to manage pass <dtbaker@bus-prod.com>
    Re: finding the right doc WAS Re: using perl to manage  <dtbaker@bus-prod.com>
        global var disappearing, reappearing <otis@my-dejanews.com>
    Re: Help <webmaster@chatbase.com>
    Re: HTTP_REFERER (Steve MacLellan)
    Re: HTTP_REFERER <webmaster@chatbase.com>
    Re: HTTP_REFERER <webmaster@chatbase.com>
    Re: HTTP_REFERER <webmaster@chatbase.com>
    Re: Learning Perl for the first time <jbc@shell2.la.best.com>
        localtime problems... <webmaster@geeks404.com>
    Re: localtime problems... <jbc@shell2.la.best.com>
    Re: localtime problems... <webmaster@geeks404.com>
        Newbie in need (reading a file into an array) <mgeusenet@usa.net>
    Re: Newbie in need (reading a file into an array) <unclelui@grin.net>
    Re: Newbie in need (reading a file into an array) ([sp-])
    Re: Newbie in need (reading a file into an array) <rick.delaney@home.com>
    Re: Newbie in need (reading a file into an array) <rick.delaney@home.com>
    Re: Newsfeed and Local Weather <uri@sysarch.com>
    Re: pattern matching <webmaster@chatbase.com>
        Problems catching telnet escape sequence in perl TCP da <plaak@home.com>
        Q: Getting sendmail to work <aneely@odyssey.on.ca>
    Re: unos problemitas (Alan Curry)
    Re: Won't write to file in the middle of CGI script <djm@tintagel.net>
    Re: Won't write to file in the middle of CGI script <webmaster@chatbase.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 2 May 1999 00:49:11 GMT
From: larsot2@krypton.mankato.msus.edu (Timothy Larson)
Subject: Re: "Text file busy" error
Message-Id: <7gg7e7$3nq$1@nitrogen.mankato.msus.edu>

In article <7g9unu$qfm$1@nitrogen.mankato.msus.edu>,
Timothy Larson <larsot2@krypton.mankato.msus.edu> wrote:
>Sometimes my Perl script won't run and I get a 500 error from the web
>server.  When I try it from the command line I get the error "Text file
>busy".
>What the heck does that mean?  Is it in the bathroom doing some business
>and can't be disturbed?  How can a text file be busy?
>
>Any insights appreciated, thanks.
>
>Tim
>


In article <3729B9EE.755F6202@cthulhu.demon.nl>,
Erik van Roode  <newsposter@cthulhu.demon.nl> wrote:
>Jonathan Stowe wrote:
>> You are on Unix and you are trying to overwrite the binary of a running
>> program yes ?  You will have to kill the program before you can overwrite
>> the file.
>Or rename the executable.

Ack, my connection barfed halfway through the reply.  Thank goodness
for dead.article floating around...

OK, I'm not trying to overwrite anything intentionally.  All I know is that
I will get one or two runs out of the script (from the command line or
web hits, whatever) and then the "text file busy" errors start in.  If I
wait long enough they stop, and I can use the script a few more times.  I'm
admittedly a newbie to using Perl, but this doesn't happen with CGI's I
have written in other languages.  Is there something special I need to
do in Perl to say "Hey, I'm done now" other than simple program termination?
I can't very well have a CGI that only works half the time, now, can I?
:)
And BTW, it does seem to work if I copy it to a new name and run that one
a few times, then the same thing happens.

Thanks, any more ideas, just throw them my way....
Tim




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

Date: Sat, 01 May 1999 23:15:25 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: Autmatic form submission in perl script
Message-Id: <372BED7D.FB950A5A@chatbase.com>

Matt Melton wrote:
> 
> In a standard html file, a form can be autmatically submitted via the
> following:
> 
> <BODY onload="this.document.example.submit();">
> <FORM NAME="example" ACTION="./checkid.cgi" METHOD=POST>
> </FORM>
> 
> However, I have failed to get  this to work in a perl script.  Any
> suggestions?
> 
> Thanks,
> Matt

Go ask this question in a NG geared to javascript, further an HTML NG
may be of some additional help to you. If you have a problem that is
likely to be with perl, _then_ post it here. :-) I'm sorry I don't have
those NG names handy.
-- 
Regards,
Tim Greer:  chatmaster@chatbase.com / software@linkworm.com   
The Chat Base:  http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software & The Link Worm:  http://www.linkworm.com
Custom chat server scripts, CGI scripting in Perl/C, Trouble shooting,
Security, Modify & Debug, Freelance Scripting and more!


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

Date: Sun, 2 May 1999 01:00:44 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Buffering, autoflush the answer?
Message-Id: <1dr5jf9.132ryazq2833aN@p83.block1.tc5.state.ma.tiac.net>

Mark Bannister <mark@appal.com> wrote:

> Problem is that the status messages I use so I can watch the progess do
> not print any more until the entire script has run.  Problem 2 is that
> browser times out before the script gets finished.  Incidently when I
> just had the script process a few files everything printed just fine and
> during the scripts execution.
> I've tried the autoflush command after printing :
>          use FileHandle;
>         STDOUT->autoflush(1);
> but it did not seem to help.  Would system write work?
> I'm sure this is covered somewhere in FAQ's but I have had no luck
> finding it.

Maybe, but if so, it's probably in the CGI FAQs, rather than the Perl
FAQs.  It's not really specific to Perl.

Anyway, it sounds like you need to make your script into an NPH (for
Non-Parsed Headers) script.  This means that the sever passes the output
from your script directly to the client, rather than saving it all up
and waiting for the script to terminate.  You will want to find out how
to set up an NPH script on the specific server where you will run your
script.  If you're still stuck, you should probably ask in
comp.infosystems.www.authoring.cgi.

By the way, you will also want to keep the autoflush(1) of STDOUT; you
were on the right track there.

-- 
 _ / '  _      /       - 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: Sun, 2 May 1999 00:32:18 -0500
From: "Jasmine" <djm@tintagel.net>
Subject: Re: checking the existence of a directory
Message-Id: <372be281.0@206.103.97.91>

You need to use the -e flag...

unless (-e 'lib/tintagel.lib') {
   &doesnt_exist;
}
else {
  &it_exists; #do stuff
}

Regards,

Jasmine Merced
YourDomainHost
http://www.yourdomainhost.com/

Michel Dalle wrote in message <7gf4pv$56g$1@xenon.inbe.net>...
>In article <372adee9@newsread3.dircon.co.uk>, "Paul Davies"
<cobalt@dircon.co.uk> wrote:
>[snip]
>>How do I check for the existence of the directory in Perl?
>-d
>Michel.
>
>--
>aWebVisit - extracts visitor information from WWW logfiles and shows
>the top entry, transit, exit and 'hit&run' pages, the links followed
>inside your website, the time spent per page, the visit duration etc.
>For more details, see http://gallery.uunet.be/Michel.Dalle/awv.html




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

Date: Sat, 01 May 1999 22:53:35 -0500
From: Dan Baker <dtbaker@bus-prod.com>
Subject: finding the right doc WAS Re: using perl to manage passwords?
Message-Id: <372BCC3F.43A26571@bus-prod.com>

Matthew Bafford wrote:
> 
> On Sat, 01 May 1999 16:23:18 -0500, Dan Baker <dtbaker@bus-prod.com>
> lucked upon a computer, and thus typed in the following:
> : mmmm, well... running on windoze is a special sort of mitigating factor;
> : like being raised in an abusive family. It is not a minor matter to grep
> : the perdocs as far as I have been able to determine. If there is a good
> : way to do so, I'd love to hear about it! The docs are all there on my
> : installation, but I haven't found any really good way to find out where
> : to start looking when in unfamiliar ground in the windows environment.
> 
> With glob, readline, command line parsing, and a regular expression, it
> would be quite easy to make a program to search it for you.
---------
perhaps now, with some experience, I could and might create a utility to
do just that.... but you must admit it is not *trivial* and certainly
not possible for a newbie who doesn't know perl well enough to even know
which FAQ to read. Wouldn't it be nice and hugely useful for one of the
more expert programmers out there to write a dandy little search engine
and include it with the standard docs! Even nicer would be one with a
simple little GUI front end written with TK maybe?!



> 
> Or, you could run down to PPT (<URL: http://language.perl.com/ppt>).
-------
hhhmmm, don't know about that and will check it out.


> 
> Failing that, many of the Unix tools are available for Windows.
-------
is grep? if you have a link, I'll check it out.

> 
> Or, you could even *gasp* resort to the program that comes with Windows!
> The Find program (start menu) will search files.
-------
file names perhaps, but it certainly won't search the contents of files
for keywords...


> 
> Or, you could go to somewhere like tucows, I'm sure you'll find quite a
> few gooey grepers.
----------------
perhaps..... but my point is that in the win95 environment it is NOT a
trivial matter to find a place to start reading about an unfamiliar
topic for the *average* newbie. Even a well meaning and relatively
motivated person like myself resorts to the occasional request of advice
on where to look for information. I for one would appreciate people
either giving useful information, or just not replying to the really
silly ones.

Dan


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

Date: Sat, 01 May 1999 23:20:42 -0500
From: Dan Baker <dtbaker@bus-prod.com>
Subject: Re: finding the right doc WAS Re: using perl to manage passwords?
Message-Id: <372BD29A.2D553522@bus-prod.com>

> > Or, you could run down to PPT (<URL: http://language.perl.com/ppt>).
> -------

ok, checked it out.... there is a perl implementation of grep at
http://language.perl.com/ppt/src/grep/tcgrep
and I'm trying to figure out what to do with it....

Dan


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

Date: Sun, 02 May 1999 04:48:33 GMT
From: Otis Gospodnetic <otis@my-dejanews.com>
Subject: global var disappearing, reappearing
Message-Id: <7gglf1$450$1@nnrp1.dejanews.com>

Hi,

What is the correct way to declare a global variable that is to be visible
from all subroutines in the program?

I thought:
my $foo = 'bar'; # correct
$foo = 'bar';    # bad

The latter causes a warning with 'use strict'. However, I noticed that the
former may make $foo undefined in some subroutines.

The following script exhibits that:

#!/usr/bin/perl -w

use strict;
use Thread;
my $tCount = 1;
my @ids = (1 .. 4000);

my $tMax = 2;
&makeThreads;

sub makeThreads
{
    for ($tCount = $tCount; $tCount <= $tMax; $tCount++)
    {
	print "Adding Thread $tCount\n";
	my $t = Thread->new(\&dispatch, $tCount);
	$t->detach();
    }
}

sub getID
{
    return (shift @ids);
}

sub dispatch
{
    my ($tn) = @_;

    while (defined (my $id = &getID()))
    {
	print "tMax: $tMax\n";
	print "Thread $tn of ", $tMax, " working on $id\n";
	sleep 1*$tn;
	print "Free Thread Slot $tn\n";
    }
}

[otis@nyc-dev]$ uname -a
Linux nyc-dev.foobar.com 2.0.35 #1 Tue Jul 14 23:56:39 EDT 1998 i686 unknown
[otis@nyc-dev]$ perl -v

This is perl, version 5.005_03 built for i686-linux-thread

Copyright 1987-1999, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

Am I doing something wrong?

Thanks,

Otis

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Sat, 01 May 1999 23:18:25 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: Help
Message-Id: <372BEE31.A0C37161@chatbase.com>

exorcist1@my-dejanews.com wrote:
> 
> Hello, i need help on deciding something. I need to know if it would be
> faster to build a script in perl rather than c++ or c++ rather than perl. I
> am trying to make it so the script checks if an ftp site is currently up or
> has gone down (I'm not building the script though) Please help!

Does the person coding this know Perl or C well? Which can this person
code in to get the job done faster? There's your answer. :-)
-- 
Regards,
Tim Greer:  chatmaster@chatbase.com / software@linkworm.com   
The Chat Base:  http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software & The Link Worm:  http://www.linkworm.com
Custom chat server scripts, CGI scripting in Perl/C, Trouble shooting,
Security, Modify & Debug, Freelance Scripting and more!


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

Date: Sun, 02 May 1999 02:49:41 GMT
From: maclell@col.ca (Steve MacLellan)
Subject: Re: HTTP_REFERER
Message-Id: <372bb96c.36946739@news.tor.metronet.ca>

On Sat, 01 May 1999 17:33:14 GMT, "Charles R. Thompson"
<design@raincloud-studios.com> wrote:

>Steve MacLellan wrote in message
><372b40ef.6096909@news.tor.metronet.ca>...
>>Some Perl scripts I am trying to install on Red Hat are looking
>for
>>the HTTP_REFERER variable. Theserver does not seem to support
>this.
>
>
>Ummm... yes it does work.
>
>Opening the access_log for the server will show this. If it's
>not there, then someone has messed with httpd.conf and messed up
>the LogFormat. Either way, this should be working. Try one of
>the redhat newsgroups and see if your configuration needs
>fixin'. Make sure to post your version of RedHat and the server
>you are running... they are picky about those sort of things.
>
>CT
>
>
Thank-you Charles,

Best Regards,
Steve MacLellan
_______________________________________
	
	Dog BYTE FREE Classifieds
	Newsletter and discussion
	For Internet Marketers
	http://welcome.to/dogbyte
_______________________________________


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

Date: Sat, 01 May 1999 23:36:45 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: HTTP_REFERER
Message-Id: <372BF27D.D11941D0@chatbase.com>

"Charles R. Thompson" wrote:
> Opening the access_log for the server will show this. If it's
> not there, then someone has messed with httpd.conf and messed up
> the LogFormat. 

There's nothing wrong with not having your server log the referrers.
-- 
Regards,
Tim Greer:  chatmaster@chatbase.com / software@linkworm.com   
The Chat Base:  http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software & The Link Worm:  http://www.linkworm.com
Custom chat server scripts, CGI scripting in Perl/C, Trouble shooting,
Security, Modify & Debug, Freelance Scripting and more!


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

Date: Sat, 01 May 1999 23:41:28 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: HTTP_REFERER
Message-Id: <372BF398.A0076238@chatbase.com>

Steve MacLellan wrote:
> 
> Some Perl scripts I am trying to install on Red Hat are looking for
> the HTTP_REFERER variable.

Do you know for what purpose?

> Theserver does not seem to support this.

The system should. Ar you running these scripts in the proper way to
have it read that variable? I.e., from a web browser that supports it.
Some actuality don't. If you come from a bookmark, it may not/won't read
it. Is something now working, or it is just not logging/printing what
you expect to see? If you run the script from the command line, then it
won't have a referrer value either.
 
> Is there a work-around?

What are the scripts doing? Are they logging where people come from? :-)
Are they possibly checking where people are posting to the form from? Is
it just for an added feature for some counter script to log where people
came from for example?
-- 
Regards,
Tim Greer:  chatmaster@chatbase.com / software@linkworm.com   
The Chat Base:  http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software & The Link Worm:  http://www.linkworm.com
Custom chat server scripts, CGI scripting in Perl/C, Trouble shooting,
Security, Modify & Debug, Freelance Scripting and more!


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

Date: Sat, 01 May 1999 23:44:28 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: HTTP_REFERER
Message-Id: <372BF44C.2D34637E@chatbase.com>

> 
> Some Perl scripts I am trying to install on Red Hat are looking for
> the HTTP_REFERER variable.

Do you know for what purpose?

> Theserver does not seem to support this.

The system should. Are you accessing these scripts in the proper way to
have it read that variable? I.e., from a web browser that supports it.
Some actuality don't. Did you come from a bookmark?
Is something not working, or it is just not logging/printing what you
expect to see?
If you run the script from the command line, then it won't have a
referrer value either.
 
> Is there a work-around?

What are the scripts doing? Are they logging where people come from? :-)
Are they possibly checking where people are posting to the form from? Is
it just for an added feature for some counter script to log where people
came from, for example?
-- 
Regards,
Tim Greer:  chatmaster@chatbase.com / software@linkworm.com   
The Chat Base:  http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software & The Link Worm:  http://www.linkworm.com
Custom chat server scripts, CGI scripting in Perl/C, Trouble shooting,
Security, Modify & Debug, Freelance Scripting and more!


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

Date: 02 May 1999 05:38:06 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: Learning Perl for the first time
Message-Id: <372be4be$0$200@nntp1.ba.best.com>

Andrew Johnson <andrew-johnson@home.com> wrote:

> just as a counter-point opinion: it is interesting that you seem to
> deride 'use strict' as just a roadblock or something to be used by
> experts, yet you are certainly comfortable claiming (in your web page
> tutorial) that -T is useful --- going so far as to say:

>  "The hoops you have to jump through to overcome this tainting
>   process are a bit of a pain, but they are in fact a Really Good
>   Thing,..."

> Why is it that you think 'use strict' is an encumbrance only to be
> used by 'macho programmers', but -T is beneficial always? Could it
> not also be true that 'use strict' is also a good safety mechanism?

In brief, I don't. That is, I don't think 'use strict' is only good for
experts, and I don't think -T is always beneficial.

Beginners can benefit from 'use strict' -- but I think it is
counterproductive to tell someone new to programming who is trying to
make sense of their first CGI script that they have to understand
enough about lexical scoping to be able to use 'my' appropriately.

'use strict' becomes useful to them, I think, at the point when they
begin creating long enough programs to need to take steps to avoid
trampling on their own variable names. I think they'll hit that point
well short of "expert", but well beyond the "how do I print "<h1>hello
world</h1> via a CGI script?" phase.

I was being fairly flip in my original message; if I gave the wrong
impression on that point I apologize.

On the tainting issue, I only introduce it in my tutorial at the point
where the learner is creating a guestbook script that needs to write to
a local file. Since I suggest running the script in setuid mode, the
user is going to have to deal with tainting. It is a good thing in that
situation. In the "hello world" and form mailer examples that precede
it, though, I don't include it, since I think it would be overkill in
those cases, and again, would burden the student with complexities
better saved for later.

> Turning off all 'roadblocks' is easy ... so is driving off a cliff.
> Driver eductation programs do not begin by telling novices: "here's
> the keys to the jeep ... just go out and drive around wherever you
> feel like it and when you feel comfortable come back and we'll teach
> you the rules of the road and what all those funny signs and blinking
> lights mean.

Yet that is exactly the approach my 7-year-old daughter took with the
race car computer game she got at Christmas. Predictably, she spent
most of her time banging into the walls of the track, but eventually
she got the hang of it and had a good time. If I'd made her study a
Driver's Ed text before letting her play the game, I doubt the results
would have been as positive, at least from her perspective. And I'm not
losing sleep over the possibility that the "bad habits" she's learning
are going to come back to haunt her later (though you might want to ask
me again when she turns 16 :-).

Learning enough Perl to get a guestbook script working on a personal
Web site is not the same thing as piloting a massive projectile down
the streets of a residential neighborhood. Sure, novice programmers are
going to make many mistakes, some of which might have been prevented by
imposing more discipline on them than Perl requires by default. For
people embarking on a serious career as a full-time programmer, such
discipline might well be warranted from the get-go.

But those aren't the kind of people we're talking about here.

As far as I can see, the armies of accidental programmers that the
combination of the Web and Perl has given rise to represent a new
phenomenon in the history of programming. You're confronting
programming as a mass movement, with all the ugliness that implies. For
better or worse, making Perl flexible and clever enough to make easy
things easy for experienced programmers has had the (possibly
unintended, though I've yet to hear Larry say so) side effect of making
the previously impossibly hard possible: allowing lots of
non-programmers to do useful programming.

I know that the prevailing wisdom in these parts is that that's a
horrible travesty. As one of those accidental programmers, I have to
disagree. The Web content that is being created by novice Perl
programmers is of use to everyone, gurus included. The intellectual and
financial resources that have organized themselves around improving
Perl and extending it to alien architectures, in part because of the
Web/Perl connection, make Perl a better tool for everyone. The
lucrative consulting and training opportunities associated with Perl's
mass appeal are lining the pockets of the same people mourning the
passing of the Good Old Days. The large number of publishers scrambling
to put out Perl books for the newbie audience means that people whose
previous writing credits may be limited to school papers and technical
journals suddenly are pulling down book contracts.

Anyway, regardless of how one feels about this invasion of the unwashed
masses, they're here, and I don't see any signs that they're going
away. You can tell them they have to 'use strict' until you're blue in
the face, but a lot of them aren't going to understand what you're
talking about for a while yet. I just don't see a significant benefit
in making them stick 'my' in front of all their variables when they
don't know why they're doing it.

-- 
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Sun, 2 May 1999 01:19:23 -0400
From: "dave" <webmaster@geeks404.com>
Subject: localtime problems...
Message-Id: <7ggn8a$3j0m$1@newssvr03-int.news.prodigy.com>

i'm having trouble using localtime. what i want to do is extract the day of
the month, the month name, and the year to three seperate scalars. my
current expression looks something like this:
($day, $mon, $year) = localtime[3,4,5];

it gives me wierd results, and when i modify it a little, one thing will
work, but the others won't.

any suggestions?

thanks alot, this really makes or breaks a cgi i'm developing.

-dave

404 Webmaster
webmaster@geeks404.com
http://www.geeks404.com/




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

Date: 02 May 1999 06:08:21 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: localtime problems...
Message-Id: <372bebd5$0$200@nntp1.ba.best.com>

dave <webmaster@geeks404.com> wrote:
> i'm having trouble using localtime. what i want to do is extract the day of
> the month, the month name, and the year to three seperate scalars. my
> current expression looks something like this:
> ($day, $mon, $year) = localtime[3,4,5];

> it gives me wierd results, and when i modify it a little, one thing will
> work, but the others won't.

> any suggestions?

Enclose the localtime function in parens:

($day, $mon, $year) = (localtime)[3,4,5];

-- 
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Sun, 2 May 1999 02:20:27 -0400
From: "dave" <webmaster@geeks404.com>
Subject: Re: localtime problems...
Message-Id: <7ggqqq$5kic$1@newssvr04-int.news.prodigy.com>

thank you! that's exactly what was the problem. but is there any way to get
the full year i.e. 1999 vs. 99?

-dave

404 Webmaster
webmaster@geeks404.com
http://www.geeks404.com/

John Callender wrote in message <372bebd5$0$200@nntp1.ba.best.com>...
>dave <webmaster@geeks404.com> wrote:
>> i'm having trouble using localtime. what i want to do is extract the day
of
>> the month, the month name, and the year to three seperate scalars. my
>> current expression looks something like this:
>> ($day, $mon, $year) = localtime[3,4,5];
>
>> it gives me wierd results, and when i modify it a little, one thing will
>> work, but the others won't.
>
>> any suggestions?
>
>Enclose the localtime function in parens:
>
>($day, $mon, $year) = (localtime)[3,4,5];
>
>--
>John Callender
>jbc@west.net
>http://www.west.net/~jbc/




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

Date: Sat, 1 May 1999 19:03:18 -0700
From: "Matt G. Ellis" <mgeusenet@usa.net>
Subject: Newbie in need (reading a file into an array)
Message-Id: <95556DD4FDAB9044.23BB89B13484110B.9CDFB83DFA59D10D@library-proxy.airnews.net>

Okay i have a file, i want to be able to read all the lines into one big
array so i can refrence it in my script.

So $arrayname[0] would be line one and $arrayname[1] world be line 2 and so
on?

Please help?  Send e-mail anwser if ya got one




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

Date: Sat, 01 May 1999 19:44:15 -0700
From: "Luis F. Salas" <unclelui@grin.net>
Subject: Re: Newbie in need (reading a file into an array)
Message-Id: <372BBBFF.11F4@grin.net>

The following code should take care of it. to test it, use he file
myfile.txt or modify it to your file name.

perl script:

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

open (MYFILE , "< myfile.txt") || die "cannnot open file \n";

$i=0;
while ($rec = <MYFILE>) {
        $line[$i]=$rec;
        $i++;
        }
foreach (@line) {
        print "$_";
        }         

===========================================

myfile.txt:

this is
a test to
help this guy
i hope it
works
just fine

bye  

==============================================

Works fine, however I get a warning that says:

Value of <HANDLE> construct can be "0"; test with defined() at 
 ./arra.pl line 65535. 


(arra.pl is the name of my script)

Anyone care to explain to me why?

Luis

Matt G. Ellis wrote:
> 
> Okay i have a file, i want to be able to read all the lines into one big
> array so i can refrence it in my script.
> 
> So $arrayname[0] would be line one and $arrayname[1] world be line 2 and so
> on?
> 
> Please help?  Send e-mail anwser if ya got one


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

Date: Sat, 1 May 1999 23:40:32 -0400
From: splice@videotron.ca ([sp-])
Subject: Re: Newbie in need (reading a file into an array)
Message-Id: <MPG.119593369f0118709896c0@news.videotron.ca>

In article <372BBBFF.11F4@grin.net>, unclelui@grin.net says...
<clip>
> open (MYFILE , "< myfile.txt") || die "cannnot open file \n";
<clip>
> Works fine, however I get a warning that says:
> 
> Value of <HANDLE> construct can be "0"; test with defined() at 
> ./arra.pl line 65535. 

Simply means that that the MYFILE handle might be undefined after the 
open (even though it will die). Newer versions of perl are supposed to 
handle the test automatically, but you can still shut it up with the 
following:

die "cannot open file: $!" if (!defined(open(MYFILE, "<myfile.txt")));

Should work just fine.

Seb


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

Date: Sun, 02 May 1999 04:26:09 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Newbie in need (reading a file into an array)
Message-Id: <372BD384.D84542C8@home.com>

[posted & mailed]

[sp-] wrote:
> 
> > Value of <HANDLE> construct can be "0"; test with defined() at
> > ./arra.pl line 65535.
> 
> Simply means that that the MYFILE handle might be undefined after the
> open (even though it will die). 

Where did this tidbit of misinformation come from?  From perldiag:

    (W) In a conditional expression, you used <HANDLE>, <*> (glob), 
    each(), or readdir() as a boolean value.  Each of these constructs
    can return a value of "0"; that would make the conditional 
    expression false, which is probably not what you intended.  When 
    using these constructs in conditional expressions, test their
    values with the defined operator.

This simply means that if for some bizarre reason the last two
characters in your file are "\n0" (assuming $/ eq "\n") then the last
"line" will be skipped.

> Newer versions of perl are supposed to handle the test automatically, 

Yes, there is no more "need" of this warning as of 5.005 in the
construct

    while ($rec = <MYFILE>) {

> but you can still shut it up with the following:
> 
> die "cannot open file: $!" if (!defined(open(MYFILE, "<myfile.txt")));
> 
> Should work just fine.

It is customary to test assertions about how code will perform.  That
code will not change anything.  The warning directs you to use defined
in the expression containing <HANDLE>.  Thus

    while( defined($rec = <MYFILE>) ) {

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sun, 02 May 1999 04:35:06 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Newbie in need (reading a file into an array)
Message-Id: <372BD5A1.C7A4A1EC@home.com>

[posted & mailed]

Luis F. Salas wrote:
> 
> $i=0;
> while ($rec = <MYFILE>) {
>         $line[$i]=$rec;
>         $i++;
>         }

This would have been a lot easier to write as

    @line = <MYFILE>;

[snip]

> Works fine, however I get a warning that says:
> 
> Value of <HANDLE> construct can be "0"; test with defined() at
> ./arra.pl line 65535.
> 
> (arra.pl is the name of my script)
> 
> Anyone care to explain to me why?

I have answered this in a correction post but I'd like to direct you to
the place where you could find the answer yourself.  Perlfaq3:

    When I tried to run my script, I got this message. What does it
    mean? 

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 02 May 1999 00:01:51 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Newsfeed and Local Weather
Message-Id: <x7yaj83ys0.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> May I offer Version 0.01 of Uri::Filter  (or maybe that should be 
  LR> uri::filter, despite the conventions)?  I think I got everything except 
  LR> the missing commas, which are well beyond the scope of this exercise.  
  LR> :-)

i actually use some commas and fully use periods. i don't know how i got
into this habit of lower case but i like it now. i do caps for permanent
docs and such but for email and usenet my style seems to fall to
lower. i get irregular complaints about the lack of caps but my content
seems to be worth the trouble of reading it for some. i have no trouble
reading it. caps do help in some ways but i think more white space in
perl would help too (like before ; tom?). that is my opinion on a style
issue which has no true answer like no religion does. i know people who
hate all extra white space in code which it illegible to me.

so if you want to more easily read my posts, use larry's filter!

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Sat, 01 May 1999 23:23:57 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: pattern matching
Message-Id: <372BEF7D.281AC9E1@chatbase.com>

bing-du@tamu.edu wrote:
> 
> Greetings all...
> 
> I want to remove all the blank spaces before and after (but between 'a' and
> 'b') the comma ','. But the following code snippet did not work.
> 
> $test = 'a, b c';
> $test =~ s/(\s+),(\s+)/,/;
> print "test is $test\n";  # the output is still 'a, b c' but rather 'a,b c'.
> 
> Any ideas?
> 
> Thanks in advance,
> 
> Bing
Did you mean:
$test =~ s/,(\s+)/,/;

Otherwise it's looking to remove "space(s),space(s)".
-- 
Regards,
Tim Greer:  chatmaster@chatbase.com / software@linkworm.com   
The Chat Base:  http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software & The Link Worm:  http://www.linkworm.com
Custom chat server scripts, CGI scripting in Perl/C, Trouble shooting,
Security, Modify & Debug, Freelance Scripting and more!


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

Date: Sun, 02 May 1999 04:55:29 GMT
From: Peter Laakmann <plaak@home.com>
Subject: Problems catching telnet escape sequence in perl TCP daemon.
Message-Id: <372BDAD5.720ACAC1@home.com>



I've coded a simple TCP daemon in perl that operates over inetd.  For
some reason, when I hit control-C (or ^D....) in my telnet client when
connected to my daemon, causes my daemon to die.   To the best of my
understanding, hitting Control-C when telnet is in foreground, causes a
INTR signal to get send to my telnet client.  My telnet client in turn
traps this signal, and sends a telnet escape sequence to the daemon via
the socket.   What I can't figure out, is why my perl program treats
this escape sequence any differently than any other text.  I'm not
reading in anything from stdin, just printing to stdout.  My system is
RedHat5.2 (linux).  Any suggestions would be greatly appreciated.





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

Date: Sat, 01 May 1999 23:38:22 -0400
From: Amer Neely <aneely@odyssey.on.ca>
Subject: Q: Getting sendmail to work
Message-Id: <372BC8AE.A4DE2042@odyssey.on.ca>

Hi all,
I'm having a problem trying to call sendmail from an otherwise working
Perl script. I have confirmed the path to sendmail. I've read the Perl /
CGI Programming FAQ, where in fact this question (4.1) is dealt with.
Problem is it doesn't seem to work for me. The code snippet I have:

#!/usr/bin/perl
print "Content-type: text/html\n\n";

$mailfrom="aneely\@odyssey.on.ca";
$mailto="aneely\@odyssey.on.ca";
$mailsubject="Another Site Survey";
$mailbody="I sent this via a Perl script calling sendmail.\n";
open(SENDMAIL, "| /usr/lib/sendmail -t -n");
print SENDMAIL "From: $mailfrom\n";
print SENDMAIL "To: $mailto\n";
print SENDMAIL "Reply-To: $mailfrom\n";
print SENDMAIL "Subject: $mailsubject\n";
print SENDMAIL "$mailbody";
close (SENDMAIL);

I'd rather try and roll this one myself as opposed to using a Perl
module. I can't seem to get cgi.pm or any other modules to work either
under Win95. This snippet is part of a working script to generate a
Thank You HTML page which works fine. I'd like to notify myself (or
someone else) depending on a condition being met.

Any help with the sendmail is greatly appreciated. Thanks.
--
Amer Neely aneely@odyssey.on.ca
Softouch Information Services: http://www.softouch.on.ca/
Research Central: http://www.execulink.com/~aneely/
Member: International Webmasters Association: http://iwanet.org
Member: Association of Web Professionals: http://www.a-w-p.org




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

Date: Sun, 02 May 1999 02:24:33 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: unos problemitas
Message-Id: <BHOW2.2226$fO5.68295@news14.ispnews.com>

In article <MPG.119534f1a7c0efc498998e@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>"No problemo!" is pure Simpson-speak.

Didn't ALF say it a few years earlier?
-- 
Alan Curry    |Declaration of   | _../\. ./\.._     ____.    ____.
pacman@cqc.com|bigotries (should| [    | |    ]    /    _>  /    _>
--------------+save some time): |  \__/   \__/     \___:    \___:
 Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman


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

Date: Sun, 2 May 1999 00:29:11 -0500
From: "Jasmine" <djm@tintagel.net>
Subject: Re: Won't write to file in the middle of CGI script
Message-Id: <372be1c7.0@206.103.97.91>

Dear Mr. Horne:

It sounds like your problem is that you don't have your content-type defined
before it's trying to print the "Problemo" error.

Make sure that you have the line:

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

before anything that's supposed to output to the browser.

Regards,

Jasmine
YourDomainHost
http://www.yourdomainhost.com/

Steve Horne wrote in message <7gf5pa$stm$1@newsfeeds.rpi.edu>...
>Hi --
>
>I am having a very strange and inexplicable (to me) problem. I have a cgi
>script where if I run it from the prompt, it runs fine and will output the
>files it should, but if I run it from a webpage as a CGI, it keeps having a
>problem creating a file.
>
>The following line is the one that creates the problem:
>
>open (FILE, ">$fn") || print "Problemo!";
>
>where $fn is the filename. Like I said, it works fine from the prompt, it
>just won't work when I run it from the web. When I did "print `pwd`", the
>current directories are the same for both cases. I am new at Perl, so I'm
>sorry if this is something that is blatantly obvious. Thanks in advance!!
>
>-- Steve Horne
>
>




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

Date: Sat, 01 May 1999 23:53:52 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: Won't write to file in the middle of CGI script
Message-Id: <372BF680.68A7F0F9@chatbase.com>

Steve Horne wrote:
> 
> Hi --
> 
> I am having a very strange and inexplicable (to me) problem. I have a cgi
> script where if I run it from the prompt, it runs fine and will output the
> files it should, but if I run it from a webpage as a CGI, it keeps having a
> problem creating a file.
> 
> The following line is the one that creates the problem:
> 
> open (FILE, ">$fn") || print "Problemo!";
> 
> where $fn is the filename. Like I said, it works fine from the prompt, it
> just won't work when I run it from the web. When I did "print `pwd`", the
> current directories are the same for both cases. I am new at Perl, so I'm
> sorry if this is something that is blatantly obvious. Thanks in advance!!
> 
> -- Steve Horne

Sounds like your problem is that it works when you run it as your
user/group ID, but the server may be running the script as user "nobody"
rather then your account user ID.


-- 
Regards,
Tim Greer:  chatmaster@chatbase.com / software@linkworm.com   
The Chat Base:  http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software & The Link Worm:  http://www.linkworm.com
Custom chat server scripts, CGI scripting in Perl/C, Trouble shooting,
Security, Modify & Debug, Freelance Scripting and more!


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

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

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