[25316] in Perl-Users-Digest
Perl-Users Digest, Issue: 7561 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 23 14:05:36 2004
Date: Thu, 23 Dec 2004 11:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 23 Dec 2004 Volume: 10 Number: 7561
Today's topics:
Beginner's list/return/glob problem <eighner@io.com>
Re: Beginner's list/return/glob problem <mritty@gmail.com>
Re: Beginner's list/return/glob problem <eighner@io.com>
Re: Change file creation date? <j.b.l.0.2.@.hotmail.com>
Re: generating a session id <1usa@llenroc.ude.invalid>
Re: How can script find its host's name/IP address? <matthew.garrish@sympatico.ca>
Re: How can script find its host's name/IP address? <matternc@comcast.net>
Re: How can script find its host's name/IP address? <nobull@mail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 23 Dec 2004 10:40:33 -0600
From: Lars Eighner <eighner@io.com>
Subject: Beginner's list/return/glob problem
Message-Id: <slrncslt16.vfl.eighner@goodwill.io.com>
This works fine to produce a list of partial file names when
there are matching files:
(main)
if ( gen::listdbs() )
{
$content .= $main::cur->start_ul;
foreach my $item (gen::listdbs()) { $content .= $main::cur->li($item);}
$content .= $main::cur->end_ul;
}
else
{ $content .= $main::cur->p("No databases found"); }
(gen)
sub listdbs {
my @list = undef;
my $i=0;
while (<$tun::datadir/*$tun::dbsuf>)
{
$_ =~ s#$tun::datadir/(.*)$tun::dbsuf#$1#;
$list[$i] = $_;
$i++;
}
return @list;
}
Once again, it works fine when there are values, but fails when
I think @list should still be undefined. (All testing with -w
and strict - no exceptions.)
When there are no matching files, the result is a one-item
list with empty contents.
I suspect
if ( gen::listdbs() )
is getting the wrong answer, but I don't know why. I can figure
out how set some kind of flag or something, but it seems to me
there should be a neat solution.
--
Lars Eighner eighner@io.com http://www.io.com/~eighner/
War on Terrorism: Bad News from the Sanity Front
"Tactical nuclear capabilities should be used against the bin Laden
camps in the desert of Afghanistan." -Thomas Woodrow,_Washington Times_
------------------------------
Date: Thu, 23 Dec 2004 17:01:12 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Beginner's list/return/glob problem
Message-Id: <sRCyd.5948$113.3690@trndny03>
"Lars Eighner" <eighner@io.com> wrote in message
news:slrncslt16.vfl.eighner@goodwill.io.com...
> sub listdbs {
> my @list = undef;
This almost certainly is not doing what you think it's doing. This is
setting @list to be an array containing exactly one element - the
undefined value.
The correct way to initialize an array to the empty list is:
my @list = ();
However, this is wholly unnecessary, as the empty list is the default
value of an array, so this will work fine:
my @list;
Hope this helps,
Paul Lalli
------------------------------
Date: Thu, 23 Dec 2004 11:09:29 -0600
From: Lars Eighner <eighner@io.com>
Subject: Re: Beginner's list/return/glob problem
Message-Id: <slrncslunf.vfl.eighner@goodwill.io.com>
In our last episode, <sRCyd.5948$113.3690@trndny03>, the lovely
and talented Paul Lalli broadcast on comp.lang.perl.misc:
> "Lars Eighner" <eighner@io.com> wrote in message
> news:slrncslt16.vfl.eighner@goodwill.io.com...
>> sub listdbs {
>> my @list = undef;
> This almost certainly is not doing what you think it's doing. This is
> setting @list to be an array containing exactly one element - the
> undefined value.
> The correct way to initialize an array to the empty list is:
> my @list = ();
> However, this is wholly unnecessary, as the empty list is the default
> value of an array, so this will work fine:
> my @list;
Bingo!
--
Lars Eighner eighner@io.com http://www.io.com/~eighner/
"Shhh! Be vewwy, vewwy quiet! I'm hunting Muswims!"
- President Elmer Bush
------------------------------
Date: Thu, 23 Dec 2004 16:16:48 GMT
From: jbl <j.b.l.0.2.@.hotmail.com>
Subject: Re: Change file creation date?
Message-Id: <h1ols0td739ao2gi6lgc7d6e0jav3vhi7s@4ax.com>
On Wed, 22 Dec 2004 17:06:20 -0500, Chris Mattern
<matternc@comcast.net> wrote:
>Brian McCauley wrote:
>
>>
>>
>> Chris Mattern wrote:
>>
>>> jbl wrote:
>>>
>>>>I want to modify the file creation time to syncronize my local dates
>>>>with the dates on a server.
>>>
>>> You can't. There's no such thing as "file creation time", at least not
>>> on a Windows or UNIX computer. The filesystem does not track such a
>>> statistic.
>>
>> Er, NTFS5 does. (I think earlier NTFS did too).
>
>Ah, well, my Windows knowledge is is weaker than my UNIX knowledge.
>So noted.
Thanks for the replies and help.
I am using WindowsXP and I can see the file creation time.
I was wanting to use the creation date as it is not volatile, like the
last accessed time or modified time
Thanks
jbl
------------------------------
Date: 23 Dec 2004 16:24:52 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: generating a session id
Message-Id: <Xns95C8741E91DBEasu1cornelledu@132.236.56.8>
ioneabu@yahoo.com wrote in news:1103813391.302838.297640
@f14g2000cwb.googlegroups.com:
> It's like me going to the store to buy a steel, fire-proof safe and
> then deciding to build my own version out of wood. Rather than arguing
> with the salesman over the benefits of his tested and proven safe over
> my home-made solution, I should just buy the real thing and move on
> with my life without too much further probing. The wood project may be
> a fun, useful diversion in my own free time, but if I need a strong,
> secure fireproof safe, I should check with consumer reports, buy the
> best one, and use my free time to figure out what to put in it.
A genuine thank you for this post. I am sure it will be helpful to others
who might be going through a similar thought process to read this succint
and clear explanation.
Sinan.
--
A. Sinan Unur
1usa@llenroc.ude.invalid
(remove '.invalid' and reverse each component for email address)
------------------------------
Date: Thu, 23 Dec 2004 11:02:18 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: How can script find its host's name/IP address?
Message-Id: <c_Byd.28711$GK5.1490008@news20.bellglobal.com>
"KKramsch" <karlUNDERSCOREkramsch@yahooPERIODcom.invalid> wrote in message
news:cqei5u$ds9$1@reader1.panix.com...
>
>>"kj" <socyl@987jk.com.invalid> wrote in message
>>news:cqdc0l$4dd$1@reader1.panix.com...
>>>
>>> How can script find the hostname (or at least the IP address) of
^^^^^^^^
^^^^^^^^^^^^
>>> the host it is running on?
>>>
>
> What makes you think there is an environment variable that has the
> domainname info? When I run a script on my Linux box that prints
> all of %ENV, not a single %ENV value shows the machine's domain
> name.
>
What does the domain name have to do with the question as he presented it?
print $ENV{SERVER_NAME};
or if you're on IIS using asp
$Request->ServerVariables("server_name")
Matt
------------------------------
Date: Thu, 23 Dec 2004 11:32:34 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: How can script find its host's name/IP address?
Message-Id: <17SdnUWKJ9i_blfcRVn-hw@comcast.com>
Matt Garrish wrote:
>
> "KKramsch" <karlUNDERSCOREkramsch@yahooPERIODcom.invalid> wrote in message
> news:cqei5u$ds9$1@reader1.panix.com...
>>
>>>"kj" <socyl@987jk.com.invalid> wrote in message
>>>news:cqdc0l$4dd$1@reader1.panix.com...
>>>>
>>>> How can script find the hostname (or at least the IP address) of
> ^^^^^^^^
> ^^^^^^^^^^^^
>>>> the host it is running on?
>>>>
>>
>> What makes you think there is an environment variable that has the
>> domainname info? When I run a script on my Linux box that prints
>> all of %ENV, not a single %ENV value shows the machine's domain
>> name.
>>
>
> What does the domain name have to do with the question as he presented it?
>
> print $ENV{SERVER_NAME};
>
> or if you're on IIS using asp
>
> $Request->ServerVariables("server_name")
>
The OP has not stated anywhere that this is a CGI script.
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Thu, 23 Dec 2004 18:08:55 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: How can script find its host's name/IP address?
Message-Id: <cqf1b4$jg$1@sun3.bham.ac.uk>
kj wrote:
> In <cqdc0l$4dd$1@reader1.panix.com> kj <socyl@987jk.com.invalid> writes:
>
>>How can script find the hostname (or at least the IP address) of
>>the host it is running on?
>
> Sorry, I shouldn't have written "hostname"; what I want is the full
> hostname+domainname combination, as in foo.bar.com (as opposed to
> just foo).
>
> Also, I should have mentioned that I looked at the Perl FAQ, but
> didn't get a satisfactory answer to my question. The Perl FAQ does
> include a question on how to get the "hostname/domainname/IP
> address", but it doesn't really answer the question of how to get
> the domainname. It only explains how to get the hostname and the
> IP address. It gives advice on how to get the name of the local
> DNS server, but says nothing on how that script would use this
> information to obtain the host's domainname.
The built-in function gethostbyaddr can be used to get from ip address
to FQDN provided everything is correctly configured and running.
This thread, of course, has little to do with Perl. This is more of an
OS issue.
Perhaps it would help if you could tell us what it is you are going to
do with this information and on what operating system.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V10 Issue 7561
***************************************