[18797] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 965 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 23 09:06:24 2001

Date: Wed, 23 May 2001 06:05:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <990623115-v10-i965@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 23 May 2001     Volume: 10 Number: 965

Today's topics:
        columns <smitw1@hotmail.com>
    Re: columns (Anno Siegel)
    Re: columns <smitw1@hotmail.com>
    Re: converting characters in email <pne-news-20010523@newton.digitalspace.net>
        Design pattern for a generic functions dispatcher (Phouric Ung)
    Re: foreach loop and chop problem (Rafael Garcia-Suarez)
    Re: foreach loop and chop problem nobull@mail.com
        help getting data into hash from MySql <msolomon@3s-technology.com>
    Re: How can I convert a date (MM/DD/YYYY) to UTC time? <todd@designsouth.net>
    Re: How can I convert a date (MM/DD/YYYY) to UTC time? <ommadawn@club-internet.fr>
    Re: how to get the access_log file name in a program <twhu@lucent.com>
    Re: How to store data in the session with perl? <a.v.a@home.nl>
    Re: module for combinatorics? (partitions etc) (Dave Bailey)
    Re: module for combinatorics? (partitions etc) (Anno Siegel)
        Multiple Line printing (Gary)
    Re: Multiple Line printing (Anno Siegel)
    Re: Multiple Line printing (Bernard El-Hagin)
    Re: of the TWO perl-debugging books, which best? <temp1@williamc.com>
    Re: oh c'mon please, one of you perl/unix gurus!!! (Robin Breman)
        Perl crashes on exit after database access <alan1.pettigrew1@fox1-europe1.com>
    Re: Perl, Oracle and cursors gnari@my-deja.com
        Problem using "use constant => ..." with mod_perl (Apac <c.manley@_NO_SPAM_chello.nl>
        Q: about combining lines of a call record file... <tnathan@midwayisland.net>
        Running perl scripts as admin. <osbornelee@hotmail.com>
    Re: sorting a scrolling_list() nobull@mail.com
    Re: This String Formation does not work properly, pleaz (Lars)
    Re: This String Formation does not work properly, pleaz <wyzelli@yahoo.com>
    Re: Warning/Danger -- Don't use Perl for CGI <bill.kemp@wire2.com>
    Re: what does this mean? (Villy Kruse)
    Re: what does this mean? <pne-news-20010523@newton.digitalspace.net>
    Re: win32 ExitProcess makes stdout disappear <wyzelli@yahoo.com>
    Re: wwwboard.pl - Taint and Use Strict <somewhere@in.paradise.net>
    Re: XML::Simple more than one root tag?? (Sascha)
    Re: XML::Simple more than one root tag?? <thunderbear@bigfoot.com>
    Re: XML::Simple more than one root tag?? <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 23 May 2001 11:40:54 GMT
From: Willem <smitw1@hotmail.com>
Subject: columns
Message-Id: <1b8ngtc02ut15ft0vij7uka2o1rt6bb28h@4ax.com>

I want to split records of a file into colums, and with a space
between the colums.

Input from file:
02X123593791Y103970930X123593791Y103970930X123593791Y103970930X123593791Y10397093000
etc.

output to file:
02 X123593791 Y103970930 X123593791 Y103970930 X123593791 Y103970930
X123593791 Y103970930 00

Thanks in advance for the help!

Wim


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

Date: 23 May 2001 12:08:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: columns
Message-Id: <9eg976$ekt$1@mamenchi.zrz.TU-Berlin.DE>

According to Willem  <smitw1@hotmail.com>:
> I want to split records of a file into colums, and with a space
> between the colums.
> 
> Input from file:
> 02X123593791Y103970930X123593791Y103970930X123593791Y103970930X123593791Y10397093000
> etc.
> 
> output to file:
> 02 X123593791 Y103970930 X123593791 Y103970930 X123593791 Y103970930
> X123593791 Y103970930 00

So your break points are at columns

    my @cols = ( 2, 12, 22, 32, 42, 52, 62, 72, 82);

(It would have been nice of you to provide that instead of letting
your readers do the counting.)

Now walk through the string and insert a blank at each break point,
beginning with the rightmost column (why?):

    substr( $str, $_, 0) = ' ' for reverse @cols;

That's it, except there are a many other ways to do it.

Anno


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

Date: Wed, 23 May 2001 12:15:12 GMT
From: Willem <smitw1@hotmail.com>
Subject: Re: columns
Message-Id: <sqangtsfodl4q6c0u0dpcalkp03f6cvtq8@4ax.com>

Anno, Thank you very much for this solution!!


On 23 May 2001 12:08:06 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:

>According to Willem  <smitw1@hotmail.com>:
>> I want to split records of a file into colums, and with a space
>> between the colums.
>> 
>> Input from file:
>> 02X123593791Y103970930X123593791Y103970930X123593791Y103970930X123593791Y10397093000
>> etc.
>> 
>> output to file:
>> 02 X123593791 Y103970930 X123593791 Y103970930 X123593791 Y103970930
>> X123593791 Y103970930 00
>
>So your break points are at columns
>
>    my @cols = ( 2, 12, 22, 32, 42, 52, 62, 72, 82);
>
>(It would have been nice of you to provide that instead of letting
>your readers do the counting.)
>
>Now walk through the string and insert a blank at each break point,
>beginning with the rightmost column (why?):
>
>    substr( $str, $_, 0) = ' ' for reverse @cols;
>
>That's it, except there are a many other ways to do it.
>
>Anno



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

Date: Wed, 23 May 2001 10:16:08 +0200
From: Philip Newton <pne-news-20010523@newton.digitalspace.net>
Subject: Re: converting characters in email
Message-Id: <blrmgtsnk5gol56hfp8o47elv5bostm0qu@4ax.com>

On Wed, 23 May 2001 09:51:48 +1000, "Troy Boy" <troyr@vicnet.net.au>
wrote:

> s/&#8220;/\'/g
> 
> that won't work

Why not?

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
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: 23 May 2001 02:20:55 -0700
From: ph.ung@caramail.com (Phouric Ung)
Subject: Design pattern for a generic functions dispatcher
Message-Id: <e3932e1f.0105230120.55e8a84b@posting.google.com>

i would like to have some advice on perl
programming design for a dynamic function
dispatcher.

I have written a script that acts as 
a function dispatcher. It is supposed
to call various perl functions based on
the command line arguments.
It works as followed :

the script synopsis is :
> process_action.pl MY_ACTION

the design of process_action.pl looks like:

----------------------------------------------
#!perl.exe

use MyModule::SubModule;
use MyOtherModule;
use ...;

%ACTION_MAPS = (
  ACTION1 => MyModule::SubModule::Myfunction,
  ACTION2 => MyOtherModule::MyOtherFunction,
  ...
);

$Action = $argv[0];

# Various common processing

# Call the desired function eventually
&$ACTION_MAPS{$Action}();

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

The drawbacks of this method are :
- the number of actions can be significant
(30 or 40). So i have many "use" statements
The various function modules use different
perl modules. Some uses XML, DBI, HTTP, aso...
So when the script is running it takes
an incredible amount of memory (18 Meg
just for a perl script, couldn't believe it !).

- if one module has some compilation errors
(happened during development step), the whole
script fails and any other actions fail also.

The advantage is that the script provides
a single entry point, so the common codes
are written once.

I was think of modifying the script using
dynamic module loading methods, like :

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

#!perl.exe

%ACTION_MAPS = (
  ACTION1 => MyModule::MyFunction,
  ...
);

$Action=$argv[0];

# Various Processing

# Call the desired function
$module = ExtractModuleNameFromFullFunctionName($ACTION_MAPS{$Action});
eval {
  use $module;
  &$ACTION_MAPS{$Action}();
}
die $@ if $@;

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

Should works but seems awkward, i was wondering if there
are better things to do.

Thanks in advance

Phouric Ung


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

Date: 23 May 2001 07:05:01 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: foreach loop and chop problem
Message-Id: <slrn9gmo7q.5qc.rgarciasuarez@rafael.kazibao.net>

angry_garden_salad@yahoo.com wrote in comp.lang.perl.misc:
} HI,
} I have the following script:
} #!/usr/bin/perl

