[23656] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5863 Volume: 10

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

Date: Wed, 26 Nov 2003 21: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)

Perl-Users Digest           Wed, 26 Nov 2003     Volume: 10 Number: 5863

Today's topics:
        Does alarm work on w2k? Default@IO_Error_1011101.xyz
    Re: Does alarm work on w2k? Default@IO_Error_1011101.xyz
    Re: Does alarm work on w2k? <l0g0m0tion@earthlink.net>
    Re: Does alarm work on w2k? Default@IO_Error_1011101.xyz
    Re: execute debugger commands at startup (Peter Scott)
        Help on TCL Lists (RACHAK)
    Re: Help on TCL Lists (William Herrera)
    Re: keeping anonymous hash sorted (Geraldo)
    Re: keeping anonymous hash sorted (Jay Tilton)
        Mac OS 10.3, perl 5.8.2, library problem: modules not s (Randall Perry)
        mod_perl <ned@challis2000.fsnet.co.uk>
        module load question <camattern@acm.org>
    Re: module load question <bigiain@mightymedia.com.au>
    Re: Perl Editor (krakle)
    Re: Perl Regex - Hex bytes <enon@erewhon.com>
    Re: Perl Regex - Hex bytes <usenet@morrow.me.uk>
        Problem writing byte values to a file <gregory_deal@hotmail.com>
    Re: Problem writing byte values to a file (John Stanley)
    Re: store  password  in a module ? (Malcolm Dew-Jones)
    Re: store  password  in a module ? (Sam Holden)
    Re: store  password  in a module ? <usenet@morrow.me.uk>
    Re: store  password  in a module ? (Malcolm Dew-Jones)
    Re: store  password  in a module ? (Qiang)
    Re: Unexpected tell() result (Malcolm Dew-Jones)
    Re: Unexpected tell() result <REMOVEsdnCAPS@comcast.net>
        went to 5.8.1 and now my while statement fails (pui ming Wong)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 26 Nov 2003 23:45:16 GMT
From: Default@IO_Error_1011101.xyz
Subject: Does alarm work on w2k?
Message-Id: <gWaxb.648$i81.504@nwrdny02.gnilink.net>

Hi, i just started programming a month ago.
I know almost nothing... any sort of help with this script
would be excellent.

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?

Also although i may be able to work this out eventually, any tips on
how to display the current port in a more effective way would be very
helpfull.

Here is the script.

#!
use strict;
use warnings;
use Socket;
$| = 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)
    {
        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)
        {
            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)
            {
                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)
            {
                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;
                };
            }
        }
    }
}
kill("TERM", $kidpid1);
kill("TERM", $kidpid2);
kill("TERM", $kidpid3);
print "\nDone.\n" && exit;


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

Date: Thu, 27 Nov 2003 00:09:41 GMT
From: Default@IO_Error_1011101.xyz
Subject: Re: Does alarm work on w2k?
Message-Id: <9hbxb.789$lF6.512@nwrdny01.gnilink.net>

Sorry this line should be commented out: LINE 24

>     if ($counter >= 250) {print "\n@ports_even1\n";my $pause = <STDIN>;}

Was using that for debugging.


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

Date: Thu, 27 Nov 2003 00:57:17 GMT
From: Christopher Shatto <l0g0m0tion@earthlink.net>
Subject: Re: Does alarm work on w2k?
Message-Id: <NZbxb.20988$Rk5.18616@newsread1.news.atl.earthlink.net>



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.



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

Date: Thu, 27 Nov 2003 02:10:22 GMT
From: Default@IO_Error_1011101.xyz
Subject: Re: Does alarm work on w2k?
Message-Id: <i2dxb.965$i81.230@nwrdny02.gnilink.net>

> 
> 
> 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?


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

Date: Thu, 27 Nov 2003 00:34:15 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: execute debugger commands at startup
Message-Id: <bEbxb.504282$9l5.472368@pd7tw2no>

In article <1069808906.934751@sj-nntpcache-3>,
 "Yuri Shtil" <yshtil@cisco.com> writes:
>The GNU debugger gdb has an excellent feature that allows to place the
>debugger commands in a file (.gdbinit) and have them executed by the
>debugger at startup.
>This way one can set various options, breakpoints etc thus saving time on
>typing.
>
>I wonder if something like that is possible with perldb. The .perldb file
>can only contain perl code, not debugger commands.

This is why I added the 'source' command to the debugger, which
allows you to execute a file containing debugger commands.
Comes with Perl 5.8.0 onwards.

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http//www.perlmedic.com/


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

Date: 26 Nov 2003 16:48:41 -0800
From: sitaramr@yahoo.com (RACHAK)
Subject: Help on TCL Lists
Message-Id: <f2800baa.0311261648.25163ba6@posting.google.com>

InPut File
============
BUCKET|Drawing Type|Assembly|Stage|1|GTTBRG001_ASM|
BUCKET|Drawing Type|Machining|Stage|2|GTTBRG002|
LOCKING BUCKET|Drawing Type|Machining|Stage|3|GTTBRG003|
NOZZLE TURBINE|Drawing Type|Assembly|Stage|3|GTTBSG003_ASM|
NOZZLE TURBINE|Drawing Type|Machining|Stage|3|GTTBSG003|
STUB SHAFT COMPRESSOR|Drawing
Type|Machining|Stage|0|LOCATION|FWD|GTCPRO000|
COMPRESSOR|Drawing Type|Machining|Stage|1|LOCATION|FWD|SUB
LOCATION|FWD1|GTTCRX001|


The above data is in a input file, will be dynamic, can change over a
period and more Key Value pairs can be added

File Description:
First Column is Header Info for each record              Example:
COMPRESSOR
Last Column is  the Final Value that has to be returned.      EXAMPLE:
GTTCRX001

Remaining Columns are represented/used as Key Value Pairs. 
Expample: 
Drawing Type, Machining
Stage,1
LOCATION,FWD
SUB LOCATION, FDW1
We can add any number of Key Value pairs for each record. 


Help:
Can some one provide me a solution for doing this task.

Read the File & For each record ( combination of First & Last Column 
: get all the Key Value Pairs )
Check this key value pairs exists in a list "INLIST" and if all the
Key Value Pairs are found Return the last Column


INLIST: ( Is not a file but output of another Process )
{COMPRESSOR-> Drawing Type->Machining->Linear
Assembly->BKT->Stage->1->LOCATION->FWD1->SUB
LOCATION->FWD1->CAP->Assembly }

Example:

Drawing Type->Machining ( Key Value Match found for Column1=COMPRESSOR
 when compared between INLIST and input File )
+
Stage->1 ( Key Value Match for Column1=COMPRESSOR  when compared
between INLIST and input File )
+
LOCATION->FWD1 ( Key Value Match for Column1=COMPRESSOR  when compared
between INLIST and input File )
+
SUB LOCATION->FWD1 ( Key Value Match for Column1=COMPRESSOR  when
compared between INLIST and input File )

Since all the 4 Key Value Pairs exists in the "INLIST"  

Retrun Last Column from InputFile "GTTCRX001"


Thanks in Advance
RACHAK


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

Date: Thu, 27 Nov 2003 02:54:49 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: Help on TCL Lists
Message-Id: <3fc56722.435558377@news2.news.adelphia.net>

On 26 Nov 2003 16:48:41 -0800, sitaramr@yahoo.com (RACHAK) wrote:

>InPut File
>============
>BUCKET|Drawing Type|Assembly|Stage|1|GTTBRG001_ASM|
>BUCKET|Drawing Type|Machining|Stage|2|GTTBRG002|
>LOCKING BUCKET|Drawing Type|Machining|Stage|3|GTTBRG003|
>NOZZLE TURBINE|Drawing Type|Assembly|Stage|3|GTTBSG003_ASM|
>NOZZLE TURBINE|Drawing Type|Machining|Stage|3|GTTBSG003|
>STUB SHAFT COMPRESSOR|Drawing
>Type|Machining|Stage|0|LOCATION|FWD|GTCPRO000|
>COMPRESSOR|Drawing Type|Machining|Stage|1|LOCATION|FWD|SUB
>LOCATION|FWD1|GTTCRX001|
>
>
>The above data is in a input file, will be dynamic, can change over a
>period and more Key Value pairs can be added
>
>File Description:
>First Column is Header Info for each record              Example:
>COMPRESSOR
>Last Column is  the Final Value that has to be returned.      EXAMPLE:
>GTTCRX001
>
>Remaining Columns are represented/used as Key Value Pairs. 
>Expample: 
>Drawing Type, Machining
>Stage,1
>LOCATION,FWD
>SUB LOCATION, FDW1
>We can add any number of Key Value pairs for each record. 
>
>
>Help:
>Can some one provide me a solution for doing this task.
>
>Read the File & For each record ( combination of First & Last Column 
>: get all the Key Value Pairs )
>Check this key value pairs exists in a list "INLIST" and if all the
>Key Value Pairs are found Return the last Column
>
>
>INLIST: ( Is not a file but output of another Process )
>{COMPRESSOR-> Drawing Type->Machining->Linear
>Assembly->BKT->Stage->1->LOCATION->FWD1->SUB
>LOCATION->FWD1->CAP->Assembly }
>
>Example:
>
>Drawing Type->Machining ( Key Value Match found for Column1=COMPRESSOR
> when compared between INLIST and input File )
>+
>Stage->1 ( Key Value Match for Column1=COMPRESSOR  when compared
>between INLIST and input File )
>+
>LOCATION->FWD1 ( Key Value Match for Column1=COMPRESSOR  when compared
>between INLIST and input File )
>+
>SUB LOCATION->FWD1 ( Key Value Match for Column1=COMPRESSOR  when
>compared between INLIST and input File )
>
>Since all the 4 Key Value Pairs exists in the "INLIST"  
>
>Retrun Last Column from InputFile "GTTCRX001"
>

Why do you need to do this?

anyway, you probably need to set up the lines as arrays of hashrefs and then
compare, like

my @lines = <DATA>;
my @data;
foreach(@lines) {
	chomp;
	s/\|$//;
	my @a = split /\|/;
	my $head = shift @a or warn 'Bad data line: $_';
	my $tail = pop @a or warn 'Bad data line: $_';
	my %h = @a;
	$h{'Header Info'} = $head;
	$h{'Final Value Returned'} = $tail;
	push @data, \%h;
}

my @listlines = '{COMPRESSOR->Drawing Type->Machining->Linear
Assembly->BKT->Stage->1->LOCATION->FWD1->SUBLOCATION->FWD1->CAP->Assembly}';
my @list;
foreach(@listlines) {
	s/^\{|\}$//g;
	my @a = split /\-\>/;
	my $head = shift @a or warn 'Bad data line: $_';
	my %h = @a;
	$h{'Header Info'} = $head;
	push @list, \%h;
}

 ...now do a compare of the two arrays of hashrefs.


---
Use the domain skylightview (dot) com for the reply address instead.


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

Date: 26 Nov 2003 15:08:29 -0800
From: gerard@keyms.com (Geraldo)
Subject: Re: keeping anonymous hash sorted
Message-Id: <88267fd7.0311261508.16f8d2c@posting.google.com>

You can set the Dumper module to sort the keys.

use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
my %hash = ( do => 'doh', re => 'reh', me => 'meh', fa => 'fah' );
open OUT, '>tmp';
print OUT Dumper \%hash;
close OUT;

prints
$VAR1 = {
          'do' => 'doh',
          'fa' => 'fah',
          'me' => 'meh',
          're' => 'reh'
        };

cheers
Geraldo


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

Date: Thu, 27 Nov 2003 04:25:05 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: keeping anonymous hash sorted
Message-Id: <3fc56f87.339213030@news.erols.com>

"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'] );



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

Date: 26 Nov 2003 18:14:49 -0800
From: rgp@systame.com (Randall Perry)
Subject: Mac OS 10.3, perl 5.8.2, library problem: modules not seen
Message-Id: <fac8f6c0.0311261814.5405882e@posting.google.com>

Just upgraded from 5.8 to 5.8.2 on OSXS 10.3.1.

