[23975] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6176 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 22 00:05:35 2004

Date: Sat, 21 Feb 2004 21:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 21 Feb 2004     Volume: 10 Number: 6176

Today's topics:
    Re: Can Perl do this task??? <jwillmore@remove.adelphia.net>
    Re: Checking HTML, following links and such <spam@gurka.se>
    Re: Checking HTML, following links and such <spam@gurka.se>
    Re: Checking HTML, following links and such <usenet@morrow.me.uk>
    Re: help on hash of hashes (Stephen Moon)
    Re: help on hash of hashes <usenet@morrow.me.uk>
    Re: how add/update/delete data in MySQL database here? <gp@nospm.hr>
    Re: how add/update/delete data in MySQL database here? <gnari@simnet.is>
    Re: how add/update/delete data in MySQL database here? <gp@nospm.hr>
    Re: how add/update/delete data in MySQL database here? <nospam@bigpond.com>
        NEWBIE Question Subroutine help <dayton500@NOSPAMhotmail.com>
    Re: NEWBIE Question Subroutine help <beable+unsenet@beable.com.invalid>
    Re: NEWBIE Question Subroutine help <usenet@morrow.me.uk>
        parsing data file into mysql table - help <smrtalec_NO_SPAM@algxmail.com>
        perl and curse-based U.I. <toylet_at_mail.hongkong.com>
    Re: Simple code runs on linux, but not on windows -- wh <usenet@morrow.me.uk>
    Re: Simple code runs on linux, but not on windows -- wh <jwillmore@remove.adelphia.net>
    Re: Simple code runs on linux, but not on windows -- wh <tadmc@augustmail.com>
    Re: trapping file i/o error <no@nowhere.com>
    Re: Win 2K3 & File Locking <ben@liddicott.com>
    Re: WWW::Mechanize error confusion <jwillmore@remove.adelphia.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 21 Feb 2004 22:56:12 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Can Perl do this task???
Message-Id: <pan.2004.02.22.03.56.10.653435@remove.adelphia.net>

On Sat, 21 Feb 2004 16:08:52 +0000, R.Mariotti wrote:

> Unix system:  I have a compiled application that can only use STDIO
> but I now need it to talk to a remote server using TCP on a particular
> socket.
> 
> I've tried some hardware type interfaces in between but its difficult
> if not impossible to control the port assignments.
> 
> I was thinking that I could create a perl program and via a pipe
> connect it to my compiled application and the perl program could use a
> module like Sockets::IO to connect to and pass the IO through both
> ways.   Sometimes the traffic is incoming and sometimes its outgoing.
> 
> Am I crazy or would this be possible and viable?    Any other
> suggestions also appreciated.

Try reading `perldoc perlipc` to see if what you want to do is listed in
there. It *seems* like you're over complicating something simple -or- I'm
missing something rather complex :-)

You could, maybe, use two fifo's.  One for writing and one for reading. 
Both the script and the application could use these fifo's to communicate.
 There is a section in perlipc that covers fifo's, as well as some other
 tactics to deal with this situation.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Innovation is hard to schedule.   -- Dan Fylstra 




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

Date: Sun, 22 Feb 2004 01:47:13 +0100
From: "Joti" <spam@gurka.se>
Subject: Re: Checking HTML, following links and such
Message-Id: <c18u82$1g0khc$1@ID-224346.news.uni-berlin.de>


"Gunnar Hjalmarsson" <noreply@gunnar.cc> skrev i meddelandet
news:c18aci$1fsean$1@ID-184292.news.uni-berlin.de...
> Joti wrote:
> > "Ben Morrow" <usenet@morrow.me.uk> skrev i meddelandet
> > news:c1893k$mb$1@wisteria.csv.warwick.ac.uk...
> >>
> >> Try WWW::Mechanize.
> >
> > I'm sorry, but i don't really know that much about perl, only the
> > basic stuff. Not about what ever WWW::Mechanize is. I've made a
> > google search but I still don't seem to understand. Could someone
> > explain?
>
> It's a Perl module, available at www.cpan.org.
>
> One of the characteristics of Perl is that a lot of useful tools are
> provided in the form of modules, i.e. separate files with code that
> you load into your main program and make use of in accordance with the
> documentation for respective module. WWW::Mechanize is not part of the
> standard Perl distribution, so to use it, you need to download and
> install it. Learning how to do that is one of the first things you
> should do.
>
>      http://learn.perl.org/
>
> HTH
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>

