[18317] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 485 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 14 06:06:13 2001

Date: Wed, 14 Mar 2001 03:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984567909-v10-i485@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 14 Mar 2001     Volume: 10 Number: 485

Today's topics:
    Re: "uninitiatlized value" errors? (Martien Verbruggen)
    Re: $ENV{'HTTP_REFERER'} (Tony L. Svanstrom)
    Re: Array Comparison question (Martien Verbruggen)
    Re: Behavior of => after newline <rick.delaney@home.com>
    Re: Can a regex do this? <uri@sysarch.com>
    Re: CPAN Question (Martien Verbruggen)
    Re: Exp. Perl/CGI programmer needed (David H. Adler)
    Re: Formatting HTML using Perl <pne-news-20010314@newton.digitalspace.net>
        graphic manipulation on Perl <kellyboy@nospanner>
    Re: graphic manipulation on Perl <galen.menzel@mail.utexas.edu>
    Re: graphic manipulation on Perl (Martien Verbruggen)
    Re: Grokking map and grep <persicom@acedsl.com>
    Re: Grokking map and grep (Philip Lees)
    Re: How do I get the name of a variable as a string? <donotreply@interbulletin.bogus>
    Re: How to reverse a loop ? <rick.delaney@home.com>
        mime::lite newbie question <apmk@MailAndNews.com>
        Monitoring a Serial Port (/dev/ttyd2) (David Walford)
        Newbie: Need RegExp pattern matching help <djmarcus@ex-pressnet.com>
    Re: oraperl to dbd <galen.menzel@mail.utexas.edu>
        recursive subroutine call <linear@eecs.umich.edu>
    Re: recursive subroutine call <meisl@amvt.tu-graz.ac.at>
    Re: reference problems (Gwyn Judd)
    Re: Run a combination of programs <tony_curtis32@yahoo.com>
    Re: XS: Accessing 'enum' constants <c_clarkson@hotmail.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 14 Mar 2001 21:36:16 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: "uninitiatlized value" errors?
Message-Id: <slrn9auid0.i2s.mgjv@martien.heliotrope.home>

On Tue, 13 Mar 2001 14:04:03 -0500,
	Tad McClellan <tadmc@augustmail.com> wrote:
> John A. Grant <jazrant@zsc.nrcan.zc.ca> wrote:
> 
>>    In C I would have:
>>        somefunc("some string");
>>        somefunc(NULL);


> In Perl that would be:
> 
>    somefunc("some string"); # or, better, somefunc('some string');
>    somefunc(undef);

Just as an addition:

when called as somefunc(), the first argument will also be undef in the
sub. This is somehting that is often used to give default values to
unspecified arguments.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Freudian slip: when you say one thing
Commercial Dynamics Pty. Ltd.   | but mean your mother.
NSW, Australia                  | 


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

Date: Wed, 14 Mar 2001 02:37:07 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: $ENV{'HTTP_REFERER'}
Message-Id: <1eq8pry.19a065z1ncbrm6N%tony@svanstrom.com>

S51 <sdfg@asd.g> wrote:

> "Richard" <rworth5@home.com> wrote in message
> news:QQ9r6.3609$rB2.288054@news1.rdc1.mb.home.com...
> > Unfortunatley I have already thought of that, but there is no change.
> Since
> > it is spelled the exact same way in many other scripts, as well as in the
> > books I have. The spelling should not affect this.
> 
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> foreach (sort keys %ENV)
> {
>     print "$_=$ENV{$_}<BR>\n";
> }

text/plain might be better; that way you get a "correct" text-file
instead of "broken" HTML...


        /Tony


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

Date: Wed, 14 Mar 2001 21:46:58 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Array Comparison question
Message-Id: <slrn9auj12.i2s.mgjv@martien.heliotrope.home>

[reformatted some of article to wrap more logically]

On Tue, 13 Mar 2001 14:22:51 -0800,
	Mahesh A <maheshasolkar@yahoo.com> wrote:
>> ""shazad malik"" hallian@hotmail.com> wrote in message
>> news:F218B2J4XtliS01qCcW0000f8b6@hotmail.com...
>
>> Basically, I have small array which is a subset of the big array. So
>> all elements in small arrayll be present in the big array.  In a
>> nutshell, I'm trying to: "GROUP COMMON ELEMENTS"  between the two and
>> one array "UNIQUE ELEMENTS" in another array."
> 
> A Hash can be used to do the kind of grouping you intend to, like ...
> 
> #!/usr/local/bin/perl -w
> 
> my @arrayOne = qw ( zero one two four five six seven eight);
> my @arrayTwo = qw ( one two three four six seven nine);
> 
> map { if (exists ($tempHash{$_})) { $tempHash{$_}++ } else { $tempHash{$_} =
> 1}} @arrayOne;
> map { if (exists ($tempHash{$_})) { $tempHash{$_}++ } else { $tempHash{$_} =
> 1}} @arrayTwo;

Uck.

Wouldn't it be better to refer the OP to the FAQ, section 4? It has
several questions to which the answers would most likely help the OP.
Code in the FAQ is more likley to be correct than something you cook up
in the heat of the moment, too.

How can I remove duplicate elements from a list or array?
How can I tell whether a list or array contains a certain
       element?
How do I compute the difference of two arrays?  How do I
       compute the intersection of two arrays?
How do I test whether two arrays or hashes are equal?

I'm a bit unclear what the OP means by the second, crudely loud,
question "UNIQUE ELEMENTS", but it's either answered by the first or the
third item above, I think. The first screamer "GROUP COMMON ELEMENTS"
would be the intersection.

I must say the code in the FAQ is easier to follow than this. I didn't
even try, because the lack of formatting, and the overflow of bracketing
just makes my head hurt.

And I don't like map in a void context when there are better constructs
to do this work.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | life ain't fair, but the root
Commercial Dynamics Pty. Ltd.   | password helps. -- BOFH
NSW, Australia                  | 


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

Date: Wed, 14 Mar 2001 03:12:14 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Behavior of => after newline
Message-Id: <3AAEE4D1.C793706B@home.com>

[posted & mailed]

"Gary E. Ansok" wrote:
> 
> @f = grep -f =>
>        @in;
> print "Arrow on 1:", scalar @f, "\n";
> 
> @f = grep -f
>        => @in;
> print "Arrow on 2:", scalar @f, "\n";
> 
> For the first grep, the => quotes the word before it, and we are
> testing the truth value of the string "-f" (always true).
> 
> For the second, no auto-quoting is done, and the value tested is
> that returned by the -f function for each data item (false for
> this data).

This is a bug.  It is fixed in v5.6.1-to-be.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Wed, 14 Mar 2001 04:35:10 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Can a regex do this?
Message-Id: <x7vgpd9ddt.fsf@home.sysarch.com>

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

  BL> Tad McClellan wrote:
  >>> Operators do things. The pattern match operator does the matching,
  >>> the regex is just one of the operands.
  >> ^^^^^^^^
  >> Errr, arguments?

  BL> Parameters!

  BL> Gee, what a choice. I never really know for sure which word to use.

damian conway says that in a sub you have parameters which are passed
arguments in the calling code. operators have operands.

what m// is called, an operator or a function in perl is tricky. in use
it is no different from other perl functions like print or splice. it
has different behavior in list or scalar context like many perl funcs,
it just has a special syntax. so the regex in m// is an argument to the
match operator. the regex and replacement strings are arguments to
s///. if either are bound with =~ then that is another argument (instead
of $_). other languages just make this look like a typical verbose
function call like match( $string, $regex ) or replace( $string, $regex,
$replace). we all know that perl's syntax is better. :)

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 14 Mar 2001 21:48:17 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: CPAN Question
Message-Id: <slrn9auj3h.i2s.mgjv@martien.heliotrope.home>

On Tue, 13 Mar 2001 16:07:56 +0100,
	Klaus-Dieter Söder <meisterplan@t-online.de> wrote:
> Thanks.
> 
>> But why not just use the Paradox Export function?
> 
> Because I am a totally newbe in the Database sector, I even don´t know
> that there exists a Paradox Export function.
> 
> You know my next questions?
> 
> Where can I get information about that?

Euhmmmm.... 

In a group where they talk about databases? Maybe even one specifically
for paradox?

Is that correct?

Do I win something?

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.   | you come to the end; then stop.
NSW, Australia                  | 


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

Date: 14 Mar 2001 05:37:45 GMT
From: dha@panix6.panix.com (David H. Adler)
Subject: Re: Exp. Perl/CGI programmer needed
Message-Id: <slrn9au0t9.ov7.dha@panix6.panix.com>

On Tue, 13 Mar 2001 03:17:01 GMT, waystar <waystar@home.com> wrote:
>Please accept my apologies if this post is not within the rules. Good help
>is hard to find these days:)

Well, it helps if you look in the right places... which this isn't.

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. :)  (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Another good source of information on how Usenet functions is
news.newusers.questions (information from which is also available at
http://www.geocities.com/nnqweb/).

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,

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"I'll keep him as an insurance policy, since, unfortunately, I can't
kill him twice." - Scaroth


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

Date: Wed, 14 Mar 2001 08:24:50 +0100
From: Philip Newton <pne-news-20010314@newton.digitalspace.net>
Subject: Re: Formatting HTML using Perl
Message-Id: <c47uat8stgkcjsj94ahn5tg4ftbohtcfl4@4ax.com>

On 13 Mar 2001 11:16:13 -0800, merlyn@stonehenge.com (Randal L.
Schwartz) wrote:

> >>>>> "Michael" == Michael D Kirkpatrick <wizard@psychodad.com> writes:
> 
> Michael> Like <P> does not necessarily have to have a </P> tag.
> 
> It does in XHTML, which is what the world is moving to.

<nitpick>There is no <P> tag in XHTML.</nitpick>

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Tue, 13 Mar 2001 20:44:01 -0600
From: "kellyboy" <kellyboy@nospanner>
Subject: graphic manipulation on Perl
Message-Id: <tatmimpi13m8ba@corp.supernews.com>

is there ways to manipulate graphic files thru perl... I looked around and
couldnt figure out which is which...

Im looking for way to copy/resize the .jpg( or any other types) to make a
thumbnail from original...

I want to do that from command line and maybe use that for cgi script..

  my linuxbox is a slackware without any of those X window setup
installed...(I only use bare install thats all

thanks

kellyboy
--





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

Date: Tue, 13 Mar 2001 21:53:05 -0600
From: Galen Menzel <galen.menzel@mail.utexas.edu>
Subject: Re: graphic manipulation on Perl
Message-Id: <3AAEEB21.802F314C@mail.utexas.edu>

kellyboy wrote:
> 
> is there ways to manipulate graphic files thru perl... I looked around and
> couldnt figure out which is which...
> 
> Im looking for way to copy/resize the .jpg( or any other types) to make a
> thumbnail from original...
> 
> I want to do that from command line and maybe use that for cgi script..
> 

Check out the PerlMagick module here:

http://cpan.valueclick.com/authors/id/J/JC/JCRISTY/

galen


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

Date: Wed, 14 Mar 2001 21:50:10 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: graphic manipulation on Perl
Message-Id: <slrn9auj72.i2s.mgjv@martien.heliotrope.home>

On Tue, 13 Mar 2001 21:53:05 -0600,
	Galen Menzel <galen.menzel@mail.utexas.edu> wrote:
> kellyboy wrote:
>> 
>> is there ways to manipulate graphic files thru perl... I looked around and
>> couldnt figure out which is which...
>> 
>> Im looking for way to copy/resize the .jpg( or any other types) to make a
>> thumbnail from original...
>> 
>> I want to do that from command line and maybe use that for cgi script..
>> 
> 
> Check out the PerlMagick module here:
> 
> http://cpan.valueclick.com/authors/id/J/JC/JCRISTY/

Of course, to be able to use the PerlMagick module, you'll first need to
install ImageMagick on your machine, and you'll have to make sure that
the versions match up. Maybe you should just go to
http://www.imagemagick.org/, and download a complete bundle, including
the Perl modules from there.

PerlMagick is silly as a module on its own. :)

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd.   | make up 3/4 of the population.
NSW, Australia                  | 


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

Date: Wed, 14 Mar 2001 00:01:43 -0500
From: "Matthew O. Persico" <persicom@acedsl.com>
Subject: Re: Grokking map and grep
Message-Id: <3AAEFB37.BABEBE1A@acedsl.com>

Anno Siegel wrote:
> 
> According to Philip Lees <pjlees@ics.forthcomingevents.gr>:
> > Hi. I had to write a script to read comma-delimited data from a file
> > in a format like this:
> >
> > number, other data, other data, .....
> >
> > (There are also some junk lines that I'm not interested in - I only
> > want the ones that begin with a number followed by a comma.)
> >
> > The lines must then be sorted numerically on the first (number) column
> > and the output written to another file.
> >
> > I managed that OK, then I started thinking about grep and map, which I
> > haven't fully grokked yet. I came up with the following:
> >
> > #!perl -w
> >
> > use strict;
> >
> > open ( IN, "ECG_done.txt" ) || die "Can't open input file: $!";
> > open ( OUT, ">ECG_done_sorted.txt" ) || die "Can't open output file:
> > $!";
> >
> > my $count;
> > print OUT map { ++$count; join ',', @$_ } sort { $$a[0] <=> $$b[0] }
> > map { [ split /,/ ] } grep { /^\d+,/ } (<IN>);

Hmm. If you are going to sort on field 0 anyway, and then rejoin on the
delimiter, why bother? Save some cycles and try this:

print OUT map { ++$count; $_ } sort { $a <=> $b } grep { /^\d+,/ } <IN>;

You don't need the () around <IN> to get list context, either.

-- 
Matthew O. Persico
    
http://www.acecape.com/dsl
AceDSL:The best ADSL in Verizon area


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

Date: Wed, 14 Mar 2001 07:14:26 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Grokking map and grep
Message-Id: <3aaf1a09.62123038@news.grnet.gr>

On Wed, 14 Mar 2001 00:01:43 -0500, "Matthew O. Persico"
<persicom@acedsl.com> wrote:


>Hmm. If you are going to sort on field 0 anyway, and then rejoin on the
>delimiter, why bother? Save some cycles and try this:
>
>print OUT map { ++$count; $_ } sort { $a <=> $b } grep { /^\d+,/ } <IN>;

Well, this works in that it produces the right output, but it
generates a metric buttload of warning messages about the sort
argument not being numeric.

>You don't need the () around <IN> to get list context, either.

Noted. Thanks.

Phil
--
@x=split//,'Just another Perl decoder,';split//,'*'x@x;%i=split/=/,
'AA=a=aa= =1=,';for$i(0..$#x){$_[$i]=chr($=+5);while($_[$i]ne$x[$i])
{$_[$i]=$i{$_[$i]}if$i{++$_[$i]};print@_,"\r";while(rand!=rand){}}}
Ignore coming events if you wish to send me e-mail


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

Date: Wed, 14 Mar 2001 04:10:31 +0000
From: Prem <donotreply@interbulletin.bogus>
Subject: Re: How do I get the name of a variable as a string?
Message-Id: <3AAEEF37.38D9DE74@interbulletin.com>

mjc,

:-) No, I did not lose any sleep over it, and I hope Tad did not either :-)
I appreciate the replies I am getting here, including the one I got from Tad,...helps me explore and expand my knowledge of perl

