[16207] in Perl-Users-Digest
Perl-Users Digest, Issue: 3619 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 11 11:05:51 2000
Date: Tue, 11 Jul 2000 08:05:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963327917-v9-i3619@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 11 Jul 2000 Volume: 9 Number: 3619
Today's topics:
-w and Use of uninitialized value at <mike.solomon@eps.ltd.uk>
Re: -w and Use of uninitialized value at <uackermann@orga.com>
Re: -w and Use of uninitialized value at <mike.solomon@eps.ltd.uk>
Re: -w and Use of uninitialized value at <uackermann@orga.com>
Re: -w and Use of uninitialized value at <aqumsieh@hyperchip.com>
Re: -w and Use of uninitialized value at <stephen.kloder@gtri.gatech.edu>
Re: -w and Use of uninitialized value at <tony_curtis32@yahoo.com>
Re: <newbie> (11 .. 21) for arrays. (Keith Calvert Ivey)
Re: array, hashes = headaches (Keith Calvert Ivey)
Re: array, hashes = headaches <bart.lateur@skynet.be>
Re: Comparing two strings (golf, anyone?) (Keith Calvert Ivey)
Re: Comparing two strings (golf, anyone?) <uri@sysarch.com>
Re: Comparing two strings (golf, anyone?) (Keith Calvert Ivey)
Re: Comparing two strings (golf, anyone?) (Damian Conway)
Re: Comparing two strings (golf, anyone?) <bart.lateur@skynet.be>
Construct html page from text file. <kenhlee@tm.net.my>
Re: Construct html page from text file. <flavell@mail.cern.ch>
Re: Convert integers to strings <bart.lateur@skynet.be>
Re: Convert integers to strings <iltzu@sci.invalid>
Re: Cookie & redirect <care227@attglobal.net>
Driving Rexec (like Expect) <simon.brown@kns.ch>
Re: Driving Rexec (like Expect) <prakash@gate.net>
Re: Faster way to do it... (M.J.T. Guy)
Re: Getting a unique machine ID on win32? <care227@attglobal.net>
Re: Hash vs. Array memory usage (Anno Siegel)
Re: How to display the correct time from a time server <abcd@abcd.a>
is process running? <zfido88@zr.ru>
Re: is process running? (Rafael Garcia-Suarez)
Looking for free script <sneddonb@whiteoaksemi.com>
Re: map question <stephen.kloder@gtri.gatech.edu>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 11 Jul 2000 14:54:33 +0100
From: "mike solomon" <mike.solomon@eps.ltd.uk>
Subject: -w and Use of uninitialized value at
Message-Id: <8kf90o$2c94v$1@ID-36965.news.cis.dfn.de>
Since looking at this newsgroup I have decided to start experimenting with
using the -w flag in my scripts
the following script is called from the Unix command line and gives
information about a user or several users
it can either be called as : name userid or just as name then it requests a
user id
if I run it without an argument I get :
Use of uninitialized value at /usr/local/sscript/name line 10.
the question i have is how can i stop this message
and is there any reason i shoulnt use unintialised values
i have looked at the faq and found no help there
anyway the script is :
#! /usr/local/bin/perl -w
#name
#Mon Jun 26 13:01:01 BST 2000 itdmjs
#show user name
use strict;
my $NAME = $ARGV[0];
while ( ${NAME} eq "" ) {
print "\nENTER NAME TO FIND : \n";
$NAME = <STDIN>;
chomp($NAME);
}
#set name to lowercase
$NAME = lc($NAME);
#open password file for reading
open(PASSWD,'/etc/passwd');
while(<PASSWD>) {
my ( $USERID, $UNAME ) = (split(/:/))[0, 4];
$_ = lc($_);
if ( $_ =~ /$NAME/ ) {
print "$USERID $UNAME\n";
}
}
__END__
------------------------------
Date: Tue, 11 Jul 2000 16:14:41 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: -w and Use of uninitialized value at
Message-Id: <396B2BD1.8AFD7545@orga.com>
mike solomon wrote:
>
> my $NAME = $ARGV[0];
>
my $NAME;
$ARGV[0] ? $NAME = $ARGV[0] : $NAME = "";
should work.
Ulrich
--
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925
mailto:uackermann@orga.com
------------------------------
Date: Tue, 11 Jul 2000 15:21:52 +0100
From: "mike solomon" <mike.solomon@eps.ltd.uk>
Subject: Re: -w and Use of uninitialized value at
Message-Id: <8kfake$2bsa0$1@ID-36965.news.cis.dfn.de>
this certainly gets rid of the message
unfortunately it also stops the script working with a command line argument
Ulrich Ackermann <uackermann@orga.com> wrote in message
news:396B2BD1.8AFD7545@orga.com...
> mike solomon wrote:
> >
> > my $NAME = $ARGV[0];
> >
>
> my $NAME;
> $ARGV[0] ? $NAME = $ARGV[0] : $NAME = "";
>
> should work.
>
> Ulrich
> --
> Ulrich Ackermann
> ORGA Kartensysteme GmbH (SY-PEAT-STA)
> Tel.:+49.5254.991-925
> mailto:uackermann@orga.com
>
------------------------------
Date: Tue, 11 Jul 2000 16:39:04 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: -w and Use of uninitialized value at
Message-Id: <396B3188.EEEA028F@orga.com>
mike solomon wrote:
>
> this certainly gets rid of the message
>
> unfortunately it also stops the script working with a command line argument
>
> >
> > my $NAME;
> > $ARGV[0] ? $NAME = $ARGV[0] : $NAME = "";
> >
> > should work.
> >
I'm sorry. What definitly is working is:
my $NAME;
if (defined $ARGV[0]) {
$NAME = $ARGV[0];
}
else {
$NAME = "";
}
But please don't ask me why the ?: operator isn't doing what I thought
he should do ... ;-)
Ulrich
--
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925
mailto:uackermann@orga.com
------------------------------
Date: Tue, 11 Jul 2000 14:43:00 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: -w and Use of uninitialized value at
Message-Id: <7awvisk9s9.fsf@merlin.hyperchip.com>
"mike solomon" <mike.solomon@eps.ltd.uk> writes:
> Since looking at this newsgroup I have decided to start experimenting with
> using the -w flag in my scripts
Good. The next step for you would be to start using the strict
pragma. Read more on it 'perldoc strict'.
> the following script is called from the Unix command line and gives
> information about a user or several users
>
> it can either be called as : name userid or just as name then it requests a
> user id
>
> if I run it without an argument I get :
>
> Use of uninitialized value at /usr/local/sscript/name line 10.
>
> the question i have is how can i stop this message
let's see.
> and is there any reason i shoulnt use unintialised values
Not if you know exactly what you're doing.
> i have looked at the faq and found no help there
>
> anyway the script is :
>
> #! /usr/local/bin/perl -w
> #name
> #Mon Jun 26 13:01:01 BST 2000 itdmjs
> #show user name
>
> use strict;
>
> my $NAME = $ARGV[0];
If you supply no arguments in the command line, @ARGV will be empty. So
$ARGV[0] will be undefined. Why not set $NAME to the empty string if
@ARGV is empty?
my $NAME = $ARGV[0] || '';
or, equivalently,
my $NAME = shift || '';
> while ( ${NAME} eq "" ) {
>
> print "\nENTER NAME TO FIND : \n";
>
> $NAME = <STDIN>;
> chomp($NAME);
You can do the above two steps in one:
chomp($NAME = <>);
> }
>
> #set name to lowercase
> $NAME = lc($NAME);
>
> #open password file for reading
> open(PASSWD,'/etc/passwd');
check for your opens:
open PASSWD, '/etc/passwd' or
die "Can't open /etc/passwd: $!\n";
> while(<PASSWD>) {
>
> my ( $USERID, $UNAME ) = (split(/:/))[0, 4];
>
> $_ = lc($_);
>
> if ( $_ =~ /$NAME/ ) {
> print "$USERID $UNAME\n";
> }
> }
> __END__
Why do you capitalize your variable names? By convention, all capital
variables refer to constants.
HTH,
--Ala
------------------------------
Date: Tue, 11 Jul 2000 10:40:58 -0400
From: Stephen Kloder <stephen.kloder@gtri.gatech.edu>
Subject: Re: -w and Use of uninitialized value at
Message-Id: <396B31FA.5A519502@gtri.gatech.edu>
mike solomon wrote:
> this certainly gets rid of the message
>
> unfortunately it also stops the script working with a command line argument
>
> Ulrich Ackermann <uackermann@orga.com> wrote in message
> > my $NAME;
> > $ARGV[0] ? $NAME = $ARGV[0] : $NAME = "";
> >
> > should work.
Try:
my $NAME = $ARGV[0]?$ARGV[0]:'';
Or even (save a few keystrokes):
my $NAME = @ARGV?$ARGV[0]:'';
------------------------------
Date: 11 Jul 2000 10:01:37 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: -w and Use of uninitialized value at
Message-Id: <871z10btim.fsf@limey.hpcc.uh.edu>
>> On Tue, 11 Jul 2000 14:54:33 +0100,
>> "mike solomon" <mike.solomon@eps.ltd.uk> said:
> Since looking at this newsgroup I have decided to start
> experimenting with using the -w flag in my scripts
<monty burns>excellent...</monty burns>
> if I run it without an argument I get :
> Use of uninitialized value at /usr/local/sscript/name
> line 10.
v.i.
> and is there any reason i shoulnt use unintialised
> values
Yes. If a value is uninitialised and you try to use it,
undefined (= bad) things will happen.
> my $NAME = $ARGV[0];
> while ( ${NAME} eq "" ) {
$ARGV[0] will only have a defined value if there was
something on the command line. With no args, there will
be no values in @ARGV, and thus $NAME will be undefined.
(It's "nicer" to use lowercase for variable names; UPPER
for constants and filehandles.)
my $name = shift;
if (! defined $name) {
# get it from user
}
or
my $name;
if (@ARGV) {
$name = $ARGV[0];
} else {
# get it from user
}
There are other ways too, which no doubt others will
offer...
> #open password file for reading
> open(PASSWD,'/etc/passwd');
What happens if the open() fails?
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: Tue, 11 Jul 2000 13:21:05 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: <newbie> (11 .. 21) for arrays.
Message-Id: <396f1ece.47687568@nntp.idsonline.com>
rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote:
>Correction:
> @tabledata=split(/\s*\|\s*/, $_);
Or just
@tabledata = split /\s*\|\s*/;
Including $_ works, of course, but it defeats the whole purpose
of having a default variable.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Tue, 11 Jul 2000 13:27:58 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: array, hashes = headaches
Message-Id: <39701f9b.47892698@nntp.idsonline.com>
"moishe" <moishe@mitechnyc.com> wrote:
>while ( <DATA> ) {
> if ( /UID:\s+(.+)/ {
> $uid=$1;
> }
> if ( /Address:\s+(.+)/ ) {
> $users{$uid}{$address} = $1;
> }
> if ( /Phone:\s+(.+)/ ) {
> $users{$uid}{$phone} = $1;
> }
>}
You haven't defined $address and $phone, as Perl would have told
you if you'd been using -w and strict as you should be. You
probably want to use literal strings, not variables, there, like
this:
$users{$uid}{Address} = $1;
Or do this:
my(%users, $uid);
while (<DATA>) {
chomp;
my($label, $value) = split /:\s*/, $_, 2;
if ($label eq 'UID') { $uid = $value }
else { $users{$uid}{$label} = $value }
}
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Tue, 11 Jul 2000 15:51:03 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: array, hashes = headaches
Message-Id: <7q8mmscljn67tudg0qtfk4n4rqts6h4uc5@4ax.com>
moishe wrote:
>The file looks like:
>
>UID: 123
>Name: moishe
>Address: 23 Camle Lane
>Phone: 555-2222
>UID: 99999
>Name: someone else
>Address: somewhere
>Phone: 111-3334
>
>I did something like:
>
>while ( <DATA> ) {
> if ( /UID:\s+(.+)/ {
> $uid=$1;
> }
> if ( /Address:\s+(.+)/ ) {
> $users{$uid}{$address} = $1;
Oops. You want the string "Address", not the variable $address -- which
probably isn't set. Are you running using -w?
> }
> if ( /Phone:\s+(.+)/ ) {
> $users{$uid}{$phone} = $1;
Same thing. "Phone", not "$phone".
> }
>}
And you forgot the "UID:" part in your printout.
--
Bart.
------------------------------
Date: Tue, 11 Jul 2000 13:16:51 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Comparing two strings (golf, anyone?)
Message-Id: <396e1c6d.47078329@nntp.idsonline.com>
fosterd@hartwick.edu (Decklin Foster) wrote:
>Hmm, actually this is shorter and doesn't need scalar context:
>
>sub compare{($a=$_[0]^$_[1])=~tr/\0//}
What kind of golfer are you, using tr?
sub compare{($a=$_[0]^$_[1])=~y/\0//}
And it can be still shorter with $a in place of $_:
sub compare{$_=$_[0]^$_[1];y/\0//}
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Tue, 11 Jul 2000 13:30:11 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Comparing two strings (golf, anyone?)
Message-Id: <x73dlgn6ak.fsf@home.sysarch.com>
>>>>> "KCI" == Keith Calvert Ivey <kcivey@cpcug.org> writes:
KCI> fosterd@hartwick.edu (Decklin Foster) wrote:
>> Hmm, actually this is shorter and doesn't need scalar context:
>>
>> sub compare{($a=$_[0]^$_[1])=~tr/\0//}
KCI> What kind of golfer are you, using tr?
KCI> sub compare{($a=$_[0]^$_[1])=~y/\0//}
KCI> And it can be still shorter with $a in place of $_:
KCI> sub compare{$_=$_[0]^$_[1];y/\0//}
heh, you are just a hacker (in the pejorative real golf sense :)
sub compare{$_=pop^pop;y/\0//}
or
sub compare{(pop^pop)=~y/\0//}
play in the Perl Golf Apocalypse, coming to the tpc4 near you!
rules and registration are at http://www.sysarch.com/perl/golf/
grand poobah of the PGA,
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 11 Jul 2000 14:05:13 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Comparing two strings (golf, anyone?)
Message-Id: <39712924.50334298@nntp.idsonline.com>
Uri Guttman <uri@sysarch.com> wrote:
> sub compare{(pop^pop)=~y/\0//}
Is that a 5.6 thing? I get "Can't modify bitwise xor in
character translation...."
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: 11 Jul 2000 14:05:36 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Comparing two strings (golf, anyone?)
Message-Id: <8kf9jg$bk8$1@towncrier.cc.monash.edu.au>
"Lauren Smith" <lauren_smith13@hotmail.com> writes:
>But can it be done *in constant time*? Ho ho. :-)
Yep:
sub compare {
my $len = any(0..length $_[0]);
my $common = substr($_[0],0,$len) eq substr($_[1],0,$len);
return any(eigenstates length $common) >= all(eigenstates length $common);
}
Damian
------------------------------
Date: Tue, 11 Jul 2000 16:42:23 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Comparing two strings (golf, anyone?)
Message-Id: <q8cmms4ohmj1va4vk14mekp3uqct3gnb9g@4ax.com>
Keith Calvert Ivey wrote:
>Uri Guttman <uri@sysarch.com> wrote:
>
>> sub compare{(pop^pop)=~y/\0//}
>
>Is that a 5.6 thing? I get "Can't modify bitwise xor in
>character translation...."
Good question.
There were times, when applying y/// or tr/// to a string that couldn't
be modified, made Perl complain about it, even, as in this case, it only
served to count characters.
I'm not sure when, or if, it got fixed.
Testing it on my Perl (DynamicState 5.6 of May 6 2000) shows it still IS
NOT fixed.
--
Bart.
------------------------------
Date: Tue, 11 Jul 2000 18:59:40 +0800
From: "Ken H. Lee" <kenhlee@tm.net.my>
Subject: Construct html page from text file.
Message-Id: <396afda0.0@news.tm.net.my>
Hi,
I am tring to read from a text file and print the html page. The code is
something like this:
print "HTTP 1.0 200 OK/n";
print "pragma: no-cache\n";
print "Content-type: text/html\n";
print "\n";
$file = "nlplus.tpl";
open (IDFILE, $file);
print "<html>\n";
print "<body>\n";
print "<h1>test1 </h1>\n";
while (<IDFILE>)
{
$rec = $_;
print $rec;
}
print "<h1>test1 </h1>\n";
print "</body>";
print "</html>";
close (IDFILE);
I can see the "test" line on my browser but not the contain inside the
"while" loop.
When I try in DOS prompt : perl nlplus.pl, the correct html page can come
out.
I am running NT 4.0 with IIS 3.0.
Any idea what is the problem ?
Thanks.
Ken
------------------------------
Date: Tue, 11 Jul 2000 13:12:15 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Construct html page from text file.
Message-Id: <Pine.GHP.4.21.0007111309160.15622-100000@hpplus03.cern.ch>
On Tue, 11 Jul 2000, Ken H. Lee wrote:
> print "HTTP 1.0 200 OK/n";
> print "pragma: no-cache\n";
> print "Content-type: text/html\n";
> print "\n";
You could beneficially learn about here-documents.
> $file = "nlplus.tpl";
> open (IDFILE, $file);
You haven't been paying attention. You failed to test the result of
the open. You failed to heed the repeated warnings about the current
directory setting.
The time that you're wasting isn't only your own.
------------------------------
Date: Tue, 11 Jul 2000 15:28:40 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Convert integers to strings
Message-Id: <918mmso80e92a7pvns06e7le8ooorqkk4f@4ax.com>
Gwyn Judd wrote:
>>..Is there something
>>.. like IntToStr() or Str()?
>>
>>
>>No, but you can easily make then yourself.
>>
>> sub IntToStr {shift}
>>
>> sub StrToInt {$_ [0]}
>
>You have these around the wrong way.
Kidding aside, you may be right. Since bitwise logical operators
distinguish between numeric arguments, and strings, a more generally
useful definition would be:
sub IntToStr { "$_[0]" }
--
Bart.
------------------------------
Date: 11 Jul 2000 13:46:51 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Convert integers to strings
Message-Id: <963323049.29568@itz.pp.sci.fi>
In article <918mmso80e92a7pvns06e7le8ooorqkk4f@4ax.com>, Bart Lateur wrote:
>Kidding aside, you may be right. Since bitwise logical operators
>distinguish between numeric arguments, and strings, a more generally
>useful definition would be:
>
> sub IntToStr { "$_[0]" }
..and conversely:
sub StrToInt { $_[0]+0 }
Except of course neither one is restricted to integers, so s/Int/Num/g
might make the names more appropriate. Does anyone really care?
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method." -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Tue, 11 Jul 2000 09:25:32 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Cookie & redirect
Message-Id: <396B204C.BE41AE0@attglobal.net>
Chello wrote:
>
> $cookie=$q->cookie(-name=>'mysite.com',-value=>$cook_value,-expires=>'+1y');
> print $q->redirect(-cookie=>$cookie,-URL=>$url);
>
You can't set a cookie when using the redirect() way of printing a
header. I don't see it cited in the online documentation, but in the
text documentation (The Official Guide to Programming with CGI.pm)
it clearly states that the cookie will be ignored. In my experience
this has held true.
------------------------------
Date: Tue, 11 Jul 2000 12:05:15 +0200
From: "Simon Brown" <simon.brown@kns.ch>
Subject: Driving Rexec (like Expect)
Message-Id: <8kergs$27hc8$1@ID-6220.news.cis.dfn.de>
Hi All,
I need to drive rexec from Windows NT Perl, rexec requires input from me
(password).
I am sure there is a Perl module that supports this - a bit like Expect on
Unix, but what is this module???
All replies received with thanks, please copy to me directly as well.
--
Simon Brown, 7031 Laax, Switzerland
------------------------------
Date: 11 Jul 2000 12:55:08 GMT
From: Prakash Kailasa <prakash@gate.net>
Subject: Re: Driving Rexec (like Expect)
Message-Id: <8kf5fc$1viq$1@news.gate.net>
The name of the module is "Expect" (surprise).
Get it from <http://search.cpan.org/search?dist=Expect.pm>
You will also need the IO::Stty and IO::Tty modules, which should
be available on the same site or any other CPAN site.
However, I am not sure if they work on Windows NT.
/prakash
Simon Brown <simon.brown@kns.ch> wrote:
: Hi All,
: I need to drive rexec from Windows NT Perl, rexec requires input from me
: (password).
: I am sure there is a Perl module that supports this - a bit like Expect on
: Unix, but what is this module???
: All replies received with thanks, please copy to me directly as well.
: --
: Simon Brown, 7031 Laax, Switzerland
------------------------------
Date: 11 Jul 2000 12:28:13 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Faster way to do it...
Message-Id: <8kf3st$avh$1@pegasus.csx.cam.ac.uk>
Tad McClellan <tadmc@metronet.com> wrote:
>sept00@my-deja.com <sept00@my-deja.com> wrote:
>
>>When trying to replace strings in a text file for later output, I need
>>to read in a file, transfer it into a string and let the regular
>>expressions run over it, right? But now I'm stumped
>
>You are computing the same regex everytime through the loop.
>
>This is going to be pretty darn slow.
>
>Use qr// or the m//o option, if possible for a big speedup.
We don't know what the OP's real code looks like, but the example as
posted only contained constant regexes such as 'BLAH1'. So in this
case /o would make no difference.
Mike Guy
------------------------------
Date: Tue, 11 Jul 2000 09:34:46 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Getting a unique machine ID on win32?
Message-Id: <396B2276.4DF65B53@attglobal.net>
TM wrote:
>
> Seriously now
>
I _am_ serious. There is no way that anyone thought of to
programatically extract the bits of information that you requested.
------------------------------
Date: 11 Jul 2000 10:21:05 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Hash vs. Array memory usage
Message-Id: <8keseh$28n$1@lublin.zrz.tu-berlin.de>
Michael Carman <mjcarman@home.com> wrote in comp.lang.perl.misc:
>If you're truly concerned about using too much memory, look into using a
>tied hash. Essentially this is a database file allowing the use of disk
Not quite. This is what the DB_* modules do, but in general a hash
can be tied to any class at all if it (the class) provides the appropriate
set of methods.
Anno
------------------------------
Date: Tue, 11 Jul 2000 14:08:19 +0200
From: "Lou" <abcd@abcd.a>
Subject: Re: How to display the correct time from a time server on a page?
Message-Id: <8kf2qd$1kp$2@sunce.iskon.hr>
"Abigail" <abigail@delanet.com> wrote in message
news:slrn8mktpk.7v7.abigail@alexandra.delanet.com...
>
> #!/opt/perl/bin/perl -wT
> use strict;
> print <<__END__
> Content-type: text/plain
>
> Please look at your watch.
> __END__
>
>
> HTH. HAND.
I have been reading yours st*pid answers, and there are more people here
like you, your a hacker ha?
If you haven't got an answer to someone question don't reply it.
You're just vain little girl in the world. You don't know anything about
perl, you just now how to **** people.
That's you're job is suppose, that's only thing that you now. Nice culture
you have. I hope you're pround of yourself, that's somethin you should be
proud of, there isn't many people that knows this like you do.
You're the best, do you know what for are computers? Oh I'am silly how could
you know something like that, let me try like this: do you know what for is
that box that you have somewhere on a tree, or somewhere where you live.
------------------------------
Date: Tue, 11 Jul 2000 17:39:19 +0400
From: "Roman Chumakov" <zfido88@zr.ru>
Subject: is process running?
Message-Id: <8kf848$q2h$1@news.sovam.com>
How can I know is a process with pid $pid running?
thanks,
Roman
------------------------------
Date: Tue, 11 Jul 2000 13:48:03 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: is process running?
Message-Id: <slrn8mm9l9.nr5.rgarciasuarez@rafael.kazibao.net>
Roman Chumakov wrote in comp.lang.perl.misc:
>How can I know is a process with pid $pid running?
use 'kill 0':
if (kill 0, $pid) {
print "process $pid is running\n";
}
(cf. the perlipc manpage).
--
Rafael Garcia-Suarez
------------------------------
Date: Tue, 11 Jul 2000 10:59:03 -0400
From: Bill Sneddon <sneddonb@whiteoaksemi.com>
Subject: Looking for free script
Message-Id: <396B3637.F47DE81B@whiteoaksemi.com>
Okay I might get flamed but... I have done some looking with no luck.
I was looking for a perl program that strips out the PostScript
formating chars and
created a nice looking document. Any suggestion on where I might
look? It seems like something that would have been done before.
sneddonb@whiteoaksemi.com
------------------------------
Date: Tue, 11 Jul 2000 08:36:53 -0400
From: Stephen Kloder <stephen.kloder@gtri.gatech.edu>
Subject: Re: map question
Message-Id: <396B14E4.8C706EA@gtri.gatech.edu>
Apparently you did not read the original post too thoroughly.
John Harden Borwick wrote:
> In article <396476A6.5F14D445@gtri.gatech.edu>,
> Stephen Kloder <stephen.kloder@gtri.gatech.edu> wrote:
> >The problem is that in both examples, you modify the elements in the
> >array via tr///, and then store the return value (# of characters
> >changed, not the resulting string) back into the same array, thus
> >destroying the data. You have 2 options:
> >1) Don't bother with a return value:
> > map {tr/a/b/} @ary;
>
> Map in a void context isn't a good idea. Foreach was written for this sort
> of thing:
>
> tr/a/b/ foreach @ary;
In the original post:
::How can I use map to achieve the following?
::for (@ary) { tr/a/b/; }
He was aware of for and foreach, bet wanted to use map.
> >2) Store the return value elsewhere (in case you have a use for it):
> > @returnvals = map {tr/a/b/} @ary;
>
> From my understanding of the question, this "option" isn't very helpful
> to the poster.
>
His problem was not that he was getting return values, but that they were
destroying the original values. Storing the return values elsewhere avoids the
void context you complained about above, and keeps the transliterated strings.
> What about
>
> @newvals = map { my $new_value = $_; $new_value =~ tr/a/b/; $new_value } @ary;
>
> Which seems to be what the poster had in mind? This solution preserves
> @ary and puts the appropriate transliterated values in the new array.
>
Again, check the original post:
::I can't figure out how to actually modify *and*
::return the elements of @ary.
Sounds like keeping the original values was not requested.
------------------------------
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 3619
**************************************