[19001] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1196 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 26 11:10:31 2001

Date: Tue, 26 Jun 2001 08:10:10 -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: <993568210-v10-i1196@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 26 Jun 2001     Volume: 10 Number: 1196

Today's topics:
    Re: reg expr <jonni@ifm.liu.se>
    Re: right symbol? <ren@tivoli.com>
    Re: Script stops on multiple question marks (Darren Spidell)
    Re: Script stops on multiple question marks <ren@tivoli.com>
    Re: Setting Return-Path in sendmail from Perl (Suresh Ramasubramanian)
    Re: Small Database Becomes Large Database <amessent@vianet.co.uk>
        Troubleshooting a CGI Script <mikes@escape.com>
        untie attempted while 1 inner references still exist <m.grimshaw@salford.ac.uk>
    Re: untie attempted while 1 inner references still exis (Anno Siegel)
    Re: untie attempted while 1 inner references still exis <m.grimshaw@salford.ac.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 26 Jun 2001 15:37:36 +0200
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: reg expr
Message-Id: <9ha32v$f3s$1@newsy.ifm.liu.se>

> this line does the reverse of what i want
> print "test",($tmp=~/(.*)~/),"\n";

Why not reverse it then?
print "test",($tmp=~/~(.*)/),"\n";

--
_______________________________
Jonas Nilsson




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

Date: 26 Jun 2001 08:35:48 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: right symbol?
Message-Id: <m3r8w77497.fsf@dhcp9-173.support.tivoli.com>

On 25 Jun 2001, merlyn@stonehenge.com wrote:

>>>>>> "Ren" == Ren Maddox <ren@tivoli.com> writes:
> 
> Ren> print "http://somewhere/abc.asp?param1=$var1&param2=",
> Ren>   format_string($var2);
> 
> Ren> ("?" and "&" are not special in a string)
> 
> But the ampersand is special to HTML.  You need to code it
> as &amp; or the day you have a parameter called "copy", you'll
> be unexpectedly surprised with a copyright symbol showing up.

What's HTML?  :)

But seriously, I didn't even actually parse the HTML, I was just
answering the Perl question.  If I look at the HTML then I might feel
obligated to address all sorts of off-topic issues (in general, not
necessarily in this thread).

It seems like a fine line.  If someone is doing something that is
obviously incorrect, but is also only a tangential issue to their
on-topic query, then it seems that pointing out the problem is the
right thing to do.  But how far do you take it?  I usually just ignore
the details that are neither Perl-related nor particularly germane to
the query at hand.

For that matter, there's actually no indication in the original post
that this actually is HTML.  For all we know this string is going to
be passed to wget.  And if that's the case, using &amp; is likely to
yield incorrect results.  So deciding which is correct requires more
information than we have been given.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 26 Jun 2001 05:05:36 -0700
From: dspidell@mta.ca (Darren Spidell)
Subject: Re: Script stops on multiple question marks
Message-Id: <f5d27ac9.0106260405.485893ca@posting.google.com>

Ren Maddox <ren@tivoli.com> wrote in message news:<m3sngo8cqm.fsf@dhcp9-173.support.tivoli.com>...
> On 25 Jun 2001, dspidell@mta.ca wrote:
> 
> [snip]
> > The problem is: If a response contains a string of 3 or more
> > question marks, the script simply stops. The section of code is
> > below.
> > 
> > if (($i > $start_value+$part_1_num)&($i <= $start_value+$part_2_num))
> > #Checks to see which part of the assessment the current question is in
> >   {
> >     print "$response[$i], ";
> >     my $temp_answer = $answers[$i-$start_value];
> >     $temp_response = $response[$i];
> >     if ($temp_answer =~ /< *$temp_response *>/)
> >     {
> >       $part_2++;
> >     }
> >   }
> > 
> > If the response is "etre???", the script prints "etre???," then
> > quits.  It seems to stop when it hits the regular expression.
> 
> Are you intending the pattern to allow special regex characters?  Or
> should that pattern match three literal "?"-s?  Or are you using a
> wildcard-style pattern where "?" represents any character?
> 
> As you've written it, the response is treated as a regex, and "?" is
> special there.  If you don't want it to be special, use quotemeta() or
> "\Q".  If you *do* want the regex behavior, then realize that "???" is
> not valid regex syntax.  Finally, if you want wildcard behavior, then
> you need to preprocess the response:
> 
> $temp_response =~ s/\*/.*/g;
> $temp_response =~ tr/?/./;
> 
> Unfortunately, this makes it difficult to handle other special regex
> characters.

Thanks for the response. I don't want the pattern to to allow special
characters other than "<", ">" and spaces. In the example above it
should only match on "etre", or the same with spaces on either side of
it. It is part of a fill in the blank used in a sentence, so we are
allowing spaces. The "<" and ">" are used to separate possible answers
in the answer field.

The really strange thing about it is it works fine if the user puts
one or two question marks. It doesn't match, but it shouldn't. When I
say it works, I mean the script continues to be processed. With 3
question marks, the script stops.


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