OK, thanks =)




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

Date: Sun, 22 Feb 2004 02:53:06 +0100
From: "Joti" <spam@gurka.se>
Subject: Re: Checking HTML, following links and such
Message-Id: <c19239$1e7lfk$1@ID-224346.news.uni-berlin.de>


"Joti" <spam@gurka.se> skrev i meddelandet
news:c18u82$1g0khc$1@ID-224346.news.uni-berlin.de...
>
> "Gunnar Hjalmarsson" <noreply@gunnar.cc> skrev i meddelandet
> news:c18aci$1fsean$1@ID-184292.news.uni-berlin.de...
> > Joti wrote:
> > > "Ben Morrow" <usenet@morrow.me.uk> skrev i meddelandet
> > > news:c1893k$mb$1@wisteria.csv.warwick.ac.uk...
> > >>
> > >> Try WWW::Mechanize.
> > >
> > > I'm sorry, but i don't really know that much about perl, only the
> > > basic stuff. Not about what ever WWW::Mechanize is. I've made a
> > > google search but I still don't seem to understand. Could someone
> > > explain?
> >
> > It's a Perl module, available at www.cpan.org.
> >
> > One of the characteristics of Perl is that a lot of useful tools are
> > provided in the form of modules, i.e. separate files with code that
> > you load into your main program and make use of in accordance with the
> > documentation for respective module. WWW::Mechanize is not part of the
> > standard Perl distribution, so to use it, you need to download and
> > install it. Learning how to do that is one of the first things you
> > should do.
> >
> >      http://learn.perl.org/
> >
> > HTH
> >
> > --
> > Gunnar Hjalmarsson
> > Email: http://www.gunnar.cc/cgi-bin/contact.pl
> >
>
> OK, thanks =)
>
>
Now, I've downloaded the module and tried to install it as
http://www.cpan.org/modules/INSTALL.html says. However there's something
wrong when i write "nmake" after "perl makefile.pl":
~"nmake is not an internal command, external command, program or a
commandfile."
(sorry if my translation Swedish-English isn't perfect)
Neither do dmake nor make work.




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

Date: Sun, 22 Feb 2004 02:02:45 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Checking HTML, following links and such
Message-Id: <c192k5$es3$1@wisteria.csv.warwick.ac.uk>


"Joti" <spam@gurka.se> wrote:
>
> Now, I've downloaded the module and tried to install it as
> http://www.cpan.org/modules/INSTALL.html says. However there's something
> wrong when i write "nmake" after "perl makefile.pl":
> ~"nmake is not an internal command, external command, program or a
> commandfile."

You need to install nmake: read c:/perl/html/perlwin32.html to see where
to download it from.

Alternatively (assuming ActiveState Perl) you may have better luck with
ppm install WWW::Mechanize.

Ben

-- 
"If a book is worth reading when you are six,                * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis


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

Date: 21 Feb 2004 17:32:56 -0800
From: vibfft@yahoo.com (Stephen Moon)
Subject: Re: help on hash of hashes
Message-Id: <9feadd98.0402211732.4e906160@posting.google.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<c18ang$8t9$1@mamenchi.zrz.TU-Berlin.DE>...
> Stephen Moon <vibfft@yahoo.com> wrote in comp.lang.perl.misc:
> [in reply to a posting of mine (Anno)]
> 
> > Have another question.  I fixed the code as you told me to
> 
> Please show a little of the context you are replying to.  It seems to
> me that you are really replying to Paul Lalli.  You have incorporated
> some of his advice, it appears, but partly ignored mine.
> 
> You did reduce the code to the essentials, and that makes it much more
> usenet-friendly.  Now if it also used the DATA filehandle for input, and
> STDOUT for output, instead of external files, it would be an ideal
> example of code you can copy/paste into an editor and run it.  Well,
> there is still an unused and undeclared variable.  The code should run
> under strict and warnings.
> 

You are pretty funny:) just kidding:)  I did take your advice and the
prior poster.  I just realized that my mistake was making some changes
to the original
code without carefully taking a look at what it did.  Your advice also
helped me since it showed how I can debug my program.  Much thanks to
both of you.