best,
Prem

_______________________________________________
Submitted via WebNewsReader of http://www.interbulletin.com



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

Date: Wed, 14 Mar 2001 03:34:38 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: How to reverse a loop ?
Message-Id: <3AAEEA0F.2F439CB4@home.com>

Bernie Cosell wrote:
> 
> } for my $bid_el (reverse @bids)
> } {
> } }
> 
> Meta question on efficiency: does Perl actually construct a temporary
> reversed-list, or does it do some magic to optimize that out?

The former.

$ perl -Dts -e '@a=(1..3);for (@a) { print }'
 ...
(-e:1)  pushmark
    =>  *
(-e:1)  gv(main::a)
    =>  *  GV()
(-e:1)  rv2av
    =>  *  AV()
(-e:1)  null
    =>  *  AV()
(-e:1)  gv(main::_)
    =>  *  AV()  GV()
(-e:1)  enteriter

$ perl -Dts -e 'for (1..3) { print }'
 ...
(-e:1)  pushmark
    =>  *
(-e:1)  const(IV(1))
    =>  *  IV(1)
(-e:1)  const(IV(3))
    =>  *  IV(1)  IV(3)
(-e:1)  gv(main::_)
    =>  *  IV(1)  IV(3)  GV()
(-e:1)  enteriter