No -w ? no use strict ?

} @hosts=`cat /u/hosts`;
} @lists=`cat /u/lists`;

Most inefficient way to read files, because you're using an external process
(cat).

} foreach $host ( @hosts ) {
} chop $host;
} foreach $list ( @lists ) {
} chop $list;
} if ( $host eq $list ) {
} print "they match!!\n";
} }
} }
} }

The 2d foreach is _in_ the 1st one. Then the chop on @lists elements
will be executed as many times as there are elements in @hosts.

Did you know that chop (or, better in this case, chomp) works on lists?
Read "perldoc -f chomp". You can do :

  @hosts = chomp `cat /u/hosts`;
  @lists = chomp `cat /u/lists`;

This will remove the trailing \n at the end of each line in the arrays.

BTW. Apparently you're looking for lines that appear in both files. Your
algorithm is not efficient. See the FAQ (in perlfaq4) :

  How do I compute the difference of two arrays?  How do I compute the
  intersection of two arrays?

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: 23 May 2001 08:32:05 +0100
From: nobull@mail.com
Subject: Re: foreach loop and chop problem
Message-Id: <u97kz88ovz.fsf@wcl-l.bham.ac.uk>

rgarciasuarez@free.fr (Rafael Garcia-Suarez) writes:

> Read "perldoc -f chomp". You can do :
> 
>   @hosts = chomp `cat /u/hosts`;
>   @lists = chomp `cat /u/lists`;