> > while ( my $line = <DATA_IN> ) {
> >     chomp($line);
> >     if($line =~ s/^(.*?):\s*//){ <===fixed here
> >     	my $who = $1;
> > 	$rfwho = \$who;
> 
> Unused, undeclared.  Why is it here?
> 

well, I was trying to use the reference of $who in the following loop
in different scope for some other thing and didn't come around fixing
it.

> >     	my $rfrec = {};
> >     	$HoH{$who} = $rfrec;
> >     	for my $field ( split /\s+/, $line) {
> >         	my ($key, $value) = split /=/,$field;
> >         	$rfrec->{$key} = $value;
> >     	}
> >     }
> > }
> > 
> > foreach my $family ( sort keys %HoH ) {
> >     	printf(DATA_OUT "$family:\n");
> > 	foreach my $role ( sort keys %{ $HoH{$family} } ) {
> 
> It doesn't make much sense to sort the roles, since they are largely
> independent in each family.  If there were a set of roles that must
> be present in every family it would make sense to place these first
> and sort them, but in general it doesn't.
> 
> >          printf(DATA_OUT "$role=$HoH{$family}{$role}\n");
> 
> Still using printf without a format.  I told you it's going to bite.
>

Well, I am a C programmer, so bear with me.  I takes a little while to
make a transition.
 
> > 	}
> > }
> > 
> > The output that I get is below:
> > 
> > flintstones:
> > lead=fred
> > pal=barney
> > jetsons:
> > boy=elroy
> > lead=george
> > wife=jane
> > simpsons:
> > kid=bart
> > lead=homer
> > wife=marge
> > 
> > How can I change the above code so that I can output as below?
> 
> To see the relation of what you have to what you want more clearly,
> print one line for each family.  I think your original code tried to
> do that, but it didn't seem to make sense then.  It does now.  So,
> instead of your second loop, do this:
> 
>     foreach my $family ( sort keys %HoH ) {
>         my $line = "$family: ";
>         foreach my $role ( keys %{ $HoH{$family} } ) {
>             $line .= "$role=$HoH{$family}{$role} ";
>         }
>         print "$line\n"; # not printf!
>     }
> 
> This prints
> 
>     flintstones: pal=barney lead=fred 
>     jetsons: boy=elroy lead=george wife=jane 
>     simpsons: kid=bart lead=homer wife=marge 
> 
> while you want
> 
> > flintstones:,jetsons:,simpsons:
> > lead=fred,boy=elroy,kid=bart
> > pal=barney,lead=george,lead=homer
> > ,wife=jane,wife=marge
> 
> Looking at it and squinting a little we see that the columns of the first
> one make up the lines of the second.  So the problem turns out to be
> one of matrix transposition.
> 
> > Is this even possible?  I have been struggling with this one a bit.
> 
> It's certainly possible, I'll sketch a solution.  You may want to try and
> come up with your own method, the one I'm using is a little advanced.
> 
> It also ignores the HoH representing the families.  Looking at the
> line-wise output again, it appears that it essentially reproduces the
> input lines.  So to arrive at the wanted output, we can start directly
> from the input without building the HoH structure.
> 
> We build an array of arrays, splitting the input lines on white space,
> then transpose that.  The first line of the resulting array of arrays
> contains the families, the following lines contain the various roles.
> We never bothered to separate the role specifications ("lead", "wife"...)
> from the associated names.  We print the families and the role lines in
> slightly different formats.  The result is:
> 
>     flintstones: jetsons: simpsons:
>     lead=fred, lead=george, lead=homer
>     pal=barney, wife=jane, wife=marge
>     , boy=elroy, kid=bart
> 
> The table is differently arranged from your example, but it contains
> the same information.
> 
> Anno
> 
> --------------------------------------------------------
> #!/usr/bin/perl
> use strict; use warnings;
> 
> my @columns = transpose( map [ split], <DATA>);
> 
> print "@$_\n" for shift @columns; # print header
> foreach ( @columns ) {
>      print join( ', ', @$_), "\n"; # print role columns
> }
> 
> sub transpose {
>     my $max = 0;
>     $max > @$_ or $max = @$_ for @_; # length of longest line
>     map [ map shift( @$_) || '', @_], 1 .. $max;
> }
> 
> __DATA__
> flintstones: lead=fred pal=barney 
> jetsons: lead=george wife=jane boy=elroy
> simpsons: lead=homer wife=marge kid=bart

