[26160] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8350 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 23 18:05:53 2005

Date: Tue, 23 Aug 2005 15:05:12 -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           Tue, 23 Aug 2005     Volume: 10 Number: 8350

Today's topics:
        Formatting XML output from a hashref <perlquestions@mail.com>
        Oraperl - terminates script on error. How to handle?? <egoduk@NOSPAM_hotmail.com>
    Re: Padding Problem UPDATE (Still broken) <hal@thresholddigital.com>
        Passing a Module as an Object or Reference <hal@thresholddigital.com>
    Re: Passing a Module as an Object or Reference <john@castleamber.com>
        Perl <-> C language interaction <laurent.gauch@ANTI-SPAMamontec.com>
    Re: Perl <-> C language interaction <jgibson@mail.arc.nasa.gov>
    Re: Perl <-> C language interaction <john@castleamber.com>
    Re: perl and ai/neural networks <jgibson@mail.arc.nasa.gov>
    Re: perl and ai/neural networks <"h.v.niekerk at hccnet.nl">
    Re: Use of uninitialized value in substitution (s///) <tadmc@augustmail.com>
        Using JOIN: Converting scalar to array <ben@dover.backwards>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 23 Aug 2005 14:43:33 -0400
From: "Sam" <perlquestions@mail.com>
Subject: Formatting XML output from a hashref
Message-Id: <defqol$1es$1@newslocal.mitre.org>

I have a hash ref of data that needs to be written out to an XML document. 
Using a hashref to create an XML document can easily be done with 
XML::Simple, but as the documentation states,
XML::Simple is able to present a simple API because it makes some 
assumptions on your behalf. These include:

  a.. You don't want fine-grained control of the formatting of generated XML
Unfortunatly, this is eactly what I want since all the attributes and values 
are being put on the same line. While that way is perfectly valid XML syntax 
and machine readable, it is not human readable.
Does anyone know of a way (another module perhaps) that I can use to insert 
newlines and tabs into the document without post processing the xml?

Thank you.




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

Date: Tue, 23 Aug 2005 22:25:07 +0100
From: "Edward" <egoduk@NOSPAM_hotmail.com>
Subject: Oraperl - terminates script on error. How to handle??
Message-Id: <430b941b$0$22909$ed2619ec@ptn-nntp-reader01.plus.net>

In the below code, I'm trying to run an SQL insert statement. I've
deliberately arranged for the insert to fail by attempting to update a
number field with '1A046011' (spot the letter A). When I run the script,
it
terminates when it reaches this error and returns me to the shell.
How can I handle this error? I need to use ora_rollback() to undo an
earlier
truncate of the table being updated!

Thanks in advance,

Edward.

Code snippet:

$sql="insert into
mask_day_bucket(sku,loc,day,profile_id)values('1A046011','1','monday','1')
";
if($csr=&ora_open($lda,$sql))
 {
    print "Update ok";
 }
else
 {
    prnt("Error - $ora_errstr ");
 }


Error message:

DBD::Oracle::st execute failed: ORA-01722: invalid number (DBD ERROR:
OCIStmtExecute) [for statement ``insert into
mask_day_bucket(sku,cfc,day,profile_id)values('1A046011','1','monday','1')
''
with params: ]) at
/usr/local/perl-5.8.0/lib/site_perl/5.8.0/sun4-solaris-thread-multi/Oraper
l.pm
line 132, <IN> line 3.


--
I am using the free version of SPAMfighter for private users.
It has removed 7524 spam emails to date.
Paying users do not have this message in their emails.
Try www.SPAMfighter.com for free now!




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

Date: Tue, 23 Aug 2005 15:34:45 -0400
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Re: Padding Problem UPDATE (Still broken)
Message-Id: <p8WdnRT6YsDO55beRVn-tA@comcast.com>

Jim,

Encryption is not something I understand or do well.  Your answers were not
only helpful, but your sources were good ones for me to learn from.

Between your post and the sources you cited, I was able to take care of
several tweaks and get everything working.

Hal



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

Date: Tue, 23 Aug 2005 15:43:03 -0400
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Passing a Module as an Object or Reference
Message-Id: <YcCdnZ2dnZ1hz1W4nZ2dndvhlt6dnZ2dRVn-yJ2dnZ0@comcast.com>

I have a module, TD::Log.pm (TD is the company name, so most modules are in
that directory).  When I write a program, I use:

use TD::Log;

as expected.  I also have other modules I use.  I know a module can
reference the function "entry()" in the instance TD::Log in the main
program by using:

main::TD::Log::entry("status: adding today's data to file");

However, what I'd like to do, when I open a new module from main, say
"TD::IncomingData.pm" is to use main::TD::Log::entry more simply.  Is there
some way, from the main program, I can pass a reference to the instance of
TD:Log the main program uses to TD::IncomingData so I can reference the
routines directly in TD::IncomingData?  Something like:

use TD::Log;
use TD::IncomingData;

        incomingdatainit({some reference to TD::Log});

And then, from then on, I can reference the routines in main::TD::Log as I
would "normally" reference routines in the IncomingData module?  (Like with
"entry()" instead of "main::TD::Log::entry()"?)

AND (2nd part of question), once I've done that, is there a way to tell if I
have been passed main::Log and using that, instead of the routine not being
accessible?

Thanks!

Hal




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

Date: 23 Aug 2005 20:40:37 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Passing a Module as an Object or Reference
Message-Id: <Xns96BB9F77EDC44castleamber@130.133.1.4>

Hal Vaughan <hal@thresholddigital.com> wrote:

> I have a module, TD::Log.pm (TD is the company name, so most modules
> are in that directory).  When I write a program, I use:
> 
> use TD::Log;
> 
> as expected.  I also have other modules I use.  I know a module can
> reference the function "entry()" in the instance TD::Log in the main
> program by using:
> 
> main::TD::Log::entry("status: adding today's data to file");
> 
> However, what I'd like to do, when I open a new module from main, say
> "TD::IncomingData.pm" is to use main::TD::Log::entry more simply.  Is
> there some way, from the main program, I can pass a reference to the
> instance of TD:Log the main program uses to TD::IncomingData so I can
> reference the routines directly in TD::IncomingData?  Something like:
> 
> use TD::Log;
> use TD::IncomingData;
> 
>         incomingdatainit({some reference to TD::Log});

my $incoming = new TD::IncomingData;

$incoming->init();

:

> And then, from then on, I can reference the routines in main::TD::Log
> as I would "normally" reference routines in the IncomingData module? 
> (Like with "entry()" instead of "main::TD::Log::entry()"?)

Read on Perl OO. There is an excellent book on it, or perldoc perltoot 
(for example)


-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Tue, 23 Aug 2005 20:50:14 +0200
From: "Amontec, Larry" <laurent.gauch@ANTI-SPAMamontec.com>
Subject: Perl <-> C language interaction
Message-Id: <430b6fe4$1@news.vsnet.ch>

Hi all,

I have to parse ASCII text file and then to use the the parsed data to a 
C program. Than the C program will act on an dedicated external USB 
device via its dedicated driver.

Perl is just great to do the parse of the text file, since the text file 
is not so structured.

My question: how can I interact between a perl script to a C program. I 
mean I will have pointer of structure to pass to the C program.

Are there any tutorial or other paper describing the mechanisms and 
possibilities we have to do.

Best regards,
Laurent

------------ And now a word from our sponsor ---------------------
For a secure high performance FTP using SSL/TLS encryption
upgrade to SurgeFTP
----  See http://netwinsite.com/sponsor/sponsor_surgeftp.htm  ----


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

Date: Tue, 23 Aug 2005 12:37:54 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Perl <-> C language interaction
Message-Id: <230820051237549628%jgibson@mail.arc.nasa.gov>

In article <430b6fe4$1@news.vsnet.ch>, Amontec, Larry
<laurent.gauch@ANTI-SPAMamontec.com> wrote:

> Hi all,
> 
> I have to parse ASCII text file and then to use the the parsed data to a 
> C program. Than the C program will act on an dedicated external USB 
> device via its dedicated driver.
> 
> Perl is just great to do the parse of the text file, since the text file 
> is not so structured.
> 
> My question: how can I interact between a perl script to a C program. I 
> mean I will have pointer of structure to pass to the C program.
> 
> Are there any tutorial or other paper describing the mechanisms and 
> possibilities we have to do.

perldoc perlxs
perldoc perlxstut
perldoc xsubpp


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: 23 Aug 2005 19:58:11 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Perl <-> C language interaction
Message-Id: <Xns96BB984736CBEcastleamber@130.133.1.4>

