[23657] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5864 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 27 06:05:53 2003

Date: Thu, 27 Nov 2003 03:05:08 -0800 (PST)
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, 27 Nov 2003     Volume: 10 Number: 5864

Today's topics:
        .*? instad of .* (Zhidian Du)
    Re: .*? instad of .* <bigiain@mightymedia.com.au>
    Re: .*? instad of .* Default@IO_Error_1011101.xyz
    Re: .*? instad of .* <noreply@gunnar.cc>
    Re: .*? instad of .* <tassilo.parseval@rwth-aachen.de>
    Re: .*? instad of .* <tassilo.parseval@rwth-aachen.de>
        Configuring Perl for Linux 8 (Ryan Ritten)
    Re: Configuring Perl for Linux 8 <thepoet_nospam@arcor.de>
    Re: Configuring Perl for Linux 8 <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: creating unix-like text files in windows <huppu1@ROSKAPOSTI.yahoo.com>
        Curses %$#@! Default@IO_Error_1011101.xyz
    Re: Does alarm work on w2k? (Anno Siegel)
        floating point <eddhig22@yahool.com>
    Re: floating point <josef.moellers@fujitsu-siemens.com>
    Re: floating point <bernard.el-haginDODGE_THIS@lido-tech.net>
    Re: floating point (Anno Siegel)
    Re: floating point (Jay Tilton)
        How to create a DBM database in Perl (Topher)
    Re: keeping anonymous hash sorted <eddhig22@yahool.com>
    Re: mod_perl (Rafael Garcia-Suarez)
    Re: Regex Question (max)
    Re: Unexpected tell() result (Malcolm Dew-Jones)
    Re: went to 5.8.1 and now my while statement fails (Rafael Garcia-Suarez)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 26 Nov 2003 21:37:31 -0800
From: zdu@cs.nmsu.edu (Zhidian Du)
Subject: .*? instad of .*
Message-Id: <e4c69a32.0311262137.20008a75@posting.google.com>

I read a program that strip tags of html

while(<>){

  s/<.*?>//gs

}

I am courious why it uses .*?, not .*


Another question, while(<>) read one line at a time or a couple lines of a time?  
How do I know it?


Thanks.

Z. Du


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

Date: Thu, 27 Nov 2003 17:07:50 +1100
From: Iain Chalmers <bigiain@mightymedia.com.au>
Subject: Re: .*? instad of .*
Message-Id: <bigiain-8C3A70.17075027112003@news.fu-berlin.de>

In article <e4c69a32.0311262137.20008a75@posting.google.com>,
 zdu@cs.nmsu.edu (Zhidian Du) wrote:

> I read a program that strip tags of html
> 
> while(<>){
> 
>   s/<.*?>//gs
> 
> }
> 
> I am courious why it uses .*?, not .*

Because .* will strip a _lot_ more than just tags - compare the outputs 
of these:

perl -e '$_="<h1>a heading</h1>";s/<.*>//gs;print'

perl -e '$_="<h1>a heading</h1>";s/<.*?>//gs;print'

of course this perfectly valid html comment tag:

some text <!-- this is a comment with a > in it --> some more text

breaks .*? too...

 ...the _real_ answer is - you can't (reliably) use a regex to parse 
(arbitrary) html - if you want to parse html, use a real parser that 
knows about html... Start with HTML::Parser or similar...

cheers,

big

-- 
'When I first met Katho, she had a meat cleaver in one hand and
half a sheep in the other. "Come in", she says, "Hammo's not here.
I hope you like meat.' Sharkey in aus.moto


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

Date: Thu, 27 Nov 2003 06:18:04 GMT
From: Default@IO_Error_1011101.xyz
Subject: Re: .*? instad of .*
Message-Id: <wGgxb.3480$lF6.2341@nwrdny01.gnilink.net>

> I read a program that strip tags of html
>   s/<.*?>//gs
> I am courious why it uses .*?, not .*

The ? makes the * non greedy.
Im not sure how to explain it exactly though.

 .* means zero or more of any character except newline, but prefer more.
 .*? means the same but dont prefer the or more part.

I think that regex means:
substitute
<
followed by zero or more non newline chars
but dont prefer more over zero
followed by >

I am new to programming so check with more experienced posters.


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

