[23629] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5836 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 20 18:05:52 2003

Date: Thu, 20 Nov 2003 15:05:10 -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           Thu, 20 Nov 2003     Volume: 10 Number: 5836

Today's topics:
    Re: Comments: locking variables <xxala_qumsiehxx@xxyahooxx.com>
    Re: Comments: locking variables <xxala_qumsiehxx@xxyahooxx.com>
        DBI Question <kbass@midsouth.rr.com>
    Re: DBI Question <kbass@midsouth.rr.com>
    Re: DBI Question <kbass@midsouth.rr.com>
    Re: DBI Question (Tad McClellan)
        How to pause display of long STDOUT Default@IO_Error_1011101.xyz
    Re: How to pause display of long STDOUT <abigail@abigail.nl>
    Re: How to pause display of long STDOUT <xx087@freenet.carleton.ca>
    Re: How to pause display of long STDOUT <emschwar@pobox.com>
    Re: How to pause display of long STDOUT Default@IO_Error_1011101.xyz
    Re: How to pause display of long STDOUT <shuffman@ichips.intel.com>
        How to save state while debugging? <bill_knight2@yahoo.com>
    Re: Image::Magick memory leak question <stanb@panix.com>
    Re: Image::Magick memory leak question <mgjv@tradingpost.com.au>
        MIN MAX for GREP? (Chris Doe)
    Re: MIN MAX for GREP? (Tad McClellan)
    Re: Need some help... <usenet@dwall.fastmail.fm>
    Re: Perl Sendmail Question <me@privacy.net>
    Re: Perl Sendmail Question <notspam@spamfree.dud>
    Re: Protecting Source code of a perl script <REMOVEsdnCAPS@comcast.net>
        Retrieving dynamic web content <cckim@stanford.edu>
    Re: Retrieving dynamic web content <abigail@abigail.nl>
    Re: Retrieving dynamic web content (Tad McClellan)
    Re: Retrieving dynamic web content <cckim@stanford.edu>
    Re: Retrieving dynamic web content (Sam Holden)
        status of redirecting STDOUT/STDERR to file (jonathan)
    Re: where is DBI::DWIM? ctcgag@hotmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 20 Nov 2003 19:07:18 GMT
From: "Ala Qumsieh" <xxala_qumsiehxx@xxyahooxx.com>
Subject: Re: Comments: locking variables
Message-Id: <Gh8vb.11423$Dh4.1302@newssvr13.news.prodigy.com>


"Matthew Braid" <mb@uq.net.au.invalid> wrote in message
news:bphbeu$8lu$1@bunyip.cc.uq.edu.au...
> Hi all,
>
> I need to lock down some keys in a blessed hash so that they cannot be
> directly altered (eg through $self->{key} = "whatever"). This is
> important as the key in question holds a security flag for the current
> instance, and I don't want it to be _too_ easy to circumvent :)
>
> I can't use the class extensions that perl5 has (due to perceived
> 'flimsyness' by the powers-that-be), but I've worked around this using
> Tie::Watch (which, since it is in existing programs here, is apparently
ok).

You can completely dispense of using any modules if you so wish. Here's an
example that does what you want. It uses tie(), and you pass the key that
you want to lock in the tie() call. It can be easily extended to handle
multiple locked keys. The main thing to look at is the STORE method which
checks if we're trying to overwrite a locked key.

## START OF CODE

#!perl -w

use strict;

package lockKey;

sub TIEHASH {
  my ($class, $key) = @_;

  my $obj = bless {
     LOCKED => $key,
     HASH   => {},
    };
  return $obj;
}

sub FETCH { $_[0]{HASH}{$_[1]} }

sub STORE {
  my ($this, $k, $v) = @_;

  if ($this->{LOCKED} eq $k) {
    # only store if it's not defined already.
    return if exists $this->{HASH}{$k};
  }

  $this->{HASH}{$k} = $v;
}

sub FIRSTKEY {  # copied from perltie
  my $this = shift;
  my $a    = keys %{$this->{HASH}};          # reset each() iterator
  each %{$this->{HASH}};
}

sub NEXTKEY  { each %{$_[0]{HASH}} }

package main;

my %hash;
tie %hash, 'lockKey', 'AltUID';

$hash{test}   = 'a';
$hash{AltUID} = 'value1';

print "$_ = $hash{$_}.\n" for keys %hash;

$hash{test}   = 'b';
$hash{AltUID} = 'value1';

print "$_ = $hash{$_}.\n" for keys %hash;

__END__
test = a.
AltUID = value1.
test = b.
AltUID = value1.


--Ala




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

Date: Thu, 20 Nov 2003 21:23:17 GMT
From: "Ala Qumsieh" <xxala_qumsiehxx@xxyahooxx.com>
Subject: Re: Comments: locking variables
Message-Id: <9havb.395$bE.373@newssvr14.news.prodigy.com>

"Ala Qumsieh" <xxala_qumsiehxx@xxyahooxx.com> wrote in message
news:Gh8vb.11423$Dh4.1302@newssvr13.news.prodigy.com...

> my %hash;
> tie %hash, 'lockKey', 'AltUID';
>
> $hash{test}   = 'a';
> $hash{AltUID} = 'value1';
>
> print "$_ = $hash{$_}.\n" for keys %hash;
>
> $hash{test}   = 'b';
> $hash{AltUID} = 'value1';
                   ^^^^^^
                   ^^^^^^
That should have been 'value2' (or anything else different from 'value1').
That doesn't change the output though.

> print "$_ = $hash{$_}.\n" for keys %hash;
>
> __END__
> test = a.
> AltUID = value1.
> test = b.
> AltUID = value1.

--Ala




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

Date: Thu, 20 Nov 2003 21:52:45 GMT
From: "kbass" <kbass@midsouth.rr.com>
Subject: DBI Question
Message-Id: <NIavb.30934$oC5.28755@clmboh1-nws5.columbus.rr.com>

I am receiving a variable from HTML called 'STerr' and reading it into my
CGI program. The variable is accepted into the program and filters down into
a SQL statement. My problem is that I get no results from within my CGI
program but when I place this same SQL statement within Postgres, I receive
data back.

If I get rid of the $dbh->quote, the SQL statement still returns no data.  I
have attempted to set $territory and $territory_quoted within my SQL
statements and still no data. What am I doing incorrect to not get data back
within my CGI program but retrieve data from the Postgres backend? The
database is Postgres.

