[19318] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1513 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 13 21:06:24 2001

Date: Mon, 13 Aug 2001 18:05:15 -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: <997751114-v10-i1513@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 13 Aug 2001     Volume: 10 Number: 1513

Today's topics:
    Re: $string = s/\|//g; error - why? <gnarinn@hotmail.com>
    Re: Accessing a widget when defined local to a sub <Pcmann1@btinternet.com>
    Re: Accessing a widget when defined local to a sub <gnarinn@hotmail.com>
    Re: Anyone know a mailist list opt-in script that can a (Steve)
    Re: array question... sort of <leary@foad.NOSPAM.org>
    Re: array question... sort of (Tad McClellan)
        DBD::DB2 help <jim3@psynet.net>
        Embedding perl under Windows (Cory C. Albrecht)
        FAQ: How can I reliably rename a file? <faq@denver.pm.org>
        Global hash requires explicit package name?? <miscellaneousemail@yahoo.com>
    Re: Global hash requires explicit package name?? <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Global hash requires explicit package name?? <krahnj@acm.org>
    Re: How do I assing an entire array? (wade)
    Re: How do I assing an entire array? (Stan Brown)
    Re: How do I assing an entire array? (Stan Brown)
    Re: How do I assing an entire array? (Stan Brown)
    Re: How do I assing an entire array? <bart.lateur@skynet.be>
    Re: How do I assing an entire array? <Tassilo.Parseval@post.rwth-aachen.de>
        Module installation problem <ronnie@r-davies.demon.co.uk>
    Re: Module installation problem <bart.lateur@skynet.be>
    Re: Module installation problem <bart.lateur@skynet.be>
        Multiple field seperators with split() <dont@mail.me>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 13 Aug 2001 22:40:37 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: $string = s/\|//g; error - why?
Message-Id: <997742437.0876297624781728.gnarinn@hotmail.com>

