[17981] in Perl-Users-Digest
Perl-Users Digest, Issue: 141 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 25 11:36:33 2001
Date: Thu, 25 Jan 2001 08:10:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980439016-v10-i141@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 25 Jan 2001 Volume: 10 Number: 141
Today's topics:
right place for a mod_perl question? <dwb1@home.com>
Split string into two arrays scottpa@my-deja.com
String comparing? <wavetable@birdmail.com>
Re: String comparing? (Bernard El-Hagin)
Re: String comparing? <wavetable@birdmail.com>
Re: String comparing? (Bernard El-Hagin)
Re: String comparing? <wavetable@birdmail.com>
Re: String comparing? (Bernard El-Hagin)
Re: String comparing? <wavetable@birdmail.com>
Re: String comparing? <wavetable@birdmail.com>
Re: String comparing? <tore@extend.no>
Re: Time / Date Format <matt@sergeant.org>
unexplained warning ? <strawman@plexi.com>
Re: unexplained warning ? (Chris Fedde)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 25 Jan 2001 13:58:00 GMT
From: "Daniel W. Burke" <dwb1@home.com>
Subject: right place for a mod_perl question?
Message-Id: <Pine.LNX.4.20.0101250858170.17416-100000@ethyl.addictmud.org>
I'm not sure if this is the right place for a mod_perl type
question, so if not, please let me know where the beast place
would be :)
In case it is, I'll ask anyways :)
We're having trouble with some subs that take optional
parameters... Typically we've always done something like :
# blah blah...
&SomeFunc;
# blah blah...
sub Somefunc
{
my $var = shift;
if (defined($var)) {
# do something
}
}
What we're finding is, sometimes, (not always), when the script
is run in mod_perl, it's passing a value to the sub that's a
reference to a scalar in the Apache package. I ran some tests,
and the variable is set to "Apache=SCALAR(0x????????)"... I checked
a value of it, and it's a number that doesn't make sense to me...
The number is the same across all apache processes, but it tends
to change every time apache is restarted...
The kicker is, some functions it seems to happen 100% of the time...
others, it only happens when the sub is used in some places, but
not when it's used in others...
I did discover that a fix is to call the sub like this:
&SomeFunc(); # note the () added
But I'm hoping that's not the route we have to take... some of the
subs causing trouble are called 100's of times, spread across 250
files...
Any help would be wonderful :)
Dan.
------------------------------
Date: Thu, 25 Jan 2001 15:49:07 GMT
From: scottpa@my-deja.com
Subject: Split string into two arrays
Message-Id: <94phtg$i52$1@nnrp1.deja.com>
I wonder if anyone could check my code and see if it could be more
compact. I need to break the following string up into two arrays @parm
and @type and I wondered if there was a tidier way of doing it?
$_='charparm string dateparm datetime intparm number';
$parm=1;
foreach $item (@arguments)
{
if ($parm) {
$parm=0;
push (@parms, $item);
}
else {
$parm=1;
push (@type, $item);
}
}
OUTPUT:
Parm: charparm dateparm intparm
Type: string datetime number
Thanks for your time,
Alan
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 25 Jan 2001 15:59:33 +0200
From: "wavetable" <wavetable@birdmail.com>
Subject: String comparing?
Message-Id: <94pbc5$poi$1@news.kolumbus.fi>
Is it possible to compare two strings with functions like "contains",
"starts with", "ends with"? As I don't know how to compare a whole line read
from a file with a string (the line contains the line change character,
right?). Thanks for any help...
------------------------------
Date: Thu, 25 Jan 2001 14:08:28 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: String comparing?
Message-Id: <slrn970cqq.2q0.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 25 Jan 2001 15:59:33 +0200, wavetable <wavetable@birdmail.com>
wrote:
>Is it possible to compare two strings with functions like "contains",
>"starts with", "ends with"? As I don't know how to compare a whole line read
>from a file with a string (the line contains the line change character,
>right?). Thanks for any help...
I'm not sure if I understand your question, but you either want to use
regular expressions to compare two strings, in which case you should
read:
perldoc perlre
OR, you'd like to remove the "line change character", as you call it,
from each line in a file and then compare the stripped line with a
string, in which case you should read:
perldoc -f chomp
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Thu, 25 Jan 2001 16:20:19 +0200
From: "Bonehead" <wavetable@birdmail.com>
Subject: Re: String comparing?
Message-Id: <94pci8$qhe$1@news.kolumbus.fi>
Sorry I didn't mention that this would be in a cgi script.
I read all the lines from a file to an array and want to compare the line
with a string like "goo". So if I type "goo" in a line in the text file the
script checks if the line in the file contains the string "goo" ;) with the
if(boolean) function. Thanks..
"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> wrote in message
news:slrn970cqq.2q0.bernard.el-hagin@gdndev25.lido-tech...
> On Thu, 25 Jan 2001 15:59:33 +0200, wavetable <wavetable@birdmail.com>
> wrote:
> >Is it possible to compare two strings with functions like "contains",
> >"starts with", "ends with"? As I don't know how to compare a whole line
read
> >from a file with a string (the line contains the line change character,
> >right?). Thanks for any help...
>
> I'm not sure if I understand your question, but you either want to use
> regular expressions to compare two strings, in which case you should
> read:
>
> perldoc perlre
>
> OR, you'd like to remove the "line change character", as you call it,
> from each line in a file and then compare the stripped line with a
> string, in which case you should read:
>
> perldoc -f chomp
>
> Cheers,
> Bernard
> --
> #requires 5.6.0
> perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$
?] }'
------------------------------
Date: Thu, 25 Jan 2001 14:26:22 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: String comparing?
Message-Id: <slrn970dsb.2q0.bernard.el-hagin@gdndev25.lido-tech>
[Please don't put your reply ahead of what you're replying to]
On Thu, 25 Jan 2001 16:20:19 +0200, Bonehead <wavetable@birdmail.com>
wrote:
>"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> wrote in message
>news:slrn970cqq.2q0.bernard.el-hagin@gdndev25.lido-tech...
>> On Thu, 25 Jan 2001 15:59:33 +0200, wavetable <wavetable@birdmail.com>
>> wrote:
>> >Is it possible to compare two strings with functions like "contains",
>> >"starts with", "ends with"? As I don't know how to compare a whole line
>read
>> >from a file with a string (the line contains the line change character,
>> >right?). Thanks for any help...
>>
>> I'm not sure if I understand your question, but you either want to use
>> regular expressions to compare two strings, in which case you should
>> read:
>>
>> perldoc perlre
>>
>> OR, you'd like to remove the "line change character", as you call it,
>> from each line in a file and then compare the stripped line with a
>> string, in which case you should read:
>>
>> perldoc -f chomp
>
>Sorry I didn't mention that this would be in a cgi script.
What difference does that make?
>I read all the lines from a file to an array and want to compare the line
>with a string like "goo". So if I type "goo" in a line in the text file the
>script checks if the line in the file contains the string "goo" ;) with the
>if(boolean) function. Thanks..
And my reply doesn't help you because...?
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Thu, 25 Jan 2001 16:36:19 +0200
From: "Bonehead" <wavetable@birdmail.com>
Subject: Re: String comparing?
Message-Id: <94pdg8$qvj$1@news.kolumbus.fi>
----- Original Message -----
From: "Bernard El-Hagin" <bernard.el-hagin@lido-tech.net>
Newsgroups: comp.lang.perl.misc
Sent: Thursday, January 25, 2001 4:26 PM
Subject: Re: String comparing?
> What difference does that make?
>
I guess none... I know very little about perl. But what I meant was that I
don't know how to implement it in a script. Thanks..
------------------------------
Date: Thu, 25 Jan 2001 14:43:32 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: String comparing?
Message-Id: <slrn970esi.2q0.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 25 Jan 2001 16:36:19 +0200, Bonehead <wavetable@birdmail.com>
wrote:
>
>> What difference does that make?
>>
>
>I guess none... I know very little about perl. But what I meant was that I
>don't know how to implement it in a script. Thanks..
Since you found it necessary to e-mail me privately with the above, you
could have at least taken the advice I privately gave you, which is to
read the docs I pointed you to and try to come up with a script
yourself. Then, if it doesn't work the way you expect, post it here and I
GUARANTEE that someone will help you fix it. Just show some effort and
stop trying to get a free script out of this group. That's not what it's
here for.
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Thu, 25 Jan 2001 16:54:04 +0200
From: "Bonehead" <wavetable@birdmail.com>
Subject: Re: String comparing?
Message-Id: <94pehm$rgu$1@news.kolumbus.fi>
I mailed you by accident. You should notice that the mail you got was the
same as the one in the group
------------------------------
Date: Thu, 25 Jan 2001 16:56:18 +0200
From: "Bonehead" <wavetable@birdmail.com>
Subject: Re: String comparing?
Message-Id: <94pell$rjb$1@news.kolumbus.fi>
Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> wrote in message
news:slrn970esi.2q0.bernard.el-hagin@gdndev25.lido-tech...> On Thu, 25 Jan
2001 16:36:19 +0200, Bonehead <wavetable@birdmail.com>
> GUARANTEE that someone will help you fix it. Just show some effort and
> stop trying to get a free script out of this group. That's not what it's
> here for.
I'm not asking for a "free script" when I'm asking about how to compare two
strings.
------------------------------
Date: Thu, 25 Jan 2001 16:17:18 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: String comparing?
Message-Id: <MPG.14da61e54b7dd01989861@news.online.no>
In article <94pbc5$poi$1@news.kolumbus.fi>, wavetable@birdmail.com
says...
> Is it possible to compare two strings with functions like
> "contains", "starts with", "ends with"?
In Perl you don't need such things; You got regular expressions, whose
function is to do "something" with "something" based on a - right -
regular expression.
More information about regular expressions;
'perldoc perlre'
If you really want to use 'contains', 'starts with' etc., I suggest you
create functions to deal with such matter.
--
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/
------------------------------
Date: Thu, 25 Jan 2001 11:15:42 +0000
From: Matt Sergeant <matt@sergeant.org>
Subject: Re: Time / Date Format
Message-Id: <3A700ADE.8010106@sergeant.org>
PaAnWa wrote:
> I am trying to add a time/date stamp to form data run through a script and
> then written to a file. How do I capture the server t/d in the following
> format:
> YYYY/MM/DD HH:MM:SS
use Time::Object;
my $date = localtime;
print $date->strftime("%Y/%m/%d %H:%M:%S");
Matt.
------------------------------
Date: Thu, 25 Jan 2001 10:26:05 -0500
From: Edward D'Flea <strawman@plexi.com>
Subject: unexplained warning ?
Message-Id: <3A70458D.EB383D0B@plexi.com>
I have a short little script that works as expected, but gives me a
warning I can't figure out. First of all, I have:
$ perl -v
This is perl, version 5.005_03 built for i386-linux
...
Here's the problem lines:
1 #! /usr/local/bin/perl -w
...
29 foreach $module (@module_list)
30 {
31 print "Processing: $module\n";
32
33 if(open (MODULE_MAKEFILE, "./$module/Makefile")) {
34
35 while (chop($line = <MODULE_MAKEFILE>)) {
36
37 if (($line =~ /USES =/) || ($line =~ /REQUIRES =/))
{
...
This gives me the warnings:
Processing: dir1
Use of uninitialized value at ./depend3b.pl line 35, <MODULE_MAKEFILE>
chunk 13.
Processing: dir2
Use of uninitialized value at ./depend3b.pl line 35, <MODULE_MAKEFILE>
chunk 13.
Processing: dir3
Use of uninitialized value at ./depend3b.pl line 35, <MODULE_MAKEFILE>
chunk 13.
Processing: dir6
Use of uninitialized value at ./depend3b.pl line 35, <MODULE_MAKEFILE>
chunk 13.
The script processes the correct directories and gives me the results I
want. I just need to understand the warning.
Can anybody out there answer this one. Forgive me if this is a
fundamental question.
------------------------------
Date: Thu, 25 Jan 2001 16:03:45 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: unexplained warning ?
Message-Id: <B7Yb6.1302$B9.194320384@news.frii.net>
In article <3A70458D.EB383D0B@plexi.com>,
Edward D'Flea <strawman@plexi.com> wrote:
>I have a short little script that works as expected, but gives me a
>warning I can't figure out. First of all, I have:
>$ perl -v
>
>Processing: dir1
>Use of uninitialized value at ./depend3b.pl line 35, <MODULE_MAKEFILE>
>chunk 13.
>
I suspect that <MODULE_MAKEFILE> is returning eof which cannot be chopped.
You might want to do the chop outside the while condition.
Also, consider using chomp rather than chop.
ymmv
chris
--
This space intentionally left blank
------------------------------
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 V10 Issue 141
**************************************