[13658] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1068 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 15 15:07:13 1999

Date: Fri, 15 Oct 1999 12:06:53 -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: <940014412-v9-i1068@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 15 Oct 1999     Volume: 9 Number: 1068

Today's topics:
    Re: Keeping TEXTAREA intact? <jtribbeck@argogroup.com>
        Long Raw datatype with Oraperl fifi@wizard.com
    Re: lookbehind capabilities was [Re: Help - Perl regula <ltl@rgsun5.viasystems.com>
    Re: Macintosh: Get info about aliases (Chris Nandor)
    Re: Making a hash of subroutines <sariq@texas.net>
    Re: Making a hash of subroutines (Craig Berry)
    Re: Making a hash of subroutines (Bart Lateur)
    Re: Making a hash of subroutines <stampes@xilinx.com>
    Re: Making a hash of subroutines (Larry Rosler)
    Re: Making a hash of subroutines <aqumsieh@matrox.com>
        maybe FAQ: web link consistency checker in perl wanted (Peter Galbavy)
        Merging Arrays bfredett@us.ibm.com
    Re: Merging Arrays <rasmusr@online.no>
    Re: Merging Arrays <vincent.murphy@cybertrust.gte.com>
    Re: Merging Arrays blfredette@my-deja.com
    Re: Merging Arrays <ltl@rgsun5.viasystems.com>
        Modul-Initialisation Problem <azielke@hotmail.com>
    Re: Modul-Initialisation Problem (Martien Verbruggen)
    Re: Modul-Initialisation Problem <azielke@hotmail.com>
    Re: Module throws exception only when I'm catching it? <alexkrowitz@my-deja.com>
    Re: Module throws exception only when I'm catching it? (Ilya Zakharevich)
    Re: move files in directories recusively in Windows usi <cassell@mail.cor.epa.gov>
    Re: move files in directories recusively in Windows usi (David Wall)
    Re: move files in directories recusively in Windows usi <ltl@rgsun5.viasystems.com>
    Re: move files in directories recusively in Windows usi (David Wall)
        msql module <jamescwm@singnet.com.sg>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 13 Oct 1999 09:19:52 +0100
From: Jason P Tribbeck <jtribbeck@argogroup.com>
Subject: Re: Keeping TEXTAREA intact?
Message-Id: <380440A8.B8C0046@argogroup.com>

emlyn_a@my-deja.com wrote:
> 
> I've read some questions about replacing \n with <br> tags for paragraph
> breaks in a form textarea, but what if you simply want the textarea to
> be written to a field as one long line (with or without <br>s)?
> 
> Does there need to be a special "wrap" tag included in the html
> (virtual,physical,off) before it's sent to the cgi? I've tried all
> kinds of approaches (using MacPerl), but for every linebreak, it
> inserts an unrecognizable square character - very strange.
> 
> Hope there are some ideas out there...

The square characters are probably because of the CRLF that Windoze
uses. If you're changing \n into <br>, then you'd end up with \r<br>
instead of \r\n.

What you could do is to remove all \r, and then change \n into <br>, and
when you want to pop it back in to your HTML, change the <br> back int
\r\n.

AIUI the difference between virtual, physical and off wrapping is what
is displayed and subsequently sent to the browser:

With off, no word wrapping occurs, and so what is seen on the screen is
sent to the browser.

With physical, word wrapping occurs, and any 'forced' linefeeds (ie.
where the words wrap) are sent to the browser, so in effect, WYSIWTBG
(what you see is what the browser gets).

With virtual, word wrapping occurs, but any 'forced' linefeeds are /not/
sent to the browser; they are replaced by spaces - it's a case of
WYTIWTBG (what you type is what the browser gets).


-- 
Jason Tribbeck                                          Argo Interactive
ltd
Senior Design Engineer                             7 Dukes Court,
Chichester
                                                       West Sussex, PO19
2FX
Tel: +44 1243 815 815 Fax: +44 1243 815 805                         
England


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

Date: Tue, 12 Oct 1999 23:20:19 GMT
From: fifi@wizard.com
Subject: Long Raw datatype with Oraperl
Message-Id: <7u0fn7$jak$1@nnrp1.deja.com>

I need some help. I am attempting to update a "LONG RAW" field. Whether
or not I set the $ora_long variable, I keep getting the error:

1461, ORA-01461: can bind a LONG value only for insert into a LONG
column (DBD: oexec error)

when I try to update with a long text string. If I change the text
string to something really small like a two digit number then it takes
it fine. Is there a problem with "LONG RAW" as opposed to "LONG?" If I
change the field to "LONG" and set the $ora_long it works fine, but I
need to store binary data so "LONG" by itself won't work.

Any and all help is appreciated.

Stephanie



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 12 Oct 1999 23:57:21 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: lookbehind capabilities was [Re: Help - Perl regular expression question!]
Message-Id: <7u0ht1$eve$1@rguxd.viasystems.com>

Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
:>[A complimentary Cc of this posting was sent to lt lindley 
:><lee.lindley@bigfoot.com>],
:>who wrote in article <7trode$qcs$1@rguxd.viasystems.com>:
:>> :>> A backreference has a fixed length when it is actually tested. 
:>> 
:>> :>???  How do you decide at compile time what length a backreference is
:>> :>going to have?
:>> 
:>> You don't.  You recalculate the length each time it is applied.

:>Thanks, but no, thanks.  ;-)

