[16579] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3991 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 11 18:11:40 2000

Date: Fri, 11 Aug 2000 15:10:43 -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: <966031841-v9-i3991@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 11 Aug 2000     Volume: 9 Number: 3991

Today's topics:
    Re: Extracting string between XML tag pair from file (Doran)
        Hashes of Hashes of Hashes of Hashes.... <grichard@uci.edu>
    Re: Hashes of Hashes of Hashes of Hashes.... (Steven M. O'Neill)
    Re: Hashes of Hashes of Hashes of Hashes.... <mjcarman@home.com>
        Help: Embedded Perl 5.002 Port DLL fails on Win95 shl@acut.com
    Re: How to Access a hash value? <fthomas@colonypapers.com>
    Re: How to Access a hash value? <care227@attglobal.net>
    Re: How to pass a complex hashreference between two pro <kjetilskotheim@iname.com>
    Re: How to pass a complex hashreference between two pro (Lupe Christoph)
        How to replace the newline in perl? coughlan@gothaminteractive.com
        Intershop <zkent@mail.com>
    Re: London =?iso-8859-1?Q?=A330-35K?= Perl Programmers  (David H. Adler)
    Re: London =?iso-8859-1?Q?=A330=2D35K?= Perl Programmer <care227@attglobal.net>
    Re: multi file modules <memmett@fraser.sfu.ca>
        Negativity in Newsgroup <drawbridge@home.com>
        NewBie question about a search in a Array <info@digitaltango.com>
    Re: NewBie question about a search in a Array <care227@attglobal.net>
    Re: NewBie question about a search in a Array <newsposter@cthulhu.demon.nl>
    Re: NewBie question about a search in a Array (Andrew Johnson)
    Re: NewBie question about a search in a Array <info@digitaltango.com>
    Re: NewBie question about a search in a Array <lr@hpl.hp.com>
    Re: ODBC question <drawbridge@home.com>
    Re: ODBC question lancepr@my-deja.com
    Re: ODBC question <drawbridge@home.com>
    Re: ODBC question <care227@attglobal.net>
    Re: ODBC question <drawbridge@home.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 11 Aug 2000 20:37:40 GMT
From: doran@NOSPAMaltx.net (Doran)
Subject: Re: Extracting string between XML tag pair from file
Message-Id: <39946393.16257470@news2.brandx.net>

On Wed, 09 Aug 2000 08:30:01 GMT, marcel@codewerk.com (Marcel
Grunauer) wrote:

>On Wed, 09 Aug 2000 10:54:44 +0300, Sasa Danicic
><Sasa.Danicic@eurodyn.com> wrote:
>
>>I've got a huge file so I've need to extract a string which matches
>>between first occurance of XML pair of tags.
>
>
>Have a look at XML::Parser (from CPAN).

XML::Simple is another, ah, simple option if all you need is the value
between a single pair of tags.

db




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

Date: Fri, 11 Aug 2000 11:11:15 -0700
From: "Gabe" <grichard@uci.edu>
Subject: Hashes of Hashes of Hashes of Hashes....
Message-Id: <8n1fts$7s1$1@news.service.uci.edu>

What I have is a table with message ids and parent ids. A parent id is the
message id of the message the current record is a reply to. Root messages
have a parent id of "0". So you can see I'm trying to construct a tree of
messages. I want to eventually print that tree out. So I figured I have to
first store everything in some structure like a hash of a hash of
hashreferences, and then somehow iterate over each strand printing them out
as we go. Problem is I don't know how since I'm just starting to get my head
around references.

So, how do I print a threaded conversation like that?

I don't really have any code yet, I don't know really how to begin, I have:

my $pid = '0';
my $parents = $dbh->prepare(qq{SELECT mid FROM messages WHERE pid =
'$pid'});
$parents->execute;

while (my $mid = $parents->fetchrow_array) {
# now I want to print $mid, test if $mid is a parent, print it's children,
# test if its children are parents, print their children and on and on
}


Thanks if you can help or direct me to help!

Gabe




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

Date: 11 Aug 2000 14:23:18 -0400
From: steveo@panix.com (Steven M. O'Neill)
Subject: Re: Hashes of Hashes of Hashes of Hashes....
Message-Id: <8n1gam$5p3$1@panix6.panix.com>

foreach

Gabe <grichard@uci.edu> wrote:
>What I have is a table with message ids and parent ids. A parent id is the
>message id of the message the current record is a reply to. Root messages
>have a parent id of "0". So you can see I'm trying to construct a tree of
>messages. I want to eventually print that tree out. So I figured I have to
>first store everything in some structure like a hash of a hash of
>hashreferences, and then somehow iterate over each strand printing them out
>as we go. Problem is I don't know how since I'm just starting to get my head
>around references.
>
>So, how do I print a threaded conversation like that?
>
>I don't really have any code yet, I don't know really how to begin, I have:
>
>my $pid = '0';
>my $parents = $dbh->prepare(qq{SELECT mid FROM messages WHERE pid =
>'$pid'});
>$parents->execute;
>
>while (my $mid = $parents->fetchrow_array) {
># now I want to print $mid, test if $mid is a parent, print it's children,
># test if its children are parents, print their children and on and on
>}
>
>
>Thanks if you can help or direct me to help!
>
>Gabe
>
>


-- 
Steven O'Neill                                         steveo@panix.com


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

Date: Fri, 11 Aug 2000 13:50:37 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Hashes of Hashes of Hashes of Hashes....
Message-Id: <39944AFD.8B8083CA@home.com>

Subject: Hashes of Hashes of Hashes of Hashes....

What does this have to do with your problem? A good subject will bring
better responses. You want to do threading, so maybe that should be in
your subject?

Gabe wrote:
> 
> What I have is a table with message ids and parent ids.
[...]
> 
> So, how do I print a threaded conversation like that?
> 

This seems to be becoming a (semi) FAQ. Here's a simple threading
algorithm, a search on deja should pull up other ideas:

#!/usr/local/bin/perl -w
use strict;
my (%msgs, %children);

while (<DATA>) {
    next if /^#/; # Skip comment line
    my ($id, $pid, $name) = split;
    $msgs{$id}{parent} = $pid;
    $msgs{$id}{name}   = $name;

    push(@{$children{$pid}}, $id);
}

foreach (@{$children{0}}) {
    Thread($_, 0);
}

sub Thread {
    my $id    = shift;
    my $depth = shift;

    print "  " x $depth . "* $msgs{$id}{name}\n";

    if (exists $children{$id}) {
        foreach (@{$children{$id}}) {
            Thread($_, $depth + 1);
        }
    }
}

__DATA__
# ID    Parent ID   Name
1       0           msg1
2       0           msg3
3       0           msg7
4       0           msg8
5       1           msg2
6       2           msg4
7       6           msg5
8       2           msg6


This prints out:
* msg1
  * msg2
* msg3
  * msg4
    * msg5
  * msg6
* msg7
* msg8

> Problem is I don't know how since I'm just starting to get my 
> head around references.

Type this at your command line:
    perldoc perlref
    perldoc perlreftut

That should get you up and running with references and complex data
structures.

-mjc


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

Date: Fri, 11 Aug 2000 19:03:49 GMT
From: shl@acut.com
Subject: Help: Embedded Perl 5.002 Port DLL fails on Win95
Message-Id: <8n1img$1jc$1@nnrp1.deja.com>

Hi,

We have created a DLL based on Perl release 5.002 which allows the Perl
intepreter to be embedded and called form a C++ client as well as
provide the necessary module glue to allow it to execute C++ native
functions.

We have had this working for some time now (1year +) on Windows NT and
Windows 98.

However I have not been able to make it work on Windows 95 because the
DLL refuses to load with the very peculiar and rather undocumented Error
:
1114 A dynamic link library (DLL) initialization routine failed.
ERROR_DLL_INIT_FAILED

I have tried a number of avenues, mostly in the dark. In particular, I
thought for a while that we had blown some sort of TLS (Thread Local
Storage) limit.

NOTE: Depends.exe finds no undefined or unreachable dependencies that
are not satisfied under Windows 95
This DLL depends on: KERNEL32, ADVAPI32.dll and MSVCRT.DLL.

I know we must be blowing some sort of internal Table limit of the
Linker/Loader specific to Windows 95. However I have not been very lucky
finding any documentation which either provides some "under the hood"
info and even a list of WIn32 APIs not implemented in WIndows 95.

Would a kind sole provide some hints of where to look next ? Or some
information of what was changed in a later version of Perl to make it
work under WIndows 95 (release notes on the cpan site does not have
explicit statements to that effect).

Regards,

Serge Limondin,


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


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

Date: Fri, 11 Aug 2000 15:23:26 -0400
From: <fthomas@colonypapers.com>
Subject: Re: How to Access a hash value?
Message-Id: <qnYk5.9159$Yl1.317615@nntp3.onemain.com>

[snip]
"Drew Simonis" <care227@attglobal.net> wrote in message
news:3994174B.66F7C9FE@attglobal.net...

> Should be: #!/usr/local/bin/perl -Tw
> use strict;
>
> Why do it with an if(){}?
>
> open MASTPASS, "<filename" or die $!;

> I don't know why you are doing it this way, but I can't imagine
> that its working.  Lets see a copy of some of the data you are
> working through, could we?
> You are use'ing CGI, so lets use it...
>
> print header; etc...  If you are importing the standard functions,
> why not use them?  Lots of HTML shortcuts for you.
>
Below is the actual script I am trying to create. With regard to the cgi.pm,
I couldn't find enough information in the cgi.pm documentation to be
confident that I knew what I was doing so I defaulted back to using HTML
print statements. The file filename.txt is as follows:
ed
1234
tom
4567
gary
7894
"end filename.txt"

################Script Start
#!/usr/local/bin/perl

use CGI qw(:standard);

my $custnum = param("CustNum");
my $userid = param("UserID");


if(open(MASTPASS, filename.txt")){

 $key = <MASTPASS>;

 while($key ) {   #read in customer number and user name from file
  chomp($key);
  $value = <MASTPASS>;
  chomp($value);
  $users{$key} = $value;
  $key = <MASTPASS>;}

 close (MASTPASS);

 $customer_number = $users{$userid};
 $customer_number_attempt = $custnum;

 if ($customer_number_attempt eq $customer_number) #This statement seems to
cause the problem
  print "Content-type: text/html\n\n";
  print "<head>\n";
  print "<title>On line ordering</title>\n";
  print "</head>";
  print "<body>";
  print "<h1>Order Form Returned </h1>";  #Create Order Form Here
  print "</body>";

 }else{

 print header, start_html("On line ordering"), h1("Re-enter Login");
 print hr, start_form;
 print p("Please enter your customer number", textfield("CustNum"));
 print p("Please enter your user ID", textfield("UserID"));
 print p(submit("Submit"));
 print end_form, hr;}

}else{
  #print can't open file
  print "Content-type: text/html\n\n";
  print "<head>\n";
  print "<title>On line ordering</title>\n";
  print "</head>";
  print "<body>";
  print "<h1>Problem with system Contact Customer Service</h1>";
  print "</body>";}






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

Date: Fri, 11 Aug 2000 15:59:26 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: How to Access a hash value?
Message-Id: <39945B1E.7DF47A4E@attglobal.net>

fthomas@colonypapers.com wrote:
> 
> ed
> 1234
> tom
> 4567
> gary
> 7894
> "end filename.txt"

Why did you build the data file like this?  Custom would have the 
name and number on a line together, and would make life alot easier:

ed:1234
tom:4567
gary:7894


> 
> if(open(MASTPASS, filename.txt")){

1 open brace.  No matching close.

> 
>  $key = <MASTPASS>;
> 
>  while($key ) {   #read in customer number and user name from file
>   chomp($key);
>   $value = <MASTPASS>;
>   chomp($value);
>   $users{$key} = $value;
>   $key = <MASTPASS>;}

This is still a mess, and is confusing to look at.  (I know what 
it is doing, but there are much better ways, assuming you properly
format your data file.

> 
>  close (MASTPASS);
> 
>  $customer_number = $users{$userid};
>  $customer_number_attempt = $custnum;
> 
>  if ($customer_number_attempt eq $customer_number) #This statement seems to

no opening brace.


>   print "Content-type: text/html\n\n";
>   print "<head>\n";
>   print "<title>On line ordering</title>\n";
>   print "</head>";
>   print "<body>";
>   print "<h1>Order Form Returned </h1>";  #Create Order Form Here
>   print "</body>";
> 
>  }else{
> 
>  print header, start_html("On line ordering"), h1("Re-enter Login");
>  print hr, start_form;
>  print p("Please enter your customer number", textfield("CustNum"));
>  print p("Please enter your user ID", textfield("UserID"));
>  print p(submit("Submit"));
>  print end_form, hr;}
> 
> }else{
>   #print can't open file
>   print "Content-type: text/html\n\n";
>   print "<head>\n";
>   print "<title>On line ordering</title>\n";
>   print "</head>";
>   print "<body>";
>   print "<h1>Problem with system Contact Customer Service</h1>";
>   print "</body>";}

Running this gives:

$ ./test.pl
String found where operator expected at ./test.pl line 27, near "print
""
  (Might be a runaway multi-line "" string starting on line 9)
        (Missing semicolon on previous line?)
syntax error at ./test.pl line 27, near "print ""
Execution of ./test.pl aborted due to compilation errors.


How can you identify problems when it does not even compile?
Your lack of indentation makes following the flow very difficult, 
and further hampers debugging.


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

Date: Fri, 11 Aug 2000 19:25:04 +0200
From: Kjetil Skotheim <kjetilskotheim@iname.com>
To: Konstantinos Agouros <elwood@news.agouros.de>
Subject: Re: How to pass a complex hashreference between two processes?
Message-Id: <39944500.79803F66@iname.com>

Data::Dumper + socket + eval is not a bad idea I think.
At least I know it works, as I've done it myself.
(Although I do not know if Data::Dumper handles
"curcular" referencing and stuff like that, as it was
not necessary for me to know, you should check that if
needed).

Konstantinos Agouros wrote:
> 
> Hi,
> 
> I need to get something like $a where $a is a hashref with arrays and other
> hashreferences in it. From process a to process b. If this would be a C-program
> I would use shared memory. I don't like the idea of constructing something
> parseable and reparse it. The other idea I have would be, to use Data::Dumper
> write the result on a named pipe or socket and eval it on the other site.
> So what's the best way to do this if both processes are on the same Unix-
> Machine?

-- 
Kjetil Skotheim
kjetilskotheim@iname.com


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

Date: 11 Aug 2000 20:30:48 +0200
From: lupe@alanya.lupe-christoph.de (Lupe Christoph)
Subject: Re: How to pass a complex hashreference between two processes?
Message-Id: <8n1goo$hdb$1@alanya.lupe-christoph.de>

elwood@news.agouros.de (Konstantinos Agouros) writes:

>I need to get something like $a where $a is a hashref with arrays and other
>hashreferences in it. From process a to process b. If this would be a C-program
>I would use shared memory.

And why do you reject shared memory in Perl? Look at
IPC::Cache, IPC::Shareable, IPC::Shareable::SharedMem.

>I don't like the idea of constructing something 
>parseable and reparse it. The other idea I have would be, to use Data::Dumper
>write the result on a named pipe or socket and eval it on the other site.
>So what's the best way to do this if both processes are on the same Unix-
>Machine?

I'd rather use a binary format (Storable). Also, have a look
at FreezeThaw. For ideas where to put the encoded data, check
out Apache::Session. It offers a number of methods to store
session data.
-- 
| lupe@lupe-christoph.de       |        http://free.prohosting.com/~lupe |
| "jryy vg ybbxf yvxr gur l2x oht qvqa'g erne vg'f htyl urnq." "lrc. gur |
| qbbzfnlref unir orra cebira jebat lrg ntnva."  ....  "qvq lbh frr gung |
| gbb?" "ubhfgba. jr unir n ceboyrz."           User Friendly 2000-01-01 |


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

Date: Fri, 11 Aug 2000 18:59:29 GMT
From: coughlan@gothaminteractive.com
Subject: How to replace the newline in perl?
Message-Id: <8n1ied$1f7$1@nnrp1.deja.com>

Hi, I'm trying to parse an excel spreadsheet, but I'm having trouble
because the data contains newlines.  That makes it more complex that it
seems.

I thought to replace the windows newline char \n\r with a token,
process the data line by line, and then swap the \n\r back in when I'm
done.

perl -p -e 's/\r\n/~NEWLINETOKEN~/;' gc2.CSV > gc2.out

The problem is this - I need to preserve the newline at the end of each
row.

To do this, I manually added a final column in excel to do an dditional
substitution in perl.

perl -p -e 's/"FinalColumn"/\n/;' gc2.out > gc2.ready

The problem is that this seems to crap out half way, as if it can't
manage the data as one line.

Is there a buffer limit?

Any suggestions? I just want to use the Text:CVS routines to manage the
excel data, but the newlines in the data are driving me crazy!



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


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

Date: Fri, 11 Aug 2000 16:51:14 -0400
From: Zachary Kent <zkent@mail.com>
Subject: Intershop
Message-Id: <39946742.893378E1@mail.com>

Has anyone here used Intershop (Merchant, to be specific)?  I hear it is
written in Perl and extendable by adding new code.  Does anyone have any
experience with it?  What were your thoughts on it vs. other e-commerce
solutions?  What did it cost?

I ask this question in this group cus I am a perl programmer and I want
to know what other perl programmers have to say about this product.  I
tried the alt.comp.intershop group but it is a just a bunch of chain
letters and scams.

Thanks


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

Date: 11 Aug 2000 20:09:21 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: London =?iso-8859-1?Q?=A330-35K?= Perl Programmers Required
Message-Id: <slrn8p8nbh.cu2.dha@panix2.panix.com>

On Thu, 10 Aug 2000 13:00:00 -0400, Drew Simonis
<care227@attglobal.net> wrote:

>checker wrote:
>> 
>> London £30-35K Perl Programmers Required
>> 
>> http://www.hotrecruit.co.uk ,a rapidly expanding Internet
>> recruitment advertising company require Perl programmers to join
>> our team.
>> 
>
>
>Ohhh, you've done it now...
>
>dha should be along any time now...

Jeez... Can't you people do *anything* without me?? :-)

Well, here goes...

You have posted a job posting or a resume in a technical group.

Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.

Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :)

Please do not explain your posting by saying "but I saw other job
postings here".  Just because one person jumps off a bridge, doesn't
mean everyone does.  Those postings are also in error, and I've
probably already notified them as well.

If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.

There is a Perl Jobs Announce list that may be more helpful to you.  See
<http://www.pm.org/mailing_lists.shtml> for details.

Yours for a better usenet,

Wheee....

dha


-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Perl Porters, Inc. today announced the release of version .006 of
their popular Perl5 compiler suite, codenamed `Rabid Rat'."
	- Nathan Torkington on p5p (this was a *joke*)


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

Date: Fri, 11 Aug 2000 16:10:35 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: London =?iso-8859-1?Q?=A330=2D35K?= Perl Programmers Required
Message-Id: <39945DBB.C481B11E@attglobal.net>

"David H. Adler" wrote:
> 
> On Thu, 10 Aug 2000 13:00:00 -0400, Drew Simonis
> <care227@attglobal.net> wrote:
> 
> >
> >Ohhh, you've done it now...
> >
> >dha should be along any time now...
> 
> Jeez... Can't you people do *anything* without me?? :-)


But we miss you ever so much when you aren't here.  Er.... um..
maybe its just me.  buahahaha.


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

Date: 11 Aug 2000 11:43:46 -0700
From: Matthew Emmett <memmett@fraser.sfu.ca>
Subject: Re: multi file modules
Message-Id: <yvw9og2zk599.fsf@fraser.sfu.ca>


Abe and Jason,

Success!  Thanks for your help....

Abe Timmerman <abe@ztreet.demon.nl> writes:

> On 09 Aug 2000 20:46:54 -0700, Matthew Emmett <memmett@fraser.sfu.ca>
> wrote:
> 
> > package Roster;
> I take that to be:
> 	package RosterUI;

No.  That's what's I was trying to do.  Have the Roster class defined
over multiple .pm files.

> You can then call the method like:
> 
> 	$self->build_StudentRoster();
> 
> There should be a reference to the actual object whenever you call an
> object-method (how is perl to know on what object(instance of the class)
> the call is supposed to work?).

Right!  I, ahem, should have realized that.  Anyway, that turned out
to be the key...  Oh, and I did a

use lib './Modules';

in the main program.



So, to summerize:

I now have the Roster class defined over two files: Roster.pm and
RosterUI.pm.

# shddb (main program)
# ...
use lib './Modules';
use Roster;
# ...


# Modules/Roster.pm
package Roster;
use RosterUI;
# ...
sub new {
# ...
  $self->build_StudentRoster();
# ...
}
# ...


# Modules/RosterUI.pm
package Roster;

sub build_StudentRoster {
  my $self = shift;
  # ...
}


Thanks again,
Matt


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

Date: Fri, 11 Aug 2000 21:28:03 GMT
From: DM <drawbridge@home.com>
Subject: Negativity in Newsgroup
Message-Id: <39947037.905C0883@home.com>

Why are there so many negative remarks in this newsgroup?  

People come here with problems and people come here to help others. 
Some questions may not exactly fit the mold, so then don't answer it. 
Perl has so many uses that many of us peogrammers aren't sure where to
turn to look for answers.  Some users won't know if a question was asked
before because someone else asked it in the past.  Get real, there are
new Perl users everyday getting stuck on things you once got stuck on.

No one knows EVERYTHING about this language.  There is no Wise King
here.  So thank you to all of the helpful ones on this group, and to all
of the netative unhelpful ones...go look at yourself in the mirror
because your ego is out of control.


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

Date: Fri, 11 Aug 2000 20:14:02 GMT
From: "Etienne Laverdiere" <info@digitaltango.com>
Subject: NewBie question about a search in a Array
Message-Id: <e8Zk5.142102$Gh.2089147@news20.bellglobal.com>

Hi all,

Is there a "keyword" that could make this :
I have search a while for this, but I dont find it.

if ($value in @Array){
    code;
    }

or

if ($value in ('value1', 'value2', $value3, value4)){
    code;
    }

Thanks for answering.

Etienne Laverdiere




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

Date: Fri, 11 Aug 2000 16:19:48 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: NewBie question about a search in a Array
Message-Id: <39945FE4.C0EC6600@attglobal.net>

Etienne Laverdiere wrote:
> 
> Hi all,
> 
> Is there a "keyword" that could make this :
> I have search a while for this, but I dont find it.
> 
> if ($value in @Array){
>     code;
>     }
> 

http://www.perl.com/pub/doc/manual/html/pod/perlfunc/grep.html


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

Date: 11 Aug 2000 20:39:37 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: NewBie question about a search in a Array
Message-Id: <8n1oa9$jkv$2@internal-news.uu.net>

Etienne Laverdiere <info@digitaltango.com> wrote:
> Hi all,

> Is there a "keyword" that could make this :
> I have search a while for this, but I dont find it.

> if ($value in @Array){
>     code;
>     }

perlfaq4: How can I tell whether a list or array contains a certain element?

Erik



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

Date: Fri, 11 Aug 2000 20:42:36 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: NewBie question about a search in a Array
Message-Id: <0zZk5.22585$k5.225158@news1.rdc1.mb.home.com>

In article <e8Zk5.142102$Gh.2089147@news20.bellglobal.com>,
 Etienne Laverdiere <info@digitaltango.com> wrote:

! Is there a "keyword" that could make this :
! I have search a while for this, but I dont find it.
! 
! if ($value in @Array){
!     code;
!     }
 
You could check the faqs:

    perlfaq4: How can I tell whether a list or array contains a 
              certain element?

Or, for more fun, get Damian's new Quantum::Superpositions module
and use the 'any()' superposition constructor/operator thingy it
provides:

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

    my @array = qw/foo bar blah quux/;
    my $value = 'blah';

    if ( $value eq any(@array) ) {
        print "<$value> is in <@array>\n";
    }
    __END__
    
(but you should *really* look at the faq answer).

regards,
andrew

-- 
Andrew L. Johnson   http://members.home.net/perl-epwp/
      They're not soaking, they're rusting!
          -- my wife on my dishwashing habits


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

Date: Fri, 11 Aug 2000 20:45:51 GMT
From: "Etienne Laverdiere" <info@digitaltango.com>
Subject: Re: NewBie question about a search in a Array
Message-Id: <3CZk5.142181$Gh.2091534@news20.bellglobal.com>

Thanks guys,

Etienne Laverdiere

"Andrew Johnson" <andrew-johnson@home.com> wrote in message
news:0zZk5.22585$k5.225158@news1.rdc1.mb.home.com...
> In article <e8Zk5.142102$Gh.2089147@news20.bellglobal.com>,
>  Etienne Laverdiere <info@digitaltango.com> wrote:
>
> ! Is there a "keyword" that could make this :
> ! I have search a while for this, but I dont find it.
> !
> ! if ($value in @Array){
> !     code;
> !     }
>
> You could check the faqs:
>
>     perlfaq4: How can I tell whether a list or array contains a
>               certain element?
>
> Or, for more fun, get Damian's new Quantum::Superpositions module
> and use the 'any()' superposition constructor/operator thingy it
> provides:
>
>     #!/usr/bin/perl -w
>     use strict;
>     use Quantum::Superpositions;
>
>     my @array = qw/foo bar blah quux/;
>     my $value = 'blah';
>
>     if ( $value eq any(@array) ) {
>         print "<$value> is in <@array>\n";
>     }
>     __END__
>
> (but you should *really* look at the faq answer).
>
> regards,
> andrew
>
> --
> Andrew L. Johnson   http://members.home.net/perl-epwp/
>       They're not soaking, they're rusting!
>           -- my wife on my dishwashing habits




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

Date: Fri, 11 Aug 2000 14:19:02 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: NewBie question about a search in a Array
Message-Id: <MPG.13fe0d9e60b9eb6298ac6d@nntp.hpl.hp.com>

In article <39945FE4.C0EC6600@attglobal.net> on Fri, 11 Aug 2000 
16:19:48 -0400, Drew Simonis <care227@attglobal.net> says...
> Etienne Laverdiere wrote:

 ...

> > Is there a "keyword" that could make this :
> > I have search a while for this, but I dont find it.
> > 
> > if ($value in @Array){
> >     code;
> >     }
> 
> http://www.perl.com/pub/doc/manual/html/pod/perlfunc/grep.html

A you know by now from the other answers, that is *really* poor advice.  
The quoted FAQ specifically says "Don't do this!"

  Please do not use

    $is_there = grep $_ eq $whatever, @array;

  or worse yet

    $is_there = grep /$whatever/, @array;

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


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

Date: Fri, 11 Aug 2000 18:29:05 GMT
From: DM <drawbridge@home.com>
Subject: Re: ODBC question
Message-Id: <3994464B.918F04EB@home.com>

Thanks, but I have been there already.  I even have the book "Win32 on
NT".  The site is good if things are working correctly but not if
something is amiss.  I was hoping to get some help on this problem
because I have nowhere else to go for an answer.

After following all steps in the ODBC install the ODBC.pm works fine
from the prompt, but seesm to be missing something through a web server.

The following line causes the error:
use Win32::ODBC;


Error:
Missing $ on loop variable at C:\perl\lib/Exporter.pm line 40. BEGIN
failed--compilation aborted at C:\Inetpub\wwwroot\cgi-bin\engine6.pl

I am having trouble figuring out exactly what the error is because
Exporter.pm is not commented.  I am assuming certian variables needed
are not being passed to the module.  Hopefully soeone can provide some
helpful advise.

___James


"Dr. Peter Dintelmann" wrote:
> 
>     Hi,
> 
> DM schrieb in Nachricht <3992EFFF.2CBB1281@home.com>...
> 
> >How do you install Win32::ODBC?
> 
>     maybe you should have a look at http://www.roth.net/perl/odbc/
> 
>     Best regards,
> 
>         Peter Dintelmann


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

Date: Fri, 11 Aug 2000 19:03:33 GMT
From: lancepr@my-deja.com
Subject: Re: ODBC question
Message-Id: <8n1im1$1j5$1@nnrp1.deja.com>

I am having a similar problem.

I just set up Active perl and I can't get it to connect to my SQL server

The problem I think I am having is understanding how the DSN works.
In asp i use
MyConn.Open "FILEDSN=c:\ODBC\Data Sources\sql.dsn"
What would be the perl equivalent of this?
Do need to install some sort of driver package to make this work?

Thanks

Lance


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


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

Date: Fri, 11 Aug 2000 19:59:53 GMT
From: DM <drawbridge@home.com>
Subject: Re: ODBC question
Message-Id: <39945B91.AF56D64E@home.com>

Lance,

The perl equivalent is:

$db = new Win32::ODBC("DSN=dnsname;;;")
      or die Win32::ODBC::Error();

As long as the DNS is registered in the windows ODBC manager.  My code
works fine, just not as a CGI script which is is making it impossible to
figure out what to fix on my setup.  

Unfortunatly, the ODBC newsgroup doesn't have nearly as many users on
it, so I came over here.  Thanks for your input.  If you find out
anything else, please let me know.  Good luck.
___James

lancepr@my-deja.com wrote:
> 
> I am having a similar problem.
> 
> I just set up Active perl and I can't get it to connect to my SQL server
> 
> The problem I think I am having is understanding how the DSN works.
> In asp i use
> MyConn.Open "FILEDSN=c:\ODBC\Data Sources\sql.dsn"
> What would be the perl equivalent of this?
> Do need to install some sort of driver package to make this work?
> 
> Thanks
> 
> Lance
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.


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

Date: Fri, 11 Aug 2000 16:04:00 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: ODBC question
Message-Id: <39945C30.5295C3AB@attglobal.net>

DM wrote:
> 
> As long as the DNS is registered in the windows ODBC manager.  

Typo:  DSN, not DNS.  And again, you have quoted jeopardy style
and are posting off topic, evidenced by:

>                                                                My code
> works fine, just not as a CGI script which is is making it impossible to
> figure out what to fix on my setup.
> 
> Unfortunatly, the ODBC newsgroup doesn't have nearly as many users on
> it, so I came over here.  

And now you have again shown your lack of courtesy and knowlege
of long standing Usenet customs.  In other words, you have shown
yourself to be one real ass.

*plonk*


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

Date: Fri, 11 Aug 2000 21:21:54 GMT
From: DM <drawbridge@home.com>
Subject: Re: ODBC question
Message-Id: <39946ECB.DA0B5FD3@home.com>

The customs are to call one another an ass?

> > Unfortunatly, the ODBC newsgroup doesn't have nearly as many users on
> > it, so I came over here.

Means I looked elseware for help when I didn't find it.  It is true,
there are less posting there.
This means nothing negative in any way.

Everyone makes typos.

I expected more understanding from the Perl community.  I guess I
thought wrong.  If I try to help people on here all I get is negativity.

___James


Drew Simonis wrote:
> 
> DM wrote:
> >
> > As long as the DNS is registered in the windows ODBC manager.
> 
> Typo:  DSN, not DNS.  And again, you have quoted jeopardy style
> and are posting off topic, evidenced by:
> 
> >                                                                My code
> > works fine, just not as a CGI script which is is making it impossible to
> > figure out what to fix on my setup.
> >
> > Unfortunatly, the ODBC newsgroup doesn't have nearly as many users on
> > it, so I came over here.
> 
> And now you have again shown your lack of courtesy and knowlege
> of long standing Usenet customs.  In other words, you have shown
> yourself to be one real ass.
> 
> *plonk*


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

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


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