Date: Thu, 27 Nov 2003 08:10:11 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: .*? instad of .*
Message-Id: <bq481h$1t412h$1@ID-184292.news.uni-berlin.de>

Zhidian Du wrote:
> I read a program that strip tags of html
> 
> while(<>){
> 
>   s/<.*?>//gs
> 
> }
> 
> I am courious why it uses .*?, not .*

That is a FAQ.

     perldoc -q greedy

> Another question, while(<>) read one line at a time or a couple
> lines of a time? How do I know it?

Read about $. and $/ in

     perldoc perlvar

Please learn to study the FAQ and the rest of the docs. The
documentation is part of the Perl distribution, and also available on
line, e.g. at

     http://www.perldoc.com/

More about how to post here at
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 27 Nov 2003 08:14:45 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: .*? instad of .*
Message-Id: <bq4bpl$8l8$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Default@IO_Error_1011101.xyz:

>> I read a program that strip tags of html
>>   s/<.*?>//gs
>> I am courious why it uses .*?, not .*
> 
> The ? makes the * non greedy.

Yup, greediness is the technical term here.

> Im not sure how to explain it exactly though.
> 
> .* means zero or more of any character except newline, but prefer more.

Not quite. In the substitution

    s/<.*?>//gs

the /s modifier will make the dot '.' also match newlines. So this
pattern then reads:

Substitute '<' followed by an arbitrary amount of arbitrary characters
up to the _first_ occurance of '>'.

If we have a greedy pattern

    s/<.*>//gs

this becomes:

Substitute '<' followed by an arbitrary amount of arbitrary characters
up the _last_ occurance of '>'.
    
Note that 

    s/<.*?>//gs;

could also be written as

    s/<[^>]>//g

Does the same but would read:

Substitute '<' followed by an arbitrary amount of characters _other_than_
'>'. So once it encounters a '>' the regex is done extracting the
substring.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 27 Nov 2003 08:24:23 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: .*? instad of .*
Message-Id: <bq4cbn$961$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Gunnar Hjalmarsson:

> Zhidian Du wrote:

>> Another question, while(<>) read one line at a time or a couple
>> lines of a time? How do I know it?
> 
> Read about $. and $/ in
> 
>      perldoc perlvar
> 
> Please learn to study the FAQ and the rest of the docs. 

perlvar.pod is probably not the expected spot to look for that.
Actually, it's pretty hard to figure out where to find information on

    while (<>)

when being new to perl. My first guess was perlsyn.pod but it is in fact
to be found in perlop.pod. You might even need both: First perlsyn.pod
to find out that 'while' works on an expression (so it's not
while(LIST)) which is evaluated in scalar context and after that,
figuring out what '<>' does in scalar context with the help of
perlop.pod.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 26 Nov 2003 22:35:31 -0800
From: sparticusREMOVE@thesparticusarena.com (Ryan Ritten)
Subject: Configuring Perl for Linux 8
Message-Id: <f4d27a4f.0311262235.5c4b9080@posting.google.com>

Hello,

I have perl installed on my linux 8 box.  I wrote a quick script that
prints would the word hello is you type this from the command line :

"perl test.pl"

now the weird thing is that when I go to my browser and point it at
"test.pl" (that file btw is on my website)... it doesn't print the
word hello... it instead prints out "all" the code in the file.  So
essentially it doesn't execute the perl script... it just displas it
on the screen

Now I am almost 100% positive this has soemthign to do with a
misconfigured httpd.conf file... but I went into it and it seems to
have the line where the perl module is loaded "not" commented out...
so it should load.

I did restart httpd....  is there something I'm missing in httpd.conf?
 Why doens't httpd not execute the script when that file is requested?

any help at all would be greatly appreciated!!!!

-Ryan Ritten


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

Date: Thu, 27 Nov 2003 08:18:46 +0100
From: "Christian Winter" <thepoet_nospam@arcor.de>
Subject: Re: Configuring Perl for Linux 8
Message-Id: <3fc5a557$0$20223$9b4e6d93@newsread2.arcor-online.net>

"Ryan Ritten" <sparticusREMOVE@thesparticusarena.com> wrote:
> Hello,
> 
> I have perl installed on my linux 8 box. 
Hi,

there is no such thing like a "linux 8". This is
your distributions version number.