Well, if you won't do it for me, I guess I'll have to do it myself.

#!/usr/lib/lprgs/perl -w
use strict;
$_ = qq/kfo, kfoooo and foooood are ok, but kfood, kfod and kfoood aren't\n/;
while (/(fo+)/gc) {
	unless (/\G(?<!k$1(?=d))/gc) {
		my $pos = pos;
		my $lth = length $1;
		substr $_, $pos - $lth - 1, $lth + 2, 'yuck';
		pos = $pos - $lth + 4; # add back yuck & get past what was d.
	}
}
print;
__END__
kfo, kfoooo and foooood are ok, but yuck, yuck and yuck aren't

Or maybe I'll just wait until you get the //r implemented.
-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Tue, 12 Oct 1999 23:33:34 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Macintosh: Get info about aliases
Message-Id: <pudge-1210991933440001@192.168.0.77>

In article <mark-1010991712080001@squirrel.tgsoft.com>,
mark@squirrel.tgsoft.com (mark thompson) wrote:

# I am writing a perl program to do backups from my macintosh to
# a remote machine that has a tape drive (think of unix rdump... though
# that isn't exactly what I'm doing).
# 
# I have run into a problem with aliases. I can detect them easilly enough
# with -l; but FSpGetCatInfo - which I use to get the finder information and
# file size, seems to 'follow' aliases... ie. it is stat rather than lstat.
# 
# In order to back up aliases, I need to get the finder info (lstat). I seem
# to be able to actually READ the alias with POSIX::, but maybe I have that
# wrong... it would be nice if a guru would give me tips on this, too.

Well, I do not know offhand ... check the MacPerl mailing lists.  There is
a list for toolbox modules and a general list; either would be
appropriate.

    http://www.macperl.org/

What I would do is look in the Inside Macintosh docs and find out how to
do it in C and then see if the functions are available in the MacPerl
toolbox, etc.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Tue, 12 Oct 1999 15:42:13 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Making a hash of subroutines
Message-Id: <38039D25.CEFB2811@texas.net>

schablone@my-deja.com wrote:
> 
> If anyone can help me on this one, the post of Lord High Keeper of Tall
> Lattes and Pineapple Cubes is theirs for the asking (once I've actually
> got the Umbrella of World Power in my hands, that is).

I'd accept Lord High Keeper of Pints of Ale and Bricks of Cheese.

> Here's the code:
> 
> #!/usr/bin/perl -w
> #use strict;

Don't know why you commented 'use strict;'.  With the dereferencing
fixed, it runs under 'strict' just fine.

> 
> my %test;
> my @data;
> 
> @data = ('244', 'Slightly Evil Bob', 'Chicken & Cucumber');
> 
> %test = (
>                 id              => $data[0],
>                 name            => $data[1],
>                 sandwich        => $data[2]
>         );
> 
> DoSomething (\%test, "Favourite Sandwich Data for: ");

So far, so good.

> 
> exit(0);
> 
> sub DoSomething {
>   my %Newhash = shift;

This tries to put a single item (the hash ref) into a hash.  Thus the
'Odd number of elements in hash list' error.

You'll want to store the hash ref in a scalar.  I.e.,

  my $Newhashref = shift;

>   my $message = shift;
> 
>   print $message;
>   print $Newhash{'name'}."\n";
>   print $Newhash{'sandwich'};

Now, you have to dereference.  I.e.,

  print $$Newhashref{'name'}."\n";
  print $$Newhashref{'sandwich'};
 
> }
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