In article <b1b8a8d6.0108130625.62302061@posting.google.com>,
Richard Lawrence <ralawrence@my-deja.com> wrote:
>Hi all,
>
>I'm a little lost. Can someone please explain to me why:
>
>  $string = s/\|//g;
>
>causes the error:
>
>  Use of uninitialized value in substitution (s///)
>
>I looked in "man perlre" and was told that the pipe is Alternation but
>I'm a little confused because I've escaped it with the \.
>

the problem is not the s/// but rather the string that the s/// is
bound to (is acting on). in this case you have nothing bound so the
default ($_) is used. your statement is equivalent to
       $string = ($_ =~ s/\|//g);
$_ is probably undefined, resulting in your warning

>All I want to do is take a string and remove all the pipes from it!

then my guess is that you meant:
       $string =~ s/\|//g;

gnari


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

Date: Mon, 13 Aug 2001 23:57:22 +0100
From: "Peter Mann" <Pcmann1@btinternet.com>
Subject: Re: Accessing a widget when defined local to a sub
Message-Id: <9l9lv0$is$1@neptunium.btinternet.com>

Dear gnari,

Thanks for the code example! But ill try to get exectly to the point what my
problem is!
In the following code example the sub 'fillCombo' works great! When I press
the button on my form, the combo widget gets populatd. Just what I want!

However, someone from another newsgroup advised me always to 'use strict'.
The problem is when I use strict I get the problem

      Global symbol "$combo1" requires explicit package name at program.pl
line 30.

So therefore change the line and place 'my' in front of it, like so

     my $combo1=$page1_p->BrowseEntry(-label=>"combo box : ");

This solves the problem, and my program then loads. However, now I can't
access me widget since it is defined local to the sub 'donotebook'. This is
the only difficulty I am having!


I would really appreaciate any further advice on this, I hope now Ive
explained more clearly the problem I am having.

Thanks in advance

  - Pete







use Tk;
use Tk::DialogBox;
use DBI;
use Tk::NoteBook;
use Tk::LabEntry;
use TK::BrowseEntry;
use strict;

use vars qw($top);

$top = MainWindow->new;
my $pb = $top->Button(-text => "Notebook", -command => \&donotebook);
$pb->pack;
MainLoop;


my $f;


sub donotebook {
    if (not defined $f) {

 $f = $top->DialogBox(-title => "Example",
        -buttons => ["OK", "Cancel"]);
 my $n = $f->add('NoteBook', -ipadx => 6, -ipady => 6);

 my $page1_p = $n->add("page1", -label => "Page 1");
 my $page2_p = $n->add("page2", -label => "Page 2");

 $combo1=$page1_p->BrowseEntry(-label=>"combo box : ");
 $combo1->pack(-side=>'top', -anchor=>'nw');

 $page1_p->Button(-text=>"Go", -command=>\&fillCombo)
                               ->pack(-side   => 'top', -anchor => 'e');

 $n->pack(-expand => "yes", -fill => "both", -padx => 5, -pady => 5,
          -side => "top");
  }
  my $result = $f->Show;
}





sub fillCombo
{
  $combo1->insert('end', 'item1', 'item2');
}




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

Date: Mon, 13 Aug 2001 23:02:19 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Accessing a widget when defined local to a sub
Message-Id: <997743739.605692516546696.gnarinn@hotmail.com>

In article <9l9lv0$is$1@neptunium.btinternet.com>,
Peter Mann <Pcmann1@btinternet.com> wrote:
>
>However, someone from another newsgroup advised me always to 'use strict'.
>The problem is when I use strict I get the problem
>
>      Global symbol "$combo1" requires explicit package name at program.pl
>line 30.
>

(snip)


>use strict;
>
>use vars qw($top);

this line tells perl that you want to use the variable $top as a global
(you are 'declaring' a global variable) and strict will not raise error
on that account. just add all the variables you want in that list

  use vars qw($top $combo1 $combo2
              $anothervar @anarray %ahashjustformeasure
	     );

  use vars qw($evenmorevariables_ina_separate_usevars);

gnari


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

Date: 13 Aug 2001 23:23:28 GMT
From: steve@zeropps.uklinux.net (Steve)
Subject: Re: Anyone know a mailist list opt-in script that can automatically send daily messages?
Message-Id: <slrn9ngnn3.ht3.steve@zero-pps.localdomain>

On 13 Aug 2001 10:57:46 -0700, Jerry wrote:
>Hello,
>
>Does anyone know a mailist list opt-in script that can automatically
>send daily messages?
>
>I need a script where I can add 7 days of meditations and have the
>script send out each daily meditation automatically for the week.
>
>I have seen lots of mailing list scripts, but I haven't found one that
>will send out automatic messages for the days of the week.

I'd tend to go for cron jobs and bash scripts if it's really as simple 
ay you've explained it above. 

If you need some further assistance mail me as I don't see it as being 
a perl problem. 

--
Cheers
Steve              email mailto:steve@zeropps.uklinux.net

%HAV-A-NICEDAY Error not enough coffee  0 pps. 

web http://www.zeropps.uklinux.net/

or  http://start.at/zero-pps

 12:10am  up 31 days,  2:13,  2 users,  load average: 1.00, 1.13, 1.13


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

Date: Mon, 13 Aug 2001 17:48:58 -0500
From: "Leary" <leary@foad.NOSPAM.org>
Subject: Re: array question... sort of
Message-Id: <bMYd7.51436$C7.16685819@e3500-chi1.usenetserver.com>

Please disregard the previous post in this thread by me. My stupid
fingers<g> caused a typo. When I fixed my mistake, the code snippet
functioned flawlessly.

"Leary" <leary@foad.NOSPAM.org> wrote
>
> "Tad McClellan" <tadmc@augustmail.com> wrote;
> > Leary <leary@foad.NOSPAM.org> wrote:
> >
> <snip>
>  >
> > When you find yourself explicitly indexing into an array, you
> > should pause and consider if you doing it the "non-Perl way".
> > You seldom need to index arrays yourself in Perl:
> >
> >    foreach my $aref ( @array ) {
> >       $tot += $aref->[8];
> >    }
> >
> This loop causes an error;
> Use of uninitialized value in array element at C:\Perl\hsesum4.pl line 18,
> <TEST
> DATA> line 979.
>
> I'm guessing that is just an eof thing since my sample data has exactly
979
> lines in it, starting at one, not zero.
>
> It also gives an incorrect total, 7785.25. The difference is the exact
> amount of the first transaction in the sample data I am working with ...
> could it have added that first element twice?
>
> > Let perl manage the indexing for you. Machines make mistakes far
> > less often than people do  :-)
>
>
>
>





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

Date: Mon, 13 Aug 2001 17:53:40 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: array question... sort of
Message-Id: <slrn9ngj34.6cb.tadmc@tadmc26.august.net>

Leary <leary@foad.NOSPAM.org> wrote:
>
>"Tad McClellan" <tadmc@augustmail.com> wrote;
>> Leary <leary@foad.NOSPAM.org> wrote:
>>
><snip>
> >
>> When you find yourself explicitly indexing into an array, you
>> should pause and consider if you doing it the "non-Perl way".
>> You seldom need to index arrays yourself in Perl:
>>
>>    foreach my $aref ( @array ) {
>>       $tot += $aref->[8];
>>    }
>>
>This loop causes an error;
>Use of uninitialized value in array element at C:\Perl\hsesum4.pl line 18,
><TEST
>DATA> line 979.
>
>I'm guessing that is just an eof thing since my sample data has exactly 979
>lines in it, starting at one, not zero.


I expect so. Then it is the loading up of the array that is broken.
Can't help with that part. No code (hint).


>It also gives an incorrect total, 7785.25. The difference is the exact
>amount of the first transaction in the sample data I am working with ...
>could it have added that first element twice?


Only if you put it into the array twice :-)