Now watch the stack grow with reverse().

$ perl -Dts -e '@a=(1..3);for (reverse @a) { print }'
 ...
(-e:1)  pushmark
    =>  *
(-e:1)  pushmark
    =>  **
(-e:1)  gv(main::a)
    =>  **  GV()
(-e:1)  rv2av
    =>  **  IV(1)  IV(2)  IV(3)
(-e:1)  reverse
    =>  *  IV(3)  IV(2)  IV(1)
(-e:1)  null
    =>  *  IV(3)  IV(2)  IV(1)
(-e:1)  gv(main::_)
    =>  *  IV(3)  IV(2)  IV(1)  GV()
(-e:1)  enteriter

Patches welcome, but I'm not sure this is common enough to warrant a
patch.  At some point the programmer has to take some responsibility for
optimization.

Even the 1..N optimization only happens in the common case.

$ perl -Dts -e 'for (0, 1..3) { print }'
 ...
(-e:1)  pushmark
    =>  *
(-e:1)  const(IV(0))
    =>  *  IV(0)
(-e:1)  const(AV())
    =>  *  IV(0)  AV()
(-e:1)  rv2av
    =>  *  IV(0)  IV(1)  IV(2)  IV(3)
(-e:1)  null
    =>  *  IV(0)  IV(1)  IV(2)  IV(3)
(-e:1)  gv(main::_)
    =>  *  IV(0)  IV(1)  IV(2)  IV(3)  GV()
(-e:1)  enteriter


-- 
Rick Delaney
rick.delaney@home.com


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

Date: Tue, 13 Mar 2001 23:59:06 -0500
From: Siva <apmk@MailAndNews.com>
Subject: mime::lite newbie question
Message-Id: <3AB36396@MailAndNews.com>

Hello,
       I'm using Mime::Lite to send mails thru SMTP. i want to know how
       to check the return status of

       MIME::Lite->send('smtp', "iplmail.wipro.com",Timeout=>60);
       $msg->send

       I'd like to know how you'd check whether the server was down after 
the 
timeout expired and then branch off accordingly. I'm not getting the syntax 
right when i try with 'if' or 'unless'. can someone help me out??
       regards,
       siva



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

Date: 14 Mar 2001 06:55:33 GMT
From: davewal@echo.corp.sgi.com (David Walford)
Subject: Monitoring a Serial Port (/dev/ttyd2)
Message-Id: <98n4l5$b4u$1@murrow.corp.sgi.com>

Is there a way to have a perl script monitor a serial port on a local system in
order to receive input from it?

Here is a description on what I am trying to accomplish.  I have a Crestron
system that can send a command (string) out onto a 9 pin serial.  I would like
to have a perl script running on my system that constently looking for this
command and respond instantly to it.

Anyone have experience doing this and if so, where could I get examples and/or
what should I read up on?

Thanks
David


-- 
------------------------------------------------------------
 David M. Walford               | email: davewal@corp.sgi.com



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

Date: Tue, 13 Mar 2001 23:46:04 -0500
From: "David J. Marcus" <djmarcus@ex-pressnet.com>
Subject: Newbie: Need RegExp pattern matching help
Message-Id: <tatts7m4iar3fa@corp.supernews.com>

Hi