Read the docs 'Before you post.'

perldoc perlsub
perldoc perlref

- Tom


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

Date: Tue, 12 Oct 1999 21:11:45 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Making a hash of subroutines
Message-Id: <s0790h64bhk81@corp.supernews.com>

schablone@my-deja.com wrote:
: My plan for world domination is proceeding pretty well and I'm working
: on a databasey-type application to keep track of my enemies and their
: favourite types of sandwich.
: 
: For various perverse and twisted reasons I wish to pass some values
: in a hash to a subroutine. Unfortunately men in black suits are beaming
: radiowaves at my brain and I am unable to think properly, so I can't get
: my code (below) to work.

I hate it when that happens...

: I know hashes are flattened in subroutine calls, so I want to pass a
: reference to the hash. Only it doesn't seem to work. Am I barking up the
: wrong tree?

Right idea, wrong execution.  See below.

: If anyone can help me on this one, the post of Lord High Keeper of Tall
: Lattes and Pineapple Cubes is theirs for the asking (once I've actually
: got the Umbrella of World Power in my hands, that is).

What's the bennie package look like?

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

That doesn't do you any good if you comment it out.

: my %test;
: my @data;
: 
: @data = ('244', 'Slightly Evil Bob', 'Chicken & Cucumber');
: 
: %test = (
: 		id 		=> $data[0],
: 		name 		=> $data[1],
: 		sandwich	=> $data[2]
: 	);

You could express this as

  @test{'id', 'name', 'sandwich'} = @data;

or even

  @test{'id', 'name', 'sandwich'} = ( '244', 
                                      'Slightly Evil Bob',
                                      'Chicken & Cucumber' );

were you in the mood to ditch the @data variable.  Hash slices are your
slightly scary and often puzzling friends. :)

: DoSomething (\%test, "Favourite Sandwich Data for: ");
: 
: exit(0);
: 
: 
: sub DoSomething {
:   my %Newhash = shift;
:   my $message = shift;

The first arg is a hash *reference*, but you're shifting it out into a
*hash*.  Bad, bad, bad.  A reference is a scalar.  Recoding:

  my ($nhref, $message) = @_;

:   print $message;
:   print $Newhash{'name'}."\n";
:   print $Newhash{'sandwich'};

  print $message,
        $nhref->{name}, "\n",
        $nhref->{sandwich};

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "There it is; take it."  - William Mulholland


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

Date: Tue, 12 Oct 1999 21:00:25 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Making a hash of subroutines
Message-Id: <3804a07a.1376804@news.skynet.be>

schablone@my-deja.com wrote:

>%test = (
>		id 		=> $data[0],
>		name 		=> $data[1],
>		sandwich	=> $data[2]
>	);
>
>DoSomething (\%test, "Favourite Sandwich Data for: ");
>
>sub DoSomething {
>  my %Newhash = shift;
>  my $message = shift;
>
>  print $message;
>  print $Newhash{'name'}."\n";
>  print $Newhash{'sandwich'};
>}

You're passing a hashref, but you want to use it as a hash. You can use
a hashref instead, by doing

	sub DoSomething {
		my $Newhash = shift;
		print $Newhash->{sandwich};
	}

but this works too:

	sub DoSomething {
		local *Newhash = shift;
		print $Newhash{sandwich};
	}

Assigning a hashref to a typeglob (a "record" of basic Perl datatypes)
only affects the hash part of it. You need to use "local" instead of
"my" because there's no such thing as a lexical typeglob (lexical ->
"my").

-- 
	Bart.


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

Date: 12 Oct 1999 20:51:17 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: Making a hash of subroutines
Message-Id: <7u0706$9p1@courier.xilinx.com>

David Amann <dove@synopsys.com> wrote:
: sub DoSomething {

:     my $r_hash  = shift;          #$r_hash now holds the address of
:                                   # %test
:     my $message = shift;

:     # Check out the following to see how to get stuff out of
:     # The hash reference.
:     print "$message\n";
:     print "ID: " . $r_hash->{"id"} . "\n";
:     print "Name: " . $r_hash->{"name"} . "\n";
:     print "Sandwich: " . $r_hash->{"sandwich"} . "\n";
: }

And you can eliminate some of the concatanation and quoting to
make things a little more readable:

print "ID:       $r_hash->{id}\n";
print "Name:     $r_hash->{name}\n";
print "Sandwich: $r_hash->{sandwich}\n";

