[19005] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1200 Volume: 10

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

Date: Tue, 26 Jun 2001 15:10:13 -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: <993593413-v10-i1200@ruby.oce.orst.edu>
Content-Type: text

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

Today's topics:
        Problems with Crypt Modules (Irene Fung)
    Re: Problems with Crypt Modules <dwilga-MUNGE@mtholyoke.edu>
    Re: regular expression problem <stevea@wrq.com>
    Re: Troubleshooting a CGI Script (dave)
    Re: untie attempted while 1 inner references still exis <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>
        Upgrading a File Lock (What do you think this is, a Hol (Miko O'Sullivan)
    Re: Upgrading a File Lock (What do you think this is, a <boa@aaanet.ru>
    Re: Upgrading a File Lock (What do you think this is, a ctcgag@hotmail.com
    Re: using strict (Tramm Hudson)
    Re: using strict (Anno Siegel)
    Re: using strict <ren@tivoli.com>
    Re: using strict (Tramm Hudson)
        weird hash behaviour. (Entropy Gideoned)
        why are reference addresses not the same in C and Perl? (J.A.P.H.)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 26 Jun 2001 19:30:50 GMT
From: iwf@po.cwru.edu (Irene Fung)
Subject: Problems with Crypt Modules
Message-Id: <3b38e156.1292506325@news.cwru.edu>

I'm running Perl 5.6.1 under BSD/OS 4.2.  I've been trying to use the
Crypt::Blowfish module to encrypt a file and then decrypt a file.  At
the 224 byte length, the decryption fails.  It will decrypt correctly
all the text up to that length and then show gibberish after that.

I can't figure out what's wrong.  I've also tried the Crypt::DES
module and the Crypt::Blowfish_PP module.  They decrypt partially and
then fail.  I don't know whether the encryption or the decryption part
is failing.

Any ideas?

Thanks.

Irene


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

Date: Tue, 26 Jun 2001 21:00:33 GMT
From: Dan Wilga <dwilga-MUNGE@mtholyoke.edu>
Subject: Re: Problems with Crypt Modules
Message-Id: <dwilga-MUNGE-C6086D.17003226062001@nap.mtholyoke.edu>

In article <3b38e156.1292506325@news.cwru.edu>, iwf@po.cwru.edu (Irene Fung) 
wrote:

> I'm running Perl 5.6.1 under BSD/OS 4.2.  I've been trying to use the
> Crypt::Blowfish module to encrypt a file and then decrypt a file.  At
> the 224 byte length, the decryption fails.  It will decrypt correctly
> all the text up to that length and then show gibberish after that.

Most of the Crypt:: modules work on a fixed-size buffer. To work on an 
arbitrary number of bytes, use Crypt::CBC in conjunction with ::Blowfish.

-- 
Dan Wilga          dwilga-MUNGE@mtholyoke.edu
** Remove the -MUNGE in my address to reply **


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

Date: Tue, 26 Jun 2001 19:59:12 GMT
From: Steve Allan <stevea@wrq.com>
Subject: Re: regular expression problem
Message-Id: <uwv5znhbr.fsf@wrq.com>

Bart Lateur <bart.lateur@skynet.be> writes:

<snip>

>So what does \G do? It matches an anchor at the current position of pos,
>i.e. right after the previous match. Witness:
>
>	$_ = "abc";
>	/b/g and s/\G/!/;
>	print;
>-->
>	ab!c
>
>You need the /g for the // or otherwise pos would be unaffected.

<snip>

I'm trying to understand this \G thing, so I ran the above in Perl
5.005 on w2k.  I get different results:

% cat foo.pl
#!/usr/bin/perl -w
use strict;
$_ = 'abc';
/b/g and s/\G/!/;
print;

% perl foo.pl
!abc

Did I type something incorrectly?

-- 
-- Steve __


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

Date: 26 Jun 2001 12:04:25 -0700
From: usted@cyberspace.org (dave)
Subject: Re: Troubleshooting a CGI Script
Message-Id: <e2c00ae.0106261104.730b1bd0@posting.google.com>

whereis perl #make sure this agrees with your #!/path/

run it from the command line

dave


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

Date: Tue, 26 Jun 2001 19:15:34 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: untie attempted while 1 inner references still exist
Message-Id: <3B38D146.3BDD92DE@salford.ac.uk>



Anno Siegel wrote:
> 
> According to Mark Grimshaw  <m.grimshaw@salford.ac.uk>:
> >
> >
> > nobull@mail.com wrote:
> > >
> > > Mark Grimshaw <m.grimshaw@salford.ac.uk> writes:
> > >
> > > > I need the return for $dbobj->sync();
> > >
> > > Is there any particular reason you don't want to say
> > > tied(%USER)->sync(); ?
> > >
> > > --
> > >      \\   ( )
> > >   .  _\\__[oo
> > >  .__/  \\ /\@
> > >  .  l___\\
> > >   # ll  l\\
> > >  ###LL  LL\\
> >
> > don't know.  Anyway, didn't know I could do that - thanks.  Is there any
> > advantage other than not having to explictly return and collect the
> > tie() object?
> 
> I think the particular error (well, warning) you ran into is a good
> reason not to keep copies of a tied object around and to rely on tied()
> instead.  The difference is a bit like the difference of using length()
> on a string instead of keeping it in an extra variable.  Whenever
> you have the string, you know how to get its length, and whenever you
> have a tied variable you can have its tied object as well.  Some pervert
> may even have gone and re-tied your variable, then where would you be...
> 

OK - I'll give it a try.

BTW - while I have your attention, is there anyway to find out (besides
a regexp) whether a variable-length variable is a digit?  I'm sure I've
done this before - isdigit() rings a bell but I can't find it in any
book.


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

Date: 26 Jun 2001 18:21:36 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: untie attempted while 1 inner references still exist
Message-Id: <9hajrg$2ks$2@mamenchi.zrz.TU-Berlin.DE>

According to Mark Grimshaw  <m.grimshaw@salford.ac.uk>:
 
> BTW - while I have your attention, is there anyway to find out (besides
> a regexp) whether a variable-length variable is a digit?  I'm sure I've
> done this before - isdigit() rings a bell but I can't find it in any
> book.

If a variable contains a digit, its length is 1 because a digit is
a single character.  I suppose you want to check if it is a number.
There's a FAQ about that, for various meanings of "number".  See
"perldoc -q number".

Anno


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

Date: Tue, 26 Jun 2001 20:20:40 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: untie attempted while 1 inner references still exist
Message-Id: <3B38E088.67A2FA56@salford.ac.uk>



Anno Siegel wrote:
> 
> According to Mark Grimshaw  <m.grimshaw@salford.ac.uk>:
> 
> > BTW - while I have your attention, is there anyway to find out (besides
> > a regexp) whether a variable-length variable is a digit?  I'm sure I've
> > done this before - isdigit() rings a bell but I can't find it in any
> > book.
> 
> If a variable contains a digit, its length is 1 because a digit is
> a single character.  I suppose you want to check if it is a number.
> There's a FAQ about that, for various meanings of "number".  See
> "perldoc -q number".
> 
> Anno

silly me - I tried perldoc -q digit.  So I guess its a regular
expression or the cumbersome strtod...

Thanks.


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

Date: 26 Jun 2001 13:37:42 -0700
From: miko@idocs.com (Miko O'Sullivan)
Subject: Upgrading a File Lock (What do you think this is, a Holiday Inn?)
Message-Id: <db27ea77.0106261237.4a10857d@posting.google.com>

I have an interesting file lock need that I can't quite figure out how
to do. Let me try to explain:

I'm writing a system with a rudimentary rollback/commit ability.  I'd
like to get a shared lock on the data file while the editing script
calculates some changes to the data.  I want the lock to be sharable
so that other processes can read the data as it is while the lengthy
changes are calculated.  I'll enforce the rule in my scripts that
anybody who gets a shared lock will only open for reading, not
writing.

Once the editing script has calculated all the changes and is ready to
commit, I'd like to get an exclusive lock on the data file.  There's
the problem: the script can't get an exclusive lock while it currently
has a shared-lock, but if it lets the shared lock go then some other
weasely script might slip and get an exclusive lock before the editing
script can get one.

So what to do? Can I "upgrade" the lock from shared to exclusive, sort
of like upgrading from a room to a suite at the Holiday Inn?

-Miko


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

Date: Wed, 27 Jun 2001 01:05:49 +0400
From: "Oleg Bakiev" <boa@aaanet.ru>
Subject: Re: Upgrading a File Lock (What do you think this is, a Holiday Inn?)
Message-Id: <9hatg8$1n3v$1@pa.aaanet.ru>


"Miko O'Sullivan" <miko@idocs.com> :
news:db27ea77.0106261237.4a10857d@posting.google.com...
>
> So what to do? Can I "upgrade" the lock from shared to exclusive, sort
> of like upgrading from a room to a suite at the Holiday Inn?
>
You could use an additional file as a semaphore. Say you need to change
shared lock to exclusive. You lock exclusively /tmp/semaphore(1), unlock
your main file(2), lock it exclusively(3), unlock /tmp/semaphore(4). If your
programs will use this protocol, different instances could't lock the main
file at the moment between (2) and (3).




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

Date: 26 Jun 2001 21:11:22 GMT
From: ctcgag@hotmail.com
Subject: Re: Upgrading a File Lock (What do you think this is, a Holiday Inn?)
Message-Id: <20010626171121.371$lZ@newsreader.com>

miko@idocs.com (Miko O'Sullivan) wrote:

> So what to do? Can I "upgrade" the lock from shared to exclusive, sort
> of like upgrading from a room to a suite at the Holiday Inn?

There was a discussion about this recently, under "2 questions about
flock". It's not easy to do.  The problem is that you couldn't just obtain
an ordinary shared lock, you would have to announce at the time you obtain
the shared that you intend to upgrade.  (otherwise you would have to
programs with shared locks, holding each others exclusives hostage.)  So
you either have to use a system that has a "protected" lock, or fake it by
locking an auxillary file.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
                       Usenet for the Web


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

Date: 26 Jun 2001 17:57:27 GMT
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: using strict
Message-Id: <9haie7$9go$1@sloth.swcp.com>

[ Posted and cc'd to cited authors ]


Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote (in part):
> ...  Strictures only change the compile-time behavior, at run-time
> there is no difference.

That's not true.  strict also has the run-time effect of disallowing
symbolic references, among other things:

	#!/usr/bin/perl -w
	use strict;
	sub foo { print "Foo!\n" }
	my $f = "foo";
	$f->();

Tramm
-- 
  o   hudson@swcp.com                  hudson@turbolabs.com   O___|   
 /|\  http://www.swcp.com/~hudson/          H 505.323.38.81   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.986.60.75   \ \/\_\  
  0                                                            U \_  | 


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

Date: 26 Jun 2001 18:29:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: using strict
Message-Id: <9hak9o$2ks$3@mamenchi.zrz.TU-Berlin.DE>

According to Tramm Hudson <hudson@swcp.com>:
> [ Posted and cc'd to cited authors ]
> 
> 
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote (in part):
> > ...  Strictures only change the compile-time behavior, at run-time
> > there is no difference.
> 
> That's not true.  strict also has the run-time effect of disallowing
> symbolic references, among other things:
> 
> 	#!/usr/bin/perl -w
> 	use strict;
> 	sub foo { print "Foo!\n" }
> 	my $f = "foo";
> 	$f->();

You are right, this would have to be done at run time.  I was trying
to over-state the point that efficiency is no concern when it comes
to warnings and strictures.  Thanks for catching it.

Anno


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

Date: 26 Jun 2001 14:15:58 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: using strict
Message-Id: <m3d77r59xt.fsf@dhcp9-173.support.tivoli.com>

[Re-inserted original text from OP for context.]

On 26 Jun 2001, hudson@swcp.com wrote:

> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote (in part):
>>According to Aman Patel <patelnavin@icenet.net>:
>>> "In short, does the use strict pragma add load the to perl
>>> interpreter/compiler..."
>>> 
>>> If my script is NOT using strict pragma, but compiles and runs
>>> perfectly if done under use strict pragma, will there be any
>>> performance loss if i add 'use strict;' at the top of my script.
>>
>> ...  Strictures only change the compile-time behavior, at run-time
>> there is no difference.
> 
> That's not true.  strict also has the run-time effect of disallowing
> symbolic references, among other things:

[snipped example]

To be fair, the OP indicated that the script "compiles and runs
perfectly" under strict, so the handling of symbolic references is not
germane.  Taken in context, Anno's statement is true (well, at least
as far as symbolic references are concerned).

-- 
Ren Maddox
ren@tivoli.com


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

Date: 26 Jun 2001 21:11:26 GMT
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: using strict
Message-Id: <9hatpu$i0h$1@sloth.swcp.com>

[ Posted and cc'd to cited author.  The horse isn't quite dead yet... ]

Ren Maddox  <ren@tivoli.com> wrote:
> To be fair, the OP indicated that the script "compiles and runs
> perfectly" under strict, so the handling of symbolic references is not
> germane.  Taken in context, Anno's statement is true (well, at least
> as far as symbolic references are concerned).

Well, it is possible to craft a script that runs fine with strict
enabled and dies with out it, but I believe that you must be
deliberate about doing so:

	#!/usr/bin/perl -w
	#use strict;

	sub foo { 42 }
	my $f = "foo";
	my $b = "bar";

	eval { $f->() } and $b->();

I doubt that anyone would use such a construct in a real program.
But a test for strictness is very introspective.  I may have to
use it for the next Obfuscated Perl contest.


Tramm
-- 
  o   hudson@swcp.com                  hudson@turbolabs.com   O___|   
 /|\  http://www.swcp.com/~hudson/          H 505.323.38.81   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.986.60.75   \ \/\_\  
  0                                                            U \_  | 


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

Date: Tue, 26 Jun 2001 02:02:05 GMT
From: entropy@consultant.com (Entropy Gideoned)
Subject: weird hash behaviour.
Message-Id: <3b37ebe7.12936581@news.magna.com.au>

OK, 

now I actually think it is behaving properly, and I'm a moron... but I
just cant see what I'm going wrong.. Here is whats killing me, output
from debug:

  DB<19> x $rldr
0  HASH(0x202738bc)
   'BLvl' => 'm'
   'Ctrl' => ' '
   'Desc' => 'a'
   'ELvl' => ' '
   'RecStat' => 'c'
   'Type' => 'a'
   'Undef2ldr' => 0
   'Undefldr' => ' 22'
   'base_addr' => 00289
   'len_impl' => ' '
   'len_len_field' => 4
   'len_start_char' => 5
   'ln_rec' => ' '
   'rec_len' => 00942
  DB<20> x $rldr{'Desc'}
0  undef
  DB<21> x $rldr{Desc}
0  undef
  DB<22>

It says that rldr is a hash, good!
it has a key 'Desc', which has "a" in it.

but x $rldr{'Desc'} shows undef! So do all the other keys.

Am I moron? Is my perl broken? It's on a AIX box, and the hash is
generated off in a magical perl module... MARC.pm

Any ideas?

Brock Henry
PS: please reply as email as well if possible, I'm anxious to fix this
beasty.


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

Date: Tue, 26 Jun 2001 21:42:38 GMT
From: dont@mailme.com (J.A.P.H.)
Subject: why are reference addresses not the same in C and Perl?
Message-Id: <3b3901c3.1294910082@news.erols.com>


My perl program calls a constructor in an XS file which returns a
reference to a new object. Out of curiosity, I placed the following
statement in the CODE section of the XS function 'new': 

printf("Address from C:%x",RETVAL);

In perl, once the the object is created, with something like

$reference = package->new;

I added this line:

print "Address from perl: $reference\n";

The two addresses I get back are not the same. Can someone here
explain why this is the case?

Thanks.


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

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


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