> I wrote a quick script that
> prints would the word hello is you type this from the command line :
> 
> "perl test.pl"
> 
> now the weird thing is that when I go to my browser and point it at
> "test.pl" (that file btw is on my website)... it doesn't print the
> word hello... it instead prints out "all" the code in the file.  So
> essentially it doesn't execute the perl script... it just displas it
> on the screen

That's a FAQ.

> Now I am almost 100% positive this has soemthign to do with a
> misconfigured httpd.conf file... but I went into it and it seems to
> have the line where the perl module is loaded "not" commented out...
> so it should load.

So why do you ask in a Perl newsgroup? It's a problem
of your webserver config. You don't even write which
webserver you are running.

> I did restart httpd....  is there something I'm missing in httpd.conf?
>  Why doens't httpd not execute the script when that file is requested?

I'm almost 200% sure google would have helped you
solve your problem within 5 minutes. I tried
http://www.google.com/search?q=configure+apache+perl+cgi
and the first hit lead to a solution for the apache
webserver.

> any help at all would be greatly appreciated!!!!

HTH
-Christian



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

Date: Wed, 26 Nov 2003 23:25:32 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Configuring Perl for Linux 8
Message-Id: <ct84qb.m5c.ln@goaway.wombat.san-francisco.ca.us>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

On 2003-11-27, Ryan Ritten <sparticusREMOVE@thesparticusarena.com> wrote:
>
> I have perl installed on my linux 8 box.

Linux 8 is out?  Wow, that's fast coding from the latest 2.4 stable.

> now the weird thing is that when I go to my browser and point it at
> "test.pl" (that file btw is on my website)... it doesn't print the
> word hello... it instead prints out "all" the code in the file.  So
> essentially it doesn't execute the perl script... it just displas it
> on the screen
>
> Now I am almost 100% positive this has soemthign to do with a
> misconfigured httpd.conf file.

It is.  I'd ask your question someplace relevant to Apache, since your
question really has little to do with Perl.  Try the Apache web site or
the newsgroup comp.infosystems.www.servers.unix.

- --keith

- -- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/xabrhVcNCxZ5ID8RAt/+AJ0Z/YR5TO8UadmxSkx92xJ9Y0dY4ACfecWL
U8KOiKHB4fnqHdQpKMTCM0s=
=q7gy
-----END PGP SIGNATURE-----


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

Date: Thu, 27 Nov 2003 12:17:50 +0200
From: "Huppu" <huppu1@ROSKAPOSTI.yahoo.com>
Subject: Re: creating unix-like text files in windows
Message-Id: <3fc5d010@usenet01.boi.hp.com>

binmode helped, thank you for advices.

<-_->




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

Date: Thu, 27 Nov 2003 05:05:24 GMT
From: Default@IO_Error_1011101.xyz
Subject: Curses %$#@!
Message-Id: <oCfxb.3216$lF6.2555@nwrdny01.gnilink.net>

<cry>
Not getting any sort of error at all, the program just ends.  0_o
Exporter and DynaLoader are both installed.
Curses is installed properly.

If i run the program from the debugger these messeges appear.

Subroutine bits redefined at C:/Perl/lib/Strict.pm line 101.
Subroutine import redefined at C:/Perl/lib/Strict.pm line 107.
Subroutine unimport redefined at C:/Perl/lib/Strict.pm line 112.
Subroutine Croaker redefined at C:/Perl/lib/Warnings.pm line 292.
Subroutine bits redefined at C:/Perl/lib/Warnings.pm line 298.
Subroutine import redefined at C:/Perl/lib/Warnings.pm line 330.
Subroutine unimport redefined at C:/Perl/lib/Warnings.pm line 368.
Subroutine __chk redefined at C:/Perl/lib/Warnings.pm line 396.
Subroutine enabled redefined at C:/Perl/lib/Warnings.pm line 444.
Subroutine warn redefined at C:/Perl/lib/Warnings.pm line 457.
Subroutine warnif redefined at C:/Perl/lib/Warnings.pm line 470.

Here is the script, I'm only using curses to try and clean up the display.
Please help this is way over my newbie head.

#!
use Strict;
use Warnings;
use Curses;
use Socket;
initscr;
$| = 1;

my ($internet_addr, $paddr, $remote_port, $remote_host, $kidpid1,
    $kidpid2, $kidpid3, @ports_even1, @ports_odd1, @ports_even2,
    @ports_odd2,);