-- 
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: Tue, 12 Oct 1999 15:29:04 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Making a hash of subroutines
Message-Id: <MPG.126d560784bdbf1f98a084@nntp.hpl.hp.com>

In article <7u0706$9p1@courier.xilinx.com> on 12 Oct 1999 20:51:17 GMT, 
Jeff Stampes <stampes@xilinx.com> says...
> David Amann <dove@synopsys.com> wrote:
> : sub DoSomething {
> 
> :     my $r_hash  = shift;          #$r_hash now holds the address of
> :                                   # %test
> :     my $message = shift;
> 
> :     # Check out the following to see how to get stuff out of
> :     # The hash reference.
> :     print "$message\n";
> :     print "ID: " . $r_hash->{"id"} . "\n";
> :     print "Name: " . $r_hash->{"name"} . "\n";
> :     print "Sandwich: " . $r_hash->{"sandwich"} . "\n";
> : }
> 
> And you can eliminate some of the concatanation and quoting to
> make things a little more readable:
> 
> print "ID:       $r_hash->{id}\n";
> print "Name:     $r_hash->{name}\n";
> print "Sandwich: $r_hash->{sandwich}\n";

And you can eliminate some of the print statements and quoting to
make things a little more readable:
 
print <<END;
ID:       $r_hash->{id}
Name:     $r_hash->{name}
Sandwich: $r_hash->{sandwich}
END

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 14 Oct 1999 15:16:40 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Making a hash of subroutines
Message-Id: <x3yaepl7nxj.fsf@tigre.matrox.com>


schablone@my-deja.com writes:

> I know hashes are flattened in subroutine calls, so I want to pass a
> reference to the hash. Only it doesn't seem to work. Am I barking up the
> wrong tree?

No. But, you did read perldata and perldsc .... didn't you?

> If anyone can help me on this one, the post of Lord High Keeper of Tall
> Lattes and Pineapple Cubes is theirs for the asking (once I've actually
> got the Umbrella of World Power in my hands, that is).

hmmm.. ok.

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

Uncomment that!!!!

> my %test;
> my @data;
> 
> @data = ('244', 'Slightly Evil Bob', 'Chicken & Cucumber');
> 
> %test = (
> 		id 		=> $data[0],
> 		name 		=> $data[1],
> 		sandwich	=> $data[2]
> 	);
> 
> DoSomething (\%test, "Favourite Sandwich Data for: ");

Here you pass a reference to %test to the subroutine
DoSomething(). Good.

