[22703] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4924 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 2 03:05:52 2003

Date: Fri, 2 May 2003 00:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 2 May 2003     Volume: 10 Number: 4924

Today's topics:
    Re: another beginner question <you.gotta@be.kidding.com>
    Re: built in function 'map' examples? (Sam Holden)
    Re: Elegant test for A in B OR B in A? <usenet@tinita.de>
    Re: Elegant test for A in B OR B in A? <uri@stemsystems.com>
    Re: Elegant test for A in B OR B in A? (Malcolm Dew-Jones)
        Forms structure <samj@austarmetro.com.au>
    Re: Forms structure <tassilo.parseval@rwth-aachen.de>
    Re: Get somthing between ( ) from a long string - how - <michael.p.broida@boeing.com>
    Re: Get somthing between ( ) from a long string - how - (Damian James)
        Help: Newbie Looks for advice on glob/read files script (entropy123)
    Re: Help: Newbie Looks for advice on glob/read files sc (Damian James)
    Re: Help: Newbie Looks for advice on glob/read files sc <tassilo.parseval@rwth-aachen.de>
        Help: Save Search Terms in an Array? (entropy123)
    Re: Help: Save Search Terms in an Array? <grazz@pobox.com>
    Re: Is it possible to pass @somethig and $something_els <michael.p.broida@boeing.com>
    Re: Is it possible to pass @somethig and $something_els <REMOVEsdnCAPS@comcast.net>
    Re: Is it possible to pass @somethig and $something_els <you.gotta@be.kidding.com>
    Re: Is it possible to pass @somethig and $something_els (Tad McClellan)
    Re: Newbie Problem: Cannot see result of .pl <you.gotta@be.kidding.com>
    Re: Oracle 9i problem <rereidy@indra.com>
    Re: Parsing multiple files and mixing the data <abigail@abigail.nl>
    Re: Perl - DBI - How to store connection info in a sepa (deepak p)
    Re: Perl - DBI - How to store connection info in a sepa (Bryan Castillo)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 01 May 2003 19:00:15 -0700
From: Michael Eric Battle <you.gotta@be.kidding.com>
Subject: Re: another beginner question
Message-Id: <3EB1D12F.81F8039C@be.kidding.com>

It's easier than all that.  Try:

foreach ( qw(name1 name2 name3 name4 name5 name6 name7) )
{
    # Do something with $_
    # which will hold each name in turn.
}

As Martien mentioned, foreach and for 
are aliases, but foreach is preferred.

Your original code would work if you 
just drop the subscripts, like this:

@names = qw(name1 name2 name3 name4 name5 name6 name7);
for ( @names )
{
    # $_ will hold each name in turn.
}

In general if you have to say something twice
you're not taking the shortest course.
But there may be a reason to do that.

MikEB


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

Date: 2 May 2003 04:24:04 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: built in function 'map' examples?
Message-Id: <slrnbb3sn4.16k.sholden@flexal.cs.usyd.edu.au>

On Thu, 01 May 2003 18:13:41 +0200, Winfried Koenig <w.koenig@acm.org> wrote:
> Sam Holden wrote:
> 
>> For example, map would be useful in your first example, if you had an function
>> which returned the maximum value it was passed:
>> 
>> $maxlen = max(map {length} @lines);
> 
> With perl v5.8.0 you may use:
> 
> #!/usr/local/bin/perl
> 
> use strict;
> use warnings;
> use List::Util qw(min max);
> 
> my @lines = qw(ab abcde abc);
> my $minlen = min(map {length} @lines);
> my $maxlen = max(map {length} @lines);
> print "$minlen $maxlen\n";

I do in fact use List::Util a lot. In fact, to check my code I used almost
the code you posted above :)

-- 
Sam Holden



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

Date: 1 May 2003 22:07:03 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: Elegant test for A in B OR B in A?
Message-Id: <b8s5q7$d88qb$1@ID-24002.news.dfncis.de>

Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "TM" == Tina Mueller <usenet@tinita.de> writes:

>   TM> yep, i agree to that. (but hey, don't we all know Morgan's
>   TM> Transform(?) by heart? ;-) i wasn't sure if i should post it

> de Morgan's theorem

ah, i see, in german we call it the law of de Morgan.
didn't know the english expression.

> A and B  same as !A or !B

little typo:
  !(A and B) == !A or !B

regards, tina
-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
http://www.tinita.de/peace/link.html - Spread Peace


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

Date: Thu, 01 May 2003 22:21:24 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Elegant test for A in B OR B in A?
Message-Id: <x74r4ez4t8.fsf@mail.sysarch.com>

>>>>> "TM" == Tina Mueller <usenet@tinita.de> writes:

  TM> Uri Guttman <uri@stemsystems.com> wrote:
  >>>>>>> "TM" == Tina Mueller <usenet@tinita.de> writes:

  TM> yep, i agree to that. (but hey, don't we all know Morgan's
  TM> Transform(?) by heart? ;-) i wasn't sure if i should post it

  >> de Morgan's theorem

  TM> ah, i see, in german we call it the law of de Morgan.
  TM> didn't know the english expression.

s/theorem/law/

i blew it there. it is a law. and you can get arrested for violating
it. :)

  >> A and B  same as !A or !B

  TM> little typo:
  TM>   !(A and B) == !A or !B

another mistake. groggy brane syndrome. :)

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 1 May 2003 19:46:33 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Elegant test for A in B OR B in A?
Message-Id: <3eb1dc09@news.victoria.tc.ca>

Uri Guttman (uri@stemsystems.com) wrote:

:   >> A and B  same as !A or !B

:   TM> little typo:
:   TM>   !(A and B) == !A or !B

: another mistake. groggy brane syndrome. :)

A little mistake, kind of like a freudian slip.

My point is that the logic is tricky enough that it's *very* easy to get
it wrong.  Not hard, just tricky. 



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

Date: Fri, 02 May 2003 04:34:16 GMT
From: "Sam Jesse" <samj@austarmetro.com.au>
Subject: Forms structure
Message-Id: <3eb1f547$1@news.comindico.com.au>

Hello every one.. great to have a group like you.
since my back groud is Microsfot Access and VB6..  and after doing lots of
reading and buying some very good books on perl and regex. I have not come
accross an example on how to construct a form with text boxs, botton,
dataGrids ...etc.
is  this going to happen under perl or perl uses html which I have to learn
to custom make my form and link data and other info to it. I am confused as
to how perl does it. and what is the differnet between CGI and GUI? I would
appriciagte a link to some basic reading on this issue. thanks to all
Sam




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

Date: 2 May 2003 06:15:19 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Forms structure
Message-Id: <b8t2dn$dsk$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Sam Jesse:

> Hello every one.. great to have a group like you.
> since my back groud is Microsfot Access and VB6..  and after doing lots of
> reading and buying some very good books on perl and regex. I have not come
> accross an example on how to construct a form with text boxs, botton,
> dataGrids ...etc.
> is  this going to happen under perl or perl uses html which I have to learn
> to custom make my form and link data and other info to it. I am confused as
> to how perl does it. 

The form itself is not created in Perl but rather in HTML. You can
certainly use Perl to generate the necessary HTML code but you shouldn't
do it before you've understood the basic lifecycle of a CGI request and
response.

> and what is the differnet between CGI and GUI? 

The former stands for 'common gateway interface'. It is a convention how
two (or possibly more) networked computers interact with each other.
Most commonly this is a client machine with a webbrowser on one side and
the webserver on the other.

A GUI is a 'graphical user interface'. It defines how a human interacts
with a computer. Those two really don't have much in common.