I am new to Perl but have programmed extensively in other languages.

I am trying to write a Perl application that extracts specific values from
an HTML page obtained from a website.

The entire HTML stream is in a variable ($html = $response->content).

I would love some help in constructing the proper program to extract
multiple values from several portions of the entire HTML stream. Given my
knowledge of C++, Java, VB and others I suspect I could hardcode a bunch of
substrings and do it the 'wrong' (non-Perl) way, but I would like to learn
how to do it properly in Perl.

Basically I'm trying to walk through the HTML string extracting the desired
values along the way. The general approach (algorithm if you will) is to
implement the following logic:

For each desired item:
    1) Skip over all the preceding text which, in all likelihood, spans
several lines worth (includes "\n")
    2) Extract some value which may be sandwiched between two patterns

I need each iteration of the above two steps to continue where the previous
iteration left off.

For a more concrete example:

    # get item count
    skip over '<TABLE>'
    skip over '<H2>'
    convert to number starting from the current position

    # get item #1
    skip over '<TD>'
    extract text up to '</TD>' and set the current position to point past
the '</TD>'

    # get item #2
    ...etc...

The question, is what is the best and/or elegant way to do this in Perl?


A second silly Perl question: How does one invoke a function that resides in
a different file?

In particular:
    in file ProgA.pl
            funcB()

    in file ProgB.pl
            funcB() { ...body... }

What declarations do I need to make? How do I tell Perl while running file
ProgA.pl that the desired program is in file ProgB.pl?

-TIA
David




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

Date: Tue, 13 Mar 2001 21:44:47 -0600
From: Galen Menzel <galen.menzel@mail.utexas.edu>
Subject: Re: oraperl to dbd
Message-Id: <3AAEE92F.9177EBBB@mail.utexas.edu>