use strict
 ...

$territory  = param("STerr");
#$territory  = '1-1-1-1-1-2-0'; # Sample data

View_Info();

##############################
# Procedure: View_Info       #
##############################
sub View_Info {

               $sql = "select fyear,
                       fqtr,
                       adjtype,
                       adjref,
                       subdist,
                       subdate,
                       adjgoalvolqty
              from fy04q1bulletin
                 where subdist = ?
               ";

        $sth = $dbh->prepare($sql);
        my $territory_quoted = $dbh->quote( $territory);
        $sth->execute($territory_quoted);

        $sth->bind_columns(undef, \( $fyear, $fqtr, $adjtype, $adjref,
$subdist,
 $subdate, $aprreason, $custid, $custname, $custtype, $adjstatus,
$declreason, $
proccomments, $dispflag, $losingorg, $losingterr, $gainorg, $gainterr,
$revfilte
rtype, $revfilterdesc, $adjrevamt, $adjpackqty, $adjprvyear,
$adjpackprvyear, $a
djgoalrevamt, $adjgoalvolqty ));

 ...

  while (@rows= $sth->fetchrow_array) {
     print<<HTML;
     <tr>
       <td><center>$rows[0]</center></td>
       <td><center>$rows[1]</center></td>
       <td><center>$rows[2]</center></td>
       <td><center>$rows[3]</center></td>
       ...




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

Date: Thu, 20 Nov 2003 22:08:57 GMT
From: "kbass" <kbass@midsouth.rr.com>
Subject: Re: DBI Question
Message-Id: <ZXavb.30935$oC5.30643@clmboh1-nws5.columbus.rr.com>


"kbass" <kbass@midsouth.rr.com> wrote in message
news:NIavb.30934$oC5.28755@clmboh1-nws5.columbus.rr.com...
> I am receiving a variable from HTML called 'STerr' and reading it into my
> CGI program. The variable is accepted into the program and filters down
into
> a SQL statement. My problem is that I get no results from within my CGI
> program but when I place this same SQL statement within Postgres, I
receive
> data back.
>
> If I get rid of the $dbh->quote, the SQL statement still returns no data.
I
> have attempted to set $territory and $territory_quoted within my SQL
> statements and still no data. What am I doing incorrect to not get data
back
> within my CGI program but retrieve data from the Postgres backend? The
> database is Postgres.
>
> use strict
> ...
>
> $territory  = param("STerr");
> #$territory  = '1-1-1-1-1-2-0'; # Sample data
>
> View_Info();
>
> ##############################
> # Procedure: View_Info       #
> ##############################
> sub View_Info {
>
>                $sql = "select fyear,
>                        fqtr,
>                        adjtype,
>                        adjref,
>                        subdist,
>                        subdate,
>                        adjgoalvolqty
>               from fy04q1bulletin
>                  where subdist = ?
>                ";
>
>         $sth = $dbh->prepare($sql);
>         my $territory_quoted = $dbh->quote( $territory);
>         $sth->execute($territory_quoted);
>
>         $sth->bind_columns(undef, \( $fyear, $fqtr, $adjtype, $adjref,
> $subdist,
>  $subdate, $aprreason, $custid, $custname, $custtype, $adjstatus,
> $declreason, $
> proccomments, $dispflag, $losingorg, $losingterr, $gainorg, $gainterr,
> $revfilte
> rtype, $revfilterdesc, $adjrevamt, $adjpackqty, $adjprvyear,
> $adjpackprvyear, $a
> djgoalrevamt, $adjgoalvolqty ));
>
> ...
>
>   while (@rows= $sth->fetchrow_array) {
>      print<<HTML;
>      <tr>
>        <td><center>$rows[0]</center></td>
>        <td><center>$rows[1]</center></td>
>        <td><center>$rows[2]</center></td>
>        <td><center>$rows[3]</center></td>
>        ...
>
>

As a side note, when I add the $dbh->trace functionality and the $dbh->quote
used in my CGI program, I get information the message below.  Without the
$dbh->quote used, I received an error message and get the information
message below too.

I didn't place the entire trace file messages into this posting since it is
fairly large. Hope this helps.  Thanks!

Kevin
-------------------------------------------------------
Within database trace on & $dbh->quote used
-------------------------------------------------------
 ...
 <- STORE= 1 at PgPP.pm line 173 via
/home/salesplan/website/cgi-bin/abb1.cgi
 line 125
    -> STORE for DBD::PgPP::st (DBI::st=HASH(0x851e038)~0x8114278
'NUM_OF_PARAMS
' 1)
    STORE DBI::st=HASH(0x8114278) 'NUM_OF_PARAMS' => 1
    <- STORE= 1 at PgPP.pm line 174 via
/home/salesplan/website/cgi-bin/abb1.cgi
 line 125
    <- prepare= DBI::st=HASH(0x851e038) at abb1.cgi line 125 via
/home/salesplan
/website/cgi-bin/abb1.cgi line 82
    -> quote in DBD::_::db for DBD::PgPP::db
(DBI::db=HASH(0x851870c)~0x8514034
'1-1-1-1-1-2-0')
    <- quote= ''1-1-1-1-1-2-0'' at abb1.cgi line 126 via
/home/salesplan/website
/cgi-bin/abb1.cgi line 82
    -> execute for DBD::PgPP::st (DBI::st=HASH(0x851e038)~0x8114278
''1-1-1-1-1-
2-0'')
1   <- FETCH= 1 ('NUM_OF_PARAMS' from cache) at PgPP.pm line 281 via
/home/sales
plan/website/cgi-bin/abb1.cgi line 127
    -> quote for DBD::PgPP::db (DBI::db=HASH(0x8514034)~INNER
''1-1-1-1-1-2-0'')
    <- quote= ''''1-1-1-1-1-2-0'''' at PgPP.pm line 288 via
/home/salesplan/webs
ite/cgi-bin/abb1.cgi line 127
1   <- FETCH= DBD::PgPP::Protocol=HASH(0x84e086c) ('pgpp_handle' from cache)
at
PgPP.pm line 291 via /home/salesplan/website/cgi-bin/abb1.cgi line 127
1   -> STORE for DBD::PgPP::st (DBI::st=HASH(0x8114278)~INNER
'NUM_OF_FIELDS' 26
)
    STORE DBI::st=HASH(0x8114278) 'NUM_OF_FIELDS' => 26
1   <- STORE= 1 at PgPP.pm line 309 via
/home/salesplan/website/cgi-bin/abb1.cgi
 line 82
1   -> STORE for DBD::PgPP::st (DBI::st=HASH(0x8114278)~INNER 'NAME'
ARRAY(0x854
7fe8))
1   <- STORE= 1 at PgPP.pm line 310 via
/home/salesplan/website/cgi-bin/abb1.cgi
 line 82
    <- execute= '0E0' at abb1.cgi line 127 via
/home/salesplan/website/cgi-bin/a
bb1.cgi line 82
 ....

---------------------------------------------------------------
Within database trace on & within $dbh->quote used
----------------------------------------------------------------
-> STORE for DBD::PgPP::st (DBI::st=HASH(0x851e038)~0x8114278 'NUM_OF_PARAMS
' 1)
    STORE DBI::st=HASH(0x8114278) 'NUM_OF_PARAMS' => 1
    <- STORE= 1 at PgPP.pm line 174 via
/home/salesplan/website/cgi-bin/abb1.cgi
 line 125
    <- prepare= DBI::st=HASH(0x851e038) at abb1.cgi line 125 via
/home/salesplan
/website/cgi-bin/abb1.cgi line 82
    -> quote in DBD::_::db for DBD::PgPP::db
(DBI::db=HASH(0x851870c)~0x8514034
'1-1-1-1-1-2-0')
    <- quote= ''1-1-1-1-1-2-0'' at abb1.cgi line 126 via
/home/salesplan/website
/cgi-bin/abb1.cgi line 82
    -> execute for DBD::PgPP::st (DBI::st=HASH(0x851e038)~0x8114278
'1-1-1-1-1-2
-0')
1   <- FETCH= 1 ('NUM_OF_PARAMS' from cache) at PgPP.pm line 281 via
/home/sales
plan/website/cgi-bin/abb1.cgi line 127
    -> quote for DBD::PgPP::db (DBI::db=HASH(0x8514034)~INNER
'1-1-1-1-1-2-0')
    <- quote= ''1-1-1-1-1-2-0'' at PgPP.pm line 288 via
/home/salesplan/website/
cgi-bin/abb1.cgi line 127
1   <- FETCH= DBD::PgPP::Protocol=HASH(0x84e086c) ('pgpp_handle' from cache)
at
PgPP.pm line 291 via /home/salesplan/website/cgi-bin/abb1.cgi line 127
    !! ERROR: 1 'Unknown message type: '.' at
/usr/local/lib/perl5/site_perl/5.8
 .0/i686-linux/DBD/PgPP.pm line 634
'
    <- execute= undef at abb1.cgi line 127 via
/home/salesplan/website/cgi-bin/a
bb1.cgi line 82




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

Date: Thu, 20 Nov 2003 22:16:23 GMT
From: "kbass" <kbass@midsouth.rr.com>
Subject: Re: DBI Question
Message-Id: <X2bvb.30936$oC5.4937@clmboh1-nws5.columbus.rr.com>


"kbass" <kbass@midsouth.rr.com> wrote in message
news:ZXavb.30935$oC5.30643@clmboh1-nws5.columbus.rr.com...
>
> "kbass" <kbass@midsouth.rr.com> wrote in message
> news:NIavb.30934$oC5.28755@clmboh1-nws5.columbus.rr.com...
> > I am receiving a variable from HTML called 'STerr' and reading it into
my
> > CGI program. The variable is accepted into the program and filters down
> into
> > a SQL statement. My problem is that I get no results from within my CGI
> > program but when I place this same SQL statement within Postgres, I
> receive
> > data back.
> >
> > If I get rid of the $dbh->quote, the SQL statement still returns no
data.
> I
> > have attempted to set $territory and $territory_quoted within my SQL
> > statements and still no data. What am I doing incorrect to not get data
> back
> > within my CGI program but retrieve data from the Postgres backend? The
> > database is Postgres.
> >
> > use strict
> > ...
> >
> > $territory  = param("STerr");
> > #$territory  = '1-1-1-1-1-2-0'; # Sample data
> >
> > View_Info();
> >
> > ##############################
> > # Procedure: View_Info       #
> > ##############################
> > sub View_Info {
> >
> >                $sql = "select fyear,
> >                        fqtr,
> >                        adjtype,
> >                        adjref,
> >                        subdist,
> >                        subdate,
> >                        adjgoalvolqty
> >               from fy04q1bulletin
> >                  where subdist = ?
> >                ";
> >
> >         $sth = $dbh->prepare($sql);
> >         my $territory_quoted = $dbh->quote( $territory);
> >         $sth->execute($territory_quoted);
> >
> >         $sth->bind_columns(undef, \( $fyear, $fqtr, $adjtype, $adjref,
> > $subdist,
> >  $subdate, $aprreason, $custid, $custname, $custtype, $adjstatus,
> > $declreason, $
> > proccomments, $dispflag, $losingorg, $losingterr, $gainorg, $gainterr,
> > $revfilte
> > rtype, $revfilterdesc, $adjrevamt, $adjpackqty, $adjprvyear,
> > $adjpackprvyear, $a
> > djgoalrevamt, $adjgoalvolqty ));
> >
> > ...
> >
> >   while (@rows= $sth->fetchrow_array) {
> >      print<<HTML;
> >      <tr>
> >        <td><center>$rows[0]</center></td>
> >        <td><center>$rows[1]</center></td>
> >        <td><center>$rows[2]</center></td>
> >        <td><center>$rows[3]</center></td>
> >        ...
> >
> >
>
> As a side note, when I add the $dbh->trace functionality and the
$dbh->quote
> used in my CGI program, I get information the message below.  Without the
> $dbh->quote used, I received an error message and get the information
> message below too.
>
> I didn't place the entire trace file messages into this posting since it
is
> fairly large. Hope this helps.  Thanks!
>
> Kevin
> -------------------------------------------------------
> Within database trace on & $dbh->quote used
> -------------------------------------------------------
> ...
>  <- STORE= 1 at PgPP.pm line 173 via
> /home/salesplan/website/cgi-bin/abb1.cgi
>  line 125
>     -> STORE for DBD::PgPP::st (DBI::st=HASH(0x851e038)~0x8114278
> 'NUM_OF_PARAMS
> ' 1)
>     STORE DBI::st=HASH(0x8114278) 'NUM_OF_PARAMS' => 1
>     <- STORE= 1 at PgPP.pm line 174 via
> /home/salesplan/website/cgi-bin/abb1.cgi
>  line 125
>     <- prepare= DBI::st=HASH(0x851e038) at abb1.cgi line 125 via
> /home/salesplan
> /website/cgi-bin/abb1.cgi line 82
>     -> quote in DBD::_::db for DBD::PgPP::db
> (DBI::db=HASH(0x851870c)~0x8514034
> '1-1-1-1-1-2-0')
>     <- quote= ''1-1-1-1-1-2-0'' at abb1.cgi line 126 via
> /home/salesplan/website
> /cgi-bin/abb1.cgi line 82
>     -> execute for DBD::PgPP::st (DBI::st=HASH(0x851e038)~0x8114278
> ''1-1-1-1-1-
> 2-0'')
> 1   <- FETCH= 1 ('NUM_OF_PARAMS' from cache) at PgPP.pm line 281 via
> /home/sales
> plan/website/cgi-bin/abb1.cgi line 127
>     -> quote for DBD::PgPP::db (DBI::db=HASH(0x8514034)~INNER
> ''1-1-1-1-1-2-0'')
>     <- quote= ''''1-1-1-1-1-2-0'''' at PgPP.pm line 288 via
> /home/salesplan/webs
> ite/cgi-bin/abb1.cgi line 127
> 1   <- FETCH= DBD::PgPP::Protocol=HASH(0x84e086c) ('pgpp_handle' from
cache)
> at
> PgPP.pm line 291 via /home/salesplan/website/cgi-bin/abb1.cgi line 127
> 1   -> STORE for DBD::PgPP::st (DBI::st=HASH(0x8114278)~INNER
> 'NUM_OF_FIELDS' 26
> )
>     STORE DBI::st=HASH(0x8114278) 'NUM_OF_FIELDS' => 26
> 1   <- STORE= 1 at PgPP.pm line 309 via
> /home/salesplan/website/cgi-bin/abb1.cgi
>  line 82
> 1   -> STORE for DBD::PgPP::st (DBI::st=HASH(0x8114278)~INNER 'NAME'
> ARRAY(0x854
> 7fe8))
> 1   <- STORE= 1 at PgPP.pm line 310 via
> /home/salesplan/website/cgi-bin/abb1.cgi
>  line 82
>     <- execute= '0E0' at abb1.cgi line 127 via
> /home/salesplan/website/cgi-bin/a
> bb1.cgi line 82
> ....
>
> ---------------------------------------------------------------
> Within database trace on & within $dbh->quote used
> ----------------------------------------------------------------
> -> STORE for DBD::PgPP::st (DBI::st=HASH(0x851e038)~0x8114278
'NUM_OF_PARAMS
> ' 1)
>     STORE DBI::st=HASH(0x8114278) 'NUM_OF_PARAMS' => 1
>     <- STORE= 1 at PgPP.pm line 174 via
> /home/salesplan/website/cgi-bin/abb1.cgi
>  line 125
>     <- prepare= DBI::st=HASH(0x851e038) at abb1.cgi line 125 via
> /home/salesplan
> /website/cgi-bin/abb1.cgi line 82
>     -> quote in DBD::_::db for DBD::PgPP::db
> (DBI::db=HASH(0x851870c)~0x8514034
> '1-1-1-1-1-2-0')
>     <- quote= ''1-1-1-1-1-2-0'' at abb1.cgi line 126 via
> /home/salesplan/website
> /cgi-bin/abb1.cgi line 82
>     -> execute for DBD::PgPP::st (DBI::st=HASH(0x851e038)~0x8114278
> '1-1-1-1-1-2
> -0')
> 1   <- FETCH= 1 ('NUM_OF_PARAMS' from cache) at PgPP.pm line 281 via
> /home/sales
> plan/website/cgi-bin/abb1.cgi line 127
>     -> quote for DBD::PgPP::db (DBI::db=HASH(0x8514034)~INNER
> '1-1-1-1-1-2-0')
>     <- quote= ''1-1-1-1-1-2-0'' at PgPP.pm line 288 via
> /home/salesplan/website/
> cgi-bin/abb1.cgi line 127
> 1   <- FETCH= DBD::PgPP::Protocol=HASH(0x84e086c) ('pgpp_handle' from
cache)
> at
> PgPP.pm line 291 via /home/salesplan/website/cgi-bin/abb1.cgi line 127
>     !! ERROR: 1 'Unknown message type: '.' at
> /usr/local/lib/perl5/site_perl/5.8
> .0/i686-linux/DBD/PgPP.pm line 634
> '
>     <- execute= undef at abb1.cgi line 127 via
> /home/salesplan/website/cgi-bin/a
> bb1.cgi line 82
>
>

The error message points to the line featuring the $sth->bind_columns()
statement.
Statement has no result columns to bind (perhaps you need to successfully
call execute first) at /home/salesplan/website/cgi-bin/abb1.cgi line 129.





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

Date: Thu, 20 Nov 2003 16:26:00 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: DBI Question
Message-Id: <slrnbrqfro.56k.tadmc@magna.augustmail.com>

kbass <kbass@midsouth.rr.com> wrote:

> I am receiving a variable from HTML 


No you're not, as that is impossible.

You meant you are receiving _values_ from a web server, I expect.


> use strict
> ...
> 
> $territory  = param("STerr");


If this is your real code, then where is the declaration
for that variable (and for all of the others too)?

If this in not your real code, then why is it even here?


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


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

Date: Thu, 20 Nov 2003 19:11:14 GMT
From: Default@IO_Error_1011101.xyz
Subject: How to pause display of long STDOUT
Message-Id: <ml8vb.57018$bQ3.49701@nwrdny03.gnilink.net>

I've implemented a pause in the help section of this.
Thing is in that case i knew the text was more than a screenfull.
What if i'm not sure if the display will be more than a screenfull,
is there a 'more' or 'less' like command i can implement?

Also if anyone is familiar with Getopt... is there a way to collect the
initial file args from this command line w/o using a -<option>?

#!
use strict;
use warnings;
use Getopt::Long;

#Gather input files#
my $file = "";
my $dbfile = "words";
my $files = lc(shift) || help() && die "\n";
unshift (@ARGV, $files);

#Get options#
my $opt_help = '';            # -h  Help.
my $opt_ignore = '';          # -i  Ignore case while searching words.
my $opt_select = '';          # -s  Select a database (or create one).
my $opt_read = '';            # -r  Read from the database.
my $opt_write = '';           # -w  Write to the database.
my $opt_clear = '';           # -x  Clear the database.
GetOptions ('h' => \$opt_help, 'x' => \$opt_clear,
            'i' => \$opt_ignore, 's' => \$opt_select,
            'r' => \$opt_read, 'w' => \$opt_write);

#Main#
if ($opt_help eq "1") {help();}
if ($opt_select eq "1") {select_db();}
if ($opt_write eq "1") {write_db();}
if ($opt_read eq "1") {read_db();}
if ($opt_clear eq "1") {clear_db();}
if ($opt_help eq "" && $opt_select eq "" && $opt_write eq "" &&
    $opt_read eq "" && $opt_clear eq "")
    {help() && die "\nQuitting... No options selected.\n";}

print "\nDone.\n";

#Subroutines#
sub select_db
{
     my $new_db = "";
     print "\n" . ' ' . '='x78 . "\n";
     print " Select or create a database.  " .
     'The default database is: "' . "$dbfile" . '"' . "\n";
     print ' ' . '='x78 . "\n\n";
     while ($new_db eq "")
     {
          print 'Enter the name of the database: ';
          chomp ($new_db = lc<STDIN>);
     }
     my $new_db_1 = "$new_db" . ".pag";
     my $new_db_2 = "$new_db" . ".dir";
     if (!-e $new_db_1 and !-e $new_db_2)
     {
          print "\n".'Create new database "'."$new_db".'" (y or n) ';
          chomp (my $verify = lc<STDIN>);
          die "\n".'Quitting: "'."$new_db".'" was not created'."\n"
          unless ($verify eq "y");
     }
     else {print 'Selecting the "'."$new_db".'" database.'."\n\n";}
     $dbfile = $new_db;
}
sub write_db
{
     print "\nUpdating database...\n";
     dbmopen(my %WORDS,"$dbfile",0644)||die "\nCan't open $dbfile $!\n";
     foreach $file (<${files}>)
     {
          open(READFILE, "$file") || warn "\nCan't open $file $!\n";
          while (<READFILE>)
          {
               foreach my $word (split (/\W+/))
               {
                    if ($opt_ignore eq "1") {$word = lc($word);}
                    $WORDS{$word}++;
               }
          }
          close (READFILE) || warn "\nCan't close $file $!\n";
     }
     dbmclose(%WORDS) || warn "\nCan't close $dbfile #!\n";
     print "\nFinished updating database.\n\n";
}
sub read_db
{
     print "\n".' '.'='x78 . "\n This will read the ".'"'."$dbfile" .
           '" database.' . "\n" . ' ' . '='x78 . "\n\n";
     print "Press <Enter> to continue.";
     my $pause = <STDIN>; $pause = undef; print "\n\n";
     dbmopen(my %WORDS,"$dbfile",0644)||die "Can't open $dbfile:\n#!\n";
     while ((my $key, my $value) = each(%WORDS))
     {print "$key has been seen $value times.\n";}
     dbmclose(%WORDS) || warn "\nCan't close $dbfile #!\n";
}
sub clear_db
{
     print "\n" . ' ' . '='x78 . "\n";
     print ' This will clear the "' . "$dbfile" . '" database.';
     print "\n" . ' ' . '='x78 . "\n\n";
     print 'Are you sure you wish to do this (y or n)? ';
     chomp (my $verify = lc<STDIN>);
     print "\n";
     die 'Quitting: The "'."$dbfile".'" database was not cleared.'."\n"
     unless ($verify eq "y");
     dbmopen(my %WORDS, $dbfile,0666)||die "Can't open $dbfile: $!\n";
     %WORDS = ();
     dbmclose (%WORDS);
     die '"' . "$dbfile" . '" has been cleared.' . "\n";
}
sub help
{
print <<ENDTEXT;

     USAGE:    perl 17_1.plx [file or wildcard] [options]

     OPTIONS:  -h  Help.
               -i  Ignore case while searching words.
               -r  Read from the database.
               -s  Select a database (or create a new one).
               -w  Write to the database.
               -x  Clear the database.

     NOTES:    Default database will be used unless -n is specified.
               You will not be able to write to the database unless
               files are specified and the -w switch is issued.
ENDTEXT
print "\nPress <Enter> to continue... ";
chomp (my $pause = <STDIN>);
print <<ENDTEXT;
-----------------------------Examples-----------------------------------

perl 17_1.plx file.txt -w          Updates the default database with
                                   information obtained from the
                                   specified files.
perl 17_1.plx *.* -n -w -r         Creates a new database from the
                                   information contained in the
                                   specified files, and then reads it.
perl 17_1.plx -n -r                Selects an alternate database and
                                   reads the contents.
perl 17_1.plx -r -n -c             Selects an alternate database and
                                   clears then reads the contents.
perl 17_1.plx -r -?                Reads from the default database and
                                   displays this help screen.

ENDTEXT
}


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

Date: 20 Nov 2003 20:15:59 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: How to pause display of long STDOUT
Message-Id: <slrnbrq87u.7ug.abigail@alexandra.abigail.nl>

Default@IO_Error_1011101.xyz (Default@IO_Error_1011101.xyz) wrote on
MMMDCCXXXIII September MCMXCIII in <URL:news:ml8vb.57018$bQ3.49701@nwrdny03.gnilink.net>:
??  I've implemented a pause in the help section of this.
??  Thing is in that case i knew the text was more than a screenfull.
??  What if i'm not sure if the display will be more than a screenfull,
??  is there a 'more' or 'less' like command i can implement?

What's wrong with:

    perl your_program arguments | more


Abigail
-- 
print v74.117.115.116.32, v97.110.111.116.104.101.114.32,
      v80.101.114.108.32, v72.97.99.107.101.114.10;


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

Date: 20 Nov 2003 20:16:35 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: How to pause display of long STDOUT
Message-Id: <slrnbrq8ah.cjj.xx087@smeagol.ncf.ca>

Default@IO_Error_1011101.xyz <Default@IO_Error_1011101.xyz> wrote:
>  is there a 'more' or 'less' like command i can implement?

Collect your help into a scalar $help, then:
    system "echo '$help'|less";

>  Also if anyone is familiar with Getopt... is there a way to collect the
>  initial file args from this command line w/o using a -<option>?
    
Just read them from @ARGV after calling GetOptions.

-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


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

Date: Thu, 20 Nov 2003 13:39:14 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: How to pause display of long STDOUT
Message-Id: <etou14yvkp9.fsf@fc.hp.com>

Glenn Jackman <xx087@freenet.carleton.ca> writes:
> Default@IO_Error_1011101.xyz <Default@IO_Error_1011101.xyz> wrote:
>>  is there a 'more' or 'less' like command i can implement?
>
> Collect your help into a scalar $help, then:
>     system "echo '$help'|less";

Use $ENV{PAGER}, by preference, falling back to less and then more if
$ENV{PAGER} is not set.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Thu, 20 Nov 2003 21:17:23 GMT
From: Default@IO_Error_1011101.xyz
Subject: Re: How to pause display of long STDOUT
Message-Id: <Dbavb.5019$vz.4660@nwrdny01.gnilink.net>

hmm im getting strange results.. likely due to the fact that the
print statement is part of a while loop.

wondering if perhaps a for statement could be the solution.
something like this: for ($i = 1; $i <= 40; $i++)
only thing with that is after the for is exhausted i need it to start the
for operation over again untill the while is completly finished.

footnote:  im on a w2k $erver.


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

Date: 20 Nov 2003 14:35:18 -0800
From: Sam Huffman <shuffman@ichips.intel.com>
Subject: Re: How to pause display of long STDOUT
Message-Id: <po8smkism6x.fsf@pdxlx1644.pdx.intel.com>

Glenn Jackman <xx087@freenet.carleton.ca> writes:

> Default@IO_Error_1011101.xyz <Default@IO_Error_1011101.xyz> wrote:
> >  is there a 'more' or 'less' like command i can implement?
> 
> Collect your help into a scalar $help, then:
>     system "echo '$help'|less";

Or, to avoid the problem of shell-mangling of the help message:

open(HELP, "| /usr/bin/less");

<print your help output to HELP>

close(HELP);


Sam


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

Date: Thu, 20 Nov 2003 19:35:10 +0000 (UTC)
From: bill <bill_knight2@yahoo.com>
Subject: How to save state while debugging?
Message-Id: <bpj51e$o5q$1@reader2.panix.com>




Sometimes, the bug one is trying to figure out doesn't come up
until a long time after the start of the program's execution.  This
can make the debugging extremely time-consuming.  In such, it would
be nice to be able to save the program's state shortly before the
bug appears, so that subsequent debugging cycles can re-start from
the saved state, without having to go back all the way to the
beginning.  Is there a way to do this in perldb? If not, are there
any Perl debuggers that have this feature?

Thanks!

bill



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

Date: Thu, 20 Nov 2003 20:52:10 +0000 (UTC)
From: Stan Brown <stanb@panix.com>
Subject: Re: Image::Magick memory leak question
Message-Id: <bpj9hq$pv9$1@reader2.panix.com>

In <3fbc4f37.145998938@news2.news.adelphia.net> posting.account@lynxview.com (William Herrera) writes:

>On Wed, 19 Nov 2003 19:57:31 +0000 (UTC), Stan Brown <stanb@panix.com> wrote:
>>
>>BTW, adding  @$image = ();, right before the undef $image; call seems to
>>have drasticly lowered the ammount of memory that it's leaking.
>>
>>Does that make any sens at all? I would hhave thoughtthat the undef would
>>have deleted all parts of the $image object. Am I wrong?
>>

>With some module objects, who knows? You are undefining a reference to the
>object, which cetainly frees the object (the array) if there are no other
>references to it. However, it may be that the object's code keeps some hidden
>reference to instances of itself (circular?) which then preserves all the
>elements in the array when you undefine it. When you instead set the array
>contents to none, you dereference and destroy all the actual elements in the
>array. So the amount of leak is limited to just the empty array object's memory
>usage alone, probably a much smaller leak.. I hope this makes sense. In any
>case, I suggest considering saving required states, exiting, and  re-running
>the script itself periodically, to keep any remaining  leakiness under control.
Yes, it make perfect sense. I was naievly believing that since I had left
the subroutine, and the $image object was "local" to it, that all traces of
it would eb retruned to the free pool, as would be done, for non malloced
memory in C. 

This seems to be a pretty basic weakness of perl. I wonder if perl6
addresses this?

-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin


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

Date: 20 Nov 2003 21:44:15 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Image::Magick memory leak question
Message-Id: <slrnbrqddg.vu6.mgjv@verbruggen.comdyn.com.au>

On Wed, 19 Nov 2003 19:57:31 +0000 (UTC),
	Stan Brown <stanb@panix.com> wrote:
> In <bpgf47$fei$2@wisteria.csv.warwick.ac.uk> Ben Morrow <usenet@morrow.me.uk> writes:

>>> my $image = Image::Magick->new(magick=>'GIF',font=>'clean');
>>>     $image->Read($l_tmpfile);
>>>     undef $image;
>>>     
>>> In a loop leaks memory. 

[snip of other material, which is not relevant to this point]

> BTW, adding  @$image = ();, right before the undef $image; call seems to
> have drasticly lowered the ammount of memory that it's leaking.

It shouldn't make a difference.

An ImageMagick object is a blessed reference to an array of
ImageMagick objects. If you undef the object, then all other elements
in the data structure should automatically be freed up. getting rid of
them explicitly by doing @$im = (); _should_ not make a difference.

If it does, then there is a bug in ImageMagick, and the authors should
be told.

When you report the bug, make sure you try the latest version, and
include information about the versions of Perl, IM and your
platform/OS. It would also be a good idea to mention how you measure
that there is a memory leak, and how large it is.

Martien
-- 
                        | 
Martien Verbruggen      | If at first you don't succeed, destroy all
Trading Post Australia  | evidence that you tried.
                        | 


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

Date: 20 Nov 2003 12:39:26 -0800
From: chris_doe@hotmail.com (Chris Doe)
Subject: MIN MAX for GREP?
Message-Id: <c61ae869.0311201239.e81c406@posting.google.com>

I have a large .CSV file with 10 fields on each line.  The first field
is a EPOCH date which is the only field I am interested in.

My dilemma: Based on a START and END date provided from the user, I
need to be able to PIPE all lines within that CSV file to a temporary
file which start with an EPOCH date ( >= START date and <=END date )

I have been  trying something along the lines of

grep "^\{$min, $max\}" file.csv > temp.csv  but no luck... Any ideas

Regards
Chris


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

Date: Thu, 20 Nov 2003 16:31:20 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: MIN MAX for GREP?
Message-Id: <slrnbrqg5o.56k.tadmc@magna.augustmail.com>

Chris Doe <chris_doe@hotmail.com> wrote:

> Subject: MIN MAX for GREP?


There is no need to shout at us.


> I have a large .CSV file with 10 fields on each line.  The first field
> is a EPOCH date which is the only field I am interested in.
>
> My dilemma: Based on a START and END date provided from the user, I
> need to be able to PIPE all lines within that CSV file to a temporary
> file 


That cannot be done.

A pipe connects two _programs_.

You simply want to _write_ it to a file, I expect.


> which start with an EPOCH date ( >= START date and <=END date )
> 
> I have been  trying something along the lines of
> 
> grep "^\{$min, $max\}" file.csv > temp.csv  but no luck... Any ideas


That is not Perl, that is grep(1).

Please ask Perl questions in the Perl newsgroup, ask questions about
OS-specific tools in the appropriate OS-specific newsgroup.


Here is how you can do it with Perl:

   # untested
   while ( <CSV> ) {
      # get fields into @record somehow (hint: use a module)
      print OUT if $record[0] >= $start and $record[0] <= $end;
   }


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


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

Date: Thu, 20 Nov 2003 20:44:02 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Need some help...
Message-Id: <Xns9439A00DAD731dkwwashere@216.168.3.30>

warpman <warpman999@netscape.net> wrote:

> sub get_variables {
> 
>    if ($FORM{'followup'}) {
>       $followup = "1";
>       @followup_num = split(/,/,$FORM{'followup'});
>       $num_followups = @followups = @followup_num;
>       $last_message = pop(@followups);
>       $origdate = "$FORM{'origdate'}";
>       $origname = "$FORM{'origname'}";
>       $origsubject = "$FORM{'origsubject'}";
>   }
[snip rest of code]

Looks familiar.  Checking... yup, it's code from WWWBoard from Matt's 
Script Archive.  Some better-quality replacements are available at 
http://nms-cgi.sourceforge.net/.  

If you're trying to learn Perl, please don't use Matt's scripts as a 
model.  If you search the Google usenet archive* you'll find plenty of 
past discussions on why this code is so reviled.

* http://groups.google.com/

-- 
David Wall


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

Date: Fri, 21 Nov 2003 08:11:46 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: Perl Sendmail Question
Message-Id: <bpj3n5$1ob6qm$1@ID-172104.news.uni-berlin.de>


"Sean O'Dwyer" <notspam@spamfree.dud> wrote in message
news:notspam-40E364.12335520112003@news-server.si.rr.com...
> In trying to get bounces from bad e-mail addresses sent back to their
> original sender instead of the server's admin -- this is a small
> distributed content situation, not spam! -- I'm looking at getting
> sendmail to send the original outgoing e-mail in the following way.
> Instead of...
>
> $mailprog = '/usr/lib/sendmail -t';
>
> ...in my script, I'd use...
>
> $mailprog = "/usr/lib/sendmail -f myname\@mydomain.com -t";
>
> Is this correct? And does the myname@mydomain.com address have to be a
> "trusted user" on the server or can it be any e-mail address?

No Perl content here.  Move on over to comp.mail.sendmail




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

Date: Thu, 20 Nov 2003 21:04:45 GMT
From: Sean O'Dwyer <notspam@spamfree.dud>
Subject: Re: Perl Sendmail Question
Message-Id: <notspam-7DF838.16044520112003@nycmny-nntp-rdr-03-ge0.rdc-nyc.rr.com>

In article <bpj07s$1p0fog$1@ID-184292.news.uni-berlin.de>,
 Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:

> Sean O'Dwyer wrote:
> > In trying to get bounces from bad e-mail addresses sent back to
> > their original sender instead of the server's admin -- this is a
> > small distributed content situation, not spam! -- I'm looking at
> > getting sendmail to send the original outgoing e-mail in the
> > following way.
> 
> <snip>
> 
> I don't know if you can control the return-path in the way you
> describe. One thing I do know, and that may justify this topic in
> clpmisc, is that by using the Perl module Mail::Sender you can easily
> set the return-path.

Thanks for your patience. I'll give that a try.

Sean


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

Date: Thu, 20 Nov 2003 17:02:26 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Protecting Source code of a perl script
Message-Id: <Xns9439B7A419081sdn.comcast@216.196.97.136>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

ctcgag@hotmail.com wrote in news:20031120130645.330$nD@newsreader.com:

> "Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote:
[...] 
>> What makes you think that hiding the source code will make your
>> application more secure?
> 
> Reality.

Hah.  It will make your application more secure if and only if there are 
no crackers who will try to reverse-engineer your algorithms, *and* there 
are no bugs or holes that can be found by white-hats.

>> Typically, a dedicated cracker will figure out
>> what the program is doing and find a way around it anyhow,
> 
> True, and a dedicated lock-picker can pick my lock.  But I'd prefer
> not to make the parts transparent, as that would lower the bar for how
> dedicated he would have to be.

That analogy is not quite on.  The parts need not be transparent, but the 
design of the lock should be published.  Would you trust a lock from a 
manufacturer who refused to tell you how it worked, but simply said, 
"Trust me.  It's super-duper secure.  Nobody can pick this lock!" ?

With the conventional tumbler-lock, you know how it works; you know its 
limitations.  It's not very secure, but it's a known quantity.

With a secret design, a dedicated picker *will* take it apart to find out 
how it works, and will find its weaknesses, if it has any.  The 
manufacturer may or may not already know of these weaknesses.

>> while your
>> program may not be reviewed for bugs or security holes by your peers.
> 
> It seems like a rather unlikely event that some kind-hearted person is
> going to stumble upon your code uninvited, find the holes, and point
> them out to you.  Premeditated code review is a great thing, but in
> the absense of it, it's hard to see how making the code available to
> untrustworthy parties is a good thing.

It may seem unlikely, but nearly every month some white-hat finds and 
reports (or patches) a security hole in sendmail, bind, or any of a 
hundred other unix networking and administration tools.  Often, these are 
professionals who have encountered a problem at work, but often they are 
also hobbyists who are endeavoring to understand the program.

There is no possibility of such peer-review with, say, Microsoft 
networking and administration tools.  Many bugs are reported, and many 
patches come out.  These must perforce come by way of internal code 
review at Microsoft, or painstaking reverse-engineering by people in the 
field.

I suspect there are far more latent security holes in MS-Windows OS 
software than in unix OS software, simply because in the unix world, it 
is all laid bare for everyone to see.

Take for example the PGP program with which I signed this message.  
Nobody will argue that it's not secure -- and its source code is open for 
anyone to see.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP71IKmPeouIeTNHoEQI2ZQCfYoasY6lyFt+yaDv0rI0XM39sY94AniS2
4sSC5Mpay1HC55U8KfUYsiwu
=f7SR
-----END PGP SIGNATURE-----


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

Date: Thu, 20 Nov 2003 13:15:57 -0800
From: Charlie <cckim@stanford.edu>
Subject: Retrieving dynamic web content
Message-Id: <Pine.GSO.4.44.0311201314520.20793-100000@elaine5.Stanford.EDU>


I would like to write a script that retrieves dynamically generated web
content.  Are there any modules out there that can do this?

Thanks in advance,
Charlie



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

Date: 20 Nov 2003 22:30:49 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Retrieving dynamic web content
Message-Id: <slrnbrqg4o.7ug.abigail@alexandra.abigail.nl>

Charlie (cckim@stanford.edu) wrote on MMMDCCXXXIII September MCMXCIII in
<URL:news:Pine.GSO.4.44.0311201314520.20793-100000@elaine5.Stanford.EDU>:
@@  
@@  I would like to write a script that retrieves dynamically generated web
@@  content.  Are there any modules out there that can do this?


For a client, it doesn't matter whether web content is generated
dynamically or not. In fact, he doesn't even know.

The most commonly used modules for this sort of thing are:
LWP, LWP::Simple and WWW::Mechanize. Calling 'wget' or 'lynx'
is a solution too.

If all you want to do is to fetch a document, I'd go for LWP::Simple.



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: Thu, 20 Nov 2003 16:21:35 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Retrieving dynamic web content
Message-Id: <slrnbrqfjf.56k.tadmc@magna.augustmail.com>

Charlie <cckim@stanford.edu> wrote:
> 
> I would like to write a script that retrieves dynamically generated web
> content.  


Whether it is static or dynamic does not matter, a resource
is a resource, it is up to the server to provide the requested
resource in any way that it wants to.

If what you want to do is fetch the resource, then your Perl
program is acting as the _client_ rather than as the server.


> Are there any modules out there that can do this?


Yes.


   perldoc -q HTML

          How do I fetch an HTML file?

          How do I automate an HTML form submission?


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


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

Date: Thu, 20 Nov 2003 14:46:21 -0800
From: Charlie <cckim@stanford.edu>
Subject: Re: Retrieving dynamic web content
Message-Id: <Pine.GSO.4.44.0311201444380.11729-100000@elaine5.Stanford.EDU>


Thanks for your replies.  I made a mistake in describing my original goal:
the pages are in fact dynamically generated, but what I was actually
referring to is data that is pulled up from a db using javascript.  The
HTML code doesn't reflect the data itself; is it possible to somehow
retrieve the data that is displayed in a browser rather than the source?

Charlie

On 20 Nov 2003, Abigail wrote:

> Charlie (cckim@stanford.edu) wrote on MMMDCCXXXIII September MCMXCIII in
> <URL:news:Pine.GSO.4.44.0311201314520.20793-100000@elaine5.Stanford.EDU>:
> @@
> @@  I would like to write a script that retrieves dynamically generated web
> @@  content.  Are there any modules out there that can do this?
>
>
> For a client, it doesn't matter whether web content is generated
> dynamically or not. In fact, he doesn't even know.
>
> The most commonly used modules for this sort of thing are:
> LWP, LWP::Simple and WWW::Mechanize. Calling 'wget' or 'lynx'
> is a solution too.
>
> If all you want to do is to fetch a document, I'd go for LWP::Simple.
>
>
>
> Abigail
> --
> srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
> //=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
>



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

Date: 20 Nov 2003 22:59:53 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Retrieving dynamic web content
Message-Id: <slrnbrqhr9.4o8.sholden@flexal.cs.usyd.edu.au>

On Thu, 20 Nov 2003 14:46:21 -0800, Charlie <cckim@stanford.edu> wrote:
> 
> Thanks for your replies.  I made a mistake in describing my original goal:
> the pages are in fact dynamically generated, but what I was actually
> referring to is data that is pulled up from a db using javascript.  The
> HTML code doesn't reflect the data itself; is it possible to somehow
> retrieve the data that is displayed in a browser rather than the source?

Run it through a Javascript interpreter.

-- 
Sam Holden


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

Date: 20 Nov 2003 12:48:06 -0800
From: ttyp32000@yahoo.com (jonathan)
Subject: status of redirecting STDOUT/STDERR to file
Message-Id: <f05e664d.0311201248.436ca871@posting.google.com>

hey all,

just curious, but if I do the following (after __cut__), does this
have any repercussions for the 'regular' STDERR, STDOUT handles?

jon

__cut__
sub redirect
{
    local(*STDERR);
    local(*STDOUT) = *STDERR;
    open(STDERR, "> /tmp/logit");

    print STDERR "HERE!!!\n";
    print STDERR "HEREA!!!\n";

    close(STDERR);
}

redirect();

print STDERR "HEREB!!!\n";
print STDOUT "HEREC!!!\n";


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

Date: 20 Nov 2003 19:36:20 GMT
From: ctcgag@hotmail.com
Subject: Re: where is DBI::DWIM?
Message-Id: <20031120143620.789$R7@newsreader.com>

Eric Wilhelm <ewilhelm@somethinglike.sbcglobalDOTnet> wrote:
>
> To allow the programs to run in any order, each one would have to UPDATE
> or INSERT which means that each one needs twice as much SQL code.

Presumably you already know the primary key which already exists or is to
be used in the insert if it doesn't exist.

If you are writing for MySQL only (I think Replace is MySQL specific), then
you could make a handle/sub which just does
"insert ignore into table_foo (primary_key) values (?)"

Call it before you do whatever update you need to do.
It will create the row if necessary, and silently do nothing if
it's already there.  You don't need to explicitly check the outcome.

You can put the definition into a central module if you want.

It's simple and fairly clean.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

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


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