Read "perldoc -f chomp". You meant to say :

chomp ( @hosts = `cat /u/hosts` );
chomp ( @lists = `cat /u/lists` );

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 23 May 2001 13:05:06 +0100
From: "Mike Solomon" <msolomon@3s-technology.com>
Subject: help getting data into hash from MySql
Message-Id: <9eg92n$lcm$1@taliesin.netcom.net.uk>

I am querying a MySql database using DBI

I want to get the data into a hash where the key is the column name

the closest I have managed so far is :

my $sql = "select * from pers_add";
my $sth = $dbh->prepare("$sql");
$sth(execute);
while (my $ref = $sth->fetchrow_hashref()) {
   $date{'address1'} = $ref->{'address1'};
   $data{'address2'} = $ref->{'address2'};

   etc.  ....
}

As I have over 20 fields in my table this method is very laborious

Is there a better way of doing it.

I have been looking at this for hours and getting nowhere

Any help would be much appreciated.



Regards


Mike Solomon






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

Date: Wed, 23 May 2001 08:08:43 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: How can I convert a date (MM/DD/YYYY) to UTC time?
Message-Id: <feKO6.61369$I5.13013667@news1.rdc1.tn.home.com>

> I simply need to see if there is a way to take a date (ie 12/31/2001) and
> convert it into the number of seconds since the Epoch.
>