Take http://search.cpan.org/ for instance. The webside contains a form
which allows to enter values. What you see in your browser could be
considered a GUI. Once you enter values into the form and press the
submit button, CGI enters the scene: your values are encoded in a
CGI-conformant way and sent to the webserver. The server receives your
request, does some computation (a little script runs on the server, this
is often a Perl script but could also be written in C, VB or other
programming languages).

After this computation is done the server generates HTML and sends it
back to your browser. Here's a trivial example in Perl:

    #! /usr/bin/perl -wT
    use strict;
    use CGI::Carp qw/FatalsToBrowser/;
    use CGI qw/:standard/;

    my $value = param('keyword');
    my $match = find_value($value);
    
    print header;   # CGI responses need a CGI-header first
    
    print <<EOHTML;
    <html>
    Search results for <b>$value</b>:
    <br>
    $match
    </html>
    EOHTML

    sub find_value {
        my $term = shift;
        open DB, "database" or die $!;
        while (<DB>) {
            return $_ if /$value/;
        }
        close DB;
        return "No match";
    }

It takes one value (from the field named 'keyword' in the form),
searches a file for lines matching this pattern and returns the first
matching line. It does this by generating a little bit of HTML.

> I would
> appriciagte a link to some basic reading on this issue. thanks to all

Did you already consult google? An obvious set of keywords would be 'CGI
tutorial perl' if you are interested in the CGI/Perl combo. Note that a
lot of CGI tutorials on the web are actually of questionable quality so
be sure to read this first:

    http://www.perl.org/CGI_MetaFAQ.html

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Thu, 1 May 2003 23:02:16 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Get somthing between ( ) from a long string - how - newbie Q
Message-Id: <3EB1A778.B189222B@boeing.com>

Tony wrote:
> 
> The list of my text is a $scalar string.
> 
> I need every part between the " " to be a seperate $scalar
> or an @array list so it can be passed to anoter sub for processing.
> 
> I could pass the $scalar and process it at the "other end" but
> the problem remains that assigning to an @array by means of
> splitting causes it to be split like

	Ok, you've got the first three parts split off, and
	you have an "end" piece in $list that you want to
	split some more.

	Don't split on spaces.  Try splitting on the comma
	between the quoted strings:
		@newarray = split /,/, $list;

	That will get you an array where each element is a
	quoted string WITH the quotes.  (Assuming that the
	format of your example is consistent throughout.)
	You'll also have to remove the ( and ) in the first
	and last elements (or remove them before the split).

		Mike


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

Date: 2 May 2003 03:13:38 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Get somthing between ( ) from a long string - how - newbie Q
Message-Id: <slrnbb3oj0.m1i.damian@puma.qimr.edu.au>

On Thu, 1 May 2003 23:02:16 GMT, Michael P. Broida said:
>Tony wrote:
>> I need every part between the " " to be a seperate $scalar
>> or an @array list so it can be passed to anoter sub for processing.
>> 
>> I could pass the $scalar and process it at the "other end" but
>> the problem remains that assigning to an @array by means of
>> splitting causes it to be split like
>...
>	Don't split on spaces.  Try splitting on the comma
>	between the quoted strings:
>		@newarray = split /,/, $list;

The OP's string had spaces after the comma as well (as well as the
enclosing parentheses), so:

  $list =~ s/^(//;
  $list =~ s/)$//;
  my @new = split /, /, $list;

But then you have to worry about embedded commas. Do you want to
allow them if escaped (\,)? Does every field have quotes around it? 

If the string between the parentheses is CSV, then the best solution
is not to reinvent the wheel, but grab the Text::CSV module from CPAN,
read its docs and use it to parse the CSV.

Cheers,
Damian


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

Date: 1 May 2003 21:11:58 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Help: Newbie Looks for advice on glob/read files script...
Message-Id: <90cdce37.0305012011.3a7974a@posting.google.com>