"Amontec, Larry" <laurent.gauch@ANTI-SPAMamontec.com> wrote:

> Hi all,
> 
> I have to parse ASCII text file and then to use the the parsed data to a 
> C program. Than the C program will act on an dedicated external USB 
> device via its dedicated driver.
> 
> Perl is just great to do the parse of the text file, since the text file 
> is not so structured.

Why not use tools for C? (flex/bison). If you really want a parser, there 
is not much difference between C and Perl (ie. you specify a grammer, make 
/generate a lexer and a parser, and process the parse tree).

Often using regexps only work in very simple cases. It might be that this 
is the case, and again: there are regexp libs for C (even Perl compatible 
ones).

> My question: how can I interact between a perl script to a C program. I 
> mean I will have pointer of structure to pass to the C program.
> 
> Are there any tutorial or other paper describing the mechanisms and 
> possibilities we have to do.

There are several ways to interact, you can embed perl in C (perldoc 
perlembed), write a module in C with a Perl API, use sockets, shared 
memory, XML RPC, etc, etc.

For simple parsing most, if not all, sound like a lot of overhead to me.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Tue, 23 Aug 2005 12:41:37 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: perl and ai/neural networks
Message-Id: <230820051241373005%jgibson@mail.arc.nasa.gov>

In article <430b01ca$0$145$3a628fcd@reader2.nntp.hccnet.nl>, Huub wrote:

> Hi,
> 
> Where in the docs or faq can I find thorough info on perl with AI and 
> neural networks? I can't find a link except a few by google.

Did you look on CPAN? There are many AI:: modules there.

<http://search.cpan.org>


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: Tue, 23 Aug 2005 22:15:07 +0200
From: Huub <"h.v.niekerk at hccnet.nl">
Subject: Re: perl and ai/neural networks
Message-Id: <430b8330$0$148$3a628fcd@reader2.nntp.hccnet.nl>


> Did you look on CPAN? There are many AI:: modules there.
> 
> <http://search.cpan.org>
> 

No, I didn't. Thank you.


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

Date: Tue, 23 Aug 2005 13:53:12 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Use of uninitialized value in substitution (s///)
Message-Id: <slrndgms4o.q2s.tadmc@magna.augustmail.com>

Hugh Lawson <hlawson@triad.rr.com> wrote:

> This error occurs in this program.  


It is not an "error".

It is a "warning".


> What is uninitialized in the substitution?


$_


> ######Error comes on next line******************
> $db->filter_fetch_key  ( sub {   s/\0$// } ) ;


Where is the string that you are substituting against?

What value have you put in that string?


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


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

Date: Tue, 23 Aug 2005 19:18:24 GMT
From: "Benjamin Dover" <ben@dover.backwards>
Subject: Using JOIN: Converting scalar to array
Message-Id: <4EKOe.49096$Yx1.7386@tornado.tampabay.rr.com>

I'm looping through several web pages and picking up the contents of a
particular table.

The problem is that I can't get join to give me the constituent pieces of
the scalar/array or whatever it is at that point :-) BTW, Perl is a new
language for me, so thanks for your patience.

#!/usr/bin/perl

use warnings;
use strict;
use LWP::Simple;
use DBD::mysql;
use HTML::TableExtract;
use HTML::Entities;

my $content;
my $row;
my $i;
my (@rows, @allrows);
my @people = qw(person1 person2 person3);
my ($from_month,$from_day,$from_year) = (6,26,2005);
my ($to_month,$to_day,$to_year) = (7,23,2005);

# Problem area

foreach my $person (@people) {
    $content = get("http://xxxxx"); # from / to dates go in the real url
    die "Could not download page" unless defined $content;

    my $te = new HTML::TableExtract( depth => 1, count => 1 );
    $te->parse($content);
    @rows = $te->rows();

    if (scalar(@rows) == 3) {next;}

    foreach $i (1..scalar(@rows)-3) {
        # Shifting contents over to put $person first
        $rows[$i][2] = $rows[$i][1];
        $rows[$i][1] = $rows[$i][0];
        $rows[$i][0] = $person;

        my $row = join(",", $rows[$i]);
        ^^^^^^^^^^^^^^^^^^^^^^^
        # problem: how to make $rows[$i] usable...

        print $row . "\n";  # expect:  value1,value2,value3
    }

print "Just one iteration for now!!!"; die;
}




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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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