my $counter = 1;
my $p_e_loader1 = 2;
my $p_o_loader1 = 1;
my $p_e_loader2 = 514;
my $p_o_loader2 = 513;
print "\n" . ' ' . '='x78 . "\n";
print "\t\t\t\tPort Scanner\n";
print ' ' . '='x78 . "\n\n";

while ($counter <= 256)
{
    push (@ports_even1, $p_e_loader1);
    $p_e_loader1++;$p_e_loader1++;
    $counter++;
    if ($counter >= 250) {print "\n@ports_even1\n";my $pause = <STDIN>;}
}
$counter = 1;
while ($counter <= 256)
{
    push (@ports_odd1, $p_o_loader1);
    $p_o_loader1++;$p_o_loader1++;
    $counter++;
}
$counter = 1;
while ($counter <= 256)
{
    push (@ports_even2, $p_e_loader2);
    $p_e_loader2++;$p_e_loader2++;
    $counter++;
}
$counter = 1;
while ($counter <= 256)
{
    push (@ports_odd2, $p_o_loader2);
    $p_o_loader2++;$p_o_loader2++;
    $counter++;
}
undef $counter;

#resolve targets address
$remote_host = shift || 'localhost';
$internet_addr = inet_aton($remote_host) ||
    die "Couldn't resolve $remote_host"."'s address\n($!)\n($^E)*";

#create two processes
die "can't fork\n($!)\n($^E)\n*" unless defined($kidpid1 = fork());