With the help of many fine people on the Usenet I have written the
following script. Supposedly it gathers all the filenames named *.old,
opens one up, looks for something specific, closes the file, and then
opens the next file up ad nausem until all the files have been looked
at.

I think the problem is in the while(INPUT) expression. I use while(<>)
all the time to run individual files but the filehandle and the
filename don't seem to fit the bill...what am I missing?

The code is posted below (minus the looking for things in the file
section)..I'd appreciate any help.

Thanks,
entropy

#!/usr/bin/perl -w

@files = glob '*.old';

foreach $oldfile (@files) {
    open (INPUT, "$oldfile") or die "Can't open $oldfile: $!\n";
    while (INPUT) {
        print "The argument inside of while( } finally worked!!\n";
}
    close INPUT;
}


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

Date: 2 May 2003 05:32:23 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Help: Newbie Looks for advice on glob/read files script...
Message-Id: <slrnbb40n6.m1i.damian@puma.qimr.edu.au>

On 1 May 2003 21:11:58 -0700, entropy123 said:
>...
>I think the problem is in the while(INPUT) expression. I use while(<>)
>all the time to run individual files but the filehandle and the
>filename don't seem to fit the bill...what am I missing?
>...
>    open (INPUT, "$oldfile") or die "Can't open $oldfile: $!\n";
>    while (INPUT) {

	while (<INPUT>) {

>        print "The argument inside of while( } finally worked!!\n";
>}
>    close INPUT;
>}

Cheers,
Damian


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

Date: 2 May 2003 05:37:56 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Help: Newbie Looks for advice on glob/read files script...
Message-Id: <b8t07k$cj0$1@nets3.rz.RWTH-Aachen.DE>

Also sprach entropy123:

> With the help of many fine people on the Usenet I have written the
> following script. Supposedly it gathers all the filenames named *.old,
> opens one up, looks for something specific, closes the file, and then
> opens the next file up ad nausem until all the files have been looked
> at.
> 
> I think the problem is in the while(INPUT) expression. I use while(<>)
> all the time to run individual files but the filehandle and the
> filename don't seem to fit the bill...what am I missing?

You're missing an operator. It's 'while(<INPUT>)'.

> The code is posted below (minus the looking for things in the file
> section)..I'd appreciate any help.
> 
> Thanks,
> entropy
> 
> #!/usr/bin/perl -w
> 
> @files = glob '*.old';
> 
> foreach $oldfile (@files) {
>     open (INPUT, "$oldfile") or die "Can't open $oldfile: $!\n";
>     while (INPUT) {

Perl did in fact tell you what is wrong with the above by emitting the
warning 'Bareword found in conditional at...'.

>         print "The argument inside of while( } finally worked!!\n";
> }
>     close INPUT;
> }

Using <> is more straightforward in this case:

    local @ARGV = glob '*.old';
    while (<>) {
        ...
    }

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 1 May 2003 21:45:52 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Help: Save Search Terms in an Array?
Message-Id: <90cdce37.0305012045.a342d9a@posting.google.com>

Hey all,

Thanks for all your help. My program is looking pretty damned good
right now and I appreciate all you've collectively done. (I found
perlfaq and that is pretty damned good also....)...

My program has many regexs which look awfully similar i.e.