Date: 26 Jun 2001 08:43:08 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Script stops on multiple question marks
Message-Id: <m3n16v73wz.fsf@dhcp9-173.support.tivoli.com>

On 26 Jun 2001, dspidell@mta.ca wrote:

> Ren Maddox <ren@tivoli.com> wrote in message
> news:<m3sngo8cqm.fsf@dhcp9-173.support.tivoli.com>...
>> On 25 Jun 2001, dspidell@mta.ca wrote:
>> 
[snip]
>> > If the response is "etre???", the script prints "etre???," then
>> > quits.  It seems to stop when it hits the regular expression.
>> 
[my response snipped]
> 
> Thanks for the response. I don't want the pattern to to allow
> special characters other than "<", ">" and spaces. In the example
> above it should only match on "etre", or the same with spaces on
> either side of it. It is part of a fill in the blank used in a
> sentence, so we are allowing spaces. The "<" and ">" are used to
> separate possible answers in the answer field.

I'm confused... if "etre???" should only match "etre" then what is the
point of the "?"-s?

> The really strange thing about it is it works fine if the user puts
> one or two question marks. It doesn't match, but it shouldn't. When
> I say it works, I mean the script continues to be processed. With 3
> question marks, the script stops.

It isn't strange -- one or two question marks can be in a valid regex,
but three consecutive question marks cannot.

I'm still not clear on exactly what you are trying to achieve.  If you
want to ignore question marks, just use "tr/?//d" to strip them out.
If you want to match literal question marks, change your regex to
"/< */\Q$temp_response\E *>/".  If you want something different,
please elaborate.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 21 Jun 2001 04:48:40 GMT
From: mallet.I_Kill_Spammers@cluestick.org (Suresh Ramasubramanian)
Subject: Re: Setting Return-Path in sendmail from Perl
Message-Id: <9grub8$8vq1t$4@ID-40468.news.dfncis.de>

In comp.mail.sendmail Steven Stalzer <steve@newmediacreations.com> wrote:
> Hmm, I have indeed been using a valid From. This seems to allow a receiver to
> reply to me (such as to ask to be removed from the mailing list), but invalid
> emails in the list still get bounced back to the default Return-Path set up by
> the virtual server, rather than coming back to From, where I can deal with them.

As I said, use sendmail -f in your script to set the envelope from.

>>> I am hoping to do something like this:
>>>     open(MAIL,"|$mailprog -t");

open(MAIL,"|$mailprog -f$bounce_alias -t");

>>>     print MAIL "Return-Path: $bounce_alias\n";

	-suresh


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

Date: Tue, 26 Jun 2001 11:01:19 +0100
From: Andrew Messent <amessent@vianet.co.uk>
Subject: Re: Small Database Becomes Large Database
Message-Id: <3B385D6F.DB1902C9@vianet.co.uk>

I have heard that some of the dbm implementations muck with the file
header causing ls to report size incorrectly. Use du instead...

-- 
Andrew N. Messent
IT Specialist
amessent@vianet.co.uk

For more information about our products and services,
please visit our website at www.vianet.co.uk


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

Date: Tue, 26 Jun 2001 10:52:44 -0400
From: mike <mikes@escape.com>
Subject: Troubleshooting a CGI Script
Message-Id: <3B38A1BB.469B5CD4@escape.com>

Hi,
    I am trying to get started in learning some CGI scripting.
I have a local network and have Win95 on one machine and
Redhat Linux 6.1 on another with Apache web server running.
   So far I am not able to execute a CGI script, except by
going into the directory and just executing the script. When I browse
to the base IP address, I can get my internal web page on my Netscape
browser, but the script will not execute. Since I don't know
very much Perl programming. I made a simple program called
test.pl, which I also copied to test.cgi, in case the name was wrong.
In the program I basically have:

#!/usr/bin/perl
rename(1111,2222)


    If I execute the program from the directory, it will rename the
file 1111 to 2222. Thus I know that the script is executing.
The program will not run by browsing to the site.

In index.html, I have
put:

<!--#exec cgi="/cgi-bin/test.cgi"-->

and have used test.pl

  I have browsed the site using the URL:

Say the address was http://u.x.y.z/cgi-bin/test.cgi

or test.pl

  I get the error message: premature end of script headers in the
error_log  file.
  In my netscape 4.07 browser, I get: Internal Server Error.



Thanks

Mike






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

Date: Tue, 26 Jun 2001 11:34:48 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: untie attempted while 1 inner references still exist
Message-Id: <3B386548.85C9D699@salford.ac.uk>

Hi,

I'm getting the following warning with use diagnostics and use Carp:

untie attempted while 1 inner references still exist at
        /usr/local/apache/docs/music/cgi-bin/q3aforum/logon.cgi line 206
