[10457] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4049 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 22 20:04:01 1998

Date: Thu, 22 Oct 98 17:00:17 -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           Thu, 22 Oct 1998     Volume: 8 Number: 4049

Today's topics:
        "Document Contains no data"? piercew@netscape.net
    Re: += operator produces error, = operator doesn't? (Mark-Jason Dominus)
    Re: += operator produces error, = operator doesn't? <uri@fastengines.com>
    Re: about ssi and <img src... <keithlol@nospammindspring.com>
    Re: automatic garbage collection and memory leak DISAPP (Ilya Zakharevich)
        calling another script & location url <chi@ihomelistings.com>
    Re: calling another script & location url <rootbeer@teleport.com>
        Can a Perl program effect the parent process?? (Darren Greer)
    Re: Can a Perl program effect the parent process?? (Brand Hilton)
    Re: general problem - perl under win-nt 4.0 / iis 3.0 <rootbeer@teleport.com>
        GetServers for Novell servers <ppopour@infoave.net>
        Guides nrf@mailcity.com
        Help - dynamic images <dsutclif@NoSpam.ucsd.edu>
    Re: Perl & Y2K - booby trap code <ljz@asfast.com>
    Re: Perl & Y2K - booby trap code <tchrist@mox.perl.com>
    Re: Problem with code (Brand Hilton)
    Re: Problems with NT perl <rootbeer@teleport.com>
    Re: Problems with NT perl (Ethan H. Poole)
        regexp matching having prblems.. bthak@bascom.com
    Re: regexp matching having prblems.. <craig@admc.com>
    Re: regexp matching having prblems.. (David Alan Black)
    Re: regexp matching having prblems.. <rootbeer@teleport.com>
        web baseed email <jt@tfb.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 22 Oct 1998 22:58:06 GMT
From: piercew@netscape.net
Subject: "Document Contains no data"?
Message-Id: <70od9u$uvj$1@nnrp1.dejanews.com>

 I've got a question, hopefully someone here can help with.  I'm working on a
CGI script to take one field of input and compare that to a DBM file.  It
works fine until I get to the part of the script where I want to compare the
hash with the data entered.  If it's different then I try to add the entered
data to the hash and continue on.

 Here is the part of the code that appears to be causing the problem:

# Begin
dbmopen (%miramar,"miramar",0666) || die "Can't open DBM: $1";

# Check data

if($input{'command'} eq "") {
    print "You have entered an invalid name.";
}
else {
# Here is where the problem is at
    if($miramar{'command'} eq $input{'command'}) {
        print "$input{'command'} is already in the system.";
    }
    else {
        $miramar{'command'}="$input{'command'}";
        print "$input{'command'} had been added to the system.";
    }
}
dbmclose(%miramar);

# End

I've tried it using eq and cmp.  Using eq I get an error that doesn't even
load the page (Premature end of script headers or something) and cmp returns
it as true, but when I try to print off the keys of the hash later I get
nothing.

Another item that I'm uncertain of is opening the dbm, do I need to place a |
after to say I want to write to it?

If anyone can help or point me in a direction to get this solved it would be
much appreciated.

Wayne

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


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

Date: 22 Oct 1998 18:16:14 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: += operator produces error, = operator doesn't?
Message-Id: <70oare$2du$1@monet.op.net>

In article <362FA782.A299D30A@us.ibm.com>,
James Ludlow  <ludlow@us.ibm.com> wrote:
>Uri Guttman wrote:
>> this is interesting. we should definitely report it. maybe it is a
>> correct but undocumented side effect of parsing list operators. 

I think it's obviously a bug.  And it's not about list operators; it's
because Perl mistakes the $x for an indirect filehandle:

	$x = STDERR; 
	print $x     "foo";		# Print "foo" to STDERR
	print $x     += 1;		# Oops.

It sees what looks like an indirect object, and garden-paths and can't
figure out the +=.

>> who in this thread will send in a perlbug? the original poster should if
>> he wants to.