Found in /usr/local/lib/perl5/5.6.0/pod/perlfaq4.pod
       How can I take a string and turn it into epoch seconds?

       If it's a regular enough string that it always has the
       same format, you can split it up and pass the parts to
       `timelocal' in the standard Time::Local module.
       Otherwise, you should look into the Date::Calc and
       Date::Manip modules from CPAN.

(and Date::Manip will probably be able to go backwards too).




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

Date: Wed, 23 May 2001 12:44:35 +0100
From: "Sgluarb" <ommadawn@club-internet.fr>
Subject: Re: How can I convert a date (MM/DD/YYYY) to UTC time?
Message-Id: <9eg4cn$e49$1@reader1.imaginet.fr>


"Bill Nelson" <william.c.nelson@gte.net> a écrit dans le message news:
3B0AD4D0.6727AC4E@gte.net...
> I would like to do some date comparrisons via UTC time and am trying to
> determine how to converte a date format of something like:  12/01/2000
> to UTC without having to do all the math and figure out leap years and
> such.

use Time::Local; # timelocal($sec, $min, $hours, $mday, $mon, $year);

if (/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2}).txt/o) {
    $filedate = timelocal($6, $5, $4 ,$3 ,$2 - 1, $1 - 1900);
    etc...




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

Date: Wed, 23 May 2001 07:19:24 -0400
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: Re: how to get the access_log file name in a program
Message-Id: <9eg6dq$dc2@nntpb.cb.lucent.com>

Thanks for your suggestion. I use 'PerlSetVar' in the httpd.conf and it
works.
However, I was hoping that I can use $r->server variable to access it
instead
of putting the filename twice in the httpd.conf file.

"Jimi Thompson" <JIMIT@prodigy.net> wrote -...
> Assign it a variable and either have the user fill it in or have the
program
> scan the folder where the log files are kept.  FYI,  that may be changing
> with Apache 2.0.
>
> Tulan W. Hu <twhu@lucent.com> wrote in message
> news:9ebot3$3i7@nntpb.cb.lucent.com...
> > I can get the server name from the Apache module via the
> > $r->server->server_hostname.
> > Is there a way to get the file name of TransferLog or CustomLog from the
> > Apache module?




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

Date: Wed, 23 May 2001 11:18:51 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: How to store data in the session with perl?
Message-Id: <3B0B74BE.592A6C75@home.nl>

>
>
> Abigail
> --
> @_=map{[$!++,$_^$/]}split$²,"\@\x7Fy~*kde~box*Zoxf*Bkiaox";$\="\r";
> $|=++$*;do{($#,$=)=(rand@_,rand@_);@_[$#,$=]=@_[$=,$#]}for($*..@_);
> for$:($|..@_-$|){for($|..@_-$:){@_[$_-$|,$_]=@_[$_=>$_-$*]if$_[$_][
> $¼]<$_[$_-$*][$®];print+map{$_->[$|]}@_;select$·,$°,$½,0.1}}print$/

Wow, Abigail.
Nice code.



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

Date: 23 May 2001 09:21:34 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <slrn9gmm2o.l37.dave@sydney.daveb.net>

On Wed, 23 May 2001 03:16:19 GMT, Mark Jason Dominus <mjd@plover.com> wrote:
[...]
>I believe a similar thing should be possible for partitions, in
>subexponential time.  That is, it's not hard to figure out how many
>partitions there are of the original number X; then generate a random
>number i between 1 and P(X); then generate partition number i.

Right you are.  I didn't think of caching subpartition counts; that
was pretty stupid of me.

[I wrote]
>>The problem posed in this thread is (I think) NP complete 
>>and is probably reducible to the (NP complete) subset sum problem if
>>we accept bounds on the range of integers which may be employed in
>>constructing a solution.  
>
>The problem does have such bounds.  If you're trying to partition the
>number X, the integers employed in the solution must be in [1..X].
>If you allow integers lress than 1, the problem is no longer
>well-posed.  Allowing integers larger than X does not change the
>problem because such integers are useless.

I think the problem is still well-posed if the integers are not in 
[1,X], because of the k-constraint (the constraint that there must
be exactly k integers in the solution set).  For example if I wish
to count the k-partitions of 0 over [-1,1], I get 1 + (k >> 1).

[...]

>Second, subset-sum is a number problem, and efficient algorithms *do*
>exist.  These algorithms are polynomial in the magnitude of the number
>N; the reason subset-sum is NP-complete is not that the solution takes
>a long time, but that it takes a long time *relative to the size of
>the problem statement*, which is very brief.  

I have never heard of this definition of NP-completeness (defining
it in terms of the problem statement).  I thought an NP complete 
problem was one which could be solved in polynomial time only if you
have a way to test an arbitrary number of candidate solutions 
simultaneously (i.e. a quantum computer).  What does that have to 
do with the size of the problem statement?

--
Dave Bailey
davidb54@yahoo.com


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

Date: 23 May 2001 10:19:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: module for combinatorics? (partitions etc)
Message-Id: <9eg2rt$928$1@mamenchi.zrz.TU-Berlin.DE>

According to E.Chang <echang@netstorm.net>:

[generating partitions of a number into n parts]

> I am sure there are more elegant solutions than the following simple (8 
> lines, not 4) approach to coding it.
> 
> my ($final_sum, $num_terms, $total) = (18, 5, 0);
> my @terms;
> foreach $i (1..$num_terms-1) {
>    $rand = int rand($final_sum - $total - $num_terms + $i) +1;
>    push @terms, $rand;
>    $total += $rand;
> }
> push @terms, $final_sum - $total;

A recursive approach suggests itself:  If the number of terms is less 
than 2, return (a list consisting of) the final sum.  If it is
larger, select a possible summand $new between 1 and $final_sum -
$num_terms.  Then find a partition of $final_sum - $new into
$num_terms - 1 parts and add the selected summand to the list:

    sub gen {
        my ( $final_sum, $num_terms) = @_;
        return $final_sum if $num_terms < 2;
        my $new = 1 + int rand( $final_sum - $num_terms);
        return gen( $final_sum - $new, --$num_terms), $new;
    }

Anno


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

Date: 23 May 2001 05:01:44 -0700
From: grobitaille@mail.com (Gary)
Subject: Multiple Line printing
Message-Id: <a2051d6.0105230401.5f5a46c7@posting.google.com>

I need to parse a text file and when a pattern is matched I need to
print that line and the next 6 lines. Can someone provide me with a
perl solution


Thanks


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

Date: 23 May 2001 12:26:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Multiple Line printing
Message-Id: <9egaa9$fi2$1@mamenchi.zrz.TU-Berlin.DE>

According to Gary <grobitaille@mail.com>:
> I need to parse a text file and when a pattern is matched I need to
> print that line and the next 6 lines. Can someone provide me with a
> perl solution

You will have to specify what happens if the pattern is met again
in a stretch of lines that are already being printed.  Will this
start another batch of six lines to be printed or will it be ignored?
The following code assumes the former:

    my $n = 6;
    my $n_to_print = 0;
    while ( <DATA> ) {
        $n_to_print = $n + 1 if /PAT/;
        print if $n_to_print-- > 0;
    }

Anno


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

Date: Wed, 23 May 2001 12:57:57 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Multiple Line printing
Message-Id: <slrn9gnd23.m2v.bernard.el-hagin@gdndev32.lido-tech>

On 23 May 2001 05:01:44 -0700, Gary <grobitaille@mail.com> wrote:
>I need to parse a text file and when a pattern is matched I need to
>print that line and the next 6 lines. Can someone provide me with a
>perl solution

while(<DATA>){
  if(/PAT/ and print){
    defined($_ = <DATA>) and print for (1..6);
  }
}

Cheers,
Bernard


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

Date: Wed, 23 May 2001 12:02:51 GMT
From: PropART <temp1@williamc.com>
Subject: Re: of the TWO perl-debugging books, which best?
Message-Id: <3B0BA6D0.F46DB5F5@williamc.com>

David Combs wrote:
> 
> There are TWO perl debugging books:
> 
> .  "Debugging Perl" by Martin Brown (Osbourne/McGraw Hill)
> 
> .  CSBOOK: Why, yes: "Perl Debugged," by Peter Scott and Ed Wright.  Addison-Wesley, 2001.
> 
> I have not actually seen either one (eg, in a bookstore).
> 
> Which of the two is the best?
> 
> Are they both SO good, and SO different from each
>    other, that it's worthwhile to buy BOTH?
> 
> Thanks
> 
> David

I did browse both books in a bookstore and am very psyched about
reading Debugging Perl (tho, Perl Debugged looked excellent too). It
could just be me, but the Brown book seemed to have a lot of the stuff
a non-novice but far from expert Perl Programmer needs to take it to
the next level. My take on it is that it's a good introduction to the
*design of Perl programs, which is the area that I feel shaky about.
At work I rarely feel like I need to know more core Perl, but always
feel like that I need to improve on adding error handling and need to
get better at designing robust programs that interact well with other
programs.

--williamc


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

Date: 23 May 2001 04:32:50 -0700
From: rbreman@operamail.com (Robin Breman)
Subject: Re: oh c'mon please, one of you perl/unix gurus!!!
Message-Id: <cc88a734.0105230332.98d1c9f@posting.google.com>

Why don't you try to connect to the server via the telnet prog.
telnet <server> 80
just type GET/ (i now it's no legal cmd but) it should give you
an error with the name of the server.


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

Date: Wed, 23 May 2001 11:28:55 +0100
From: Alan Pettigrew <alan1.pettigrew1@fox1-europe1.com>
Subject: Perl crashes on exit after database access
Message-Id: <VA.00000016.00b06028@fox-europe.com>

I posted a message here some time ago regarding a crash after database 
accesses.  I didn't get any answers on what was causing it, but I have 
finally tracked it down, I hope.
I have ActiveState Perl v5.6.0 for MSWin32-x86-multi-thread
(with 1 registered patch)
Binary build 613
Built 12:36:25 Mar 24 2000

The manual suggests that
   $dbh->connect(...);
   $sth->prepare(...);
   $sth->execute($bind);
   while ($sth->fetchrow_array)
   {
       ...
   }
   $sth->finish;
   $sth->execute($bind);
   while ($sth->fetchrow_array)
   {
       ...
   }
   $sth->finish;
   $dbh->disconnect;
   exit;
is the way to do it.
I found that in some scripts I got a crash reading non-existant memory 
deep in the 'exit;', i.e. nowhere in my code.

I changed a different part of the program, and the crash went away.  I 
couldn't work out what that part of the program had to do with it, but 
since I couldn't find any answers I left it.

In a new program I now get crashes again.  After much experimentation 
removing various bits of the program I found a solution.  It seems to 
point to a bug, so I thought I would go public.
If I add
   $sth = 0;
after the '$sth->finish;' then the problem goes away.

Is this a bug?  Am I taking the right avoidance action?

Your comments would be appreciated.

Alan
The real address has no '1's



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

Date: 23 May 2001 10:52:41 GMT
From: gnari@my-deja.com
Subject: Re: Perl, Oracle and cursors
Message-Id: <9eg4pp$2eu$1@news.netmar.com>


In article <ae46436e.0105210807.3228eddb@posting.google.com>, Tobiwan
<tobiwan@my-deja.com> writes:
>I'm trying to use cursors through the Perl DBD:Oracle and DBI modules.
>However, I keep getting segmentation faults. I've read the perldoc
>pages and searched high and low, tried the example with the
>documentation, and tried the following:
>
>_______________________________________________________
>#!/usr/local/bin/perl
>use DBI;
>use DBD::Oracle qw(:ora_types);
>
>$dbh = DBI->connect('DBI:Oracle:','user/password@schema') || die
>"Cannot connect to Oracle\n";
[rest of script snipped]

this worked for me. I had to change the connect to
dbh = DBI->connect('DBI:Oracle:','user','password') || die "Cannot
connect to
Oracle\n";
and obviously add the missing bracket at the end, but no segmentation faults.

not much help, i know, but at least you know it should work.

gnari

 


>$sth1 = $dbh->prepare(q{
>BEGIN OPEN :cursor FOR
>        SELECT table_name, tablespace_name
>        FROM user_tables WHERE tablespace_name = :space;
>END;
>});
>$sth1->bind_param(":space", "INDX");
>my $sth2;
>$sth1->bind_param_inout(":cursor", \$sth2, 0, { ora_type
=>
>ORA_RSET } );
>$sth1->execute();
># $sth2 is now a valid DBI statement handle for the cursor
>while ( @row = $sth2->fetchrow_array ) {
>        print "@row\n";
>____________________________________________________________
>
>Any ideas? I don't have any problem with simple SELECT statements or
>other PL/SQL such as calling stored procedures - unless they return
>cursors!
>
>Cheers,
>Toby




 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: Wed, 23 May 2001 12:55:07 GMT
From: Craig Manley <c.manley@_NO_SPAM_chello.nl>
Subject: Problem using "use constant => ..." with mod_perl (Apache).
Message-Id: <3B0BB363.4EEF421B@_NO_SPAM_chello.nl>


Hi all,

I've got a CGI application that uses some constants exported from some
 .pm files. When running this application in mod_perl  I keep getting
this error in the httpd errorlog:

Prototype mismatch: sub Apache::ROOT::CSD::mod_2dperl::test_2ecgi::BLA
vs () at /usr/lib/perl5/5.6.0/constant.pm line 91.


This is my test script that causes the error above:

#############################
use strict;
use constant BLA => '?';

print "Content-type: text/plain\n\n";
print BLA . "\n";
#############################

Can anybody explain what's going wrong and how to solve this problem?

Thanks,
Craig Manley.


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

Date: Wed, 23 May 2001 01:55:41 -0600
From: Todd Nathan <tnathan@midwayisland.net>
Subject: Q: about combining lines of a call record file...
Message-Id: <B730C91D.2697%tnathan@midwayisland.net>

Hi,

How would i write a Perl script to combine the lines of a Call Record
into one line...?  Thanks, and you are welcome to get a hold of me
directly, I really appreciate your help!!!

\t

Sample of call record data follows...

CR 16178: CallType  1 04-MAY-2001 Disc-202
  Seize 13:59:16 Ans 13:59:27 Disc 13:59:38 TS   0
     A Party:    MOBILE (11) 8084213370     Serial ed8283c4
        0013(51: 2)     13:59:16[ 1]--13:59:38[ 1]
     B Party:    MOBILE (11) 8084213400     Serial fc097b20
        0012(51: 1)     13:59:19[ 2]--13:59:38[ 1]

CR 16194: CallType  1 04-MAY-2001 Disc-202
  Seize 13:59:26 Ans 13:59:34 Disc 13:59:43 TS   0
     A Party:    MOBILE (11) 8084213456     Serial e0da83ea
        0024(51:11)     13:59:26[ 1]--13:59:43[ 1]
     B Party:    MOBILE (11) 8084213386     Serial 874a563a
        0021(51: 8)     13:59:28[ 2]--13:59:43[ 1]

CR 16162: CallType  1 04-MAY-2001 Disc-203
  Seize 13:59:12 Ans 13:59:53 Disc 13:59:53 TS  36
     A Party:    MOBILE (11) 8084213373     Serial 7713298a
        0023(51:10)     13:59:12[ 1]--13:59:53[ 1]
     B Party:      PSTN (31) 9337
        1091(36: 2)     13:59:14[ 4]--13:59:53[ 1]





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

Date: Wed, 23 May 2001 12:04:35 +0100
From: "Lee Osborne" <osbornelee@hotmail.com>
Subject: Running perl scripts as admin.
Message-Id: <990615944.26061.0.nnrp-14.c2de1f0e@news.demon.co.uk>

Hi all,

I have several virtual sites correctly configured and fully functional on a
linux web server. Each site has its own web directory, users, etc.  In a cgi
directory outside of all these virtual sites, there are several
asministrative scripts that presumably run with administrator user
privileges, which handle tasks such as setting up new virtual domains,
adding new users to these domains, handling e-mail forwarding, etc.  I
presume that these run with administrative privileges as when I submit a
form from a web browser which calls one of these 'administrative' cgi script
outside of the current virtual site cgi directory, I get an 'Internal Server
Error'. The script in question also uses some modules which are installed in
the root version of perl.

In which case, how can I run the scripts as an administrative user?

A tough one I think?

Thanks for any help,

Lee.






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

Date: 23 May 2001 08:38:02 +0100
From: nobull@mail.com
Subject: Re: sorting a scrolling_list()
Message-Id: <u93d9w8ocr.fsf@wcl-l.bham.ac.uk>

wjohnson@roger.ecn.purdue.edu (Wyatt R Johnson) writes:

> Newsgroups: comp.lang.perl.misc

As this is a question about the API of CGI module and not Perl itself,
it would be better asked in the modules group.

> print $q->scrolling_list(
>     -name => "myname",
>     -values => \%hashref,
>     -size => 1);

> Is there a way to force the scrolling_list to display in a specified
> order and/or a sorted order?

I suggest you look at the description/examples of scrolling_list() in
"perldoc CGI".

<FISH>

 print $q->scrolling_list(
     -name => "myname",
     -values => [ sort keys %hashref ],
     -labels => \%hashref,
     -size => 1);

</FISH>
-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 23 May 2001 10:24:34 GMT
From: Lars.Plessmann@gmx.de (Lars)
Subject: Re: This String Formation does not work properly, pleaze help!
Message-Id: <3b0b8f94.3495373@news.btx.dtag.de>

I changed, but it does not cut after the dot. Not I get numbers like
132,2898430840 but it should be 132,29 then.

sub MoneyFormat
{
 # rounding the currency
 $_=sprintf("%.02f", $_); 

 # currency format adding commas for easy read
 my $buf=0;
 local $_ = shift;
 1 while s/^([-+]?\d+)(\d{3})/$1,$2/;

 # Change dots to comma and comma to dots (German form)
 tr/,./.,/;  

 return $_;
}

On Tue, 22 May 2001 23:47:14 GMT, "Todd Smith" <todd@designsouth.net>
wrote:

>
>"Lars" <Lars.Plessmann@gmx.de> wrote in message
>news:3b0af4ae.12124850@news.btx.dtag.de...
>> Heres my routine, that makes mistakes if you use big numbers >= 1000.
>> It works only with little numbers up to 999 I think. Where's the
>> problem?
>> I think it's the rounding part. How can I improve it? I don't want
>> 232.333333 or something like that. Only 2 digts after the dot.
>
>Once you do the substitution, it's not a number anymore. It's a string with
>commas in it. So run it through sprintf first, then seperate the left group
>of digits and commify them. put the commified digits back together with the
>decimal and the right group of digits, and you're done.
>
>



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

Date: Wed, 23 May 2001 21:54:09 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: This String Formation does not work properly, pleaze help!
Message-Id: <ARNO6.6$EL2.1493@vic.nntp.telstra.net>

"Lars" <Lars.Plessmann@gmx.de> wrote in message
news:3b0af4ae.12124850@news.btx.dtag.de...
> Heres my routine, that makes mistakes if you use big numbers >= 1000.
> It works only with little numbers up to 999 I think. Where's the
> problem?
> I think it's the rounding part. How can I improve it? I don't want
> 232.333333 or something like that. Only 2 digts after the dot.
>
> sub MoneyFormat
> {
>  # currency format adding commas for easy read
>  my $buf=0;
>  local $_ = shift;
>  1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
>
>  # rounding the currency
>  $_=sprintf("%.02f", $_);
>
>  # Change dots to comma and comma to dots (German form)
>  tr/,./.,/;
>
>  return $_;
> }

Using the commify routine from PerFAQ5, slightly modified to handle the
dot/comma reversal gives the following:

sub MoneyFormat {
    my $input = reverse sprintf "%.02f", shift;
    $input =~ s<(\d\d\d)(?=\d)(?!\d*\.)><$1,>g;
    $input = scalar reverse $input;
    $input =~ tr/,./.,/;
    return $input;
}

Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';




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

Date: Wed, 23 May 2001 11:03:47 +0100
From: "W K" <bill.kemp@wire2.com>
Subject: Re: Warning/Danger -- Don't use Perl for CGI
Message-Id: <990612282.10906.0.nnrp-12.c3ad6974@news.demon.co.uk>

>> > In general, it's a very bad idea to use the Perl interpreter as a CGI.
>
>> Did they say why?
>
>that would allow you to execute arbitrary code just like passing
>perl STDIN.


have I understood this?
They are saying don't have pErL* in a cgi-bin directory, as in
"/usr/local/apache/cgi-bin/perl"
Rather than having it somewhere like
"/usr/bin/perl"

Does anyone use the first variant anyway?


(* gratuitously bad capitalisation)




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

Date: 23 May 2001 08:44:12 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: what does this mean?
Message-Id: <slrn9gmu2s.91g.vek@pharmnl.ohout.pharmapartners.nl>

On Tue, 22 May 2001 13:31:40 GMT, Mark Jason Dominus <mjd@plover.com> wrote:
>In article <3B0A6621.5D671594@Mysticglow.com>,
>John Watson  <jwatson@Mysticglow.com> wrote:
>>I ran into this in an if expression and was wondering what !~ means?
>
>Good question.  I don't think anyone here knows, but it seems like the
>sort of thing that might be explained in the manual.
>
>Try doing a web search for 'perlop' and see what you come up with.
>If you find anything out, please let us know.
>


I wonder: why do a web search if the documentation and manuals are all
installed locally?


Villy


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

Date: Wed, 23 May 2001 14:53:20 +0200
From: Philip Newton <pne-news-20010523@newton.digitalspace.net>
Subject: Re: what does this mean?
Message-Id: <jjcngtgktk328j755sl8njqlfd5gpe2c4d@4ax.com>

On Tue, 22 May 2001 09:17:19 -0500, John Watson <jwatson@Mysticglow.com>
top-posted full-quoted:

> Ugh, I thought ! was not

It is. But there was no ! in there; it was an !~. Just like -> has
nothing to do with subtraction or "greater than".

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: Wed, 23 May 2001 21:37:59 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: win32 ExitProcess makes stdout disappear
Message-Id: <pCNO6.5$EL2.1471@vic.nntp.telstra.net>

"frank brown" <frank.brown@ci.seattle.wa.us> wrote in message
news:uEvO6.253$5Z.49775@news-west.eli.net...
> I recently discovered that capturing shell output via backticks in a perl
> script
> fails on W2K when executing a Win32 .exe file which exits via ExitProcess.
> Replacing ExitProcess(0) with exit(0) in the called .exe fixes the
problem.
>
> What's up with this?  A brief search thru MSDN turns up no clues.

From what I can see the documentation says exit(0) flushes the buffers, but
makes no such mention for ExitProcess(0).  This is not a Perl issue though.

Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';




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

Date: Wed, 23 May 2001 20:55:20 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: wwwboard.pl - Taint and Use Strict
Message-Id: <XGMO6.17$hi2.535649@news.interact.net.au>


"Jill" <jmjlampert@aol.com> wrote in message
news:9287c79.0105220823.5e3d9227@posting.google.com...
> Hi,
> I am a newby.
> I have modified wwwboard.pl from Matts Script Archive for use on my
> website.  Now I find that I am required to use the "-T" (Taint) switch
> and "Use Strict" pragma for security reasons.
> I have read the relevant perl documentation and references to both
> these things in several books, but am unable to put the instructions
> for untainting and declaring variables into practice.
> Has anyone out there already modified wwwboard.pl so that it will pass
> the Taint switch and Use Strict ?  If so, is there any way I could get
> hold of that modified script ?
> Any suggestions much appreciated.

All I can say is that you have one hell of a lot of work ahead of you.  In
fact, you would be better off writing one from scratch.




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

Date: 23 May 2001 04:29:15 -0700
From: tgyeti@web.de (Sascha)
Subject: Re: XML::Simple more than one root tag??
Message-Id: <c1a45ba7.0105230329.5197fad6@posting.google.com>

Thorbjørn Ravn Andersen <thunderbear@bigfoot.com> wrote in message news:<3B0A587B.80883567@bigfoot.com>...
> Sascha wrote:
> 
> > If the image have a syntax like ...
> > ---------------------------------------------------------------------
> >    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
> > 
> >    <mail>
> >            <from>USER 1</from>
> >            <to>Absender</to>
> >            <subject>test des subjects</subject>
> >    </mail>
> >    <ebene>
> >            <test>ksdjkfjsa</test>
> >            <bla>lksadjfljlksd</bla>
> >    </ebene>
> > ----------------------------------------------------------------------
> > 
> > ... then i receive a error. This is the error:
> 
> Naturally.  This is not a valid XML file.

OK, but why I not get the root (<mail> or <ebene>) not back into the hash????


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

Date: Wed, 23 May 2001 13:32:48 +0100
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: XML::Simple more than one root tag??
Message-Id: <3B0BADF0.5FF1E280@bigfoot.com>

Sascha wrote:

> > > ... then i receive a error. This is the error:
> >
> > Naturally.  This is not a valid XML file.
> 
> OK, but why I not get the root (<mail> or <ebene>) not back into the hash????

An XML-document may only have one root-element.  The standard allows
parsers to crash and die if errors in the format is found.  This is what
XML::Simple do.

Correct your XML, and try again.
-- 
  Thorbjørn Ravn Andersen                "...plus...Tubular Bells!"
  http://bigfoot.com/~thunderbear


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

Date: Wed, 23 May 2001 11:35:43 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: XML::Simple more than one root tag??
Message-Id: <918ngtoi4td0phsj6o0ivmmk87mcveml49@4ax.com>

Sascha wrote:

>> Naturally.  This is not a valid XML file.
>
>OK, but why I not get the root (<mail> or <ebene>) not back into the hash????

Well... XML parsers are supposed not to be too liberal about what they
accept. That is probably in order to avoid the messy state that HTML
browsers have brought us into. XML is intended to stay a rigid standard.

Therefore, if something isn't 100% valid XML, the parser should not
accept it.

And an XML file is supposed to have just one root element, which makes
your "XML", noit XML.

-- 
	Bart.


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

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


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