During configure I specified /Library/Perl for site-specific libs.

It compiled, tested, and installed ok. But when I went to test a
script it complained that a module wasn't there, though it's in the
perl lib path.

So I ran CPAN to re-install the module (DBI).

Here's the perl lib path:
perl -e 'print "$_\n" for @INC'
/sw/lib/perl5
/usr/local/lib/perl5/5.8.2/darwin-2level
/usr/local/lib/perl5/5.8.2
/Library/Perl/darwin-2level
/Library/Perl
/Library/Perl

Here's the old DBI:
l /Library/Perl/darwin/DBI
total 624
-r--r--r--  1 root  admin  53966  7 Dec  2002 Changes.pm
drwxr-xr-x  5 root  admin    170  7 Dec  2002 Const
-r--r--r--  1 root  admin  64423 29 Nov  2002 DBD.pm
-r--r--r--  1 root  admin  36024 24 Aug  2001 FAQ.pm
-r--r--r--  1 root  admin  14439 29 Nov  2002 Format.pm
-r--r--r--  1 root  admin  20573 29 Nov  2002 Profile.pm
-r--r--r--  1 root  admin  16411  1 Dec  2002 ProfileData.pm
drwxr-xr-x  3 root  admin    102  7 Dec  2002 ProfileDumper
-r--r--r--  1 root  admin   8112  1 Dec  2002 ProfileDumper.pm
-r--r--r--  1 root  admin  18345  1 Dec  2002 ProxyServer.pm
-r--r--r--  1 root  admin  25130 29 Nov  2002 PurePerl.pm
-r-xr-xr-x  1 root  admin  29306 29 Nov  2002 Shell.pm
-r--r--r--  1 root  admin   4594 24 Aug  2001 W32ODBC.pm

And the newly installed DBI:
l /Library/Perl/darwin-2level/DBI
total 640
-r--r--r--  1 root  admin   63911 25 Nov 11:23 Changes.pm
drwxr-xr-x  5 root  admin     170 25 Nov 11:23 Const
drwxr-xr-x  3 root  admin     102 25 Nov 11:23 DBD
-r--r--r--  1 root  admin  104617 19 Aug 20:15 DBD.pm
-r--r--r--  1 root  admin   36024 24 Aug  2001 FAQ.pm
-r--r--r--  1 root  admin   21577 19 Aug 20:15 Profile.pm
-r--r--r--  1 root  admin   16486 26 Feb  2003 ProfileData.pm
drwxr-xr-x  3 root  admin     102 25 Nov 11:23 ProfileDumper
-r--r--r--  1 root  admin    8112  1 Dec  2002 ProfileDumper.pm
-r--r--r--  1 root  admin   26172 14 May  2003 ProxyServer.pm
-r--r--r--  1 root  admin   26874 13 May  2003 PurePerl.pm
-r--r--r--  1 root  admin    4594 24 Aug  2001 W32ODBC.pm


Did I set the path wrong on configure? Or do all modules need to be
re-compiled for 5.8.2?


-- 
Randall Perry
sysTame

Xserve Web Hosting/Co-location
Website Development/Promotion
Mac Consulting/Sales

http://www.systame.com/


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