if ($kidpid1) #first parent process
{
    foreach $remote_port (@ports_even1)
    {
        my $win = new Curses;
        $win->addstr(10, 1, "$remote_port");
        $win->refresh;
#        print "\b\b\b\b    \b\b\b\b";
#        print "$remote_port";
        socket(SOCK_OUT, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
        $paddr = sockaddr_in($remote_port, $internet_addr);
        if (connect(SOCK_OUT, $paddr))
            {print "\nPort: $remote_port is open.\n";}
        eval
        {
            local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
            alarm 1;
            close(SOCK_OUT);
            alarm 0;
        };
    }
}
else #first child process
{
    #create a third process
    die "can't fork\n($!)\n($^E)\n*" unless defined($kidpid2 = fork());
    if ($kidpid2) #second parent process
    {
        foreach $remote_port (@ports_odd1)
        {
        my $win = new Curses;
        $win->addstr(10, 11, "$remote_port");
        $win->refresh;
#        print "\b\b\b\b    \b\b\b\b";
#        print "$remote_port";
            socket(SOCK_OUT, PF_INET, SOCK_STREAM,
                   getprotobyname('tcp'));
            $paddr = sockaddr_in($remote_port, $internet_addr);
            if (connect(SOCK_OUT, $paddr))
                {print "\nPort: $remote_port is open.\n";}
            eval
            {
                local $SIG{ALRM} = sub { die "alarm\n" };
                alarm 1;
                close(SOCK_OUT);
                alarm 0;
            };
        }
    }
    else #second child process
    {
        #create a fourth process
        die "can't fork\n($!)\n($^E)\n*" unless defined($kidpid3=fork());
        if ($kidpid3) #third parent process
        {
            foreach $remote_port (@ports_even2)
            {
                my $win = new Curses;
                $win->addstr(10, 21, "$remote_port");
                $win->refresh;
#               print "\b\b\b\b    \b\b\b\b";
#               print "$remote_port";
                socket(SOCK_OUT, PF_INET, SOCK_STREAM,
                       getprotobyname('tcp'));
                $paddr = sockaddr_in($remote_port, $internet_addr);
                if (connect(SOCK_OUT, $paddr))
                    {print "\nPort: $remote_port is open.\n";}
                eval
                {
                    local $SIG{ALRM} = sub { die "alarm\n" };
                    alarm 1;
                    close(SOCK_OUT);
                    alarm 0;
                };
            }
        }
        else
        {
            foreach $remote_port (@ports_odd2)
            {
                my $win = new Curses;
               $win->addstr(10, 31, "$remote_port");
               $win->refresh;
#               print "\b\b\b\b    \b\b\b\b";
#               print "$remote_port";
                socket(SOCK_OUT, PF_INET, SOCK_STREAM,
                       getprotobyname('tcp'));
                $paddr = sockaddr_in($remote_port, $internet_addr);
                if (connect(SOCK_OUT, $paddr))
                    {print "\nPort: $remote_port is open.\n";}
                eval
                {
                    local $SIG{ALRM} = sub { die "alarm\n" };
                    alarm 1;
                    close(SOCK_OUT);
                    alarm 0;
                };
            }
        }
    }
}
endwin;
kill("TERM", $kidpid1);
kill("TERM", $kidpid2);
kill("TERM", $kidpid3);
print "\nDone.\n" && exit;





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

Date: 27 Nov 2003 10:31:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Does alarm work on w2k?
Message-Id: <bq4jp9$il$1@mamenchi.zrz.TU-Berlin.DE>

 <Default@IO_Error_1011101.xyz> wrote in comp.lang.perl.misc:
> > 
> > 
> > Default@IO_Error_1011101.xyz wrote:
> > > For some reason the script seems to do the same thing with
> > > or without the alarm thing in there.  Does this alarm work on w2k?
> > 
> > No.  You can always check the perlport perldoc to see if something is 
> > not implemented completely or at all for your platform.
> > 
> > 
> ahhh thanks.. didnt know about perlport.
> alarm   Not implemented. (Win32)
> 
> any ideas about the display issues?

You posted 150 lines of code with nothing but a leading comment about alarm.
What display issues?

Anno


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

Date: Thu, 27 Nov 2003 21:48:09 +1100
From: Edo <eddhig22@yahool.com>
Subject: floating point
Message-Id: <3FC5D669.5090403@yahool.com>

Hello
why my sub cal which is suppose to return 0.879222 when it is
my $ca = cal (\@abc, \@xyz);
$ca returns 1.

how can I get it to return whatever the exact value the sub calculates?

thanks



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

Date: Thu, 27 Nov 2003 11:50:22 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: floating point
Message-Id: <3FC5D6EE.C8235217@fujitsu-siemens.com>

Edo wrote:
> =

> Hello
> why my sub cal which is suppose to return 0.879222 when it is
> my $ca =3D cal (\@abc, \@xyz);
> $ca returns 1.
> =

> how can I get it to return whatever the exact value the sub calculates?=


How are we to tell?
What does your sub look like?
How do you know it returns 1?

Too many questions, too little information ...

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Thu, 27 Nov 2003 10:53:33 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: floating point
Message-Id: <Xns944078AD46F83elhber1lidotechnet@62.89.127.66>

Edo <eddhig22@yahool.com> wrote in news:3FC5D669.5090403@yahool.com:

> Hello
> why my sub cal which is suppose to return 0.879222 when it is
> my $ca = cal (\@abc, \@xyz);
> $ca returns 1.
> 
> how can I get it to return whatever the exact value the sub calculates?


my $ca = 0.879222;


-- 
Cheers,
Bernard


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

Date: 27 Nov 2003 10:53:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: floating point
Message-Id: <bq4l3d$il$2@mamenchi.zrz.TU-Berlin.DE>

Edo  <eddhig22@yahool.com> wrote in comp.lang.perl.misc:
> Hello
> why my sub cal which is suppose to return 0.879222 when it is
> my $ca = cal (\@abc, \@xyz);
> $ca returns 1.

How about introducing us to "your sub cal"?

> how can I get it to return whatever the exact value the sub calculates?

It does.  It doesn't calculate what you think it does.

The solution to your problem may be in "perldoc -q number".

Anno


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

Date: Thu, 27 Nov 2003 11:00:11 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: floating point
Message-Id: <3fc5d753.365788787@news.erols.com>

Edo <eddhig22@yahool.com> wrote:

: why my sub cal which is suppose to return 0.879222 when it is
: my $ca = cal (\@abc, \@xyz);
: $ca returns 1.
: 
: how can I get it to return whatever the exact value the sub calculates?

How do you expect anybody to figure out what is wrong with the code unless
they can see the code?  Show that cal() subroutine.

This is certainly not a problem with floats.  Perl treats all numbers as
floats.  Perl doesn't just arbitrarily convert 0.879222 to 1 .

For a blind guess, cal() is probably trying to return an array, but you're
using it in scalar context, e.g.

    sub cal {
        my @stuff = 0.879222;
        return @stuff;
    }
    my $ca = cal();
    print $ca;



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

Date: 27 Nov 2003 02:46:08 -0800
From: chris@mkttl.co.uk (Topher)
Subject: How to create a DBM database in Perl
Message-Id: <f4487ccf.0311270246.5a82a5c@posting.google.com>

Hi,

I would appreciate some help with this. I am trying to create an admin
section for my local table tennis (yes, it's a manly sport I know...)
site and am having trouble creating any databases.

The code I have for doing this is as follows:

## write

dbmopen (%clubs, $const_database_path."clubs", 0666);

die("club id already exists!") if ($clubs{$club_id} ne "");

$clubs{$club_id} = $club_name."§".$club_short_name."§".$club_location1."§".$club_location2."§".$club_location3."§".$club_location4."§".$club_postcode."§".$club_map_href."§".$club_map_text."§".$club_website_href."§".$club_notes."§".$club_secretary_name."§".$club_secretary_add1."§".$club_secretary_add2."§".$club_secretary_add3."§".$club_secretary_add4."§".$club_secretary_postcode."§".$club_secretary
home_tel."§".$club_secretary_mobile_tel."§".$club_secretary_work_tel."§".$club_secretary_email;


dbmclose (%clubs);


I'm not too hot on this Perl business and am basically winging it with
a bit of help from a mate every now and again, but can't seem to find
anything that shows why this is not happening. I have a file
'mkttl.conf', which is linked to earlier on in the script using
require("mkttl.conf");

In mkttl.conf I define $const_database_path as
$ENV{"SITE_ROOT"}."\mkttl_concept\databases\"

I have created the databases directory, so there should be no problems
there.

I'm not getting error messages, it's just not working - annoying as
hell!

If it's any use I am using Xitami, which is the server that I have
downloaded to test scripts on before I upload stuff.

Thanks very much, if you need any more info please ask!


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

Date: Thu, 27 Nov 2003 22:00:33 +1100
From: Edo <eddhig22@yahool.com>
Subject: Re: keeping anonymous hash sorted
Message-Id: <3FC5D951.601@yahool.com>

Jay Tilton wrote:
> "Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote:
> 
> : Edo <eddhig22@yahool.com> wrote in news:3FC502EF.40103@yahool.com:
> : 
> : > Hello
> : > 
> : > I have been using Tie::IxHash to keep my hash sorted but now
> : ...
> : > the $ky is not sorted. how can I keep them sorted in this case?
> : 
> : Why do you feel you need to *keep* it sorted?  Nearly always, one doesn't 
> : care about the order of keys until one prints out the structure.
> 
> Extending that, if the hash _does_ need to stay sorted, maybe it shouldn't
> be a hash at all.  Having following the OP's progress on his code, I'm
> starting to doubt seriously whether hashes are appropriate.
> 
> The code emphasizes the sorted-ness of the hash than the hash-ness of the
> hash.  That is, a hash is used because it pairs one string with another,
> not because it's handy for finding the value associated with a key or
> ensuring the uniqueness of the keys.
> 
> The code never treats values independently of the keys--when it copies a
> set of values from one hash to another, it _always_ copies the keys too.
> 
> Maybe an array-of-arrays where each referenced array holds one key/value
> pair would be more appropriate than a hash.  That is, instead of
> 
>     %d = ( foo => 'a', bar => 'b', baz => 'c' );
> 
> it would have
> 
>     @d = ( [foo => 'a'], [bar => 'b'], [baz => 'c'] );
> 

maybe, I am not sure, over my head. my brain is allready stratched with 
the code below to try to change unless for very good reasons.

the sub check must have the correct order or sort of the keys.

sub scan ($\%\%\%) {
     my ($file, $dbits, $sbits, $set) = @_;
     my @kd = sort {$a <=> $b} (keys %$dbits);
     my @ks = sort {$a <=> $b} (keys %$sbits);
     my @vs = @$sbits{ @ks };
     for( 0 .. (@kd - @ks) ) {
         my @kdslic =  @kd[$_ .. $_+@ks-1 ];
         my @vdslic = @$dbits{@kdslic};
         my $tmp = check( \@vdslic, \@vs );
         my $sym = $1 if ($file =~/.+\/(\w+)\./);
         my @k = keys %$set;
         my $max = (sort {$b <=> $a} @k)[0] || 0;
         if (( $tmp > $max )||($tmp == 1)) {
#            tie my (%slic), 'Tie::IxHash';
#            tie %{$slic{$sym}}, 'Tie::IxHash';
             foreach my $ky ( @kdslic ){
                 $slic{$sym}{$ky} = $$dbits{$ky};
             }
             $#{$set{1}} == $enf ? return $set : push 
@{$set->{$tmp}},\%slic;
         }
     }
}

now how can I print the %set with all its keys and sub-keys sorted if I 
don't use tie at each level?



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

Date: 27 Nov 2003 09:39:56 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: mod_perl
Message-Id: <slrnbsbhe3.ub1.rgarciasuarez@rafael.serd.lyon.hexaflux.loc>

Lenny Challis wrote:
>hiya everyone, I've been learning perl for a while now and want to get into
>mod_perl after so many great reviews.
>
>Tell me, what is the best way to "learn" or atleast understand how mod_perl
>works? I have seen mod_perl o'reilly books, but cant afford them :(

http://perl.apache.org/ has lots of good docs and tutorials.

-- 
Undeclared is not *NIX


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

Date: 27 Nov 2003 03:01:59 -0800
From: hjkmax@netscape.net (max)
Subject: Re: Regex Question
Message-Id: <95401f7d.0311270301.5deffa49@posting.google.com>

How do I deal with escaped backslash in patterns?
Hope the is some light out there...
I want to match (dublequote anything dublequote) followd by equels 
like ("something"=something)

here are some of the problem pattern

"=\"=\"=\""="=\"=\"=\"" "\\\\\\\\\\"="\\\\\\\\\\" "==="="==="            

This is what I have so far.
I just don't seem to be able to match the no \ before "= unless the are two \\
I seem to be able to do one pattern but not all of them!
 
              m/
              ^"          #begining of line duble quote
              (.*?        #anything minimul match
              )
              (?:(?<!\\)   #( exept before a back slash
               "=)        #  a duble quote followed by a equal sign)
              (.*)        #anything after
              /x ;
     or
             m/
              ^"        #begining of line duble quote
              (.*?       #anything minimul match
              )
             (?:     #exept before a back slash
               "=)       #a duble quote folowed by a equal sign
              (.*)      #anything after
              /x ;

Sorry about the unclarity of the mess
Thanks
Max


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

Date: 26 Nov 2003 23:20:22 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Unexpected tell() result
Message-Id: <3fc5a5b6@news.victoria.tc.ca>

Eric J. Roode (REMOVEsdnCAPS@comcast.net) wrote:
: -----BEGIN xxx SIGNED MESSAGE-----
: Hash: SHA1

: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote in
: news:3fc53538@news.victoria.tc.ca: 

: > No, I'm just suggesting (after thinking about various possible
: > scenarios) that there is no reason to expect the value of tell to have
: > any particular value when the file is opened in append mode.

: Oh right, of course.  tell() only makes sense on files that are opened for 
: read.

or regular write mode, because the write is going to occur at the current
file pointer location.


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

Date: 27 Nov 2003 09:50:06 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: went to 5.8.1 and now my while statement fails
Message-Id: <slrnbsbi13.ub6.rgarciasuarez@rafael.serd.lyon.hexaflux.loc>

pui ming Wong wrote:
>My script which worked under 5.6.1 failed after I upgraded
>to 5.8

Which version ? Which OS ?

>The loop codes that failed is as below:
>The print count line statement never gets printed at all; why?

Probably because $msg is undefined, empty or "0" ?
Since you didn't provide the full source, or (better) the full
source trimmed down to a small example that demonstrates the
problem, it's difficult to figure out what's wrong.

> # read each message in turn
>
>  while( $msg = &read_message ) {
>    $count++;
> print "count line is $count";
>      }

>require "getopts.pl";   # option handling
>require "timelocal.pl";   # time conversion
>require "ctime.pl";   # ctime for pseudo-mailing
>require "stat.pl";   # file status
>
>Any change to these after upgrade to 5.8 ?
>that could be responsible for the failure of my old script?

No. the *.pl old-style libs are provided only for compatibility
with perl 4 scripts and are not maintained or modified anymore.
(I wonder if we shouldn't get rid of them completely, but, as
your code proves, there's still some perl 4-style code running
out there.)

The list of changes between 5.6.x and 5.8.x is outlined in the
perldelta manpage.

-- 
Ultra is not *NIX


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

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


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