> exit(0);
> 
> 
> sub DoSomething {
>   my %Newhash = shift;

Here's your mistake. You are assigning the reference that you passed
(which is a mere scalar value that happens to point to a hash) to a
hash. So effectively, you are creating a new hash called %Newhash with
one element whose key is a string of the form "HASH(0xcf72c)" and
whose value is undefined.

What you want instead, is to capture the reference, and dereference to
get your hash back. Like so:

	my $Newhash_ref = shift;     # Note that I used '$' not '%'

	my %Newhash = %$Newhash_ref; # here I use '%'

HTH,
--Ala



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

Date: 14 Oct 1999 15:04:44 GMT
From: peter@office.knowledge.com (Peter Galbavy)
Subject: maybe FAQ: web link consistency checker in perl wanted
Message-Id: <slrn80bs8c.1m.peter@office.knowledge.com>


I normally use CPAN for modules, but my cursory search for a script I
could use as a starting point for doing some internal/external link
checking for our web sites turned up not much.

Can someone point me in a direction or refer me to some code that
would help ?

Regards,
-- 
Peter Galbavy
Knowledge Matters Ltd
http://www.knowledge.com/


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

Date: Wed, 13 Oct 1999 10:35:54 GMT
From: bfredett@us.ibm.com
Subject: Merging Arrays
Message-Id: <7u1naa$efc$1@nnrp1.deja.com>

Greetings all.

I need some pointers/examples.

I am using DBD::odbc to perform several SQL queries on several DB2
tables.

Using fetchall_arrayref(), I store the result set in arrays.  Now, I'd
like to merge the arrays such that the end array would act like a Left
Outer Join.  Is this possible or am I chasing my tail?

Thanks,
Brian


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 13 Oct 1999 13:36:51 +0100
From: "Rasmus Rimestad" <rasmusr@online.no>
Subject: Re: Merging Arrays
Message-Id: <Tb_M3.555$7G2.4246@news1.online.no>

I don't know if this helps, but merging arrays is quite simple:
@array1 = ("1","2","3","4","5");
@array2 =("6","7","8","9","10);

@array3 = (@array1, @array2);

Vennlig hilsen
   Rasmus Rimestad, den blå hønas første disippel
   rasmusr@online.no
   http://dikt.cjb.net
   http://bullshitprod.virtualave.net


bfredett@us.ibm.com wrote in message <7u1naa$efc$1@nnrp1.deja.com>...
>Greetings all.
>
>I need some pointers/examples.
>
>I am using DBD::odbc to perform several SQL queries on several DB2
>tables.
>
>Using fetchall_arrayref(), I store the result set in arrays.  Now, I'd
>like to merge the arrays such that the end array would act like a Left
>Outer Join.  Is this possible or am I chasing my tail?
>
>Thanks,
>Brian
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.




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

Date: Wed, 13 Oct 1999 12:00:43 GMT
From: Vincent Murphy <vincent.murphy@cybertrust.gte.com>
Subject: Re: Merging Arrays
Message-Id: <xjgwvsrmpw6.fsf@gamora.ndhm.gtegsc.com>

>>>>> "Rasmus" == Rasmus Rimestad <rasmusr@online.no> writes:

    Rasmus> I don't know if this helps, but merging arrays is quite simple:
    Rasmus> @array1 = ("1","2","3","4","5");
    Rasmus> @array2 =("6","7","8","9","10);

    Rasmus> @array3 = (@array1, @array2);

push() is more efficient though.

perldoc -f push

<- snip ->


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

Date: Wed, 13 Oct 1999 13:40:25 GMT
From: blfredette@my-deja.com
Subject: Re: Merging Arrays
Message-Id: <7u2246$m3j$1@nnrp1.deja.com>

In article <xjgwvsrmpw6.fsf@gamora.ndhm.gtegsc.com>,
  Vincent Murphy <vincent.murphy@cybertrust.gte.com> wrote:
> >>>>> "Rasmus" == Rasmus Rimestad <rasmusr@online.no> writes:
>
>     Rasmus> I don't know if this helps, but merging arrays is quite
simple:
>     Rasmus> @array1 = ("1","2","3","4","5");
>     Rasmus> @array2 =("6","7","8","9","10);
>
>     Rasmus> @array3 = (@array1, @array2);
>
> push() is more efficient though.
>
> perldoc -f push
>

This is great for simply combining two arrays.  What if @array1 and
@array2 contain records from an SQL draw???  I need @array3 to act as a
Left Outer Join merging on a specific column(s).

Thanks,
Brian




Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 13 Oct 1999 16:13:15 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: Merging Arrays
Message-Id: <7u2b2r$12a$3@rguxd.viasystems.com>

bfredett@us.ibm.com wrote:
:>I am using DBD::odbc to perform several SQL queries on several DB2
:>tables.

:>Using fetchall_arrayref(), I store the result set in arrays.  Now, I'd
:>like to merge the arrays such that the end array would act like a Left
:>Outer Join.  Is this possible or am I chasing my tail?

Is there any particular reason why you aren't letting the database
engine do the work?

Why don't you post an example of how you would do it in SQL along
with your Perl attempt so far, then maybe someone will jump in. It's
easier for people to answer if you give them something to work with.
(I'm so glad they made those trailing prepositions legal.  
"with which to work" just doesn't sound right :-)

-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Fri, 15 Oct 1999 15:40:29 +0200
From: A Zielke <azielke@hotmail.com>
Subject: Modul-Initialisation Problem
Message-Id: <38072ECD.439F7F8B@hotmail.com>

Hi,

here's my Problem: I want to read the configuration-data for a program
from disk. I dumped a complex hash with the storage-module and would 
like to read it back into a hash(-ref) within the initialisation of
a module qConfig. Here's the code:

Perlscript:
===========

#!perl -w
use qConfig;

print "*******************************\n"
while ( my ( $k, $v ) = each %qConfig::InternHash ) {
    print "K: $k \t => \t $v\n";
}



Module qConfig:
===============

package qConfig;
use Storable;
use Win32::Mutex;

#### Start initialisation

my $Mutex = Win32::Mutex->new(0,'ConfigMutex');
if ( $Mutex->wait( 60000 ) ) {
        unless ( $ReadHashRef =
                 &Storable::retrieve( $ENV{'VISDIR'}.
                                        '/etc/dumped.hash' ) ) {
                $Mutex->release;
                die "Error while reading config!";
        }
        $Mutex->release;
} else {
        die "Timeout";
}

my %InternHash = %{$ReadHashRef};

#### End of Init

# I can print out the content of %InternHash at this place and it
# is o.k.

# some subs, etc.
#
# 

1;

#### Ende des Moduls


If I put the bit between Start and End into a sub ('Init') and call
that sub from my script after the 'use qConfig;' everything works and
I can print out the content of %qConfig::InternHash allright.
Could anybody explain this behaviour to me and maybe tell me how to do
it right?

Thanks for all hints,
    Andreas

P.S. I tried putting the initialisation of qConfig into a BEGIN-block,
     didn't work.... :(


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

Date: 15 Oct 1999 14:44:00 GMT
From: mgjv@wobbie.heliotrope.home (Martien Verbruggen)
Subject: Re: Modul-Initialisation Problem
Message-Id: <slrn80eff1.qim.mgjv@wobbie.heliotrope.home>

On Fri, 15 Oct 1999 15:40:29 +0200,
	A Zielke <azielke@hotmail.com> wrote:
> 
> #!perl -w
> use qConfig;
> 
> print "*******************************\n"
> while ( my ( $k, $v ) = each %qConfig::InternHash ) {
>     print "K: $k \t => \t $v\n";
> }
> 
> 
> 
> Module qConfig:
> ===============
> 
> package qConfig;
> use Storable;
> use Win32::Mutex;
> 
> #### Start initialisation
> 
[snip]
> my %InternHash = %{$ReadHashRef};
> 
> #### End of Init
> 

> 
> If I put the bit between Start and End into a sub ('Init') and call
> that sub from my script after the 'use qConfig;' everything works and
> I can print out the content of %qConfig::InternHash allright.

You shouldn't be able to. Not while %InternHash is lexically scoped to
the file that has the qConfig package. If you want %InternHash to be
available outside of the file, make it a package variable, and don't
scope it lexically

# perldoc -f my
A C<my()> declares the listed variables to be local (lexically) to the
enclosing block, file, or C<eval()>.
                 ^^^^

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | I'm just very selective about what I accept
Commercial Dynamics Pty. Ltd.   | as reality - Calvin
NSW, Australia                  | 


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

Date: Fri, 15 Oct 1999 17:08:11 +0200
From: A Zielke <azielke@hotmail.com>
Subject: Re: Modul-Initialisation Problem
Message-Id: <3807435B.29E162E3@hotmail.com>


> You shouldn't be able to. Not while %InternHash is lexically scoped to
> the file that has the qConfig package. If you want %InternHash to be
> available outside of the file, make it a package variable, and don't
> scope it lexically
> 

I have subs in qConfig, that access the config-hash, but they fail, too.


Andreas


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

Date: Tue, 12 Oct 1999 19:58:18 GMT
From: alex <alexkrowitz@my-deja.com>
Subject: Re: Module throws exception only when I'm catching it?
Message-Id: <7u03sg$aes$1@nnrp1.deja.com>

I just recently noticed the same thing. The only way I can explain it is
to postulate that AUTOLOAD itself is called in an eval {} block, and the
$@ return string or the $autoload name is checked for "DESTROY". In
other words, Perl makes sure that execution doesn't stop on DESTROY
calls to AUTOLOAD.

If that's what really happens, it would be fine, except that it doesn't
work when we add our own eval {} blocks.

- Alex


In article <ZAdM3.1542$%6.329647@news.itd.umich.edu>,
  mcafee@waits.facilities.med.umich.edu (Sean McAfee) wrote:
> The Curses module has an AUTLOAD method that looks like this:
>
> sub AUTOLOAD
> {
>     my($name, $val);
>
>     ($name = $AUTOLOAD) =~ s/.*:://;
>     croak "Curses does not support the curses constant '$name', used"
>     unless $_al{$name};
>
>     $val = constant($name, $_al{$name});
>     eval "sub $AUTOLOAD { $val }";
>     goto &$AUTOLOAD;
> }
>
> Mystery #1:
>
> The %_al hash does not contain the key "DESTROY", so it appears that
this
> method should call croak() whenever a Curses object is destroyed.  It
> doesn't, normally (see below).  I've checked the C source for this
module,
> and found nothing that would alter this behavior.
>
> Mystery #2:
>
> { my $win = new Curses; }
>
> This code produces no errors.
>
> eval { my $win = new Curses; };
> print $@;
>
> This code prints out
>
> (in cleanup) Curses does not support the curses constant 'DESTROY',
> used at ...
>
> So, it looks like I've caught an exception, but no exception would
have
> been thrown if I hadn't wrapped the Curses object creation and
destruction
> in an eval{}.
>
> What the heck is going on here?
>
> --
> Sean McAfee
mcafee@umich.edu
> print eval eval eval eval eval eval eval eval eval eval eval eval eval
eval
> q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker
?:~|+=-*&^%$#@!
>

--
Alex <alexkrowitz@my-dejanews.com>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 12 Oct 1999 23:22:56 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Module throws exception only when I'm catching it?
Message-Id: <7u0fsg$qn9$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Sean McAfee
<mcafee@waits.facilities.med.umich.edu>],
who wrote in article <ZAdM3.1542$%6.329647@news.itd.umich.edu>:
> Mystery #1:
> 
> The %_al hash does not contain the key "DESTROY", so it appears that this
> method should call croak() whenever a Curses object is destroyed.  It
> doesn't, normally (see below).  I've checked the C source for this module,
> and found nothing that would alter this behavior.

Failures during "invisible" execution of code (such as destruction,
END and global cleanup) are "forgiven".  I consider this as a bug.

I do not remember whether this is fixed with later Perls, at least it
is fixed during global cleanup.

> Mystery #2:
> 
> { my $win = new Curses; }
> 
> This code produces no errors.
> 
> eval { my $win = new Curses; };
> print $@;
> 
> This code prints out
> 
> (in cleanup) Curses does not support the curses constant 'DESTROY',
> used at ...

Same here.  Or probably a leakage of $@ when it should not have
leaked.  Hard to tell what is a "correct behaviour".  Reporting
details on p5p may help - but check the development releases first.

These croaks should be downgraded to warnings, not silently ignored.

Ilya


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

Date: Tue, 12 Oct 1999 15:26:41 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: move files in directories recusively in Windows using Perl
Message-Id: <3803B5A1.B34844D9@mail.cor.epa.gov>

Benny Chee wrote:
> 
> Hi,
> 
>     Is there a method to move files + directories (recursively) to
> another directory
>     using Perl for Win32 (AcitvePerl) ?
> 
>     Other than excuting DOS commands (move.exe), is there a Perl way of
> doing it?

Yes.  Take a look at the File::Find and File::Copy modules.
File::Find will let you do the recursing quite easily, and
File::Copy will let you do the moving in a nice, portable
manner.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 13 Oct 1999 02:00:22 GMT
From: darkon@one.net (David Wall)
Subject: Re: move files in directories recusively in Windows using Perl
Message-Id: <3803e7f0_1@news2.one.net>

In article <3803B5A1.B34844D9@mail.cor.epa.gov>, David Cassell <cassell@mail.cor.epa.gov> wrote:
>Yes.  Take a look at the File::Find and File::Copy modules.
>File::Find will let you do the recursing quite easily, and
>File::Copy will let you do the moving in a nice, portable
>manner.

I thought the docs for File::Find were a bit obfuscated the very first 
time I read them.  The wanted function was clear enough, but it took a bit 
of tinkering before I figured out that the other arguments were a list of 
directories.  But maybe I was just being obtuse.

One thing still seems confusing:  the docs say

"File::Find assumes that you don't alter the $_ variable. If you do then 
make sure you return it to its original value before exiting your 
function."

I take this to mean that before I assign a value to any new variables, I 
need to save a copy of the current value of $_, like so:

sub wanted {
   my $save = $_;
   if ( /pattern/ ) {
      my $pathfile = File::Find::dir . '/' . $_;  # $_ gets reset
      open FILE, $pathfile or die($!);
      # do other stuff to the file
   }
   $_ = $save;  # put $_ back to the way we started
}

Is this correct?

-- 
David Wall
darkon@one.met


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

Date: 13 Oct 1999 15:06:16 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: move files in directories recusively in Windows using Perl
Message-Id: <7u2758$lt$1@rguxd.viasystems.com>

David Wall <darkon@one.net> wrote:
:>I thought the docs for File::Find were a bit obfuscated the very first 
:>time I read them.  The wanted function was clear enough, but it took a bit 
:>of tinkering before I figured out that the other arguments were a list of 
:>directories.  But maybe I was just being obtuse.

Or maybe the documentation assumes more than a passing knowledge of
the Unix find command.

:>One thing still seems confusing:  the docs say

:>"File::Find assumes that you don't alter the $_ variable. If you do then 
:>make sure you return it to its original value before exiting your 
:>function."

:>I take this to mean that before I assign a value to any new variables, I 
:>need to save a copy of the current value of $_, like so:

:>sub wanted {
:>   my $save = $_;
:>   if ( /pattern/ ) {
:>      my $pathfile = File::Find::dir . '/' . $_;  # $_ gets reset
:>      open FILE, $pathfile or die($!);
:>      # do other stuff to the file
:>   }
:>   $_ = $save;  # put $_ back to the way we started
:>}

:>Is this correct?

No, but you are makeing progress.

Nothing in the above code would have set $_.  If you did want to
set it, use "local", but it might be easier just to not mess
with $_.

sub wanted {
	if (/pattern/) {
		local $_ = File::Find::dir . '/' . $_; # for whatever reason.
		# do other stuff with new version of $_
	}
	# At this time the local version goes out of scope and File::Find
	# gets the original back
}

See
perldoc -f local
which will lead you into perlsub.


-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Thu, 14 Oct 1999 00:35:33 GMT
From: darkon@one.net (David Wall)
Subject: Re: move files in directories recusively in Windows using Perl
Message-Id: <38052598_1@news2.one.net>

In article <7u2758$lt$1@rguxd.viasystems.com>, lee.lindley@viasystems.com wrote:
[I said the docs for File::Find were confusing]
>
>Or maybe the documentation assumes more than a passing knowledge of
>the Unix find command.

That would explain it, then, as I have only a casual knowledge of Unix 
from school, and since I majored in stats, I mostly wrote SAS programs, 
which is hardly programming at all.  I did once write a shell script which 
brought the system to a crawl until the sysadmin yelled from the next 
room that she was killing it.  It was a prank script that sent a friend 
the same email over and over, without sleeping at all......  but that's 
wandering off-topic.

[snip code and other stuff about File::Find]
>See
>perldoc -f local
>which will lead you into perlsub.

Which leads you to perlref, etc... :-)  I've read about the difference 
between 'local' and 'my', and don't really have a problem with them unless 
you start getting too subtle.  (A relative, term, I'll admit.)  My problem 
was that somehow I got it into my head that $_ stored the result of the 
last assignment to a variable.  I think you can see how I got that 
impression. Since I thought I knew what it meant, I always skimmed over $_ 
when I was looking through perlvar.

That's embarassing, and I hate to admit it.  Oh, well, the embarrassment 
will help it stick.  :-)

(But I'm still embarrassed)

-- 
David Wall
darkon@one.net


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

Date: Wed, 13 Oct 1999 20:00:11 +0800
From: "James Chua" <jamescwm@singnet.com.sg>
Subject: msql module
Message-Id: <7u1sj2$qn8$1@mawar.singnet.com.sg>

I have this problem installing the msql module from cpan.
>The module I was trying to install is msql-mysql-modules-1
>
>after extracting the zip file using winzip, i proceed to install the module
>as follows:
>
>perl makefile.pl, it then prompts me the following:
>
>(A)  which driver do u want to install?
>1)    Mysql only
>2)    msql only (either of msql 1 or msql 2)
>3)    Mysql and msql ( either of msql 1 or msql 2)
>4)    msql 1 and msql 2
>5)    Mysql, msql 1 and msql 2
>
>I chose 4 and the second prompt follows:
>
>(B)    Do you want to install the msql emulation?...........
>
>I chose  Yes
>
>(C)    Where is your msql installed? Please tell me the dir that
>contains the subdir 'include'
>
>I typed in c:\msql, the subdir 'include' is inside this msql dir
>
>(D)    Where is your msql installed? Please tell me the dir that
>contains the subdir 'lib'
>
>I typed in c:\msql also, since 'lib' is within c:\msql. But it give me this
>error:
>
>error : cannot find lib/libmsql.a in c:\msql
>
>I check up the 'lib' dir and found no file by the name libmsql.a
>The closest match i can find is libmsql.lib
>
>The msql is a win32 version obtained from joshua Dinerstein
>which is found at http://shell.warped.com/~joshua/
>
>I have used his version of msql and it works well and his version doesn't
>seem to contain the libmsql.a file.
>
>I couldn't proceed from here, please anyone out there who know the
solution,
>kindly enlighten me   ASAP. It is very urgent!!!  thank you
>
>
>From : James Chua
>
>
>
>
>





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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 1068
**************************************


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