(#1)
    
    (W) A copy of the object returned from tie (or tied) was still
    valid when untie was called.
    
here at /usr/local/apache/docs/music/cgi-bin/q3aforum/logon.cgi line 207
        main::tidy_db('HASH(0x102475d0)') called at
/usr/local/apache/docs/music/cgi-bin/q3aforum/logon.cgi line 175
        main::enter_forum(1) called at
/usr/local/apache/docs/music/cgi-bin/q3aforum/logon.cgi line 51
        main::get_input called at
/usr/local/apache/docs/music/cgi-bin/q3aforum/logon.cgi line 19

The script does what it's supposed to do - this is a warning.

Here's the script with a bit of snipping to make it clearer.

#!/usr/local/bin/perl -w
        
# Logon.cgi - Logon to system and set cookie.
                
BEGIN {unshift(@INC, '/music/perl_mng');}
                        
use diagnostics;
use Carp;
use Fcntl qw (:DEFAULT :flock);
use CGI; use POSIX; use DB_File; use Q;
        
$| = 1; # flush print buffer each time print is called
$in = new CGI;
                
#&q_head;
#print "down for maintenance<P>";
#&q_exit;

&get_input;	#### line 19
&q_exit;

sub get_input   
{
$num_display = 0;
	if ####<snip>
        elsif(($in->param('logon') && ($in->param('logon') eq
'return')))       # returning after posting
                                                                               
# topic/editing details
        {
                if($in->param('num_display'))   # point in topicdb to
start display from
                {
                        $num_display = $in->param('num_display')
                }
#               &last_seen;
                &enter_forum(1);        ##### line 51
        }
	else #### <snip>
}

sub enter_forum
{
local(@user, @prev_logon);
        &q_head;
# grab previous logon time in order to display read/unread post gif
        &lock(LOCK_SH);
        &open_user_db(O_RDONLY);        # Read only
        @prev_logon = split(/¬/, $USER{$username});
        &tidy_db(\%USER);	#### line 175
# snipped but nothing refers to %USER etc.
}

sub tidy_db
{
        untie %{$_[0]};		#### line 206
        undef %{$_[0]};		#### line 207
        close(LOCK) if(!$_[1]);
}

sub lock
{
        if(!(open(LOCK, ">lock")))
        {
                print "Error: Unable to lock lockfile - $!";
                &q_exit;
        }
        flock(LOCK, $_[0]);
}       

sub open_user_db
{
        if(!($dbobj = q_open_db(\%USER, $q_userdb, $_[0])))
        {
                &q_head;
                print "Error: unable to open user database<P>";
                &q_exit;
        }
}
                
Flow of control is &get_input -> &enter_forum -> q_exit - so nothing
else deals with %USER.
q_open_db is part of Q.pm and calls tie() returning the tie object.
&q_head simply prints the HTML header.
&q_exit simply prints the HTML tail info. and also functions as a
bailout with exit;

I've tried shifting the code on line 175 to right before the &q_exit; on
line 20 but get the same warning.

I've no idea what the warning really means.  Any ideas?


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

Date: 26 Jun 2001 11:40:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: untie attempted while 1 inner references still exist
Message-Id: <9h9sag$82v$2@mamenchi.zrz.TU-Berlin.DE>

According to Mark Grimshaw  <m.grimshaw@salford.ac.uk>:
> Hi,
> 
> I'm getting the following warning with use diagnostics and use Carp:
> 
> untie attempted while 1 inner references still exist at
>         /usr/local/apache/docs/music/cgi-bin/q3aforum/logon.cgi line 206
> (#1)
>     
>     (W) A copy of the object returned from tie (or tied) was still
>     valid when untie was called.
     
[snip most of code]
 
> sub open_user_db
> {
>         if(!($dbobj = q_open_db(\%USER, $q_userdb, $_[0])))

If the return value from q_open_db is what I suspect it to be,
this is the crucial point:  You are keeping a copy of the under-
lying object in $dbobj.  When untie() wants to destroy this object,
the warning results.  Undef $dbobj before untie(), or, better,
let it go out of scope.  Do you actually need it at all?

Anno


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

Date: Tue, 26 Jun 2001 13:02:24 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: untie attempted while 1 inner references still exist
Message-Id: <3B3879D0.5DB4D979@salford.ac.uk>



Anno Siegel wrote:
> 
> According to Mark Grimshaw  <m.grimshaw@salford.ac.uk>:
> > Hi,
> >
> > I'm getting the following warning with use diagnostics and use Carp:
> >
> > untie attempted while 1 inner references still exist at
> >         /usr/local/apache/docs/music/cgi-bin/q3aforum/logon.cgi line 206
> > (#1)
> >
> >     (W) A copy of the object returned from tie (or tied) was still
> >     valid when untie was called.
> 
> [snip most of code]
> 
> > sub open_user_db
> > {
> >         if(!($dbobj = q_open_db(\%USER, $q_userdb, $_[0])))
> 
> If the return value from q_open_db is what I suspect it to be,
> this is the crucial point:  You are keeping a copy of the under-
> lying object in $dbobj.  When untie() wants to destroy this object,
> the warning results.  Undef $dbobj before untie(), or, better,
> let it go out of scope.  Do you actually need it at all?
> 
> Anno


That's done it - thanks.  I need the return for $dbobj->sync();


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

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


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