[19924] in Perl-Users-Digest
Perl-Users Digest, Issue: 2119 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 12 21:05:48 2001
Date: Mon, 12 Nov 2001 18:05:07 -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: <1005617107-v10-i2119@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 12 Nov 2001 Volume: 10 Number: 2119
Today's topics:
Re: Can I make one perl cgi script work both in linux a (Clinton A. Pierce)
Re: creating Win32 share in Windows 2000 (Clinton A. Pierce)
Re: error message <gopher@fheer.com>
Re: error message <gopher@fheer.com>
Re: file copy problems <jurgenex@hotmail.com>
Hash Problem (SQLBoy)
Re: Hash Problem <ronh@iainc.com>
Re: Hash Problem <mgjv@tradingpost.com.au>
Re: History Event <jeff@vpservices.com>
Re: How do I search for values in an array and change t (John J. Trammell)
Re: How do I search for values in an array and change t <mgjv@tradingpost.com.au>
Re: How do I search for values in an array and change t <gamu829@yahoo.com>
Re: Perl 6 <comdog@panix.com>
Re: Problem with perl pattern matching <godzilla@stomp.stomp.tokyo>
Re: RegEx ack references ... I need a clue (Chas Friedman)
Re: RegEx problem -- trying to match To: or From: at be <s_grazzini@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 12 Nov 2001 23:33:55 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Can I make one perl cgi script work both in linux and in windows?
Message-Id: <D%YH7.13711$RI2.7580488@news2>
[Posted and mailed]
In article <9spb5o$rdj$1@news01.cit.cornell.edu>,
"Shi Jin" <sj88@cornell.edu> writes:
> in linux , the first line should be
> #!/usr/bin/perl
> But in windows, it should be
> #!E:\cygwin\bin\perl.exe
> How can I make it work in both systems?
> Thanks a lot.
This is probably the wrong group for this question.
Depends less on mixing OS's than webservers. What I usually do is
either:
1. Create a similar path on both OS's:
c:/usr/bin/perl.exe
/usr/bin/perl.exe
And the #! line #!/usr/bin/perl.exe will do the right
thing for both (single drive systems).
2. Use extensions on one OS (.pl means /usr/bin/perl.exe
in Win32) and let the "natural" thing happen in the other
OS (Unix/Apache)
#2 is the preferred way. ActiveState Perl/IIS and Unix/Apache's default
configurations lean towards this.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Mon, 12 Nov 2001 23:35:30 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: creating Win32 share in Windows 2000
Message-Id: <61ZH7.13712$RI2.7583183@news2>
[Posted and mailed]
In article <3a2d73ac.0111120555.7574e842@posting.google.com>,
jmenke@scsnet.csc.com (John Menke) writes:
> I am trying to use the Win32::NetResource package, but even the
> example script is giving me an error:
What's the error?
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Tue, 13 Nov 2001 00:25:40 GMT
From: Alfred Heer <gopher@fheer.com>
Subject: Re: error message
Message-Id: <3BF0689B.BA1959DB@fheer.com>
Bart Lateur wrote:
>
> Alfred Heer wrote:
>
> >When I use the following script, I always get an error message:
> >"Use of uninitialized value in pattern match (m//) at ... line 9"
> >(line 9 = the line with "while( $_ = $ARGV[0], /^-/ ){ ")
>
> You should only do the second part of the test (the regex) if the first
> part succeeds:
>
> while(@ARGV and $_ = $ARGV[0], /^-/) { ... }
>
> or
>
> while(defined($_ = $ARGV[0]) and /^-/) { ... }
>
> --
> Bart.
*******************
Bart, you are great, thank you.
That did it.
Now somebody should change the official perlop manual accordingly...
Fred
------------------------------
Date: Tue, 13 Nov 2001 00:31:33 GMT
From: Alfred Heer <gopher@fheer.com>
Subject: Re: error message
Message-Id: <3BF06A01.4B51D3A0@fheer.com>
Tad McClellan wrote:
>
> Alfred Heer <gopher@fheer.com> wrote:
>
> >When I use the following script, I always get an error message:
> >"Use of uninitialized value in pattern match (m//) at ... line 9"
> >(line 9 = the line with "while( $_ = $ARGV[0], /^-/ ){ ")
>
> >while( $_ = $ARGV[0], /^-/ ){
> > shift;
>
> while( $_ = shift ){
> last unless /^-/;
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
****************************
Tad, thank you, that solved the problem.
(I also corrected the code in my copy of the perlop manual ...)
Fred Heer
------------------------------
Date: Mon, 12 Nov 2001 17:16:14 -0800
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: file copy problems
Message-Id: <3bf074d8$2@news.microsoft.com>
"maddman" <maddman_75@yahoo.com> wrote in message
news:bea807ca.0111080744.496c29d7@posting.google.com...
> I have a script that needs to copy a file from the hard drive to a
> network drive. I'm fairly new to perl, so excuse me if this is a
> simple mistake. Here is the relevent code
>
> # Copy file to the share
>
> $source = qq(C:\\mydir\\) . $name;
> $dest = qq(K:\\newfile);
May I suggest to use regular slashes to separate the directories in the
path?
"C:/newfile" is easier to read and there is no danger of forgetting to
escape the backslashes or to accidently re-evaluate a string and suddenly
end up with a filename "k:<NEWLINE>ewfile"
> use File::Copy;
> copy($source, $dest);
>
> There is no error, but the file is not copied to the K:\ drive.
How do you know? You are not checking for any error condition.
jue
------------------------------
Date: 12 Nov 2001 16:54:57 -0800
From: sqlboy@playway.net (SQLBoy)
Subject: Hash Problem
Message-Id: <cd3f3068.0111121654.3d9c38bd@posting.google.com>
Hi, I've been trying to fix this for awhile and I'm not sure what is
causing it.
I'm using perl version 5.005_03.
I'm coding a perl module to allow easy remote admin to PunkBuster
server for Half-Life. The module telnet's into the server and gets a
list of players that looks like this:
7725 "ShortyMac420" 65.92.249.97:27005,154991,4209 0:04:46 [0]
Disconnected 216.25.206.67:27015
7735 "LEO" 66.65.76.50:27005,35005,4216 0:05:12 [2] Disconnected
216.25.206.67:27015
I parse the list using some quick regex and I tried to build hash of
hash references using this code
sub getPlayers
{
my ($self) = @_;
my (@output);
my (%player);
my (%players);
my $line;
my $cn = $self->{"pbconn"};
$cn->print("plist");
$cn->waitfor('/REMOTE/');
($_) = $cn->waitfor('/Next ID/');
s/\s$//mg;
@output= split (/[\r\n]+/,$_);
foreach $line (@output)
{
if($line =~
/^(\d+)\s\"(.*)\"\s([\d\.:]+),(\d+).+(\d:).+Authenticated\s([\d\.]+):(\d+)$/x)
{
my $pbid = $1;
my $name = $2;
my $cip = $3;
my $wonid = $4;
my $time = $5;
my $srvip = $6;
my $srvport = $7;
$players { $wonid } = {
"PBId"=>$pbid,
"Name"=>$name,
"WonId"=>$wonid,
"CIp"=>$cip,
"Time"=>$time,
"ServerIp"=>$srvip,
"ServerPort"=>$srvport
};
}
}
return %players;
}
Problem is, when I derefernce, I get strange results. Every other
entry in the hash is not a reference.
%pbp = $pbshots->getPlayers();
foreach $players (%pbp)
{
print $players . "\n";
}
Exampe output:
45521
HASH(0x823bfd8)
963439
HASH(0x823bf00)
20674
HASH(0x822ead0)
35290
HASH(0x823c1f4)
1403219
HASH(0x823c11c)
Can someone tell me what I'm doign wrong? I can fix it by modifying
the foreach loop to only output HASH references but I've never had to
do that and I'm using basically the same code in other modules.
Thanks.
Matt
------------------------------
Date: Tue, 13 Nov 2001 01:04:25 GMT
From: "Ron Hartikka" <ronh@iainc.com>
Subject: Re: Hash Problem
Message-Id: <tk_H7.19859$4W.211189@typhoon.mw.mediaone.net>
foreach $players (keys %pbp)
{
print $players . "\n";
}
"SQLBoy" <sqlboy@playway.net> wrote in message
news:cd3f3068.0111121654.3d9c38bd@posting.google.com...
> Hi, I've been trying to fix this for awhile and I'm not sure what is
> causing it.
> I'm using perl version 5.005_03.
>
> I'm coding a perl module to allow easy remote admin to PunkBuster
> server for Half-Life. The module telnet's into the server and gets a
> list of players that looks like this:
>
> 7725 "ShortyMac420" 65.92.249.97:27005,154991,4209 0:04:46 [0]
> Disconnected 216.25.206.67:27015
> 7735 "LEO" 66.65.76.50:27005,35005,4216 0:05:12 [2] Disconnected
> 216.25.206.67:27015
>
> I parse the list using some quick regex and I tried to build hash of
> hash references using this code
>
>
> sub getPlayers
> {
> my ($self) = @_;
> my (@output);
> my (%player);
> my (%players);
> my $line;
>
> my $cn = $self->{"pbconn"};
>
> $cn->print("plist");
> $cn->waitfor('/REMOTE/');
>
> ($_) = $cn->waitfor('/Next ID/');
> s/\s$//mg;
>
> @output= split (/[\r\n]+/,$_);
>
> foreach $line (@output)
> {
> if($line =~
>
/^(\d+)\s\"(.*)\"\s([\d\.:]+),(\d+).+(\d:).+Authenticated\s([\d\.]+):(\d+)$/
x)
> {
> my $pbid = $1;
> my $name = $2;
> my $cip = $3;
> my $wonid = $4;
> my $time = $5;
> my $srvip = $6;
> my $srvport = $7;
>
>
> $players { $wonid } = {
>
> "PBId"=>$pbid,
> "Name"=>$name,
> "WonId"=>$wonid,
> "CIp"=>$cip,
> "Time"=>$time,
> "ServerIp"=>$srvip,
> "ServerPort"=>$srvport
> };
>
> }
>
> }
>
> return %players;
> }
>
> Problem is, when I derefernce, I get strange results. Every other
> entry in the hash is not a reference.
>
> %pbp = $pbshots->getPlayers();
> foreach $players (%pbp)
> {
> print $players . "\n";
> }
>
> Exampe output:
>
> 45521
> HASH(0x823bfd8)
> 963439
> HASH(0x823bf00)
> 20674
> HASH(0x822ead0)
> 35290
> HASH(0x823c1f4)
> 1403219
> HASH(0x823c11c)
>
> Can someone tell me what I'm doign wrong? I can fix it by modifying
> the foreach loop to only output HASH references but I've never had to
> do that and I'm using basically the same code in other modules.
>
> Thanks.
>
>
> Matt
------------------------------
Date: Tue, 13 Nov 2001 01:36:20 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Hash Problem
Message-Id: <slrn9v0u9c.2q5.mgjv@verbruggen.comdyn.com.au>
On 12 Nov 2001 16:54:57 -0800,
SQLBoy <sqlboy@playway.net> wrote:
You should use -w and use strict. Are you?
> Problem is, when I derefernce, I get strange results. Every other
> entry in the hash is not a reference.
>
> %pbp = $pbshots->getPlayers();
> foreach $players (%pbp)
> {
> print $players . "\n";
> }
foreach my $player (keys %pbp)
{
print "$player\n";
# Do something with $pbp{$player}, which is a hash ref
}
Martien
--
|
Martien Verbruggen | Little girls, like butterflies, need
Trading Post Australia Pty Ltd | no excuse - Lazarus Long
|
------------------------------
Date: Mon, 12 Nov 2001 15:56:42 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: History Event
Message-Id: <3BF061BA.82E9342@vpservices.com>
Alex Shi wrote:
>
> Hello,
>
> I'm trying to identify a history event: do you think Matt is the first one
> who
> created Web based BBS using Perl? If not, who is the first one? If any
> one here happen to know about this topic please help. Thanks!
I was using web-based discussion forums built with perl as early as
1993. I'm sure there were others even before that although I don't know
any specifics.
--
Jeff
------------------------------
Date: Mon, 12 Nov 2001 17:02:18 -0600
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: How do I search for values in an array and change them?
Message-Id: <slrn9v0laf.upr.trammell@haqq.el-swifto.com>
On 12 Nov 2001 14:48:59 -0800, Nathan <nathan.franklin@idp.com> wrote:
> I'm pretty new to perl so any advice or tips would be greatly
> appreciated.
Turn on warnings, and use strict.
#!/usr/bin/perl -w
use strict;
--
Power corrupts, but intermittent power corrupts absolutely.
- Jeff Bell, in the Monastery
------------------------------
Date: Mon, 12 Nov 2001 23:26:34 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: How do I search for values in an array and change them?
Message-Id: <slrn9v0mm1.2q5.mgjv@verbruggen.comdyn.com.au>
On 12 Nov 2001 14:48:59 -0800,
Nathan <nathan.franklin@idp.com> wrote:
> Hi
>
> I'm trying to search and replace a line in an array but am not really
> sure where I've gone wrong. The first bit I'm having trouble with is
> searching the array @user for the username called $name. The second
> bit is I'm not sure why I can't replace a line in the array @list with
> the newly created one. Basically the idea is to take information from
> a log file (userlist) and add entries for each user to find out their
> total internet time and download amount.
>
> #!/usr/bin/perl
#!/usr/bin/perl -w
use strict;
> @file=`cat /userlist`;
Why are you reading in a file like this when Perl has perfectly
adequate I/O?
open(FILE, "/userlist") or die "Cannot open /userlist: $!\n";
> $output="User\tFull Name\tTotal Time\tTotal Download\tAmount Owing\n";
>
> foreach $line (@file){
And I wouldn't read all of the lines in a single array, but I would
process the file line by line.
while (my $line = <FILE>)
{
> chop $line;
Don't use chop when you really want chomp.
> @details = split(/ /, $line);
> $name=$details[0];
my ($name, $time, $usage) = (split / /, $line)[0, 3, 4];
> $fullname=`grep $name /etc/passwd|cut -d : -f 5`;
You should use the getpwnam function for this. Much more portable, and
it doesn't waste time on calling external programs. It also makes sure
that you don't accidentally get the wrong line. Imagine a password
file with these entries:
foo:x:512:100:Some name:/home/foo:/bin/sh
foobar:x:513:100:Some other name:/home/foo:/bin/sh
No, if $name is 'foo' what do you get?
Besides, the variable $fullname is misnamed, the field is called GCOS
or GECOS.
$gcos = (getpwnam $name)[6];
> $time=$details[3];
> $usage=$details[4];
If you want these, you should assigne them up there, immediately.
> chop $fullname;
It should be chomp, not chop, and this isn't necessary if you use the
right tools.
> if ( $user =~ /"$name"/ ) #if the user is not already in list add
Don't use regular expressions if you want to test for equality.
Besides that, those quotes are literal quotes in your regex.
if ($user eq $name)
{
And where did $user come from in the first place? I don't see you
setting this variable anywhere. -w and strict would have told you
that.
> {
> # #now update the user totals
> # #find them in the $list array
> # $count=0;
> # #chomp $count;
This chomp is never needed.
> # $item=$users[0];
Huh?
[snip of rest of commented out code, because it is terribly confused
and confusing]
> #add the new figures to the total
> $newitem="$name\t$fullname\t$newtime\t$newusage\n";
> $list=~ s/$newitem/$item/;
What is $list?
> }
> else
> {
> $nextline="$name\t$fullname\t$time\t$usage\n";
> push(@list, ($nextline)); #add this line to the array list
> push(@user, ($name)); #add the userid to the array user
> }
> }
>
> print $output;
Why did you even use the temporary variable $output?
> print @list;
>
> I'm pretty new to perl so any advice or tips would be greatly
> appreciated.
Done.
Now, to get back to (my interpretation of) the original question:
You have a file with user information, called /userlist. You want to
read the lines of this file, and find a particular entry for a
particular user in there. Then you want to do something with this
user's pw entry, and something else. Then you want to change that
user's record.
Now, I am going to assume that what you really want is to change the
user's record in the file, correct? You might want to read the Perl
FAQ, section 5. It contains a question about changing a line in a text
file. Normally, you'd read the file, and write to another file while
doing so. Once completed, you'd delete the original, and rename the
new file (or you copy the contents to the original).
Unfortunately, it is unclear to me what you want to do exactly, and I
am not going to guess too much :) You have also not specified what
exactly is in the file (/userlist) on a rwo by row basis. Does each
user appear only once?
Martien
--
|
Martien Verbruggen | Can't say that it is, 'cause it
Trading Post Australia Pty Ltd | ain't.
|
------------------------------
Date: Mon, 12 Nov 2001 17:07:33 -0800
From: "Greg Muth" <gamu829@yahoo.com>
Subject: Re: How do I search for values in an array and change them?
Message-Id: <tv0sionths80d4@corp.supernews.com>
Use hashes instead of arrays/lists. Using hashes, you don't have to search
to see if the user is already in the list, as Perl will do it for you. And
since Perl automatically initializes the value of a new hash key the first
time it is used, it is VERY easy to accumulate totals. Here is a simplified
example that assumes the first field in the file is the username and the
second is some value you want to sum for each user:
my $fin = "/some/file/name";
open SOMEFILE,"<$fin" || die "Can't open $fin";
my %totals;
while (<SOMEFILE>) {
# remember that a file read goes into $_ by default.
# remember that chomp and split work on $_ by default.
chomp;
my ($user,$value) = split / /;
$totals{$user} += $value;
}
close SOMEFILE;
foreach $user ( keys %totals) {
print "The accumulated total for user $user is $totals{$user}\n";
}
"Nathan" <nathan.franklin@idp.com> wrote in message
news:cbd95c21.0111121448.7ac51252@posting.google.com...
> Hi
>
> I'm trying to search and replace a line in an array but am not really
> sure where I've gone wrong. The first bit I'm having trouble with is
> searching the array @user for the username called $name. The second
> bit is I'm not sure why I can't replace a line in the array @list with
> the newly created one. Basically the idea is to take information from
> a log file (userlist) and add entries for each user to find out their
> total internet time and download amount.
>
> #!/usr/bin/perl
> @file=`cat /userlist`;
> $output="User\tFull Name\tTotal Time\tTotal Download\tAmount Owing\n";
>
> foreach $line (@file){
> chop $line;
> @details = split(/ /, $line);
> $name=$details[0];
> $fullname=`grep $name /etc/passwd|cut -d : -f 5`;
> $time=$details[3];
> $usage=$details[4];
> chop $fullname;
> if ( $user =~ /"$name"/ ) #if the user is not already in list add
> {
> # #now update the user totals
> # #find them in the $list array
> # $count=0;
> # #chomp $count;
> # $item=$users[0];
> # while ("$item" ne "$name")
> # {
> # ++$count;
> # # chomp $count;
> # $item=$users[$count];
> # }
> #
> # #take them out of the list
> # $item2=$list[$count];
> # chop $item2;
> print "user already entered in list\n";
> # #break up the line to take the usage & time fields
> # @oldline = split(/\t/, $item2);
> # $newtime=$oldline[3];
> # #chop $newtime;
> # $newusage=$oldline[4];
> # #chop $newusage;
> # $newtime += $time;
> # $newusage += $usage;
> #add the new figures to the total
> $newitem="$name\t$fullname\t$newtime\t$newusage\n";
> $list=~ s/$newitem/$item/;
> }
> else
> {
> $nextline="$name\t$fullname\t$time\t$usage\n";
> push(@list, ($nextline)); #add this line to the array list
> push(@user, ($name)); #add the userid to the array user
> }
> }
>
> print $output;
> print @list;
>
> I'm pretty new to perl so any advice or tips would be greatly
> appreciated.
> Thanks Nathan
------------------------------
Date: Mon, 12 Nov 2001 19:55:26 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Perl 6
Message-Id: <comdog-F001F4.19552612112001@news.panix.com>
In article <a3db0d59.0111121247.27e1a95@posting.google.com>,
raptnor@msn.com (john) wrote:
> Hi, Im just another Perl hacker with a question to the Perl community.
> Why do we need a complete redesign of our language?
> I have been keeping up with it as it has progressed pondering this
> question. I could understand a rewrite of its internals, as it needs
> to be cleaned up. During that rewrite I could see cleaning up some
> area's of the syntax and adding new features that enhance Perl.
> The idea of Perl 6 started out of the need of excitement. I think
> programming in Perl is pretty damn exciting in itself. What other
> language offers you so much access to its internals? What other
> language offers you four programming models (procedural, functional,
> oo, and declarative) that you can mix or keep separate?
these things aren't going away.
[snip language religion]
i'm not sure about your experience with other languages, but a
lot of the points you make are off of the mark, although i
won't respond to them because the following issue shouldn't
be clouded with bickering over languages.
> why do we need to redesign the language?
working on the core is getting tougher and tougher because it
has been worked over so many times. to make it easy to work on
Perl, even for things like bug fixes, the internals need to be
made cleaner.
along the way, they can fix nagging issues and add support for
things that Perl will have to deal with in the future. the
syntax of the language is how we get at these features. Perl 5
has a very messy syntax, and a lot of things would be easier
to handle if some of that changed. "Only perl can parse Perl"
might one day be a historical quote.
additionally, there are some common tasks that Perl users cannot do
very easily in Perl 5. these tasks should be made easier. the
easy things should be easy and the hard things should be possible,
this has always been the philosophy of Perl. since Perl 5 has been
around for awhile we've had the chance to see how we use it and
how we can make the things that should have been easy but aren't
actually be easy. hence, the Perl 6 RFCs.
> These are just some of the examples of things that I find concerning.
> Im afraid that the language that we enjoy working in is going to
> change into something that we wont like and I dont think the Perl
> elders have considered this as they weave the path of Perl 6.
they are certainly considering it, but things move forward. you
will, of course, still have Perl 5 and it will be as great as it
is
> Do we
> even know if the RFCs are from valid Perl users? How many people
> dumped RFC's in that don't really know Perl?
nobody established a height standard. you do not "have to be this
tall" to use Perl. everyone and anyone was welcome to post RFCs,
albeit they were vigorously peer reviewed, then either rejected
or accepted by Larry Wall who is designing the language of Perl
6. the RFC list is not the Perl 6 feature list.
you can get a lot better answers by reading the previous
discussions on the perl6 mailing lists if you have not done
so already:
http://dev.perl.org
--
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Mon, 12 Nov 2001 17:34:58 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Problem with perl pattern matching
Message-Id: <3BF078C2.6C35B76F@stomp.stomp.tokyo>
Tal Cohen wrote:
> I have the following code:
(snipped)
> Simple, but I would expect it to evaluate to Ture, but it evaluates to
> False. Any ideas?
Use of the index function will assist you to avoid
typical Metacharacter Madness. Use of regexes and
regex matching should be avoided when possible.
Godzilla!
--
Test Script:
____________
#!perl
$var1 = "path\=\(\$path \'\/raid2\/Andy\'\)";
$var2 = "path\=\(\$path \'\/raid2\/Andy\'\)";
if (index ($var1, $var2) > -1)
{ print "True\n"; }
else
{ print "False\n"; }
if (index ($var2, $var1) > -1)
{ print "True\n"; }
else
{ print "False\n"; }
exit;
Printed Results:
________________
True
True
------------------------------
Date: Mon, 12 Nov 2001 23:49:02 GMT
From: friedman@math.utexas.edu (Chas Friedman)
Subject: Re: RegEx ack references ... I need a clue
Message-Id: <3bf05fc4.3438324@news.itouch.net>
On Mon, 12 Nov 2001 23:04:00 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:
............
. (And don't you need a backslash in front of that
>'@'?)
>
> /(?:(^Mailing-List: list)|(^sender:.*?))( [^ ]+)\@/i
>
I thought that also, but it seems to work without the backslash (?)
cf
------------------------------
Date: Tue, 13 Nov 2001 01:29:52 GMT
From: "Steve Grazzini" <s_grazzini@hotmail.com>
Subject: Re: RegEx problem -- trying to match To: or From: at beginning of line
Message-Id: <kI_H7.74590$XA5.13305732@typhoon.nyc.rr.com>
"Chas Friedman" <friedman@math.utexas.edu> wrote in message
news:3bf02ccd.58387537@news.itouch.net...
> On Mon, 12 Nov 2001 12:00:08 -0800, "jennyw"
> <donotspam-jen@dangerousideas.com> wrote:
[..]
> Incidentally, you may have to worry about the fact that an email
> might contain other lines beginning with "From" or "To". Emails
> usually begin with a header "From ...". The sender usually is on a
> line beginning with "From: " There may also be lines in the body of
> the email beginning with "From " or "To ".
[..]
You'll always get a blank line between the header and the body of the
message, though. So you can bail before the body of the message, the jpeg
attachment, the .xls, etc.
while(<MAIL>) {
last if /^$/;
# do your thing with the headers
}
------------------------------
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.
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 2119
***************************************