if ($line =~ /\s(Fred)\s/) {
         $Fred +=1;
if ($line =~ /\s(Barney)\s/) {
         $Barney +=1;

How do I most efficiently pull this off?

I was thinking

@name = /Fred Barney/

while (<>) {
$line = $_;

foreach (@name) {
if ($line =~ /\s($name[$i])\s/) {
$nameflint [$i] +=1;
}
}
$i is some sort of counting variable...$i = 1 (Fred) etc...

Isn't this more inefficient? I'd rather have the program look at a
line, if it finds what it is looking for then discard the line so it
isn't searched again...

But something is missing.....

Any help out there?

Thanks,
entropy


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

Date: Fri, 02 May 2003 06:40:09 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Help: Save Search Terms in an Array?
Message-Id: <dposa.48764$J17.35155@twister.nyc.rr.com>

entropy123 <email_entropy123@yahoo.com> wrote:
> 
> My program has many regexs which look awfully similar i.e.
> 
> if ($line =~ /\s(Fred)\s/) {
>          $Fred +=1;
> if ($line =~ /\s(Barney)\s/) {
>          $Barney +=1;
> 
> How do I most efficiently pull this off?

  $ perldoc -q 'many regular expressions'

And all your code has syntax errors.  I know it's meant
as pseudocode, but sometimes just forcing yourself to 
write a "real" example is enough to lead you to the solution.

> I was thinking
> 
> @name = /Fred Barney/
> 
> while (<>) {
> $line = $_;
> 
> foreach (@name) {
> if ($line =~ /\s($name[$i])\s/) {
> $nameflint [$i] +=1;
> }
> }
> $i is some sort of counting variable...$i = 1 (Fred) etc...

Use a hash -->

  my @regexes = map qr/\b($_)\b/, qw/Fred Barney/;
  my %count;

  while (<>) {
    for my $r (@regexes) {
      $count{$1}++ if /$r/;
    }
  }

> Isn't this more inefficient? I'd rather have the program 
> look at a line, if it finds what it is looking for then 
> discard the line so it isn't searched again...
> 
> But something is missing.....

  $ perldoc -f last

And all the flow control operators are discussed in context
in "perlsyn", and there's a categorized list at the top of
the "perlfunc" manpage.

-- 
Steve


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

Date: Thu, 1 May 2003 23:07:31 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Is it possible to pass @somethig and $something_else to sub
Message-Id: <3EB1A8B3.23C4C70A@boeing.com>

"Eric J. Roode" wrote:
> 
> Do not use & to invoke functions.

	I'm not arguing, but I've never been able to get Perl to
	ACCEPT the function call unless I use the & on the call.

	I've read the docs, and seen that they say the same thing:
	it's better to NOT use the & to call functions.

	But I can't figure out what I need to do to make it WORK
	without the & there.  It usually says that it can't find
	the function. But if I just add an & it finds it easily.

	Please give some hints as to what is needed to make a
	function call without "&" work.

		Thanks!
			Mike


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

Date: Thu, 01 May 2003 19:06:03 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Is it possible to pass @somethig and $something_else to sub
Message-Id: <Xns936ECC7DBA49Bsdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Michael P. Broida" <michael.p.broida@boeing.com> wrote in
news:3EB1A8B3.23C4C70A@boeing.com:

> "Eric J. Roode" wrote:
>> 
>> Do not use & to invoke functions.
> 
>      I'm not arguing, but I've never been able to get Perl to
>      ACCEPT the function call unless I use the & on the call.
> 
>      I've read the docs, and seen that they say the same thing:
>      it's better to NOT use the & to call functions.
> 
>      But I can't figure out what I need to do to make it WORK
>      without the & there.  It usually says that it can't find
>      the function. But if I just add an & it finds it easily.

What version of perl are you using?

Can you give an example of a short program which has a subroutine
which you can't invoke without an &?  Cause... it "just works" for
me.  :-)  No hints or tips needed.  No secret trick.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+sbZsY96i4h5M0egRAipSAJ40PW8mSd8DNADj9QJVJqYcOJHN+QCg+tzE
+xPZ6cO7kWylr2jEjIdV2Ao=
=fSVX
-----END PGP SIGNATURE-----


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

Date: Thu, 01 May 2003 19:39:03 -0700
From: Michael Eric Battle <you.gotta@be.kidding.com>
Subject: Re: Is it possible to pass @somethig and $something_else to sub
Message-Id: <3EB1DA47.1657F0AE@be.kidding.com>

Tony wrote:
> 
> I do read all and sundry...including the silly replies
> that may assume that the poster has programming experience :-)

That's good.  You will make many friends that way.

> My perl experience is very new, as is my general programming
> knowledge.  I beleive that term is "newbie..."

If you are a n00b, Perl may not be the all-around best language
in which to learn general programming skills.  It's better than
BASIC, but it will still allow you to develop many rather bad
habits.  Universities teach beginning programming via
bondage-&-discipline languages like Pascal for a reason.

Personally I'd start 'em off in conventional machine language,
and use a different machine for each class.
But I enjoy hearing screams of pain.

Please:

Use the -w option, as recommended by Perl's authors.

use strict;

Get some formal training, at least enough to understand
pointers/references, the difference between pass-by-value
and pass-by-reference, what a variable's "scope" and
"visibility" are, and why global variables are 
considered harmful.

You will save yourself (and others who may 
have to maintain your code) a lot of grief.

MikEB


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

Date: Thu, 1 May 2003 22:57:27 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Is it possible to pass @somethig and $something_else to sub
Message-Id: <slrnbb3r57.2al.tadmc@magna.augustmail.com>

Michael P. Broida <michael.p.broida@boeing.com> wrote:
> "Eric J. Roode" wrote:
>> 
>> Do not use & to invoke functions.
> 
> 	I'm not arguing, but I've never been able to get Perl to
> 	ACCEPT the function call unless I use the & on the call.

> 	Please give some hints as to what is needed to make a
> 	function call without "&" work.


Parenthesis.

   func()

instead of

   &func


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


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

Date: Thu, 01 May 2003 18:28:32 -0700
From: Michael Eric Battle <you.gotta@be.kidding.com>
Subject: Re: Newbie Problem: Cannot see result of .pl
Message-Id: <3EB1C9C0.929B2C6D@be.kidding.com>

Clyde Ingram wrote:
> 
> Why do the respondent and the OP (in his reply) both:
> 
> 1) top post (like this)?, and
> 2) quote the entire posting that they reply to?

The answer to both questions is in their X-Newsreader headers.
And it should be obvious from the content of their discussion.

Wait - _You_'re using it as well!

Are you telling me that Outrage does not _require_ 
one to top post & quote the entire message?

I've never seen anyone do anything else with it,
even in less-than-tolerant froups like n.a.n-a.e,
where they're regularly larted for such behavior.

> Irritating, innit?

Very.  Downright outrageous in a long thread.

But _you_ have also:

Top posted. (Though you did put some stuff at the bottom as well.)
Quoted a loooong message which has no relevance to your post.

So my sweeping generalization stands:
Outrage lusers _always_ top post above a quote 
of the _entire_ message that they're responding to.

And I'll ask you, if you're annoyed by it:
Does Outrage _require_ this, or not?

Hey, at least they're not posting html!

MikEB


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

Date: Thu, 01 May 2003 19:27:56 -0600
From: Ron Reidy <rereidy@indra.com>
Subject: Re: Oracle 9i problem
Message-Id: <3EB1C99C.6070602@indra.com>

This is not a Perl problem.  Log onto metalink.oracle.com and look up 
this issue there.

--
Ron Reidy
Oracle DBA

yu-yu bai wrote:
> I have some perl DBI scripts that loaded data into an Oracle 8i 
> instance without any problem. 
> I created a copy of my tables in an Oracle 9i instance and tried
> to load the same data using those scripts. But I got a bunch of erros
> as following:
> 
> DBD::Oracle::st execute failed: ORA-01461: can bind a LONG value only
> for insert into a LONG column (DBD ERROR: OCIStmtExecute)
> Cannot execute:ORA-01461: can bind a LONG value only for insert into a
> LONG column (DBD ERROR: OCIStmtExecute)
> 
> DBD::Oracle::st execute failed: ORA-03120: two-task conversion
> routine: integer overflow (DBD ERROR: OCIStmtExecute)
> Cannot execute:ORA-03120: two-task conversion routine: integer
> overflow (DBD ERROR: OCIStmtExecute)
> Thanks for any help on this.
> Yu-yu



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

Date: 01 May 2003 22:38:51 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Parsing multiple files and mixing the data
Message-Id: <slrnbb38fq.415.abigail@alexandra.abigail.nl>

Martin McKenny (r1534c@motorola.com) wrote on MMMDXXIX September MCMXCIII
in <URL:news:b8p0p3$bnb$1@newshost.mot.com>:
][  Hi All,
][  
][  I want to read in the lines of multiple files in parallel in order to merge
][  the elements of each file.
][  
][  So if we have three files with listed data as follows:
][  
][  File1 contains data: a1 a2 a3
][  File2 contains data: b1 b2 b3
][  File3 contains data: c1 c2 c3
][  
][  I want to merge these to get a file containing
][  
][  Output file : a1 b1 c1 a2 b2 c2 a3 b3 c3
][  
][  I need to do this as effieciently as possible as the files in question
][  contain hundreds of thousands of data elements.


Assuming the files are given as command line arguments:

#!/usr/bin/perl

use strict;
use warnings;

my @fh = map  {open my $fh => $_ or die "Failed to open $_: $!"; $fh} @ARGV;
   @fh = grep {eof $_ ? () : do {print scalar <$_>; $_}} @fh while @fh;

__END__


Abigail
-- 
perl -Mstrict='}); print "Just another Perl Hacker"; ({' -le1


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

Date: 1 May 2003 19:34:02 -0700
From: deepak10000@hotmail.com (deepak p)
Subject: Re: Perl - DBI - How to store connection info in a separate file
Message-Id: <9e77c6b2.0305011834.5f9345dc@posting.google.com>

ctcgag@hotmail.com wrote in message news:<20030430173050.057$qV@newsreader.com>...
> deepak10000@hotmail.com (deepak p) wrote:
> > Hello,
> >
> > I was wondering if anyone knows the syntax to include DBI connection
> > info in a separate file and make a call to it from a perl dbi script.
> >
> > In the past, I have connection info hard coded in my dbi scripts and
> > they ran file. However, its preferable that this info. is kept in an
> > include file..that gets called instead of having this static info -
> > hard coded in my dbi scripts.
> >
> > I have tried to commenting out the database connection info from my
> > dbi scripts and copied the lines over to a file called
> > "connection.info" also residing in the same directory and then tried
> > inserting stmts like
> >
> > include "connection.info"
> 
> What I've done is make a module in my perl5lib path:
> 
> package My_Stuff;
> 
> sub Oracle {
>   DBI->connect("DBI:Oracle:blah","foo","bar", { RaiseError => 1 });
> };
> 
> 
> Then in my programs I just do:
> 
> my $dbh=My_Stuff::Oracle();
> 
> I've been happy with this.  I'm thinking of adding a
>   require DBI;
> to the connection subroutine, so I don't have to explicitly
> use DBI in my programs, it will automatically load it if and only
> if I actually ask for a connection.  But I wasn't sure if I would also
> need to run import (it seems like you don't need it for purely modules used
> in a purely OO way), so I haven't tried it yet.
> 
> Xho

Xho and Everyone,

Thank you!! I'm also trying to connect to an Oracle database and Xho
example illustration above worked perfectly.

Deepak


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

Date: 1 May 2003 23:48:07 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Perl - DBI - How to store connection info in a separate file
Message-Id: <1bff1830.0305012248.4ca18ab8@posting.google.com>

deepak10000@hotmail.com (deepak p) wrote in message news:<9e77c6b2.0305011834.5f9345dc@posting.google.com>...
> ctcgag@hotmail.com wrote in message news:<20030430173050.057$qV@newsreader.com>...
> > deepak10000@hotmail.com (deepak p) wrote:
> > > Hello,
> > >
> > > I was wondering if anyone knows the syntax to include DBI connection
> > > info in a separate file and make a call to it from a perl dbi script.
> > >
> > > In the past, I have connection info hard coded in my dbi scripts and
> > > they ran file. However, its preferable that this info. is kept in an
> > > include file..that gets called instead of having this static info -
> > > hard coded in my dbi scripts.
> > >
> > > I have tried to commenting out the database connection info from my
> > > dbi scripts and copied the lines over to a file called
> > > "connection.info" also residing in the same directory and then tried
> > > inserting stmts like
> > >
> > > include "connection.info"
> > 
> > What I've done is make a module in my perl5lib path:
> > 
> > package My_Stuff;
> > 
> > sub Oracle {
> >   DBI->connect("DBI:Oracle:blah","foo","bar", { RaiseError => 1 });
> > };
> > 
> > 
> > Then in my programs I just do:
> > 
> > my $dbh=My_Stuff::Oracle();

Another thing you might do is add the ability to add new database
configurations while using the same module.  (This is what I use, a
slight variation on xhos).

I have one module DBFactory that has a class method (not object)
connect
which takes a string.

For that string there should be module named DBFactory/<string>.pm
which has the
real connect method for the database Im interested in.

This allows me to add multiple configurations and choose the one I
want through
command line arg, or config file etc.....  

I left out one method list_configurations, which returns an array of
configurations (pm files under directory DBFactory - use caller to get
dirname of DBFactory.pm).  This is useful for a Tk app I have.


(Test script using DBFactory)
-------------------------------------------
#!perl -I D:/bryanc/dev_perl/dbconn
use strict;
use warnings;
use DBFactory;

foreach my $dbconfig ('mysql_finances', 'pg_psylocke') {
  my $db = DBFactory::connect($dbconfig);
  my $st = $db->prepare('select count(*) from record');
  $st->execute;
  while (my $row = $st->fetchrow_arrayref) {
    print $row->[0], "\n";
  }
  $db->disconnect;
}
-------------------------------------------
# File DBFactory.pm
package DBFactory;
use strict;
use warnings;

sub connect {
  my $module = 'DBFactory::' . shift;
  my $file   = $module . '.pm';
  $file =~ s/::/\//g;
  require $file;
  no strict 'refs';
  # call the connect method of package DBFactory::<sub module>
  return &{*{$module . '::connect'}}(@_);
}
-------------------------------------------
# File DBFactory/pg_psylocke.pm
package DBFactory::pg_psylocke;
use strict;
use warnings;
use DBI;

sub connect {
  my $options = (ref($_[0]) eq "HASH") ? $_[0] : {@_};
  $options->{RaiseError} = 1 if (not exists($options->{RaiseError}));
  return DBI->connect(
    "dbi:PgPP:dbname=psylocke;host=psylocke",
    "bryanc",
    "***",
    $options);
}

1;
-------------------------------------------
# File DBFactory/mysql_finances.pm
package DBFactory::mysql_finances;
use strict;
use warnings;
use DBI;

sub connect {
  my $options = (ref($_[0]) eq "HASH") ? $_[0] : {@_};
  $options->{RaiseError} = 1 if (not exists($options->{RaiseError}));
  return DBI->connect(
    "dbi:mysql:database=finances",
    "bryanc",
    "***",
    $options);
}

1;
-------------------------------------------

> > 
> > I've been happy with this.  I'm thinking of adding a
> >   require DBI;
> > to the connection subroutine, so I don't have to explicitly
> > use DBI in my programs, it will automatically load it if and only
> > if I actually ask for a connection.  But I wasn't sure if I would also
> > need to run import (it seems like you don't need it for purely modules used
> > in a purely OO way), so I haven't tried it yet.
> > 
> > Xho
> 
> Xho and Everyone,
> 
> Thank you!! I'm also trying to connect to an Oracle database and Xho
> example illustration above worked perfectly.
> 
> Deepak


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

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


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