See if you have the right number of entries in the array:

   print scalar(@array), " elements in \@array\n";

See what the last one looks like:

   print "@{$array[-1]}\n";


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 14 Aug 2001 00:35:02 GMT
From: Jim Thomason <jim3@psynet.net>
Subject: DBD::DB2 help
Message-Id: <jim3-D212B4.19373613082001@news1.mntp1.il.home.com>

We're using DBD::DB2 @ work and are encountering an odd problem, while 
doing a large batch import, my script will occasionally just die with a 
segmentation fault and dump core.

The DBA traced the error in DB2 to a bind on a particular column, and I 
confirmed that by peppering my script with debugging code.

We do know that if we alter the value of the column to pretty much 
anything else, the full insert will succeed without the segfault.

But it gets weirder.  Like I said, this is a batch import, pulling in 
about 100 or so records (in the subset that I'm testing with).  If I 
start counting at 1, it'll die on #50.  But then, if I restart at #47 or 
so, it'll happily insert #50 without issue and keep marching along, next 
dying at around #73.

The drops are apparently random, and the data in them has no pattern 
that we can discern.

This happens whether I use the bind_param method of DBI or if I use the 
placeholders and execute in the values.

The script works flawlessly if I import into MySQL instead of DB2.

Anyone encounter anything like this and have any ideas?


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

Date: Mon, 13 Aug 2001 23:57:39 GMT
From: coryalbrecht@hotmail.com (Cory C. Albrecht)
Subject: Embedding perl under Windows
Message-Id: <TPZd7.709332$eK2.146491182@news4.rdc1.on.home.com>

I'm trying to embed perl into a program I'm writing in order to give the us=
ers=20
some type of scripting facility. Presently I've gotten to the point where I=
=20
can load *.pl files and use perlapi functions like eval_pv(), call_argv() a=
nd=20
so on to execute the code from those files. I can even load in modules whic=
h=20
the perlembed section "Using Perl modules, which themselves use C libraries=
,=20
from your C program" said there probably would be problems doing. And with =
the=20
info given I was able to get past that no problem.

But now I'm stuck. :-(

When I first started on the embbeding of perl into my program, before I got=
=20
this far, my idea was to basically embed perl, then make available to it=20
various functions from inside my program. I had thought that xsubs would al=
low=20
me to do that, but now I see that xsubs are for importing functions in=20
external native-code shared libraries into perl. The stuff in perlembed is=
=20
basically all about calling perl code from your program, but I need the=20
embedded perl to be able to call code from the programme it's embedded insi=
de.

I'm not sure sure I'm explaining this properly, so I'm going to make 2 litt=
le=20
diagrams to help. (See below.)

So if somebody could tell what I've overlooked in the docs, or give me some=
=20
examples to work from I would greatly appreciate it. Even being told that w=
hat=20
I'm trying to do is impossible would better than continuing to waste my ty=
=20
trying to do the impossible.

Thanks in advance!

#1. (basically) how xsubs work
+------------------------------+
|                              |
| my program                   |
|                              |
|  +------------------------+  |
|  |                        |  |
|  | embedded perl          |  |
|  | "use external;         |  |
|  |  $a=3Dexternal::func();" |  |
|  |      +                 |  |
|  |      |                 |  |
+--+------+-----------------+--+
          |
          |<-xsub glue
          |
   +------+-------+
   |      |       |
   | +----v---+   |
   | | func() |   |
   | +--------+   |
   |              |
   | external.so  |
   |              |
   +--------------+

#2. what I'm actually wanting to do
+--------------------------------------------+
|                                            |
| my program                                 |
|                                            |
|  +------------------------+                |
|  |                        |                |
|  | embedded perl          |                |
|  | "use internal;         |                |
|  |  $a=3Dinternal::func();" |                |
|  |         +              |                |
|  |         |              |   +----------+ |
|  |         +--------------+---+-->func() | |
|  |                        |   +----------+ |
+--+------------------------+----------------+

--
Cory C. Albrecht


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

Date: Tue, 14 Aug 2001 00:17:00 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How can I reliably rename a file?
Message-Id: <06_d7.86$V3.170992128@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How can I reliably rename a file?

    Well, usually you just use Perl's rename() function. That may not work
    everywhere, though, particularly when renaming files across file
    systems. Some sub-Unix systems have broken ports that corrupt the
    semantics of rename()--for example, WinNT does this right, but Win95 and
    Win98 are broken. (The last two parts are not surprising, but the first
    is. :-)

    If your operating system supports a proper mv(1) program or its moral
    equivalent, this works:

        rename($old, $new) or system("mv", $old, $new);

    It may be more compelling to use the File::Copy module instead. You just
    copy to the new file to the new name (checking return values), then
    delete the old one. This isn't really the same semantically as a real
    rename(), though, which preserves metainformation like permissions,
    timestamps, inode info, etc.

    Newer versions of File::Copy exports a move() function.

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           05.16
-- 
    This space intentionally left blank


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

Date: Tue, 14 Aug 2001 00:17:55 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Global hash requires explicit package name??
Message-Id: <MPG.15e21bcb6ac54d9198973f@news.edmonton.telusplanet.net>

Hi everyone,

I am learning how to work with hashes and am getting an error which has 
me stumped. I have read through all the perlfaq's on hashes, have read 
the section on hashes in Learning Perl, and have looked up stuff on using 
hashes in Perl through Google.  

Given the following snippets of code:

print_record(\%h, "carlos\@junk.com"); # "carlos\@junk.com" is the key.

 ...

sub print_record
{
  my ($file_hash, $key) = @_;
  my ($value);
  if ($file_hash{$key}) { # <-- ERROR OCCURS HERE
    $value = $file_hash{$key};
    ($email_address, $first_name, $date_started, $tos_version) = 
split(/,/,$key.",".$value);
    write (); # uses a format to print out contents.
  }
  else {
    print "Key not found!";
  }	 
}

I get the following error:

Global symbol "%file_hash" requires explicit package name ... 

This error happens on the line indicated in comments to the code.

I tried if (%$file_hash{$key}) with no success either.  

Does anyone have any suggestions?  

Thanks.

-- 
Carlos 
www.internetsuccess.ca 
*NOTE*: Internet Success is NOT yet fully operational 
so although you are welcomed to visit and take a 
look, trying to subscribe will only be a frustration 
for you as your data will not be saved at this time.


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

Date: Tue, 14 Aug 2001 02:30:50 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Global hash requires explicit package name??
Message-Id: <3B78713A.5060001@post.rwth-aachen.de>

Carlos C. Gonzalez wrote:
> Hi everyone,
> 
> I am learning how to work with hashes and am getting an error which has 
> me stumped. I have read through all the perlfaq's on hashes, have read 
> the section on hashes in Learning Perl, and have looked up stuff on using 
> hashes in Perl through Google. 

It is rather a reference-problem.

> 
> Given the following snippets of code:
> 
> print_record(\%h, "carlos\@junk.com"); # "carlos\@junk.com" is the key.
> 
> ...
> 
> sub print_record
> {
>   my ($file_hash, $key) = @_;
>   my ($value);
>   if ($file_hash{$key}) { # <-- ERROR OCCURS HERE

if (${$file_hash}{$key}) {     # or
if ($file_hash->{$key}) {


$file_hash is a reference to a hash. To dereference it, you write:

my %hash = %$file_hash;  # which is a shortcut for
my %hash = %{$file_hash};

$hash_ref->{key} = $value on the other hand means that you put a value 
into the hash references by $hash_ref.

All this works similarly with arrays:

$array_ref->[0] will give you the first element of the array references 
by $array. You can dereference with either of the two following lines:
my @array = @{$array_ref}; # or
my @array = @$array_ref;

Read 'perldoc perlref' on that. References are often a cause for 
confusion but you'll soon get into that.

Tassilo


-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Tue, 14 Aug 2001 00:36:59 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Global hash requires explicit package name??
Message-Id: <3B7872E6.30448A09@acm.org>

"Carlos C. Gonzalez" wrote:
> 
> I am learning how to work with hashes and am getting an error which has
> me stumped. I have read through all the perlfaq's on hashes, have read
> the section on hashes in Learning Perl, and have looked up stuff on using
> hashes in Perl through Google.
> 
> Given the following snippets of code:
> 
> print_record(\%h, "carlos\@junk.com"); # "carlos\@junk.com" is the key.
> 
> ...
> 
> sub print_record
> {
>   my ($file_hash, $key) = @_;
        ^^^^^^^^^^
This is a _reference_ to a hash.


>   my ($value);
>   if ($file_hash{$key}) { # <-- ERROR OCCURS HERE

    if ( exists $file_hash->{$key} ) {


>     $value = $file_hash{$key};

        $value = $file_hash->{$key};


>     ($email_address, $first_name, $date_started, $tos_version) =
> split(/,/,$key.",".$value);
>     write (); # uses a format to print out contents.
>   }
>   else {
>     print "Key not found!";
>   }
> }
> 
> I get the following error:
> 
> Global symbol "%file_hash" requires explicit package name ...
> 
> This error happens on the line indicated in comments to the code.
> 
> I tried if (%$file_hash{$key}) with no success either.



John
-- 
use Perl;
program
fulfillment


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

Date: 13 Aug 2001 15:59:07 -0700
From: jjchen@alumni.ice.ntnu.edu.tw (wade)
Subject: Re: How do I assing an entire array?
Message-Id: <4259465b.0108131459.1ca0c29@posting.google.com>

stanb@panix.com (Stan Brown) wrote in message news:<9l97p4$bab$1@panix2.panix.com>...
> I'm trying to assign the entire contents of an array (as an array. here is
> what I'm trying:
> 
> $cols{$f_keys[0]}{'SRC_COLS'}['scols'] = @p_keys;
> 

When the Left side is a "scalar value", the right side should be "scalar value" too.
If you get the scalar value of an Array, it will returns its length.
To assign an array to another array, you must write it as:
@array = @another_array.


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

Date: 13 Aug 2001 20:42:02 -0400
From: stanb@panix.com (Stan Brown)
Subject: Re: How do I assing an entire array?
Message-Id: <9l9s4q$22r$1@panix3.panix.com>

In <3B7827AD.4080905@post.rwth-aachen.de> Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> writes:

>Stan Brown wrote:
>> I'm trying to assign the entire contents of an array (as an array. here is
>> what I'm trying:
>> 
>> $cols{$f_keys[0]}{'SRC_COLS'}['scols'] = @p_keys;

>The problem is that you try to assign an array to a hash-element. When 
>designing more complex data-structures you have to bear in mind that 
>elements of arrays or hashes may only contain scalar variables. Going 
>along with this, if you want to store the array, you have to use a
>reference to the array:

>$cols{$f_keys[0]}{'SRC_COLS'} = \@p_keys; # or: $... = [ @p_keys ];

Thaks, I thought of that, but what if @p_keys goes out of scope by the time
I need it?



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

Date: 13 Aug 2001 20:43:25 -0400
From: stanb@panix.com (Stan Brown)
Subject: Re: How do I assing an entire array?
Message-Id: <9l9s7d$27m$1@panix3.panix.com>

In <87hevbkbd0.fsf@abra.ru> Ilya Martynov <ilya@martynov.org> writes:


>SB> I'm trying to assign the entire contents of an array (as an array. here is
>SB> what I'm trying:

>SB> $cols{$f_keys[0]}{'SRC_COLS'}['scols'] = @p_keys;

>SB> Here is where I declare the array:

>SB> my ($pk_table, @p_keys)

>SB> But what I;m getting is just the qunatity of elements in the array.

>SB> What am I doing wrong?

>SB> Heres what Dump() has  to say about this:

>SB> $VAR7 = 'CONSUMER_BRKR';
>SB>     $VAR8 = {
>SB>          'NULLABLE' => 'N',
>SB>          'SRC_COLS' => [
>SB>                   2
>SB>          ],
>SB>          'SRC_TABLE' => 'BRKR',
>SB>          'DATA_LENGTH' => '5',
>SB>          'MASTER_FK' => 1,
>SB>          'DATA_SCALE' => undef,
>SB>          'DATA_PRECISION' => undef,
>SB>          'DATA_TYPE' => 'VARCHAR2'
>SB> };


>$cols{$f_keys[0]}{'SRC_COLS'}['scols'] is same as

>$cols{$f_keys[0]}{'SRC_COLS'}[0] and it is a scalar

>@p_keys is scalar context gives qunatity of elements in the array.

>If you need to assign entire contents of an array to scalar you should
>use array reference. Either [ @p_keys ] (anonymous reference with copy
>of your array) or \@p_keys (reference on your array) instead of just
>@p_keys.

Ah, that was what I was missing. That wont go out of scope.

Thnaks.


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

Date: 13 Aug 2001 20:44:44 -0400
From: stanb@panix.com (Stan Brown)
Subject: Re: How do I assing an entire array?
Message-Id: <9l9s9s$2ch$1@panix3.panix.com>

In <umbgnt4afkqt6s51chgpppedll3qgo1285@4ax.com> Philip Newton <pne-news-20010813@newton.digitalspace.net> writes:

>On 13 Aug 2001 14:54:28 -0400, stanb@panix.com (Stan Brown) wrote:

>> $cols{$f_keys[0]}{'SRC_COLS'}['scols'] = @p_keys;
>                                ^^^^^^^

>This string will be converted to the number 0 so that it can be used as
>an array index. This is unlikely to be what you want -- or if it is,
>that's not a good way to do it.

Ah (Red Face), thatnks.....


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

Date: Tue, 14 Aug 2001 00:48:17 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How do I assing an entire array?
Message-Id: <patgnts5uupfbgk6k0ugp6n9brd4bpirq2@4ax.com>

Stan Brown wrote:

>>$cols{$f_keys[0]}{'SRC_COLS'} = \@p_keys; # or: $... = [ @p_keys ];
>
>Thaks, I thought of that, but what if @p_keys goes out of scope by the time
>I need it?

That's good.

You can keep a reference to a  variable in a hash, and when the variable
goes out of scope, the hash is the only way left to access it. Until you
get rid of the reference in the hash, the variable's value itself will
not be destroyed, although the variable itself is gone.

-- 
	Bart.


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

Date: Tue, 14 Aug 2001 02:49:41 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: How do I assing an entire array?
Message-Id: <3B7875A5.20903@post.rwth-aachen.de>

Stan Brown wrote:

> In <3B7827AD.4080905@post.rwth-aachen.de> Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> writes:
[...]
> 
>>The problem is that you try to assign an array to a hash-element. When 
>>designing more complex data-structures you have to bear in mind that 
>>elements of arrays or hashes may only contain scalar variables. Going 
>>along with this, if you want to store the array, you have to use a
>>reference to the array:
>>
> 
>>$cols{$f_keys[0]}{'SRC_COLS'} = \@p_keys; # or: $... = [ @p_keys ];
>>
> 
> Thaks, I thought of that, but what if @p_keys goes out of scope by the time
> I need it?

Why should it do such a nasty thing? ;-)

Honestly, I can't quite follow you now. You certainly have to take care 
that you don't do something like this:

if ($condition) {
	my @array;
	while (<FILE>) { push @array, $_ if /some_pattern }
}
$cols{key1}{key2} = \@array;

Then @array is lost since it is only visible within the if-block and the 
Perl-interpreter will complain about an unkown variable.

So, take care to declare the array in the right block.

Tassilo


-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Tue, 14 Aug 2001 00:19:49 +0100
From: Ronnie Davies <ronnie@r-davies.demon.co.uk>
Subject: Module installation problem
Message-Id: <Tvpx3EAVCGe7EwFN@r-davies.demon.co.uk>

I am relatively new to Perl and am having problems installing modules.

I am running Activeperl for Windows and am trying to get access to a
Borland Interbase database.  I know that I need DBI and a DBD.  I used
ppm to download and install DBI which went OK but because I could not
find a .ppd file for installing the Interbase DBD driver, I was forced
to get it off CPAN and unzip it.

Having unzipped it to a new subdirectory of my c:\Perl directory, I ran
the following at the command prompt, as instructed:-

perl makefile.pl

It said it was using DBI version 1.14, then asked me for the bin and
include paths of my (local) interbase server, my Microsoft Visual C++
path and finally the lib path for the server.  It the asked for the path
of my test database so I typed in the path of one I previously made in
Interbase followed by the username and password.

It checked if my kit was complete and returned 'All Good'.

Then, the following message appeared:-

Unable to find a perl 5 (by these names: C:\Perl\bin\Perl.exe miniperl
perl perl
5 perl5.6.1, in these dirs: C:\PERL\BIN C:\Perl\bin)
Running '0 -IC:\Perl\lib C:\Perl\lib\ExtUtils\xsubpp -v 2>&1' exits with
status
16777215 at (eval 26) line 17.
Running '0 C:\Perl\lib\ExtUtils\xsubpp temp000 2>&1' exits with status
16777215
at (eval 26) line 43.
Using DBI 1.14 installed in C:/Perl/site/lib/auto/DBI
Writing Makefile for DBD::InterBase

before returning me to the command prompt.

I found a file called 'makefile' in the directory.

As instructed, I next ran nmake.exe, which I had copied to that
directory previously.  I got a fatal error U1081: '0' : program not
found.

That is the point at which I am stuck.  How do I successfully install
the DBD?  I would really appreciate some help as without the DBD, I will
be unable to continue my project.

Thank you very much in advance,

A Perl 'muppet'
-- 
Ronnie Davies

He who laughs last........thinks slowest!


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

Date: Tue, 14 Aug 2001 00:41:32 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Module installation problem
Message-Id: <6asgnt8fnq6v0jufjt6bsdnpqutlmtmh6c@4ax.com>

Ronnie Davies wrote:

>Then, the following message appeared:-
>
>Unable to find a perl 5 (by these names: C:\Perl\bin\Perl.exe miniperl
>perl perl
>5 perl5.6.1, in these dirs: C:\PERL\BIN C:\Perl\bin)
>Running '0 -IC:\Perl\lib C:\Perl\lib\ExtUtils\xsubpp -v 2>&1' exits with
>status
>16777215 at (eval 26) line 17.

You're not running this on NT, are you?

I remember having encountered the very same problem myself, and the
problem was with the "2>&1" thing. NT knows the concept, but Win95/98/ME
do not.

Gee, I currently don't use ActivePerl myself, so I can't really check.
Perhaps it has been fixed. BTW the file to check is ExtUtils/MM_Win32.pm

>I found a file called 'makefile' in the directory.
>
>As instructed, I next ran nmake.exe, which I had copied to that
>directory previously.  I got a fatal error U1081: '0' : program not
>found.

Ah yes. ExtUtils::MakeMaker, upon failure of the above (finding
perl.exe, that is), uses "0" (zero) as the name for perl.exe. Open the
makefile, search for the variable PERL, and replace the value "0" with
"perl", and do the same for FULLPERL, that might be enough to make it
work. The full path would be better still.

   HTH,
   Bart.


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

Date: Tue, 14 Aug 2001 00:55:05 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Module installation problem
Message-Id: <iltgntco0jj86b8041i4301b3601g17d9a@4ax.com>

Bart Lateur wrote:

>>Unable to find a perl 5 (by these names: C:\Perl\bin\Perl.exe miniperl ...

>I remember having encountered the very same problem myself, and the
>problem was with the "2>&1" thing. NT knows the concept, but Win95/98/ME
>do not.

Wait a minute. There was yet another problem. It was that $? returned
non-zero even if the external program was executed properly. You should
check that. Yes, that implies debugging ExtUtils::MM_Win32. Just keep a
backup of that file for when you've finished all of your tests.

-- 
	Bart.


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

Date: Mon, 13 Aug 2001 20:54:02 -0400
From: "noms" <dont@mail.me>
Subject: Multiple field seperators with split()
Message-Id: <9l9srs$6ag$1@bob.news.rcn.net>

Hey everyone, I'm running into problems when parsing some router
information.  This is mainly because I don't know how to setup multiple
field seperators in split().

I'm able to retrieve the router information and store it into an array.
Then I use the grep() function to pull the statistics information that I
need and store it into another array.  I'm having problems when I try to
split the fields in members of that array.  Here is a sample member:

     reliability 255/255, txload 1/255, rxload 1/255

I'd like to be able to pull the numerator fields, in this case 255-1-1.  I'm
trying to get those fields using the following split calls ($foo is the
sample line):

split(/[,\/\s]/, $foo);
split(/[,\/ ]/, $foo);

This produces all empty values.  Then if I just try:

split(/[,\/]/, $foo);

I get values in the array, but the average is combined with the numerator
(e.g. "reliability 255" or "txload 1").  This is fine for display, but I
need to be able to pull the numerator specifically so that I can compare it
to other routers/statistics.  Thanks in advance.




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

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


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