[19238] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1433 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 3 06:05:38 2001

Date: Fri, 3 Aug 2001 03: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)
Message-Id: <996833110-v10-i1433@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 3 Aug 2001     Volume: 10 Number: 1433

Today's topics:
    Re: #### HELP NEEDED #### (Damian James)
    Re: amount of array elements <cberry@hollywood.cinenet.net>
    Re: Check for Dups! <john@mmebs.com>
    Re: Creating small image of web page (Randal L. Schwartz)
    Re: Creating small image of web page <tsee@gmx.net>
    Re: DBI->connect parameters being pulled from XML file  <usenet@lophty.com>
    Re: FAQ: How can I expand variables in text strings? nobull@mail.com
        FAQ: How do I process/modify each element of an array? <faq@denver.pm.org>
    Re: global variables (Anno Siegel)
    Re: How to extract non-character data from socket strea <krahnj@acm.org>
    Re: join lines ? (Yves Orton)
    Re: Matching Strings in an array (Yves Orton)
    Re: newbie question <john@mmebs.com>
        ODBC help (Paul Hancock's .pm) <jtjohnston@courrier.usherb.ca>
    Re: ODBC help (Paul Hancock's .pm) <tward10@jaguar.com>
    Re: parallel execution of shell commands in Perl script <gnarinn@hotmail.com>
        PPM fails in SOAP/Parser.pm <alan1.pettigrew1@fox1-europe1.com>
    Re: Reporting Questionable Programming Activity  <Dave.Stafford@globis.net>
    Re: serial ports/modems and chat2.pl <ronan.oconnor@materna.nl>
    Re: Setting DOS Variables (Was: Matt Wrights formmail a <bart.lateur@skynet.be>
    Re: Setting DOS Variables (Was: Matt Wrights formmail a <bart.lateur@skynet.be>
    Re: Splitting a text list into smaller lists? (Yves Orton)
    Re: Splitting a text list into smaller lists? <krahnj@acm.org>
    Re: Strange behavior? (Tad McClellan)
    Re: Strange behavior? <sky@mail.lviv.ua>
    Re: Strange behavior? <sky@mail.lviv.ua>
    Re: Subject : randomizing a hash <gnarinn@hotmail.com>
    Re: Subject : randomizing a hash <bart.lateur@skynet.be>
    Re: win32.c:1631: structure has no member named `u' (J.Jacob)
        Win32::AdminMisc::UserSetMiscAttributes problem <chambon@montrouge.sema.slb.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 3 Aug 2001 05:16:28 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: #### HELP NEEDED ####
Message-Id: <slrn9mkcsb.2gv.damian@puma.qimr.edu.au>

Carlos Beguigne chose Fri, 03 Aug 2001 00:02:07 -0400 to say this:
>...
>open(file_1, "> $file") or die "$file: REASON -> $!";
>close(file_1)            or die "$file: REASON -> $!";
>...
>This works well when I run it locally from my PC but it bombs out on
>my ISP web server with the following error:
>500 internal server error 
> reason: Premature end of script headers 
>

The error is from the web server. To check the real error message from your
program, put

	use CGI::Carp qw(fatalsToBrowser);

somewhere near the beginning of the program. This should get you closer to
identifying the problem. If I had to guess, I'd say you have a permission
problem. Also, you ARE sending appropriate headers to the web server, yes?

I suggest you have a look at:

	`perldoc CGI`
	`perldoc CGI::Carp`

HTH,

Cheers,
Damian
-- 
@:=grep!($;+=m!$/|#!),split//,<DATA>;@;=0..$#:;while(@;){for($;=@;;--$;;)
{@;[$;,$:]=@;[$:,$;]if($:=rand$;+$|)!=$;}push@|,shift@;if$;[0]==@|;select
$,,$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker # rev 3.1 -- a JAPH in progress, I guess...


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

Date: Fri, 03 Aug 2001 04:27:22 -0000
From: Craig Berry <cberry@hollywood.cinenet.net>
Subject: Re: amount of array elements
Message-Id: <tmka1agqsl34bd@corp.supernews.com>

"Manuel Körner" <manuel.koerner@rexroth.de> wrote:
: how can i get the amount of elements in a referenced
: array???

  my $ar = [ qw(a b c) ];
  print 'Elements = ', scalar @$ar;

: In a normal array with $#array.

Nope.  That will give you the index of the last element.  Since array
indices start at 0 (barring changes to the deprecated $[ variable, and
don't do that), the value of $#array will be one less than the number of
items in the array. 

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Brute force done fast enough looks slick."
   |             - William Purves


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

Date: Fri, 03 Aug 2001 10:19:21 +0100
From: "J. Gregory" <john@mmebs.com>
Subject: Re: Check for Dups!
Message-Id: <3B6A6C99.E4C3595B@mmebs.com>

Are all the email addresses in your file one-per-line?

If so, you could try this:

    &check_data

    sub check_data {
        my $email_to_check = shift;
        my %existingemails = ();

        open ( EMAILS, "<address.txt") or die "Cannot open file : $!";
            while ( my $address = <EMAILS> ) {
                     if ( $email_to_check =~ /^$address$/i ) {
                            $errormessage = ("The address you entered,
<B>$email{'address'}</B> is already in our mailing list");
                            &errorpage;
                        exit;
                    } # end if
            } # end while
        close(EMAILS);
    } # end sub

    This would still seem to be a little inefficient though, as for every
address you want to check, you have to reopen your email file ( which could
start getting very big ).
    It might be easier to read the file into an associative array at the start
of your program, and then just query the array. Such like

#!/usr/bin/perl -w
use strict;

my %existingemails = ();

open ( EMAILS , "<address.txt" ) or die "Unable to open file: $!";
    while ( $address = <EMAILS> ) {
        $address = lc($address);
        $existingemails{$address} = '1';
    } # end while
close (EMAILS);
 ...
 ...
# check_data(email_address)
sub check_data {
    my $email_to_check = shift;
        $email_to_check = lc($email_to_check);
    if ( exists($existingemails{$email_to_check} ) )
   {
           my $errmsg =  "The address you entered, <B>$email{'address'}</B>";
                $errmsg .= "is already in our mailing list";
        # ( Lines split so that it will fit in the email )

            &errorpage;
            exit;
    }
    else
    {
        # Email Okay, return true.
        return 1;
    }
} # end sub


>
> Could someone show me how to modify this please using seek as I don't think
> grep is appropriate here?
> Also is it necessary to lock file for appending?
>
>
>
> &check_data;
> sub check_data{
> open (EMAILS, "+< address.txt") or die ("Can't open $email: $!");
>
> @addresses=<EMAILS>;
>
> @add = grep{ /$email{'address'}/i } @addresses;
>
> if (@add) {
>  $errormessage = ("The address you entered, <B>$email{'address'}</B> is
> already in our mailing list");
>         &errorpage;
>         exit;
> }
>
> close (EMAILS);
>
> exit;
>
> } #end of sub check_data
> #------------------------------------------------------------
>
> Thanks for the help
> --
> millside
> _____________

--

        John Gregory
        Internet Developer




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

Date: 02 Aug 2001 23:05:03 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Creating small image of web page
Message-Id: <m1elqtbrw0.fsf@halfdome.holdit.com>

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

Bart> Randal L. Schwartz wrote:
>> ImageMagick and therefore PerlMagick can take .html input and generate
>> PNG output if you have all the right helper programs.  Scaling is
>> trivial.  I was thinking of doing that for one of my columns soon.

Bart> Since you cannot exactly predict what a rendered HTML page will look
Bart> like (it depends on the browser, the installed fonts, user preferences,
Bart> the browser window size, ...) an exact thumbnail is an impossibility.

Bart> If you want one approach, try taking a screen dump of a browser
Bart> window...

Well, that's the the thing.  The ImageMagick uses HTML2PS then renders
the PS.  The HTML2PS tool has a "virtual browser" in which the screen
is rendered, and it's nicely reasonable.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Fri, 3 Aug 2001 08:34:42 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Creating small image of web page
Message-Id: <9kdgdj$9ul$04$1@news.t-online.com>

"Randal L. Schwartz" <merlyn@stonehenge.com> schrieb im Newsbeitrag
news:m14rrqceci.fsf@halfdome.holdit.com...

[snipped my not-so-well-educated rant]

> ImageMagick and therefore PerlMagick can take .html input and generate
> PNG output if you have all the right helper programs.  Scaling is
> trivial.  I was thinking of doing that for one of my columns soon.

You're right.
I should have done my homework better. However, I still think my point about
Perl being able to do this if any language can is valid ;-)

Steffen




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

Date: Fri, 03 Aug 2001 03:08:54 -0400
From: brian donovan <usenet@lophty.com>
Subject: Re: DBI->connect parameters being pulled from XML file using XML::DOM methods - throws error
Message-Id: <3B6A4E06.9080506@lophty.com>

Solved my problem and figured that I should post in case everyone else 
runs across the same problem some day (I know that I scoured the Usenet 
archives through Google and couldn't fina anything close).

see comments below

brian donovan wrote:

> I'm experiencing a curious problem.
> 
> In a script that I'm working on, I connect to a database sith the line:
> 
> my $dbh = DBI->connect($datasrc,$dbuser,$dbpass, {RaiseError => 1});
> 
> The values of the params ($datasrc, $dbuser, and $dbpass) are being 
> taken from an XML file - the relevant fragment is :
> 
>     <database>
>         <datasourcename>
>             DBI:mysql:my_db_name:localhost
>         </datasourcename>
>         <dbusername>
>             my_db_username
>         </dbusername>
>         <dbpass>
>             my_db_pass   
>         </dbpass>
>     </database>



The problem turned out to have been in my XML.

(1.)  First, I broke up the string inside of <datasourcename> into 2 new 
elements <databasename> (containing my_db_name) and <hostname> 
(containing localhost) and embedded the rest into the line in the sub 
(just on a hunch):

my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhostname",$dbuser,$dbpass, 
{RaiseError => 1});

This didn't seem to fix it although i got a slightly different error msg.

(2.) looking at the error message, I wondered about those returns 
between parameters (a light went off), so I flattened out the xml a little :

	<database>
		<databasename>my_db_name</databasename>
		<hostname>localhost</hostname>
		<dbusername>my_db_username</dbusername>
		<dbpass>my_db_pass</dbpass>
	</database>

Then it worked.  The returns and tabs before and after the contents of 
the element nodes were getting left in the text nodes whose value I was 
extracting and it was killing the DBI->connect.

I went back and tried the previous version of the scripts that I'm 
working on (before I broke up the contents of <datasource>) after just 
flattening out the xml and it didn't work.

   Maybe it choked because I didn't use numerical entities for the 
colons.  I'm too lazy to mess with it anymore tonight.  Just glad that 
it's working.


> 
> I'm processing the xml file with XML::DOM methods (getData) and dropping 
> the values of the text nodes into a hash (it makes sense for what I'm 
> doing, although from the fragment shown here, it will seem like overkill 
> to you).  The hash values are what is passed to the subroutine 
> containing the line that makes the database connection.
> 
> When I was pulling the hash values from a plain text config file, all 
> was well.  If I replace the hash elements in the sub call with the 
> quoted values from the XML file or paste them directly into the 
> DBI->conect(..), it works.
> 
> Right now, though, I'm getting an error :
> 
> Software error:
> 
> Can't connect(
>             DBI:mysql:my_db_name:localhost
>        
>             my_db_username
>        
>             my_db_pass
>          HASH(0x85efb68)), no database driver specified and DBI_DSN env 
> var not set at db-functions.pl line 16
> 
> 
> Line 16 is the line in my script containing the DBI-connect.
> 
> Anybody have any clue what the problem could be?
> 
> Thanks,
> brian donovan
> 

Apologies to anyone who may have been bored by (a.) the dumb question 
that I posted or (b.) the answer.

:D

brian donovan




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

Date: 02 Aug 2001 23:48:08 +0100
From: nobull@mail.com
Subject: Re: FAQ: How can I expand variables in text strings?
Message-Id: <u9g0b97e1c.fsf@wcl-l.bham.ac.uk>

nobull@mail.com writes:

>    $text = "@{[ system 'rm -rf /' ]}"

That should read:

$text = '@{[ system "rm -rf /" ]}'

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


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

Date: Fri, 03 Aug 2001 06:20:47 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I process/modify each element of an array?
Message-Id: <3pra7.94$l_m.210003968@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How do I process/modify each element of an array?

    Use "for"/"foreach":

        for (@lines) {
            s/foo/bar/;     # change that word
            y/XZ/ZX/;       # swap those letters
        }

    Here's another; let's compute spherical volumes:

        for (@volumes = @radii) {   # @volumes has changed parts
            $_ **= 3;
            $_ *= (4/3) * 3.14159;  # this will be constant folded
        }

    If you want to do the same thing to modify the values of the hash, you
    may not use the "values" function, oddly enough. You need a slice:

        for $orbit ( @orbits{keys %orbits} ) {
            ($orbit **= 3) *= (4/3) * 3.14159; 
        }

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           04.47
-- 
    This space intentionally left blank


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

Date: 3 Aug 2001 07:40:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: global variables
Message-Id: <9kdkh5$knn$1@mamenchi.zrz.TU-Berlin.DE>

According to Ren Maddox  <ren@tivoli.com>:
> On 2 Aug 2001, anno4000@lublin.zrz.tu-berlin.de wrote:
 
[...]

> > Okay, so you're running under strict, which is good.  In test.pl
> > you declare $TRUE with our.  As "perldoc -f our" tells you, this
> > dispenses you from using the fully qualified $main::TRUE in the
> > current block. The current block is the whole file test.pl, since
> > "our" happens top level, but not any more.  Your main program
> > constitutes another block, and you need to dispense yourself again.
> > Add another "our $TRUE;" to the main program and all will be well.
> 
> Except that test.pl includes a package declaration before the "our
> $TRUE".  So $TRUE is really $test::TRUE.  Adding an "our $TRUE;" to
> the main program, without a package declaration, is going to be
> $main::TRUE.

Quite right.  Even tough I asked what package this was happening
in, I overlooked "package test" in the actual code.  Apologies.

Anno


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

Date: Fri, 03 Aug 2001 04:37:15 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How to extract non-character data from socket stream?
Message-Id: <3B6A2AB5.CB6521CB@acm.org>

Mark Johnson wrote:
> 
> I am connecting to a network device (a router actually) over TCP.  One of
> the commands on the router outputs the results using ANSI screen formatting
> codes (nice for humans, bad for automated system monitors).
> 
> If I simply output the results to a file they look like:
> 
>         ^[[0;5hsome text here^[[0;0h;^[[0;6hsome more text^[[0;0h
> 
> but I need to be able to parse them out within the script but I don't know
> how to look for them since I can't use the ASCII representation in my
> parser code since they are binary (as far as I understand).
> 
> Any suggestions on how to extact these codes?
> 
> sub ReadFromDevice()
> {
>         my $response = <$SOCKET>;
>         my $text = PruneControlCodes( $response );
>         return $text;
> }

sub ReadFromDevice () {
     # replace formatting codes with a space
    ( my $response = <$SOCKET> ) =~ s/\e[.+?h/ /;
    return $response;
    }

And of course since there are several different codes you need something
more complicated to remove all of them. (untested, don't know if this
will work!)

sub ReadFromDevice () {
     # replace formatting codes with a space
    ( my $response = <$SOCKET> ) =~ s/\e\[[0-9;]*[ABCDHJKRfhsum]/ /;
    return $response;
    }



John
-- 
use Perl;
program
fulfillment


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

Date: 3 Aug 2001 02:26:49 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: join lines ?
Message-Id: <74f348f7.0108030126.27d7581e@posting.google.com>

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message news:<3B694758.5ECC1EA6@stomp.stomp.tokyo>...
> Yves Orton slobbered and drooled:
>  
> > Godzilla! wrote:
> > > Yves Orton ignorantly and hatefully trolled:
> > > > Godzilla! wrote:
> > > > > Tim wrote:
> > > > > > Godzilla! wrote:
> > > > > > > Tim wrote:
>  
> > > > #!perl
>  
> > > Your code produces incorrect results.
>  
> > Prove it Lizard.  I dont think you can.
> 
>  
> Clearly you don't think. Your incorrect results
> serve as proof.
> 
> 
> Godzilla!


Nice proof lizard.

Ciao.

Yves


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

Date: 3 Aug 2001 01:25:52 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: Matching Strings in an array
Message-Id: <74f348f7.0108030025.5137a224@posting.google.com>

"Andrew Hamm" <ahamm@sanderson.net.au> wrote in message news:<3b69f00a$1@news.iprimus.com.au>...
> Yves Orton wrote in message
> <74f348f7.0108020609.700ae943@posting.google.com>...
> >
> >Or if you have a lot of elements in both arrays maybe
> >
> >COVER: foreach $cname (@covers) {
> >
> > $cname!~/$_/ && next COVER foreach (@words); # Bail on negative match
> >        print $cname." matches all words\n";
> >}
> >
> Yup - good point and an excellent optimisation when there's a very strong
> chance that there will be failure - and that sounds likely when there are
> many elements in both arrays.
> 
> Permit me to translate to clearer but less compact code for or (probably)
> newbie friend (since the line you offer is fairly dense):
> 
> COVER: foreach $cname (@covers) {
>     foreach (@words) {
>         next COVER if $cname !~ /$_/;
>     }
>  do this ....
> }

Hmm.  Sorry about that.  I just felt that there was something
unaesthetic about the double block for such a simple problem.  To be
honest it took a couple of tires to get it that dense.

 COVER: foreach $cname (@covers) {
     next COVER unless $cname =~ /$_/ foreach (@words);
 }

Doesnt work. (I suppose because the first part no longer counts as a
simple statement once the unless is used.) So then I resorted to

 COVER: foreach $cname (@covers) {
     do {next COVER unless $cname =~ /$_/ } foreach (@words);
 }

But I didnt like that either cause it still has the double block. 
Then I remembered that loop control statements could be used in
logical context and there you have the dense code.

Still, its things like this that really increase the appeal of Perl
for me.
Some of the serious gurus write such elegant code that sometimes I
like to try to do the same thing.  Its kind of like math notation
though, until you fully understand whats going on the elegant stuff
can be pretty obtuse.

Yves


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

Date: Fri, 03 Aug 2001 10:20:17 +0100
From: "J. Gregory" <john@mmebs.com>
Subject: Re: newbie question
Message-Id: <3B6A6CD0.2695D166@mmebs.com>

Could you post the start of the code where you perform the "use" statement?

Marco Gouveia wrote:

> Hello,
>
>  I'm trying to run a code sample that uses socket library  (use Socket;).
>  However, I get the following error:
>
>     "use" may clash with future reserved word at perltest.pl line 3.
>     syntax error in file test2 at line 3, next 2 tokens "use Socket"
>
>  How do I correct this problem ?
>
>   Thanks
>
>         Marco Gouveia



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

Date: Fri, 03 Aug 2001 05:45:07 GMT
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: ODBC help (Paul Hancock's .pm)
Message-Id: <3B6A3B11.BBE488F9@courrier.usherb.ca>

Duuuh hmmm ?

I am running this odbc.pm
http://www.geocities.com/Area51/Cavern/4503/perl_odbc.htm

I am trying to display the contents of table1 in a MS Access 97 table:

num|rec1|rec2|rec3|
1    |aa   |bb   |cc   |
2    |aa   |bb   |cc   |

How do I configure this?

$sql = "SELECT * FROM table1 WHERE this_field='criteria';";

Failing this, what do I need to do to display the contexts of my MS
Access *.mdb table?

Thanks,

John
(An email post and reply would be helpful)


sub searchDatabase
{
$sql = "SELECT * FROM table1 WHERE this_field='criteria';";
$dsn = "MyData";
$db = new Win32::ODBC($dsn);
$db->Sql($sql);
while ($db->FetchRow())
{
($rec1, $rec2, $rec3) = $db->Data("rec1", "rec2", "rec3");
print "Record 1 = $rec1\n";
print "Record 2 = $rec2\n";
print "Record 3 = $rec3\n";
}
$db->Close();
}




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

Date: Fri, 3 Aug 2001 07:52:34 +0100
From: "Trevor Ward" <tward10@jaguar.com>
Subject: Re: ODBC help (Paul Hancock's .pm)
Message-Id: <9kdhnj$ggs5@eccws12.dearborn.ford.com>

Here is a reply from Bart which I received a couple of weeks ago.

should answer your questions.

Assuming you have a Windows machine and the Access engine: DBI+DBD::ODBC

Go to control panels, open ODBC data sources, add a new system DSN,
select your database as the source and give it a name. Close.

In perl, you can now connect with

use DBI;
my $dbh = new DBI("DBI:ODBC:$dsn", $user, $pwd);

where $dsn is the name you entered in the ODBC control panel, $user and
$pwd is an existing username and password combination.

you then need to look at the perl docs for DBI data.
--

"jtjohnston" <jtjohnston@courrier.usherb.ca> wrote in message
news:3B6A3B11.BBE488F9@courrier.usherb.ca...
> Duuuh hmmm ?
>
> I am running this odbc.pm
> http://www.geocities.com/Area51/Cavern/4503/perl_odbc.htm
>
> I am trying to display the contents of table1 in a MS Access 97 table:
>
> num|rec1|rec2|rec3|
> 1    |aa   |bb   |cc   |
> 2    |aa   |bb   |cc   |
>
> How do I configure this?
>
> $sql = "SELECT * FROM table1 WHERE this_field='criteria';";
>
> Failing this, what do I need to do to display the contexts of my MS
> Access *.mdb table?
>
> Thanks,
>
> John
> (An email post and reply would be helpful)
>
>
> sub searchDatabase
> {
> $sql = "SELECT * FROM table1 WHERE this_field='criteria';";
> $dsn = "MyData";
> $db = new Win32::ODBC($dsn);
> $db->Sql($sql);
> while ($db->FetchRow())
> {
> ($rec1, $rec2, $rec3) = $db->Data("rec1", "rec2", "rec3");
> print "Record 1 = $rec1\n";
> print "Record 2 = $rec2\n";
> print "Record 3 = $rec3\n";
> }
> $db->Close();
> }
>
>




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

Date: Fri, 3 Aug 2001 06:18:03 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: parallel execution of shell commands in Perl script
Message-Id: <996819483.452408700250089.gnarinn@hotmail.com>

In article <3B69D0E2.7DB98F90@tamu.edu>,
testaccount  <testaccount@tamu.edu> wrote:
>
>How can I make command1 and command2 run in parallel instead of
>sequentially as shown below?
>
>#!/usr/local/bin/perl
>[snip]
>system("command1");
>system("command2");
>[snip]
>exit;
>

fork();

perldoc -f fork


gnari


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

Date: Fri, 03 Aug 2001 10:53:34 +0100
From: Alan Pettigrew <alan1.pettigrew1@fox1-europe1.com>
Subject: PPM fails in SOAP/Parser.pm
Message-Id: <VA.00000018.00967469@fox-europe.com>

I have Activestate Perl 5.6.0, build 613 on a Windows 2000 machine.

I know this is not the latest, but I need to remain compatible with 
other machines, so that is what I have to use.

When I run PPM I can query modules, but when I try to search or install 
a module I get:
------
Retrieving package 'xxxx'

not well-formed line at line 1, column 17, byte 17 at 
C:/Perl/site/lib/SOAP/Parser.pm line 73
------
This is the _create line in:
sub parsefile {
    my ($self, $file) = @_;
    $self->_create_parser()->parsefile($file);
}

The same package works on my W95 machine, so I assume the problem is 
not actually in SOAP.  I have tried re-running the install to fix any 
corruptions, but this does not seem to amend anything, and the problem 
is still there.

I have tried setting trace to 4, but I get no output, not even an empty 
trace file.  Setting verbose to Yes gives no more output.

I have not tried uninstalling/re-installing Perl as I have various 
other packages installed and don't want to end up unable to re-install 
them.

Any assistance would be appreciated.

Alan
The 1s are for spam



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

Date: Fri, 03 Aug 2001 09:48:45 GMT
From: "Dave Stafford" <Dave.Stafford@globis.net>
Subject: Re: Reporting Questionable Programming Activity 
Message-Id: <1sua7.324440$XL1.5612933@nlnews00.chello.com>

"Smiley" <gurm@intrasof.com> wrote in message
> The company I'm working for purchased a Perl CGI Script that turns out
> to be seriously faulty - so much so that my boss asked me to
> investigate whether there's any international agency or organization
> set up that we can report this kind of thing to.
>
> Does anybody know?  Thanks :)

If there is such an organisation, check to see if M$oft has been reported
already:-)

Seriously though, why would there be? Certainly there would be no
international organisation as this is a local matter dealt with by local
law.

In Europe (dunno about elsewhere) you have certain rights as a consumer.
When you buy a product it is expected to work, and if it does not you can
have the product replaced or your money returned.

I would go back to the supplier and threaten to sue.






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

Date: Fri, 3 Aug 2001 10:46:54 +0200
From: "Ronan O'Connor" <ronan.oconnor@materna.nl>
Subject: Re: serial ports/modems and chat2.pl
Message-Id: <9kdoe3$cup$1@penthesilea.materna.de>


David Efflandt <see-sig@from.invalid> wrote in message
news:slrn9mju1a.ljg.see-sig@typhoon.xnet.com...
> On Thu, 2 Aug 2001, Ronan O'Connor <ronan.oconnor@materna.nl> wrote:
> > I'm looking for information on chat2.pl. Can anyone point me towards
> > documentation.
> > I'm planning to use chat2.pl to connect to a modem on the serial port.
> > Anyone know of any useful modules to do this?
>
> What OS?  Win32::SerialPort, has been ported as Device::SerialPort for
> Unix and includes many example scripts.  I have used the latter to get the
> response from AT commands in Linux.
>
I'm currently working in Red Hat and NetBsd, with plans to move to Solaris
and eventually over to Windows

If anyone can point me towards docs on chat2.pl, I'd be grateful





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

Date: Fri, 03 Aug 2001 08:42:53 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Setting DOS Variables (Was: Matt Wrights formmail alert)
Message-Id: <2dokmtkpm4861ij74tb8fm2f9lmqk38fm6@4ax.com>

Godzilla! wrote:

>> > #!perl
>
>> > open (BAT, ">special.bat");
>> > print BAT "SET test=successful";
>> > close (BAT);
>> > system ("special.bat");
>> > print $ENV{test};
>
>> > This returns:
>
>> > C:\APACHE\USERS\TEST>SET test=successful
>> > Out of environment space
> 

You can increase the environment variables space for your DOS box.
See <http://support.microsoft.com/support/kb/articles/Q261/8/25.ASP>.
And don't be fooled by the "applies to" info: it works on earlier
versions of Windows, too.

Then, launch the DOS prompt, and start the script from there.

Just a workaround? Actually: yes.

-- 
	Bart.


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

Date: Fri, 03 Aug 2001 08:49:02 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Setting DOS Variables (Was: Matt Wrights formmail alert)
Message-Id: <n9pkmt4nt8dn8sp9qg0p41md4fgpfeocu1@4ax.com>

Bart Lateur wrote:


>You can increase the environment variables space for your DOS box.
>See <http://support.microsoft.com/support/kb/articles/Q261/8/25.ASP>.
>And don't be fooled by the "applies to" info: it works on earlier
>versions of Windows, too.

A bit of hunting around, and I found the older version of this article
for Win95/Wwin98:
<http://support.microsoft.com/support/kb/articles/Q230/2/05.ASP>

(Thanks to the "site:" search option from Google (see "advanced
search"))

-- 
	Bart.


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

Date: 3 Aug 2001 02:25:10 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: Splitting a text list into smaller lists?
Message-Id: <74f348f7.0108030125.3984d1ce@posting.google.com>

"John W. Krahn" <krahnj@acm.org> wrote in message news:<3B69DFD7.BBAE494@acm.org>...
> Yves Orton wrote:
> > 
> > "John W. Krahn" <krahnj@acm.org> wrote in message news:<3B68C7B2.897DA9E9@acm.org>...
> > >
> > > #!/usr/bin/perl -w
> > > use strict;
> > >
> > > my $file = 'userfile01';
> > > my @in;
> > > # Read the file of 25000 users from stdin:
> > > while ( <> ) {
> > >
> > >     # Parse the line, using the numeral 4 as the delimiter.
> > >     push @in, split /4/;
> > >
> > >     while ( @in >= 50 ) {
> > >         open OUT, "> $file" or warn "Cannot write to $file: $!" and
> > > next;
> > >         print splice( @in, 0, 50 );
> > >         $file++;
> > >         close OUT;
> > >         }
> > >     }
> > 
> > John, nice use of the ++ operator there..  A couple or minor
> > corrections though...  I personally wouldn't just jump to the next in
> > case of an open() failure, id die() instead.  

Actually on second reading I realized what you were doing with the
next line. (Sorry I missed it) but it seems if you change it to

open OUT, "> $file" or warn "Cannot write to ".($file++).": $!" and
next;

Then it just tries a new number.  Cool idea John, I have uses for such
a technique.

> > Also the above will fail
> > to print out the last line if the number of names isnt an even
> > multiple of 50. (And to get really picky :-) I am printing the names
> > with a join as I think maybe they arent so useful all strung
> > together.) My slight modification would be:
> 
> Well, if we're going to get picky ;-) then:

Picky only in the nicest friendliest sense. (brain spelling subsystem
is on the fritz just now)

> 
> 
> > #!/usr/bin/perl -w
> > use strict;
> > 
> > my $file = 'userfile01';
> 
> After posting I realised that with 500 output files the numerical suffix
> should be longer.

Good point, but it would have just rolled over to 'userfilf00'.

> 
> my $file = 'userfile001';
> 
> > my @in;
> > # Read the file of 25000 users from stdin:
> > while ( <STDIN> ) { #using explicit for clarity
> 
> Using <STDIN> means you are resticted to STDIN only while using <> means
> you can accept input from STDIN or the command line.

I used it because I was to lazy to check to see if eof() defaults to
the currently select()ed file. (Which from you code below seems to be
true...)

> 
> >     chomp;
> >     # Parse the line, using the numeral 4 as the delimiter.
> >     push @in, split /4/;
> >     my $flush=eof(STDIN); #flush the array if eof on input
> >     while ( @in >= 50 || $flush) {
> 
> No need for the $flush variable or the "last if $flush;" statement.

Umm, now on this one im not so sure.  I used the $flush so I only
eof() once. See below for my other reservations

<Snip my rebutted code>

> 
> Or you could do it this way  :-)
> 
> #!/usr/bin/perl -w
> use strict;
> 
> my $file = 'userfile001';
> my @in;
> # Read the file of 25000 users from stdin or the command line:
> while ( <> ) {
>     local $, = local $\ = "\n";

This is a cool way to avoid using join, but I personally am always
afraid of messing with globals like these (well there are a few
exceptions).  Partly because ive not had the time to really play with
them and partly because they take a long time to explain (to
colleagues for example) and IMHO potentially lead to future
maintainability problems.  If I do, then I _always_ comment them.

>     chomp;
>     # Parse the line, using the numeral 4 as the delimiter.
>     push @in, split /4/;
> 
>     while ( @in >= 50 ) {

Sorry, but I tested this and it still fails.  I dont think you can get
around either $flush or two calls to eof.

>         open OUT, "> $file" or die "Cannot write to $file: $!";
>         print OUT splice( @in, 0, 50 );
>         $file++;
>         close OUT;
>         redo if eof() and @in;

Hmm, dont quite follow the logic here.

>     }
>  }


So I think a final  :-)  version might be

#!/usr/bin/perl -w
use strict;

my $file = 'userfile001';
my @in;
# Read the file of 25000 users from stdin or the command line:
while ( <> ) {
    local $, = local $\ = "\n"; #set field and record seperators to
newline
    chomp; #lose any newlines on input
    # Parse the line, using the numeral 4 as the delimiter.
    push @in, split /4/;

    while ( @in >= 50 || (my $flush=eof())) {
        open OUT, "> $file" or die "Cannot write to $file: $!";
        print splice( @in, 0, 50 );
        $file++;
        close OUT;
        last if $flush;
    }
}

TTYL,
Yves


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

Date: Fri, 03 Aug 2001 09:58:41 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Splitting a text list into smaller lists?
Message-Id: <3B6A75CF.9CA8355C@acm.org>

Yves Orton wrote:
> 
> "John W. Krahn" <krahnj@acm.org> wrote in message news:<3B69DFD7.BBAE494@acm.org>...
> >
> > Or you could do it this way  :-)
> >
> > #!/usr/bin/perl -w
> > use strict;
> >
> > my $file = 'userfile001';
> > my @in;
> > # Read the file of 25000 users from stdin or the command line:
> > while ( <> ) {
> >     local $, = local $\ = "\n";
> 
> This is a cool way to avoid using join, but I personally am always
> afraid of messing with globals like these (well there are a few
> exceptions).  Partly because ive not had the time to really play with
> them and partly because they take a long time to explain (to
> colleagues for example) and IMHO potentially lead to future
> maintainability problems.  If I do, then I _always_ comment them.
> 
> >     chomp;
> >     # Parse the line, using the numeral 4 as the delimiter.
> >     push @in, split /4/;
> >
> >     while ( @in >= 50 ) {
> 
> Sorry, but I tested this and it still fails.  I dont think you can get
> around either $flush or two calls to eof.

Sorry, I _did_ test this code and it _does_ work (from STDIN and the
command line.) :-)


> >         open OUT, "> $file" or die "Cannot write to $file: $!";
> >         print OUT splice( @in, 0, 50 );
> >         $file++;
> >         close OUT;
> >         redo if eof() and @in;
> 
> Hmm, dont quite follow the logic here.

redo goes to the top of the loop _without_ testing ( @in >= 50 ) so if
<> is at eof _and_ there are still elements in @in (one or more) it
writes another file with the remaining elements and @in now has zero
elements. After the file is closed it encounters the redo statement
again and eof() is still true but @in is false so it goes to the top of
the loop and tests ( @in >= 50 ) which is false and the program ends.
Is that clear?  :^)


> >     }
> >  }




John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 2 Aug 2001 23:42:40 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Strange behavior?
Message-Id: <slrn9mk7dg.ttp.tadmc@tadmc26.august.net>

Chas Friedman <friedman@math.utexas.edu> wrote:
>If someone can explain the following behavior, I'd be most appreciative:
>If  I run perl on a file containing:
>
>%try=(22,33,44,55);
>print %try->{22}; print "\n";
>print \%try->{22}; print "\n";
>$href=\%try;
>print $href->{22}; print "\n";
>@tryagain=(1,2,3);
>print @tryagain[1]; print "\n";
>
>the output is:
>
>33
>SCALAR(0x17de910)
>33
>2
>
>I can't understand:
>  1. why   print %try->{22};  isn't an error


Me either...


>  2. why the 2nd and 3rd lines of output are different


The 2nd line prints a reference, perl stringifies the ref for printing.


>  3. why   print @tryagain[1];  isn't an error


Because @tryagain[1] is a "list slice" (perldata.pod).

You should always enable warnings when developing Perl code.
perl itself would have helped with that one, if you had
asked it to...


>      (Note: print %try{22};  does produce an error message.)


Because it isn't a valid syntax, like a list slice is  :-)

"hash slice" syntax would be:   @try{22}



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


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

Date: Fri, 03 Aug 2001 12:49:28 +0300
From: Kolorove Nebo <sky@mail.lviv.ua>
Subject: Re: Strange behavior?
Message-Id: <3B6A73A8.1378D859@mail.lviv.ua>

About first question....

 ... because %try->{22} and $try(22) just the same...


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

Date: Fri, 03 Aug 2001 12:51:07 +0300
From: Roman Khutkyy <sky@mail.lviv.ua>
Subject: Re: Strange behavior?
Message-Id: <3B6A740B.5A3BD0C4@mail.lviv.ua>

Pardon...... $try{22}


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

Date: Fri, 3 Aug 2001 06:26:20 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Subject : randomizing a hash
Message-Id: <996819980.207813625689596.gnarinn@hotmail.com>

In article <Pine.GSO.4.31.0108021702570.29193-100000@epic23.Stanford.EDU>,
Stuart Aaron White  <superstu@stanford.edu> wrote:
>----- Message Text -----
>
>I'm trying to randomize a hash using the rand() function.  I decided that
>I can't do it that way, so I used the keys() function to get an array of
>the keys, randomized the keys like rand(@keyarray), and now want to guess
>the
>value based on the key.
>

please show us actual code, not unclear descriptions like your
'randomized the keys like rand(@keyarray)'.
if that meant that you did
  rand(@keyarray);
and expected the order of the elements in the array to be shuffled,
then that is your problem. in that case you should look at
  perldoc -f rand
  perldoc -q shuffle
   
gnari


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

Date: Fri, 03 Aug 2001 09:16:52 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Subject : randomizing a hash
Message-Id: <81rkmts490fth4khs4gs5n4iadak116at4@4ax.com>

Stuart Aaron White wrote:

>$randomValue = $originalarray{"$randomKey"};
>chomp ($randomValue);

Why are you chomping that? Or $randomKey, for that matter?

>So when I compare the user's guess to $randomValue, even if the user
>guesses the correct value, the test says it's wrong.

I guess you didn't chomp() the only thing you needed to chomp: the
user's input.

-- 
	Bart.


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

Date: 3 Aug 2001 02:54:46 -0700
From: joost_jacob@hotmail.com (J.Jacob)
Subject: Re: win32.c:1631: structure has no member named `u'
Message-Id: <13285ea2.0108030154.b45d5f3@posting.google.com>

Great, i am going to try that.  Meanwhile i installed Python to be
able to do some work and installing Python was easy, no errors, no
things to change.
Any idea why they have errors in the perl package ?  I did install
perl earlier succesfully from source via nmake but i do not want to
use the ms-vc++ compiler anymore.  I hope the perl people pay as much
attention to the good and free mingw32 compiler as they do to the
commercial compilers.


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

Date: Wed, 1 Aug 2001 09:23:54 +0200
From: "sylvain" <chambon@montrouge.sema.slb.com>
Subject: Win32::AdminMisc::UserSetMiscAttributes problem
Message-Id: <9k8b03$sm0$2@news.sinet.slb.com>

Hi all,
It seems I cannot change the USER_FULL_NAME attribute using
setusermiscattributes.
Has anyone seen this ?
my script is running on W2K. :

use Win32::AdminMisc;
print Win32::AdminMisc::UserSetMiscAttributes
('MYPC','sylvain',USER_FULL_NAME=>'S C');

this returns 0 and attribute remains unchanged..

help would be great
cheers
















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

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


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