cool!  I will check it out!  Well, the reason that I use sort is
because I will have frequency index associated with magnitudes.

Thanks for your help.

-Steve


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

Date: Sun, 22 Feb 2004 01:37:21 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: help on hash of hashes
Message-Id: <c1914h$du9$1@wisteria.csv.warwick.ac.uk>


vibfft@yahoo.com (Stephen Moon) wrote:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> news:<c18ang$8t9$1@mamenchi.zrz.TU-Berlin.DE>...
> >
> > Still using printf without a format.  I told you it's going to bite.
> >
> 
> Well, I am a C programmer, so bear with me.  I takes a little while to
> make a transition.

Even in C you should always printf("%s", string) rather than simply
printf(string): otherwise you've got a security hole on your hands.
What if you end up with string = "%d"?

Ben

-- 
   If you put all the prophets,   |   You'd have so much more reason
   Mystics and saints             |   Than ever was born
   In one room together,          |   Out of all of the conflicts of time.
ben@morrow.me.uk |----------------+---------------| The Levellers, 'Believers'


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

Date: Sun, 22 Feb 2004 00:43:38 +0100
From: "PHP2" <gp@nospm.hr>
Subject: Re: how add/update/delete data in MySQL database here?
Message-Id: <c18qdu$f68$1@ls219.htnet.hr>

thanks for your help


"Gregory Toomey" <nospam@bigpond.com> wrote in message
news:1859826.qnntlf9aQj@GMT-hosting-and-pickle-farming...
> PHP2 wrote:
>
> > how add/update/delete data in MySQL database here?
>
> As I previously explained, you are a moron.
>
> GO AWAY.
>
> gtoomey




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

Date: Sat, 21 Feb 2004 23:32:01 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: how add/update/delete data in MySQL database here?
Message-Id: <c18pnt$59g$1@news.simnet.is>

"PHP2" <gp@nospm.hr> wrote in message news:c18miv$b2f$1@ls219.htnet.hr...
> I am totaly newbie in Perl.. can you write to me whole script?

I do not use MySQL, but a script could contain bits like this:

    use DBI;
    my $dbh =
DBI->connect("dbi:mysql:database=$yourdatabasename",$username,$password);
    $dbh->do("INSERT INTO example VALUES ('foo','bar')");
    $dbh->do("INSERT INTO example VALUES (?,?)",'foo2','bar2');
    $dbh->do("UPDATE example set information='none' WHERE item='foo'");
    $dbh->do("DELETE FROM example WHERE cost>0");

gnari






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

Date: Sun, 22 Feb 2004 01:15:56 +0100
From: "PHP2" <gp@nospm.hr>
Subject: Re: how add/update/delete data in MySQL database here?
Message-Id: <c18sag$hbu$1@ls219.htnet.hr>

thanks

"gnari" <gnari@simnet.is> wrote in message
news:c18pnt$59g$1@news.simnet.is...
> "PHP2" <gp@nospm.hr> wrote in message news:c18miv$b2f$1@ls219.htnet.hr...
> > I am totaly newbie in Perl.. can you write to me whole script?
>
> I do not use MySQL, but a script could contain bits like this:
>
>     use DBI;
>     my $dbh =
> DBI->connect("dbi:mysql:database=$yourdatabasename",$username,$password);
>     $dbh->do("INSERT INTO example VALUES ('foo','bar')");
>     $dbh->do("INSERT INTO example VALUES (?,?)",'foo2','bar2');
>     $dbh->do("UPDATE example set information='none' WHERE item='foo'");
>     $dbh->do("DELETE FROM example WHERE cost>0");
>
> gnari
>
>
>
>




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