Joseph Mak wrote:
> 
> Hi,
> 
> I'm moving some cgi files from oraperl to dbd and I was wondering if anyone
> could help me with a line of code that I'm not sure of how to change.  I'm
> not exactly sure what the DBD equivalent of "Ora_do" is.
> 
> sub Remove_Favorite {
>     &ora_do ($lda, "DELETE FROM UserProducts WHERE
> (Email='$fields{'EMAIL'}') AND (ProductID='$fields{'PRODID'}')");
> 
>     &Show_Favorites;
> }
> 

Well, after the initial connection, which will go something like this:

use DBI;
$END{ORACLE_HOME} = <wherever oracle home is>;
my $dbh = DBI->connect("dbi:Oracle:<oracle instance>", <username>, <password>);

you can execute non repeated non-select statements with the do() method:

sub Remove_Favorite {
    $rows_affected = $dbh->do("DELETE FROM UserProducts WHERE " .
	"(Email='$fields{'EMAIL'}') AND (ProductID='$fields{'PRODID'}')" );

    &Show_Favorites;
}

perldoc DBI gets you the full documentation.

Hope that helps.
galen


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

Date: Wed, 14 Mar 2001 00:59:26 -0500
From: Hsien-Hsin Lee <linear@eecs.umich.edu>
To: Hsien-Hsin Lee <linear@eecs.umich.edu>
Subject: recursive subroutine call
Message-Id: <Pine.LNX.4.10.10103140057020.12183-100000@token.eecs.umich.edu>


Hi experts,

does perl allow recursive subroutine calls in the script ? and how ? I
tried to recursively change into unix directories, but it seems my local
values in the subroutine are lost when it returns from recursion.

thanks,
	- Sean



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

Date: 14 Mar 2001 07:11:35 +0100
From: Christian Meisl <meisl@amvt.tu-graz.ac.at>
Subject: Re: recursive subroutine call
Message-Id: <m3itlcubfs.fsf@famvtpc59.tu-graz.ac.at>

Hsien-Hsin Lee <linear@eecs.umich.edu> writes:
> does perl allow recursive subroutine calls in the script ? and how ? I
> tried to recursively change into unix directories, but it seems my local
> values in the subroutine are lost when it returns from recursion.

Recursion is possible. Maybe your mistake was the wrong use of the
'local' command, see perldoc -f local:

       local EXPR
               You really probably want to be using `my' instead,
               because `local' isn't what most people think of as
               "local".  See the Private Variables via my() entry
               in the perlsub manpage for details.
 
               A local modifies the listed variables to be local
               to the enclosing block, file, or eval.  If more
               than one value is listed, the list must be placed
               in parentheses.  See the Temporary Values via
               local() entry in the perlsub manpage for details,
               including issues with tied arrays and hashes.

See also perldoc -q local:

Found in /usr/local/lib/perl5/5.6.0/pod/perlfaq7.pod
       What's the difference between dynamic and lexical (static)
       scoping?  Between local() and my()?

Regards,
Christian

-- 
Christian Meisl <meisl@amvt.tu-graz.ac.at>        www.amft.tu-graz.ac.at
   Inst. f. Apparatebau, Mech. Verfahrenstechnik und Feuerungstechnik
------ What this country needs is a good five cent microcomputer. ------
PGP fingerprint:      DF48 2503 0411 F0EF 149C  851B 1EF0 72B9 78B6 034A


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

Date: Wed, 14 Mar 2001 05:04:10 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: reference problems
Message-Id: <slrn9atuu8.u35.tjla@thislove.dyndns.org>

I was shocked! How could Eric Schultz <hammy@charter.net>
say such a terrible thing:
>I'm having a problem with a program. Everytime I run this code:
>
>for ($j=0;$j<@workingmatches;$j++){
>($workingname,$workingpart,$workingnote) = split(/\+/,$workingmatches[$j]);
>$thisnum = $j+1;
>$thisthingone = $thisnum . "match1";
>
>$$thisthingone = "$workingname";
>}
>
>I get an error message that says I'm trying to change read only variable at

Ewww. What a horrible idiom. Don't you know symbolic references cause
cancer? Did you think of using a hash? Equivalent (but much nicer) code
would be:

for (@workingmatches)
{
    $thisnum++;
    ($workingname,$workingpart,$workingnote) = split /\+/;

    $my_things{$thisnum . 'match1'} = $workingname;

    # etc
}

How to fix your code is left as an excercise for the reader (it's not
hard, but why would you want to?) I should point out that uselessly
stringifying things will lead to the dark side.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
In science as in love, too much concentration on technique can often
lead to impotence.
-P. L. Berger


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

Date: 13 Mar 2001 20:05:40 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Run a combination of programs
Message-Id: <87r90114wb.fsf@limey.hpcc.uh.edu>

>> On Wed, 14 Mar 2001 09:43:02 +0800,
>> "John Lin" <johnlin@chttl.com.tw> said:

> Dear all, One day my colleague asked me, can you run
> several programs at a time?

That sounds more like concurrency, but it appears you mean
"N sequentially from one invoking command".

> He means:
> perl prog1.pl prog2.pl prog3.pl

1. wrapped with a shell script:

    for f in prog{1,2,3}.pl; do perl $f; done

2. inside perl, iterate over the command-line args:

    do $_ foreach @ARGV;

I'm sure there are more exotic ways.

hth
t
-- 
Just reach into these holes.  I use a carrot.


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

Date: Wed, 14 Mar 2001 02:40:32 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: XS: Accessing 'enum' constants
Message-Id: <01CE81D445DE1E87.25CC046EE88924AE.1AA0CA37E60DA2B9@lp.airnews.net>

Matt Sergeant <matt@sergeant.org> wrote
: Matthias Papesch wrote:
: >
: > Hi,
: >
: > I'm trying to create a PERL interface for a c-library and encountering a
: > few problems.
: >
: > Is there a way to access values of 'enums' from the .h file? I've been
: > searching on the web but couldn't really find anything helpful.
:
: The way I've done this in the past is to make functions that return the
: value of the enums. There's probably a nicer way, but constants in Perl
are
: just functions anyway.
:

    There's  an enum pragma available on CPAN, but i don't think
this fits the needs of the OP.

HTH,
Charles K. Clarkson





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

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 V10 Issue 485
**************************************


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