Date: Thu, 27 Nov 2003 02:21:22 -0000
From: "Lenny Challis" <ned@challis2000.fsnet.co.uk>
Subject: mod_perl
Message-Id: <bq3n30$m7q$1@newsg3.svr.pol.co.uk>

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 :(

anyone have any ideas?
Thanks alot,
Lenny




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

Date: 26 Nov 2003 23:29:59 -0500
From: Chuck Mattern <camattern@acm.org>
Subject: module load question
Message-Id: <m3ekvu4ens.fsf@gryphon.myth.comcast.net>

I've been asked to take a look at some very badly written Perl in use on a
number of our servers.  One of the issues is that as it runs it consumes more
and more memory.  I've only had a chance to do a cursory read of the code but
one thing that intrigued me was a directive to use a module that was inside of
a loop, with each iteration the module was called again.  Is it possible that
this is part of the memory consumption?  Would each reference load a new copy
of the same module in another segment of memory leaving the previous copies in
memory as well or would the new one be ignored or would each new call overwrite
the previous copy?

Looking forward to the thoughts of group,
Chuck
-- 
-----------------------------------------------------------------------
|Chuck Mattern	        | "People often find it easier to be a result |
|camattern@acm.org      | of the past than a cause of the future."    |
-----------------------------------------------------------------------


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

Date: Thu, 27 Nov 2003 15:47:43 +1100
From: Iain Chalmers <bigiain@mightymedia.com.au>
Subject: Re: module load question
Message-Id: <bigiain-01CB4E.15474327112003@news.fu-berlin.de>

In article <m3ekvu4ens.fsf@gryphon.myth.comcast.net>,
 Chuck Mattern <camattern@acm.org> wrote:

> I've been asked to take a look at some very badly written Perl in use on a
> number of our servers.  One of the issues is that as it runs it consumes more
> and more memory.  I've only had a chance to do a cursory read of the code but
> one thing that intrigued me was a directive to use a module that was inside 
> of
> a loop, with each iteration the module was called again.  Is it possible that
> this is part of the memory consumption?  Would each reference load a new copy
> of the same module in another segment of memory leaving the previous copies 
> in
> memory as well or would the new one be ignored or would each new call 
> overwrite
> the previous copy?

Neither. Perl is smarther than that.

perldoc -f use 

says (amongst other things:

>It is exactly equivalent to
>
>BEGIN { require Module; import Module LIST; }
>

and:

> The `BEGIN' forces the `require' and `import' to
> happen at compile time.  The `require' makes sure
> the module is loaded into memory if it hasn't been
> yet.


if its already loaded, "use"ing it again does nothing... You'll need to 
look somewhere else for your problem...

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: 26 Nov 2003 20:28:14 -0800
From: krakle@visto.com (krakle)
Subject: Re: Perl Editor
Message-Id: <237aaff8.0311262028.4b975fd4@posting.google.com>

Scite.


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

Date: Wed, 26 Nov 2003 18:22:20 -0600
From: JEB <enon@erewhon.com>
Subject: Re: Perl Regex - Hex bytes
Message-Id: <Xns943FC513335A6mcruise@216.196.97.136>

"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in 
news:Pine.LNX.4.53.0311261441120.1856@ppepc56.ph.gla.ac.uk:


> I think that's your clue.  Look for utf-8 in your linux locale
> setting. It's confusing Perl 5.8.0 into using unicode mode.
> 
> (And read other discussions and FAQs on this issue).
> 
> Either change your locale setting to remove the reference
> to utf-8 (I'm sure this works); or upgrade to 5.8.1, where this
> coupling between locale and Perl default behaviour was found too
> confusing and has been removed (so I'm told).



THANKS for the idea and help.

Exporting LC_ALL="en_US" in /etc/profile fixed the problem, though in a 
clumsy way. I hope it doesn't create  problems elsewhere.

JEB



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

Date: Thu, 27 Nov 2003 00:27:46 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Perl Regex - Hex bytes
Message-Id: <bq3ge2$1hc$2@wisteria.csv.warwick.ac.uk>


JEB <enon@erewhon.com> wrote:
> Exporting LC_ALL="en_US" in /etc/profile fixed the problem, though in a 
> clumsy way. I hope it doesn't create  problems elsewhere.

Installing 5.8.1 will also fix it, without the need to lose your
Unicode locale. Alternatively, as a temporary fix, you could

1. Make sure you have /usr/bin/perl5.8.0: if not, copy it from
   /usr/bin/perl
2. Remove /usr/bin/perl
3. Create a shell script /usr/bin/perl containing
  #!/bin/sh
  export LC_ALL="en_US.ISO8859-1"
  exec /usr/bin/perl5.8.0 "$@"

Yes, I think this is a pretty evil hack, too, but if you have problems
with losing the Unicode locale it may help.

Ben

-- 
   If you put all the prophets,   |   You'd have so much more reason
   Mystics and saints             |   Than ever was born
   In one room together,          |   Out of all of the conflicts of time.
ben@morrow.me.uk |----------------+---------------| The Levellers, 'Believers'


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

Date: Wed, 26 Nov 2003 21:39:00 -0500
From: "Gregory K. Deal" <gregory_deal@hotmail.com>
Subject: Problem writing byte values to a file
Message-Id: <pan.2003.11.27.02.38.59.629913@hotmail.com>

I'm trying to write out bytes to a file with values anywhere from 0 to
255. I assign a value to a variable and write it out with a "%c" format.
Something like :

$r=1; $g=128; $b=1;
printf("%c%c%c",$r,$g,$b);

The problem is when the byte values exceed 127. When less than 128, I get
expected values (writing either a 1 or a 127) :


0000000   P   6  \n   3       3  \n   2   5   5  \n 001 177 001 001 001
0000020 177 001 001 177  \n 001 177 001 001 001 177 001 001 177  \n 001
0000040 177 001 001 001 177 001 001 177  \n

When I try to write a 128 (or larger), it seems to want to write the value
out in 2 bytes instead of 1 :

0000000   P   6  \n   3       3  \n   2   5   5  \n 001 302 200 001 001
0000020 001 302 200 001 001 302 200  \n 001 302 200 001 001 001 302 200
0000040 001 001 302 200  \n 001 302 200 001 001 001 302 200 001 001 302
0000060 200  \n

Here, a "302 200" seems to show up where the "177" used to be, when I
really only expected a plain "200". So, any idea what's going on here? Am
I jumping into or enabling Unicode mode? I tried "use bytes" to turn off
this behavior, but no luck. Trying the following didn't help either :

 $rc=chr($r); $gc=chr($g); $bc=chr($b);
 print "${rc}${gc}${bc}";

How can I predictably write out bytes to a file? Thanks for any help or
guidance.


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

Date: Thu, 27 Nov 2003 02:49:30 +0000 (UTC)
From: stanley@a.shell.peak.org (John Stanley)
Subject: Re: Problem writing byte values to a file
Message-Id: <bq3onq$3aa$1@a.shell.peak.org>

In article <pan.2003.11.27.02.38.59.629913@hotmail.com>,
Gregory K. Deal <gregory_deal@hotmail.com> wrote:
>When I try to write a 128 (or larger), it seems to want to write the value
>out in 2 bytes instead of 1 :

Ain't UNICODE wonderful? 

"binmode" is no longer a DOS-ism.



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

Date: 26 Nov 2003 15:13:25 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: store  password  in a module ?
Message-Id: <3fc53395@news.victoria.tc.ca>

Qiang (shijialee@hotmail.com) wrote:
: hello,

: i have a module connect to a database and return some information for
: user. the database name and password are stored in it.

: now the user will run another perl file which use the module. however,
: i don't know how do i pretect the database password from user?

: i heard about setuid, but it seems to have it's own security problem. 

setuid to root is a security problem, setuid to some other non-priv 
user is not inherently a problem.

: can anyone recommend elegant way to solve this problem ?

Set the file containing the password to be owned by a non-priv user set up
for this task.  Do not allow any user other than the owner (which is a
dummy account) to read that password file.

Set the script that reads the password to be suid to that non-priv user.
The script can now read the password, but a user running the script
cannot, by themselves, read the password.

You must now make sure that the script is secure, in the sense that only
the appropriate people can run it, and that when they run it they can only
use it for the purpose for which it is intended.


Control who can run the script however you wish, depending on the
circumstances.  One technique is for the script to be group
read/executable, and owned by a group set up for this purpose.  Users who
should be able to run the script are placed in that group.

The script itself must control how it is used.  I think taint mode is
turned on by default in this situation, but in any case it should be,
which helps to ensure the script has no holes, and of course the script
must not do anything such as allow a user to access the command line via
the script, or to allow them to access the inner variables of the script.  
(Does taint turn of debugging? I have never thought about it, but I hope
it does.)



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

Date: 26 Nov 2003 23:31:19 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: store  password  in a module ?
Message-Id: <slrnbsadu7.lv7.sholden@flexal.cs.usyd.edu.au>

On 26 Nov 2003 15:13:25 -0800,
	Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:

[snip suid script discussion]

> (Does taint turn of debugging? I have never thought about it, but I hope
> it does.)

Of course not, using taint checking doesn't magically produce bug free
code - hence debugging is still sometimes necessary. And not being able to
use the debugger would be a pain for those who like it.

Of course you can't pass arbitrary command line arguments to the suid perl
due to the way #! works. And you can't modify the script and still have it
be suid (unless you already have access anyway), so there is no need
to disable it in the presence of taint checking. 

-- 
Sam Holden


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

Date: Thu, 27 Nov 2003 00:23:34 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: store  password  in a module ?
Message-Id: <bq3g66$1hc$1@wisteria.csv.warwick.ac.uk>


yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote:
> Qiang (shijialee@hotmail.com) wrote:
> : i heard about setuid, but it seems to have it's own security problem. 
> 
> setuid to root is a security problem, setuid to some other non-priv 
> user is not inherently a problem.

Not true. Obviously the user you are setuid-ing to can do something to
user you are setuid-ing from could not, otherwise there would be no
point. Hence, you have a potential security problem.

> : can anyone recommend elegant way to solve this problem ?
> 
> Set the file containing the password to be owned by a non-priv user set up
> for this task.  Do not allow any user other than the owner (which is a
> dummy account) to read that password file.

This is the right answer, yes.

Ben

-- 
Heracles:                                                     ben@morrow.me.uk
   Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 /Alcestis/)        [ flame, and falls out of sight.                          ]


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

Date: 26 Nov 2003 16:36:20 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: store  password  in a module ?
Message-Id: <3fc54704@news.victoria.tc.ca>

Sam Holden (sholden@flexal.cs.usyd.edu.au) wrote:
: On 26 Nov 2003 15:13:25 -0800,
: 	Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:

: [snip suid script discussion]

: > (Does taint turn of debugging? I have never thought about it, but I hope
: > it does.)

: Of course not, using taint checking doesn't magically produce bug free
: code - hence debugging is still sometimes necessary. And not being able to
: use the debugger would be a pain for those who like it.

: Of course you can't pass arbitrary command line arguments to the suid perl
: due to the way #! works. And you can't modify the script and still have it
: be suid (unless you already have access anyway), so there is no need
: to disable it in the presence of taint checking. 

That all makes sense.

Just as long as a normal user cannot run the suid program, and become the
suid user, and then also use the debugger to examine (or modify!) the
value of the variables of the program, which in this case is what must be
protected.

In any case, the user must figure out any possible interactions that the
suid program could allow that would allow the password to be learnt.  One
of my first thoughts is to try to break the protection using the debugger
by examining the variable.  I would not want to allow command line access
to the perl suid program in this case (where it is protecting data)  
until I had convinced myself (among other things) that I understood the
interactions of the suid and the debugger well enough to know it was not a
problem, or if it was a problem then to know how to prevent the use of the
debugger in this situation.

I haven't had to do this, so I do not know for sure if there is/was an
issue, therefore I mentioned it.



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

Date: 26 Nov 2003 16:46:00 -0800
From: shijialee@hotmail.com (Qiang)
Subject: Re: store  password  in a module ?
Message-Id: <b1f13455.0311261645.333c2144@posting.google.com>

Brian McCauley <nobull@mail.com> wrote in message news:<u9he0rdnon.fsf@wcl-l.bham.ac.uk>...
> shijialee@hotmail.com (Qiang) writes:
> 
> > i have a module connect to a database and return some information for
> > user. the database name and password are stored in it.
> > 
> > now the user will run another perl file which use the module. however,
> > i don't know how do i pretect the database password from user?
> 
> Aggghhhhh!  Didn't we have this thread already this week.
> 


just read it. but surprisingly there is not even a solution offerered
but tone of discussion of why security by obscurity is bad.


> > i heard about setuid, but it seems to have it's own security problem. 
> > 
> > can anyone recommend elegant way to solve this problem ?
> 
> This is the perpetual motion machine of computer programming.
> It has very little to do with the specific lanuage.
> 
> You cannot do this with a module or library that loads into the
> user-space of your program.  Some operating systems (eg VMS) have a
> concept of a priviledged library that you can call rather like an OS
> call.  (IIRC Solaris has something called "doors" which may apply).
> 
> In general the only way to do it is a helper process.  The helper
> process runs under a different UID an accepts connections from clients
> (using a UNIX domain socket or whatever) and forwards them to the
> database.


sorry, i don't quite sure how to achieve that and why that will work.
guess i really need to read a tutorial or more to understand how to do
it.

anyone have a nice link for this kind of problem?


James.


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

Date: 26 Nov 2003 15:20:24 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Unexpected tell() result
Message-Id: <3fc53538@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:3fc3e934@news.victoria.tc.ca: 

: > Dan Wilga (dwilga-MUNGE@mtholyoke.edu) wrote:
: >: I'm seeing odd results when tell() is performed right after open with
: >: append:
: ...
: > You've opend the file in append mode, so any write is supposed to go
: > to the end of the file, whereever that happens to be.  However, the
: > size of the file could be changing due to another process, so the
: > value of tell that you read at one moment doesn't really have any
: > relation to where the data gets written.

: Are you suggesting that some other process is writing to Dan's "foo" file 
: in the millisecond between its creation and his call to tell()?

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.

Therefore, as long as the write works, then the value of tell can be
anything the system finds convenient.  Some systems may always define a
pointer whenever any file is opened, and so tell has a value.  Some
systems may avoid setting up a position pointer unless they need to, and
since append doesn't require it then the pointer isn't setup.  Either
method would be correct.



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

Date: Wed, 26 Nov 2003 20:03:25 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Unexpected tell() result
Message-Id: <Xns943FD66BF9DABsdn.comcast@216.196.97.136>

-----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.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP8VbuGPeouIeTNHoEQK9AACfaehEJzLF5GZGnpLwd8L+weiZE+cAnRzy
19VDc9lqZg5FzkSX2G3X5jcF
=hetK
-----END PGP SIGNATURE-----


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

Date: 27 Nov 2003 04:23:34 GMT
From: s11976@net2.hkbu.edu.hk (pui ming Wong)
Subject: went to 5.8.1 and now my while statement fails
Message-Id: <bq3u86$ohe$1@net-sp1.hkbu.edu.hk>

My script which worked under 5.6.1 failed after I upgraded
to 5.8

The loop codes that failed is as below:
The print count line statement never gets printed at all; why?
------------------------------------------------
 # read each message in turn

  while( $msg = &read_message ) {
    $count++;
 print "count line is $count";
      }
---------------------------------------------------
and its routine is:
-------------------------------------------------------
sub read_message
{
  local( $msg ) = "";   # message to send back
  local( $prev_blank ) = 1;  # assume previous line blank
  local( $seen_from ) = 0;  # seen a from line
  local( $line ) = "";   # current line

  # reset some globals
  $msg_status = "";
  $msg_subject = "";
  $msg_date = "";
 while( $line = &get_line ) {

    if( $line =~ /^From\s+([^\s]+)\s+(.*)$/ ) {
      # if previous line was blank, then legal from line
      if( $prev_blank ) {
        # if already seen a legal from line, then this is next message
 if( $seen_from ) {
   # pushback this from line
   $line_buffer = $line;
   return $msg;
 }
 $seen_from++;
        # From line found, extract information
        ( $msg_from, $msg_date ) = ( $1, $2 );
 $msg_stamp = &rctime( $msg_date );
        $msg_age = &days_old( $msg_stamp );
      }
    } elsif( $line =~ /^[Ss]tatus: ([A-Za-z]+)/ ) {   ( $msg_status ) = ( $1 );
    } elsif( $line =~ /^[Ss]ubject: (.*)$/ ) {   ( $msg_subject ) = ( $1 );
    }

    # set previous line
    if( $line =~ /^$/ ) {
      $prev_blank = 1;
    } else {   $prev_blank = 0;
    }

    $msg .= $line;
  }

  return $msg;
}
-------------------------------------
BTW ,The perl routines required are:

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?


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

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


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