Date: Sun, 22 Feb 2004 11:37:17 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: how add/update/delete data in MySQL database here?
Message-Id: <6533101.j7jbidAFum@GMT-hosting-and-pickle-farming>

PHP2 wrote:

> thanks for your help
> 
You are asking a question about mysql; this is a Perl newsgroup.

Try www.dbforums.com or a mysql newgroup if you have mysql questions.

gtoomey



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

Date: Sat, 21 Feb 2004 17:58:50 -0700
From: "Dayton" <dayton500@NOSPAMhotmail.com>
Subject: NEWBIE Question Subroutine help
Message-Id: <g9TZb.22535$o52.5910@fed1read02>

I can't determine what I am doing wrong. I get to this point in my program
but my subroutine &S_print_sls_detail doesn't work. I have all my
variables decalred also my split command seems to work properply.
I took that while statement piece of code and ran it by itself and printed
the
variables. That worked fine. But when I try to put it into a table and a
subroutine I get nothing. Also when I display my page I get my
&S_sales_heading
below my &S_print_inv_wrapup. Not what I expected.

Any help or direction I can get would be greatly appreciated.
T.I.A.


$f_dtype = $q->param("f_dtype");

    if ($f_dtype eq "S") {
       open(FH_Sales,$fn_sal_file);
       &S_sales_heading();                               #display Sales
heading

       while (defined($p_line = <FH_Sales>)) {
         chomp($p_line);
         ($pn,$qty,$unit,$desc) = split(/\|/,$p_line);
         &S_print_sls_detail();
       }

       &S_print_inv_wrapup();
       close(FH_Sales);

    } else





###########################################################
sub S_print_sls_detail {
###########################################################
    print "<tr">\n";
    print "<td>$pn</td>\n";
    print "<td>$desc</td>\n";
    print "<td>$unit</td>\n";
    print "<td>$qty</td>\n";
    print "</tr>";
}




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

Date: Sun, 22 Feb 2004 01:26:16 GMT
From: Beable van Polasm <beable+unsenet@beable.com.invalid>
Subject: Re: NEWBIE Question Subroutine help
Message-Id: <7xeksnoqhm.fsf@dingo.beable.com>

"Dayton" <dayton500@NOSPAMhotmail.com> writes:

> I can't determine what I am doing wrong. I get to this point in my program
> but my subroutine &S_print_sls_detail doesn't work. I have all my
> variables decalred also my split command seems to work properply.
> I took that while statement piece of code and ran it by itself and printed
> the
> variables. That worked fine. But when I try to put it into a table and a
> subroutine I get nothing. Also when I display my page I get my
> &S_sales_heading
> below my &S_print_inv_wrapup. Not what I expected.

The heading below the wrapup might be because you didn't close
your table or something. It's hard to tell, because you didn't
post a working program.

You didn't "use strict", or "use warnings" did you?

> 
> Any help or direction I can get would be greatly appreciated.
> T.I.A.
> 

# At the start of your program, always put these two lines:
# then declare your variables using "my".
use strict;
use warnings;

> $f_dtype = $q->param("f_dtype");
> 
>     if ($f_dtype eq "S") {
>        open(FH_Sales,$fn_sal_file);
>        &S_sales_heading();                               #display Sales
> heading
> 
>        while (defined($p_line = <FH_Sales>)) {
>          chomp($p_line);
>          ($pn,$qty,$unit,$desc) = split(/\|/,$p_line);
>          &S_print_sls_detail();

# You don't need to put an ampersand to call a subroutine. Also, why
# not pass those variables into the subroutine so that it can see
# them? Try this:

            S_print_sls_detail($pn, $qty, $unit, $desc);

>        }
> 
>        &S_print_inv_wrapup();
>        close(FH_Sales);
> 
>     } else
> 
> 
> 
> 
> 
> ###########################################################
> sub S_print_sls_detail {
> ###########################################################
      # read the parameters passed in to the subroutine
      my $pn = shift;
      my $qty = shift;
      my $unit = shift;
      my $desc = shift;

>     print "<tr">\n";
>     print "<td>$pn</td>\n";
>     print "<td>$desc</td>\n";
>     print "<td>$unit</td>\n";
>     print "<td>$qty</td>\n";
>     print "</tr>";
> }