I did it a few hours ago.  Chip said that there was already an
exception in there for the `x' operator, and that it would be easy to
add similar exceptions for += and the others.

>I think, however, that we should confirm this behavior with someone
>running the latest release of perl.  I'm running 5.004_01, so I'm a bit
>behind the times in that regard.

The problem occurs in at least the following versions: 5.001m, 5.002,
5.003_22, 5.004_04, 5.00502, so everyone should be able to enjoy it.





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

Date: 22 Oct 1998 18:27:44 -0400
From: Uri Guttman <uri@fastengines.com>
To: mjd@op.net (Mark-Jason Dominus)
Subject: Re: += operator produces error, = operator doesn't?
Message-Id: <sarogr4kza7.fsf@camel.fastserv.com>

>>>>> "MD" == Mark-Jason Dominus <mjd@op.net> writes:

  MD> In article <362FA782.A299D30A@us.ibm.com>, James Ludlow
  MD> <ludlow@us.ibm.com> wrote:
  >> Uri Guttman wrote:
  >>> this is interesting. we should definitely report it. maybe it is a
  >>> correct but undocumented side effect of parsing list operators.

  MD> I think it's obviously a bug.  And it's not about list operators;
  MD> it's because Perl mistakes the $x for an indirect filehandle:

other posts show it with list operators too. and i saw it with

print( $n += 4 );

where $n cannot be mistaken for an indirect file handle.

print( $n+= 4 );

works.

so it is something to do with list operators and parsing their
arguments. all/some/most assignment ops seem to blow up in a list
operator if they have a space in front of them.

perl -e 'join $n += 3, 4'
perl -e 'join ($n += 3), 4'
perl -e 'join($n += 3), 4'

all fail with parse errors near "+=".

the first arg to join is not a list context but it fails
anyway. removing the space before the += always fixes these bugs.

so it may be more than just list operators. i think it is a general
parse problem with a space before x= after built in operators. x= in
expressions seems to be fine.

uri


-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Thu, 22 Oct 1998 18:54:28 -0400
From: "DuhK" <keithlol@nospammindspring.com>
Subject: Re: about ssi and <img src...
Message-Id: <70oct4$t6k$1@camel25.mindspring.com>

Thanks Daniel & Tom..,
 Your answers are very much appreciated! Daniel, your explanation has no
errors to my understanding of the sequence of events either for the ssi, or
the <img src tag. I guess, I was trying to avoid returning a bitmap, or a
content type= image...,
I'm going to go back and try it again, with content type = image first, then
maybe try loading the image file and converting it to a raw bit-map with the
perl.. ugly I know, but I have reasons for doing it this way.. Thanks again
for your help!!
Keith
Daniel Beckham wrote in message ...
>Ok, this really doesn't have anything to do with perl, but... if you are
>using SSI, then the web server is parsing out the SSI tags and replacing
>them with the proper information before ever sending the html file to the
>browser.  The webserver and the browser _then_ handle the exchange of
>text, images, etc.  Specifically, the browsers sees a link to a gif file
>in the src attribute and then asks the webserver to return the gif file
>and the webserver seeing that the gif file is an image, it returns the
>proper http headers and then the binary image data.
>
>If you are using a cgi script as in the second example, then the browser
>has already gotten the text, images, etc. and it's expecting a file where
>the src attribute is.  Since the webserver sees the *.pl file as an
>executable script, it will let the script take over and handle what
>information is sent.  It's now up to you and your script to properly send
>the http headers and binary image data.
>
>n.b. "Content-type: image/jpeg\n\n" would be valid for a *.jpg file, but
>there are probably some other headers that have to be sent also such as
>the size of the image, etc.  You will need to take a look at the proper
>RFC for the correct way to do this.
>
>Hope that was more helpful than confusing.
>
>Any out there want to correct my errors?
>
>Daniel
>
>In article <70ms9u$l65$1@camel15.mindspring.com>,
>keithlol@nospammindspring.com says...
>> Guess I'll start simple, then get more complicated..lol
>>  Ok, I have written a script (pl), that does various things
>> counter/e-mail response/ logging etc.
>> I start this script with the SSI:
>> <!--#exec cgi="cgi-bin/whatever.pl"-->
>> What is returned to the html file in place is:
>>
>> <br><b>You are visitor number:</b><br>
>> <img src="http://myurl.com/logs/graphics/2.gif" align="center">
>> <br><b>Thank you!</b><br>
>>
>> Ok, works great, but let's say I go this route and instead of the SSI, I
>> use:
>> <img src="http://myurl.com/cgi-bin/logger.pl?/index.html">
>>
>> I grab the $ENV{'QUERY_STRING'}, telling me which file I'm dealing with
>> (index.html). Then, I return:
>>
>> <br><b>You are visitor number:</b><br>
>> <img src="http://myurl.com/logs/graphics/2.gif" align="center">
>> <br><b>Thank you!</b><br>
>>
>> Ok... I get a broken image, cause NO bitmap is returned.. I still return
>> text/html.. which is what I want to do.
>>
>> My question is this.. Is there anyway to return content=text/html using
the
>> <img src.. tag?
>>
>> Or, is there a method I can use to return content text/html, using a
method
>> other than the SSI?
>>
>> Sorry.. started complicated.. stayed that way.. Thanks in Advance!!
>> Keith M.
>>
>>
>>
>>
>>
>>




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

Date: 22 Oct 1998 22:46:09 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: automatic garbage collection and memory leak DISAPPEARED
Message-Id: <70ocjh$g55$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Gulriz Aytekin Kurban 
<gulriz@cs.uchicago.edu>],
who wrote in article <lj67dc1mxl.fsf_-_@gargoyle.cs.uchicago.edu>:

> This tells me that Perl does reclaim storage for objects, 

Yes.
							    and other "my"
> variables. 

No.

Ilya



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

Date: Thu, 22 Oct 1998 15:10:30 -0700
From: Chi Yu <chi@ihomelistings.com>
Subject: calling another script & location url
Message-Id: <362FAD56.29B9F5BE@ihomelistings.com>

Greetings,

Is there a way to call another script such that the the url of the
called script remains in the browser's location url upon successful
termination of both scripts?

I always wind up with the parent script url in the location bar. I've
tried fork and exec to no avail.

If that's not possible, how difficult would it be to dynamically insert
a hidden form field into an existing html document and then print the
location of the modified html document? This way I would wind up with
the html page's url in the location bar.

Why do I care about the location url? I don't want the user to call the
first script if they hit enter. I want the second script or dynamic html
doc to be executed upon hitting enter.

The specific application I'm trying to implement is a login script that
verifies the userid/password that in turn calls another script to
dynamically build an account maintenance page. I want to insert hidden
fields with data from the user's account. I imagine I can accomplish
this by calling a second script to build the acct page or by dynamically
modifying a base acct page with the specific user data and then printing
the location of the modified page.

Which approach would you recommend? Is there a better alternative?

Thanks,
Chi Yu


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

Date: Thu, 22 Oct 1998 23:31:46 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: calling another script & location url
Message-Id: <Pine.GSO.4.02A.9810221630400.5534-100000@user2.teleport.com>

On Thu, 22 Oct 1998, Chi Yu wrote:

> Is there a way to call another script such that the the url of the
> called script remains in the browser's location url upon successful
> termination of both scripts?

There may be, but if so it's the same whether you're using Perl or not.
The docs, FAQs, and newsgroups about browsers and related issues may be of
help to you.

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 22 Oct 1998 22:31:46 GMT
From: drgreer@qtiworld.com (Darren Greer)
Subject: Can a Perl program effect the parent process??
Message-Id: <362fb18c.278438092@news.qgraph.com>

The subject explains it all....but here is my situation.  I have a
perl program that I want to set the DISPLAY env variable.
Unfortunatley from what I understand on a *nix system, a child process
(ie perl program) can not effect the parent process?)  Is there anyway
to do this.

For Example:

I set my DISPLAY env var to "0"

When I run my perl program it finds the real IP and then does a
system("export DISPLAY=$ip");

But when the perl program is done the IP is still 0.  And I do know
that $ip is not 0.

Any help would be appreciated

Darren Greer
programmer/analyst
QTI



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

Date: 22 Oct 1998 23:01:19 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: Can a Perl program effect the parent process??
Message-Id: <70odfv$gov8@mercury.adc.com>

In article <362fb18c.278438092@news.qgraph.com>,
Darren Greer <drgreer@qtiworld.com> wrote:
>The subject explains it all....but here is my situation.  I have a
>perl program that I want to set the DISPLAY env variable.
>Unfortunatley from what I understand on a *nix system, a child process
>(ie perl program) can not effect the parent process?)  Is there anyway
>to do this.
>
>For Example:
>
>I set my DISPLAY env var to "0"
>
>When I run my perl program it finds the real IP and then does a
>system("export DISPLAY=$ip");
>
>But when the perl program is done the IP is still 0.  And I do know
>that $ip is not 0.
>
>Any help would be appreciated

>From perlfaq8:

     I {changed directory, modified my environment} in a perl
     script.  How come the change disappeared when I exited the
     script?  How do I get my changes to be visible?

     Unix
         In the strictest sense, it can't be done -- the script
         executes as a different process from the shell it was
         started from.  Changes to a process are not reflected in
         its parent, only in its own children created after the
         change.  There is shell magic that may allow you to fake
         it by eval()ing the script's output in your shell; check
         out the comp.unix.questions FAQ for details.

-- 
 _____ 
|///  |   Brand Hilton  bhilton@adc.com
|  ADC|   ADC Telecommunications, ATM Transport Division
|_____|   Richardson, Texas


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

Date: Thu, 22 Oct 1998 23:18:30 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: general problem - perl under win-nt 4.0 / iis 3.0
Message-Id: <Pine.GSO.4.02A.9810221618180.5534-100000@user2.teleport.com>

On 21 Oct 1998, Andreas Krahn wrote:

> in the browser i get the error : "http/1.0 501 nicht unterstuetzt"

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.

   http://www.perl.com/CPAN/
   http://www.perl.org/CPAN/
   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
   http://www.perl.org/CPAN/doc/manual/html/pod/

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 22 Oct 1998 22:53:49 GMT
From: "Paul Popour" <ppopour@infoave.net>
Subject: GetServers for Novell servers
Message-Id: <01bdfe0e$a8bc6c80$f6a7d886@23dgwpr-p200>

The listed Win32::UserAdmin::GetServers address for Novell servers is
0x00000080.  This doesn't seem to return anything.  I can see the NT
servers using -

Win32::NetAdmin::GetServers($pdc, $domain, 0x00000008, \@servers1);
Win32::NetAdmin::GetServers($pdc, $domain, 0x00000010, \@servers2);
Win32::NetAdmin::GetServers($pdc, $domain, 0x00008000, \@servers3);

Is there a different address for novell servers in this module or is there
a module that deals with Novell?

I want to be able to query the servers for their names, their volume names
and the disk information of those volumes (total space and free space).



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

Date: Thu, 22 Oct 1998 23:22:40 GMT
From: nrf@mailcity.com
Subject: Guides
Message-Id: <70oeo0$if$1@nnrp1.dejanews.com>

Where can I find a good beginners guide to perl in the internet?
One that explains the several commands?

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


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

Date: Thu, 22 Oct 1998 15:44:38 -0700
From: "Dale Sutcliffe" <dsutclif@NoSpam.ucsd.edu>
Subject: Help - dynamic images
Message-Id: <LzOX1.2315$q15.65360@news.san.rr.com>

I need to create graph images on the fly.  For instance one web page may
contain 20 different images that were created on the fly. I have used gd.pm,
but I believe that I would have to create, save, and then display the image.
How can I display multiple images in a web page without the image existing
as a gif or jpeg file on the server?




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

Date: 22 Oct 1998 19:18:09 -400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <ltbtn4b2z2.fsf@asfast.com>

Tom Phoenix <rootbeer@teleport.com> writes:

> On Thu, 22 Oct 1998, Scratchie wrote:
> 
> > I don't know many (any?) programmers with the time to go back into
> > completed projects and check every token.
> 
> They should have checked their code when they wrote it. But what's so
> Perl-specific about this? If you must discuss this in a newsgroup, use one
> about programming in general. 

Like all other computer languages, Perl is not bug-proof.  And like
all other computer languages, Perl is not Y2K-problem-proof.  And like
all other computer languages, Perl does not automatically redo
people's programs to correct their mistakes and the fruits of their
poor judgment.  And finally, like programmers of all other languages,
Perl programmers are not immune from making these errors in judgment
in the first place.

Therefore, I, for one (and perhaps one of the very few here?), believe
that c.l.p.misc, like all other programming-language-related
newsgroups, should not be immune from discussions about ways to avoid,
correct, and prevent poor judgment and bad programming practices,
including those which have to do with Y2K-related issues.

> > Reviewing completed projects for the proper use of "localtime", on the
> > other hand, would not seem impossible or unwarranted, especially if one is
> > maintaining code that one did not write personally.
> 
> Reviewing completed projects for the proper use of "die" is neither
> impossible nor unwarranted. Reviewing completed projects for the proper
> use of "**" is neither impossible nor unwarranted. Reviewing completed
> projects for the proper use of "abs" is neither impossible nor
> unwarranted....

Of course not.  And if someone came here and suggested (to use one of
your examples) that people go back and check completed projects for
the proper use of "die", I doubt that you would be responding in the
same manner to that hypothetical person as you're responding to this
current person who's raising this Y2K-and-localtime issue.

Assuming that this is the case [but please correct me if I'm wrong,
and I will then apologize and retract my supposition], then what is so
special about Y2K issues that would lead some of you to [presumably]
react differently to them than to other, similar issues?

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -le '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x"'


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

Date: 22 Oct 1998 23:52:33 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <70ogg1$1om$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, lr@hpl.hp.com (Larry Rosler) writes:
:There is an unambiguous way that is also *standard*:  ISO 8601:1988.  
:The following is the complete long form:
:
:yyyy-mm-dd HH:MM:SS (punctuation is optional)

The day that you ask everyone on the street when they were born and they
all recite an answer in a form such as that is the day that computer
programmers should expect to use that form as their unique input and
output style.

--tom
-- 
    The only disadvantage I see is that it would force everyone to get Perl.
    Horrors.  :-)
                    --Larry Wall in  <8854@jpl-devvax.JPL.NASA.GOV>


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

Date: 22 Oct 1998 21:59:36 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: Problem with code
Message-Id: <70o9s8$gov7@mercury.adc.com>

You need to read perlfaq5.  The second question deals with what you're
trying to do.

-- 
 _____ 
|///  |   Brand Hilton  bhilton@adc.com
|  ADC|   ADC Telecommunications, ATM Transport Division
|_____|   Richardson, Texas


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

Date: Thu, 22 Oct 1998 23:17:44 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Problems with NT perl
Message-Id: <Pine.GSO.4.02A.9810221617290.5534-100000@user2.teleport.com>

On Thu, 22 Oct 1998, Commitman wrote:

> The cgi don't see that $FORM{ "FIELD" } is my form field. SUX !!!

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.

   http://www.perl.com/CPAN/
   http://www.perl.org/CPAN/
   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
   http://www.perl.org/CPAN/doc/manual/html/pod/

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 22 Oct 1998 23:22:29 GMT
From: ehpoole@ingress.com (Ethan H. Poole)
Subject: Re: Problems with NT perl
Message-Id: <V6PX1.1207$487.1596@news12.ispnews.com>

[Posted and Emailed]  In article <70o3to$e44$1@srv4-poa.nutecnet.com.br>, 
commitman@digitalnet.com.br says...
>
>The cgi don't see that $FORM{ "FIELD" } is my form field. SUX !!!
>
>Who may help me ???
>
>I'm using d post method
>
>Sory because my english !

>From your limited description, I would doubt that the problem is NT.  
Unfortunately, nobody is going to be able to help you much with the 
information you've provided.

Please don't take this the wrong way, but the more limited your English is 
the more important a good example becomes.  In this group, Perl is the one 
language *everyone* should be fluent in -- use that fact to your advantage!

-- 
Ethan H. Poole              | Website Design and Hosting,
                            | CGI Programming (Perl & C)..
========Personal=========== | ============================
* ehpoole @ ingress . com * | --Interact2Day--
http://home1.gte.net/ehp/   | http://www.interact2day.com/



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

Date: Thu, 22 Oct 1998 21:57:46 GMT
From: bthak@bascom.com
Subject: regexp matching having prblems..
Message-Id: <70o9or$r7e$1@nnrp1.dejanews.com>

okay why does the following code doesnt match...

%hash = ( 'key' => '/a?b=c/;' );
print "hash  = " . $hash{key} . "\n";

$match = $hash{key};

print "match = " . $match . "\n";

if ($hash{key} =~ /$match/) { print "match\n"; }
else { print "no match\n"; }

if ($hash{key} =~ $hash{key} { print "yeaaaaaaaaa a match"; }
else { print "awwww no match"; }

am i missing something ?????

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


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

Date: Thu, 22 Oct 1998 22:32:31 GMT
From: Craig <craig@admc.com>
Subject: Re: regexp matching having prblems..
Message-Id: <362FB751.CFC15158@admc.com>

bthak@bascom.com wrote:

> okay why does the following code doesnt match...
> 
> %hash = ( 'key' => '/a?b=c/;' );
> print "hash  = " . $hash{key} . "\n";
> 
> $match = $hash{key};
> 
> print "match = " . $match . "\n";
> 
> if ($hash{key} =~ /$match/) { print "match\n"; }
> else { print "no match\n"; }
> 
> if ($hash{key} =~ $hash{key} { print "yeaaaaaaaaa a match"; }
> else { print "awwww no match"; }
> 
> am i missing something ?????

You need to quote the meta characters.

if ($hash{key} =~ /\Q$match/) { print "match\n"; }

if ($hash{key} =~ /\Q$hash{key}/) { print "yeaaaaaaaaa a match"; }


-- 
Craig Freter    <freter@freter.com>   <http://www.freter.com>
PGP fingerprint 61 A5 E2 51 F5 AC 9D 79 DD 15 56 90 F2 0A 97 25
Axis Data Management  <http://www.admc.com>


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

Date: 22 Oct 1998 19:00:49 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: regexp matching having prblems..
Message-Id: <70odf1$puk$1@pilot.njin.net>

Hello -

bthak@bascom.com writes:

>okay why does the following code doesnt match...

>%hash = ( 'key' => '/a?b=c/;' );
>print "hash  = " . $hash{key} . "\n";


No need to bother with the concatenation operators:

  print "hash = $hash{key}\n";


>$match = $hash{key};

>print "match = " . $match . "\n";

>if ($hash{key} =~ /$match/) { print "match\n"; }
>else { print "no match\n"; }

>if ($hash{key} =~ $hash{key} { print "yeaaaaaaaaa a match"; }
>else { print "awwww no match"; }

>am i missing something ?????


Forget the variable assignments for the moment.  What it comes
down to is this:

  if ( '/a?b=c/;' =~ m!/a?b=c/! ) { ... }

or, to paraphrase:

  if the string '/a?b=c/;' contains:
        the character '/'              followed by
        zero or one 'a' characters     followed by
        the characters 'b', '=', 'c', and '/', in that order,

  then ...


which it doesn't - it contains a slash, followed by an 'a', 
followed by a question mark....

In other words, you're comparing a literal string to a regex
pattern, in which the (formerly literal) characters have special
meanings.

If you do this:

  if ($hash{key} =~ /\Q$match\E/) {}

then those characters will not gain their special values in the
pattern.


David Black
dblack@pilot.njin.net


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

Date: Thu, 22 Oct 1998 23:38:24 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: regexp matching having prblems..
Message-Id: <Pine.GSO.4.02A.9810221632370.5534-100000@user2.teleport.com>

On Thu, 22 Oct 1998 bthak@bascom.com wrote:

> okay why does the following code doesnt match...

> %hash = ( 'key' => '/a?b=c/;' );

Because you're trying to match the string '/a?b=c/' with the pattern
'/a?b=c/', and that pattern doesn't match that string. See perlre.

If you want to know whether two strings are identical, perl has an
operator for that. If you want to know whether one string can be found
within another, perl has an operator for that. If you want to convert a
string (which may contain RE metacharacters) into a regular expression (in
which those characters need to match themselves), perl has an operator for
that, too.

So, which one do you really want to do?

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 22 Oct 1998 16:40:53 -0700
From: "James King" <jt@tfb.com>
Subject: web baseed email
Message-Id: <XqPX1.21117$5w6.4907@newsfeed.slurp.net>


My company is looking into providing web-based email for our clients and we
have not been able to find a program that can allow our users to just type
in their login name and password and have it check their mail.  All the
programs that we have found are NT based and don't look directly to the mail
server to verify login and password.  IS there any perl programs that you
know of that will provide us with the service we need.

Any comments or advice would be appreciated
--

----------------------------------------------------------------------------
-----------
Sent via TFBnet - Your Connection to the world!
----------------------------------------------------------------------------
-----------




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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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