-- 
   


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

Date: Sun, 22 Feb 2004 01:30:26 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: NEWBIE Question Subroutine help
Message-Id: <c190ni$dhh$1@wisteria.csv.warwick.ac.uk>


Beable van Polasm <beable+unsenet@beable.com.invalid> wrote:
> "Dayton" <dayton500@NOSPAMhotmail.com> writes:
> > ###########################################################
> > sub S_print_sls_detail {
> > ###########################################################

There's no need for these lines of #s: they *really* don't help
readability.

>       # read the parameters passed in to the subroutine
>       my $pn = shift;
>       my $qty = shift;
>       my $unit = shift;
>       my $desc = shift;

    my ($pn, $qty, $unit, $desc) = @_;

Ben

-- 
'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'
 :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: ben@morrow.me.uk


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

Date: Sun, 22 Feb 2004 02:30:23 GMT
From: "smrtalec" <smrtalec_NO_SPAM@algxmail.com>
Subject: parsing data file into mysql table - help
Message-Id: <3vUZb.21103$wD5.18798@nwrddc03.gnilink.net>



I have a script which function is to parse through a comma seperated data
file, check if the entry is already existing, then if not enter the data
into a mysql table. However, it only seems to be finding a match on the
third time around.  ie if 'john brown' is in the data file it will only
recognise it as a match the second 'john brown'. It would almost seem the
data from the previous row though inserted has not been registered. see code
snippet below

<snippet>
#! /usr/bin/perl -w

use DBI;


read_file();

sub insert_data {
    my @$value = @_;
    my $rdate=get_date();
    my $p01=$dbh->quote ("0"); # own_id
    my $p02=$dbh->quote ($rdate); # prop_date_lmod

    ...........repetive code removed.................

   my $p12=$dbh->quote ($value->[9]); # own_mobile_phone
    my $sql = "INSERT INTO owner_info_inglewood
               VALUES ($p01,$p02,$p03,$p04,$p05,$p06,
                       $p07,$p08,$p09,$p10,$p11,$p12
                      );";

    my $sth_i = $dbh->prepare ($sql) or err_trap("failed to prepare
statement\n");
    $sth_i->execute() or err_trap("failed to execute statement\n");
    $sth_i->finish();
    $dbh->commit() or err_trap("failed to execute statement\n");
}

sub verify_row {
    my @$vrow = @_;
    my $name_l =  $dbh->quote($vrow->[0]);
    my $name_f =  $dbh->quote($vrow->[1]);
    my $own_str_addr =  $dbh->quote($vrow->[4]);
    my $own_city_addr = $dbh->quote($vrow->[5]);
    ## query property info table to retrieve property id.
    my $sql = ("SELECT own_name_l,own_name_f,
                       own_str_addr,own_city_addr
                FROM owner_info_inglewood
                WHERE own_name_l LIKE $name_l
                AND own_name_f LIKE $name_f
                AND own_str_addr LIKE $own_str_addr
                AND own_city_addr LIKE $own_city_addr;")
    or  err_trap('failed to prepare statement\n');
    my $sth_v = $dbh->prepare ($sql) or err_trap("failed to prepare
statement\n");
    $sth_v->execute or err_trap("failed to execute statement\n");
    my @own_name = $sth_v->fetchrow();
    $sth_v->finish();
    return @own_name;

}

sub read_file {
    my @own_name;
    open (SDDB, "/home/rowan/perl/ho_info.csv") || die print "::$!\n";
    $dbh = connect_try("rowan","******");
        while (<SDDB>) {
            chomp $_;
            my $row = [(split (/,/,$_))];
            ## verify existance of property and retrieve property id.
            unless (verify_row(@$row)) {
                my  $frow = format_data(@$row);
                insert_data(@$frow);
            }else{
                @own_name = verify_row(@$row);
                print "read_file::duplicate found   ->
$own_name[0],$own_name[1],$own_name[2],$own_name[3]\n";
                print "read_file::duplicate original->
$row->[0],$row->[1],$row->[4],$row->[5]\n";
            }
        }
    $dbh->disconnect or err_trap("failed to disconnect statement\n");
    close SDDB;
}

sub connect_try {
    my ($db_user,$db_password) = @_;
    my $dbh = DBI->connect("dbi:mysql:studio_3:67.**.**.**", "$db_user",
"$db_password",{AutoCommit => 0 }) or
        err_trap("error connecting to DB");
    return $dbh;
}

</snippet



+++++++++++++++++++++++++++++++
++REMOVE _NO_SPAM from return    ++
++e-mail address in order to respond.    ++
+++++++++++++++++++++++++++++++




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

Date: Sun, 22 Feb 2004 11:47:35 +0800
From: toylet <toylet_at_mail.hongkong.com>
Subject: perl and curse-based U.I.
Message-Id: <4038264e$1_3@rain.i-cable.com>


Anyone know of a good/full example of using perl's Curses::UI widgets? 
In fact, is the CPAN containing the best curses:UI widgets under the 
Linux environment?

I am loooking for something like dBase/Foxpro's @say...get system.

-- 
   .~.    Might, Courage, Vision. In Linux We Trust.
  / v \   http://www.linux-sxs.org
/( _ )\  Linux 2.4.22-xfs
   ^ ^    11:44am up 53 min 1 user 0.92 0.56


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

Date: Sat, 21 Feb 2004 23:07:37 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Simple code runs on linux, but not on windows -- why?
Message-Id: <c18obp$6o5$1@wisteria.csv.warwick.ac.uk>


tadmc@augustmail.com wrote:
>
> ( Using ?: for its side effects is a bad idea. You should use
>   it for the value that it returns instead.

Could you give some reasons for this? Obviously in the case you were
referring to 'return x ? y : z' is preferable to 'x ? return y : return
z', simply because it avoids duplicating the return; but if the
statement had been, say, 'x ? return y : die z', what would be wrong
with it?

(FWIW, I would say that the change to ?? :: to match && and || in perl6
indicates that Larry agrees with me; also, I for one would really like a
low-precedence keyword version, though precedence means that 'x and y or
z' is usually good enough.)

Ben

-- 
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 /Alcestis/)        [ flame, and falls out of sight. ]         ben@morrow.me.uk


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

Date: Sat, 21 Feb 2004 22:46:08 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Simple code runs on linux, but not on windows -- why?
Message-Id: <pan.2004.02.22.03.46.06.317327@remove.adelphia.net>

On Sat, 21 Feb 2004 21:22:42 +0000, Suresh Govindachar wrote:

<snip>
> The context:  For homework, we need to provide a .cgi and a .pl
> solution.  I am trying to submit a single .cgi file that can run
> in the shell too -- using things like:
<snip>

use CGI qw(:standard -debug);

Now, you can run the script either on the command line or through a web
server.

`perldoc CGI` for more information.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Computers will not be perfected until they can compute how much
more than the estimate the job will cost. 



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

Date: Sat, 21 Feb 2004 21:48:14 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Simple code runs on linux, but not on windows -- why?
Message-Id: <slrnc3g9ju.8ha.tadmc@magna.augustmail.com>

Ben Morrow <usenet@morrow.me.uk> wrote:
> 
> tadmc@augustmail.com wrote:
>>
>> ( Using ?: for its side effects is a bad idea. You should use
>>   it for the value that it returns instead.
> 
> Could you give some reasons for this? 


It's just my personal style I guess.

I like if/else actions to look like it.

?: for me is an if/else value rather than an if/else action.


> if the
> statement had been, say, 'x ? return y : die z', what would be wrong
> with it?


Too little typing for my tastes. :-)

   if ( x )
      { return y }
   else
      { die z }

seems to communicate much more clearly what is going on in the flow.

I am generally willing to spend a little more effort upfront if I
get a lot of debugging benefit later on. I drop bread crumbs to
help me find my way if I should become lost.

I seem to get the "opportunity" to debug my code more often than
I feel is strictly necessary. When I do have to debug, I want it
to be over with as soon as possible.  :-)

If I can read and understand the code faster, I can fix the problem faster.


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


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

Date: Sat, 21 Feb 2004 21:42:10 -0600
From: bob <no@nowhere.com>
Subject: Re: trapping file i/o error
Message-Id: <XgCdnUtyfLcdtaXd3cwC-w@speakeasy.net>

toylet wrote:
> Thank you. Seems that perl requires the programms the know about context.
> 
>> print "As a string, the last error was '$!'\n";
>> print "As a number, errno was ", $!+0, "\n";
> 
> 

Yes.  but once you *do* know about it, it can be very convenient.


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

Date: Sun, 22 Feb 2004 01:50:37 +0000 (UTC)
From: "Ben Liddicott" <ben@liddicott.com>
Subject: Re: Win 2K3 & File Locking
Message-Id: <c191td$i0l$1@sparta.btinternet.com>

As far as I know, only those which exist in Perl/Win32 anyway. Check the =
docs.

The main biggie is twofold.

1. Locks on windows are mandatory.
2. Perl flock locks don't play nicely with other win32 applications.

Windows has two kinds of mandatory locks, and no advisory locks. Share =
mode, which is applied at the time you open the file, and range locks, =
which are applied to an open file. Most applications open files with =
FILE_SHARE_READ|FILE_SHARE_WRITE, meaning that the file can be opened by =
another process with read or write access. Applications which need to =
lock a file generally deny sharing, which means that other applications =
will fail to open them. Conversely, many applications assume that if =
they can open the file, they will be able to read it. When they =
successfully open the file but fail to read any data, they will have a =
sort of "don't know why" error, and it will be treated differently from =
if they failed to open the file.

In unix, file locks are applied after the file is opened. In order to =
allow this to happen in Perl on Win32, perl's flock sets a range lock =
when you call flock. This allows interoperation with other perl modules, =
but will surprise most applications, which expect that if the file is in =
use, the open will fail.

I'm working on a portable locking implementation which provides =
share-mode opening on windows, and equivalent semantics on Unix/Linux. =
It also provides portable range locks on Solaris, BSD, Linux and Win32.=20

Not done yet though.

--=20
Cheers,
Ben Liddicott

"Paanwa" <paanwa@hotmail.com> wrote in message =
news:40350c15$0$49485$a04e5680@nnrp.fuse.net...
> Anyone aware of file locking issues specific to Perl on Windows 2003 =
server?
>=20
> 


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

Date: Sat, 21 Feb 2004 22:36:55 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: WWW::Mechanize error confusion
Message-Id: <pan.2004.02.22.03.36.53.698571@remove.adelphia.net>

On Sat, 21 Feb 2004 12:53:06 -0800, RP wrote:

> I'm running this through a web server.  The script as it is works -
> but if you change the $mech->get url like so:
> 
> $mech->get("http://www.expedia.com");
> 
> It doesn't work.  Any url other than amazon.com doesn't work....  I
> don't get it!

I'm thinking HTTP header ... meaning, you're getting a redirect header
from Amazon ... which explains why you're getting the Amazon page and not
others ... because you're not outputing any header through the script.

Best suggestion is to use an HTTP header to redirect the client versus
what you're doing - unless you have some reason for doing it this way. 
You can just use a print statement to output the proper header to the
client, such as:

print "Content-type: text/html\n\n";

Which is the standard header for an HTML page.  I'll leave finding the
proper HTTP header up to you :-)

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Whenever anyone says, "theoretically", they really mean, "not
really".   -- Dave Parnas 



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

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


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