[23382] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5601 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 2 00:05:57 2003

Date: Wed, 1 Oct 2003 21:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 1 Oct 2003     Volume: 10 Number: 5601

Today's topics:
    Re: Bad protocol 'tcp' error - ActiveState Perl (ko)
        GDBM_file install problems (perl 5.8.0, freebsd 4.8-sta <mhunter@uclink.berkeley.edu>
    Re: hashes <glex_nospam@qwest.net>
    Re: hashes (Jay Tilton)
        How to generate this list? (followup) <bryan@akanta.com>
    Re: How to generate this list? (followup) (Sam Holden)
    Re: How to generate this list? (followup) <invalid-email@rochester.rr.com>
    Re: How to generate this list? (followup) <invalid-email@rochester.rr.com>
    Re: How to generate this list? (followup) <pinyaj@rpi.edu>
    Re: Newbie Q - Nicer way to lc something? (Jay Tilton)
    Re: Newbie Q - Nicer way to lc something? (Malcolm Dew-Jones)
    Re: Oops, 5.8.1 broke my program <xaonon@hotpop.com>
    Re: Perl Book Recommendations <notspam@spamfree.dud>
    Re: Perl Book Recommendations <ict@eh.org>
    Re: Perl CGI executing command line functions (Tad McClellan)
    Re: Perl script crashing at lockfile ? <jehoshua@my-deja.com>
        Problem using LWP::UserAgent (Gaurav)
    Re: Problem using LWP::UserAgent (Tad McClellan)
    Re: regex behavior <michael.p.broida@boeing_oops.com>
    Re: regex behavior <pinyaj@rpi.edu>
    Re: regex behavior (Bill)
    Re: Saving html form into oracle database <mbudash@sonic.net>
    Re: script help to update member profiles <NOT@home.net>
        Software Marketing News <S._member@newsguy.com>
    Re: Software Marketing News (Tad McClellan)
    Re: TZ cache on some Linux kernels (David Efflandt)
    Re: TZ cache on some Linux kernels <nospam-abuse@ilyaz.org>
        Using PerScript to write macros for VC6? <me@privacy.net>
    Re: Working with a line of text ??? <noreply@gunnar.cc>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 1 Oct 2003 15:35:27 -0700
From: kuujinbo@hotmail.com (ko)
Subject: Re: Bad protocol 'tcp' error - ActiveState Perl
Message-Id: <92d64088.0310011435.13de3f48@posting.google.com>

"Mike Lottridge" <res6mtpc@verizon.net> wrote in message news:<qZCeb.540$3b7.189@nwrddc02.gnilink.net>...
> I'm getting an bad protocol error 'tcp' whenever I use any of the LWP
> modules (and PPM as well). I'm using a Windows 2000 system. There's not a
> problem with tcp on port 80, i can browse the net, plus run other command
> line cygwin utilities (wget, ...) without problems.

Have you tried the ActiveState mailing lists? There's one specifically for ppm:

http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/ppm

HTH - keith


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

Date: Wed, 1 Oct 2003 23:31:05 +0000 (UTC)
From: Mike Hunter <mhunter@uclink.berkeley.edu>
Subject: GDBM_file install problems (perl 5.8.0, freebsd 4.8-stable)
Message-Id: <slrnbnmoq5.1li.mhunter@celeste.net.berkeley.edu>

Greetings,

A script I have needs GDBM_File.  I tried getting it from cpan, but I was 
thwarted:

% perl -MCPAN -e 'install GDBM_File'
CPAN: Storable loaded ok
Going to read /usr/cpan/Metadata
  Database was generated on Wed, 01 Oct 2003 15:46:16 GMT
Running install for module GDBM_File
Running make for J/JH/JHI/perl-5.8.1.tar.gz

The most recent version "1.07" of the module "GDBM_File"
comes with the current version of perl (5.8.1).
I'll build that only if you ask for something like
    force install GDBM_File
or
    install J/JH/JHI/perl-5.8.1.tar.gz
Running make test
  Make had some problems, maybe interrupted? Won't test
  Has no own directory
Running make install
  Has no own directory
  Make had some problems, maybe interrupted? Won't install

I have cpan set to follow dependencies...when I do force install it proceeds
to try to upgrade perl to 5.8.1.  I don't want to do that (I'm afraid because
perl is part of the base system in freebsd 4.8...or should I not be afraid
afterall?)

The script I'm trying to get to compile is quite old, so I can hardly believe
that perl needs to be upgraded to fix this problem.  I tried sucking the 
GDBM_file.pm into the @INC off of cpan.org, but it didn't like that, I think
because GDBM_file needs to me made with *make* to bind it to the actual GDBM
library from gnu.

Do I need to tell cpan to grab an older version?  If so, how do I do that?

Any help appreciated,

Mike


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

Date: Wed, 01 Oct 2003 17:23:19 -0500
From: "J. Gleixner" <glex_nospam@qwest.net>
Subject: Re: hashes
Message-Id: <XqIeb.92$vN4.91555@news.uswest.net>

John Carroll wrote:
> "Jürgen Exner" <jurgenex@hotmail.com> wrote in message news:<QSpeb.23654$Wd7.21629@nwrddc03.gnilink.net>...
> 
>>John Carroll wrote:
>>
>>>How do you get the actual string value of a hash value, when the key
>>>is known?
>>
>>Do you want to the value or do you want the value as a string? Those may be
>>two different requests.
> 
> 
> I don't care what type it is, but I am comparing it to a string, so I
> assume it has to be a string for the comparison to work properly.
> 
> 
>>>%in is set using the &ReadParse from cgi-lib.pl, with "Password" being
>>>one of the keys, with a value of "test".
>>>
>>>$file_password = "test";
>>>$password = $in{"Password"};
>>
>>You are doing it right there.
>>$password now contains the value of the hash %in for the key 'Password'.
>>
>>If you want to make sure that the value is a string (why do you care?) then
>>just concatenate the value with an empty string.
> 
> 
> I don't care, but my comparison to a string doesn't work.  I
> concatenated it with an empty string and I still get the same answer
> as originally, which was that if I compare two strings that print
> identically, the comparison fails (returns not equal).  Also, if I set
> both variables to strings explicitly, or even only explicitly reset
> the variable that originally holds the value of the hash %in for the
> key 'Password', I get the comparison to work properly, but if I leave
> it as shown above, the comparison fails.

Short example..

my $file_password = "test";
my $password = $in{"Password"};
my %in;
$in{"Password"} = "test";
$in{"Password2"} = $file_password;
print "1. they're equal\n" if $file_password eq $in{"Password"};
print "2. they're equal\n" if $file_password eq $password;
print "3. they're still equal\n" if $file_password eq $in{"Password2"};

1. they're equal
2. they're equal
3. they're still equal


Maybe the values you're comparing aren't what you think they are?  Maybe 
one contains a " "?  Try:

print "-$password-\n";
print "-$in{Password}-\n";

So you can see if there are any blanks in the beginning/end.



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

Date: Wed, 01 Oct 2003 22:49:23 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: hashes
Message-Id: <3f7b5690.165868900@news.erols.com>

john.carroll@usap.gov (John Carroll) wrote:

: but my comparison to a string doesn't work.  I
: concatenated it with an empty string and I still get the same answer
: as originally, which was that if I compare two strings that print
: identically, 

Could there be leading or trailing whitespace in either string?  That
could cause them to _appear_ to be identical without being identical.
Surrounding the printed string with visible characters can reveal the
presence of whitespace.

    $file_password = "test";
    $password = $in{"Password"};
    print "-->$password<--";
    print "-->$file_password<--";
    if ($password ne $file_password) {
        $incorrect_pw = "true";
    }



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

Date: Wed, 01 Oct 2003 23:38:34 GMT
From: Bryan <bryan@akanta.com>
Subject: How to generate this list? (followup)
Message-Id: <_zJeb.472$I41.70980800@newssvr21.news.prodigy.com>

Thanks all for the suggestions!  I realized something though (sorry for 
that) that may simplify things..

In fact, I don't care about the order of A B and C.  But I do care about 
the -sum-!

For example, if you have the following formula; AxByCz, where x is the 
number of A's y is the number of B's, z is the number of C's...

If k = x + y + z, I need to find all possible x, y and z values whose 
sum is equal to k.

So, if k = 3, I could have:
x	y	z
1	0	2
1	1	1
1	2	0
2	0	1
etc, etc, etc.

Sadly, I did not drink enough coffee today to see the quick way to do 
this either... any help appreciated!

B



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

Date: 2 Oct 2003 00:36:37 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: How to generate this list? (followup)
Message-Id: <slrnbnmsok.fn8.sholden@flexal.cs.usyd.edu.au>

On Wed, 01 Oct 2003 23:38:34 GMT, Bryan <bryan@akanta.com> wrote:
> Thanks all for the suggestions!  I realized something though (sorry for 
> that) that may simplify things..
> 
> In fact, I don't care about the order of A B and C.  But I do care about 
> the -sum-!
> 
> For example, if you have the following formula; AxByCz, where x is the 
> number of A's y is the number of B's, z is the number of C's...
> 
> If k = x + y + z, I need to find all possible x, y and z values whose 
> sum is equal to k.
> 
> So, if k = 3, I could have:
> x	y	z
> 1	0	2
> 1	1	1
> 1	2	0
> 2	0	1
> etc, etc, etc.
> 
> Sadly, I did not drink enough coffee today to see the quick way to do 
> this either... any help appreciated!

A recursive solution seems simple enough (though if there is only
ever going to be X, Y, and Z then an iterative one is just as easy).

Something like (not tested, other than for syntax and with the one
case shown):

sub combs {
  my $elements = shift;
  my $count = shift;
  my @result;
  return [$count] if $elements == 1;
  die "Elements must be positive" if $elements < 1;
  for my $to_use (0 ... $count) {
    push @result, map {[$to_use, @$_]} combs($elements-1, $count-$to_use);
  }
  return @result;
}

my @results = combs(3,3); #X,Y,Z are 3 elements, and count=3.
print "x\ty\tz\n";
print join("\t", @$_),"\n" for (@results);

-- 
Sam Holden



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

Date: Thu, 02 Oct 2003 01:47:15 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: How to generate this list? (followup)
Message-Id: <3F7B8370.105@rochester.rr.com>

Bryan wrote:

> Thanks all for the suggestions!  I realized something though (sorry for 
> that) that may simplify things..
> 
> In fact, I don't care about the order of A B and C.  But I do care about 
> the -sum-!
> 
> For example, if you have the following formula; AxByCz, where x is the 
> number of A's y is the number of B's, z is the number of C's...
> 
> If k = x + y + z, I need to find all possible x, y and z values whose 
> sum is equal to k.
> 
> So, if k = 3, I could have:
> x    y    z
> 1    0    2
> 1    1    1
> 1    2    0
> 2    0    1
> etc, etc, etc.
> 
> Sadly, I did not drink enough coffee today to see the quick way to do 
> this either... any help appreciated!
> 
> B
> 

Well, there are an infinite number of solutions to this unless you put 
some constraints on the values of x y and z, like insisting they are all 
non-negative (from your example, perhaps you mean x to be positive and y 
and z to be non-negative?).  One way would be to just brute-force it:

$k=10;
for $x(0..$k){
   for $y(0..$k){
     for $z(0..$k){
       print "x=$x, y=$y, z=$z, sum=$k\n" if $x+$y+$z==$k;
     }
   }
}

There might be a slighly more efficient or elegant way, but why waste 
time on it when the computer can do it practically instantly anyway?

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Thu, 02 Oct 2003 02:30:23 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: How to generate this list? (followup)
Message-Id: <3F7B8D8B.3060906@rochester.rr.com>

Bryan wrote:

> Thanks all for the suggestions!  I realized something though (sorry for 
> that) that may simplify things..
> 
> In fact, I don't care about the order of A B and C.  But I do care about 
> the -sum-!
> 
> For example, if you have the following formula; AxByCz, where x is the 
> number of A's y is the number of B's, z is the number of C's...
> 
> If k = x + y + z, I need to find all possible x, y and z values whose 
> sum is equal to k.
> 
> So, if k = 3, I could have:
> x    y    z
> 1    0    2
> 1    1    1
> 1    2    0
> 2    0    1
> etc, etc, etc.
> 
> Sadly, I did not drink enough coffee today to see the quick way to do 
> this either... any help appreciated!
> 
> B
> 


Note that there are an infinite number of solutions unless you constrain 
  x y and z in some fashion, like perhaps non-negative integers.  It 
appears from your example you perhaps intend x to be positive and y and 
z to be non-negative?  Here's a brute force assuming all three to be 
non-negative integers:


$k=10;
for $x(0..$k){
   for $y(0..$k){
     for $z(0..$k){
       print "x=$x, y=$y, z=$z, sum=$k\n" if $x+$y+$z==$k;
     }
   }
}

Given the speed of computers, it is not worth it to come up with 
something more elegant or faster.

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Wed, 1 Oct 2003 22:44:01 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: How to generate this list? (followup)
Message-Id: <Pine.SGI.3.96.1031001224220.1137352A-100000@vcmr-64.server.rpi.edu>

On Thu, 2 Oct 2003, Bob Walton wrote:

>$k=10;
>for $x(0..$k){
>   for $y(0..$k){
>     for $z(0..$k){
>       print "x=$x, y=$y, z=$z, sum=$k\n" if $x+$y+$z==$k;
>     }
>   }
>}
>
>Given the speed of computers, it is not worth it to come up with 
>something more elegant or faster.

But you could at least give the program half a brain:

  for $x (0 .. $k) {
    for $y (0 .. ($k - $x)) {
      print "x=$x, y=$y, z=", $k-$x-$y, ", sum=$k\n";
    }
  }        

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Wed, 01 Oct 2003 23:18:00 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Newbie Q - Nicer way to lc something?
Message-Id: <3f7b5a89.166885420@news.erols.com>

Chris Smith <chris@FLARBLEinfinitemonkeys.org.uk> wrote:

: Tore Aursand wrote:
: 
: > On Wed, 01 Oct 2003 13:41:02 +0100, Chris Smith wrote:
: >> Is there a nicer way of doing the following?
: >> 
: >>     $a = lc($a);
: >> 
: >> Doesn't look "perlish" if you know what I mean.
: > 
: > No.  I don't know what you mean.  What do you mean?  Do you find solutions
: > like this one more "perlish"?
: > 
: >   $a =~ tr/A-Z/a-z/;
: > 
: > If so, you shouldn't be using Perl. :-)
: 
: I'm talking more like:
: 
: lc $a;
: 
: And return the value in $a rather than $_

Do you mean you would like the lc() function to alter its argument
in-place?  You can have that.

    use subs 'lc';
    sub lc {
        my $arg = \( @_ ? $_[0] : $_ );
        $$arg = CORE::lc $$arg;
    }

    $_ = 'HELLO, WORLD!';
    print;
    lc;
    print;

Perl programmers tend to like functions that have minimal side-effects,
but the proposed function is nothing but a side-effect.  To "look
perlish," a significant perlish quality is lost.

: $a=lc($a);
:
: is very BASIC-like if you know what I mean.

What language is it like if I do not know what you mean?  :)

Readers of technical newsgroups appreciate precision.  You might want to
avoid habitual use of imprecise language like "if you know what I mean."



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

Date: 1 Oct 2003 16:23:51 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Newbie Q - Nicer way to lc something?
Message-Id: <3f7b6207@news.victoria.tc.ca>

Chris Smith (chris@FLARBLEinfinitemonkeys.org.uk) wrote:
: Hi,

: Is there a nicer way of doing the following?

:     $a = lc($a);

perhaps

	$a = lc $a;

using $_ you can reduce that somewhat

	$_ = lc;


but I'm afraid you *can't* say what I often want to say, which is

	while (<>)
	{  chomp;
	   lc;


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

Date: 2 Oct 2003 01:37:38 GMT
From: Xaonon <xaonon@hotpop.com>
Subject: Re: Oops, 5.8.1 broke my program
Message-Id: <slrnbnnapg.9ia.xaonon@xaonon.local>

Ned i bach <slrnbnmbr0.tun.abigail@alexandra.abigail.nl>, Abigail
<abigail@abigail.nl> teithant i thiw hin:

> Xaonon (xaonon@hotpop.com) wrote on MMMDCLXXXIII September MCMXCIII in
> <URL:news:slrnbnmd8u.56b.xaonon@xaonon.local>:
> 
> >  Ned i bach <slrnbnl60m.dr.abigail@alexandra.abigail.nl>, Abigail
> > <abigail@abigail.nl> teithant i thiw hin: 
> >  
> > > What does your program do with 5.8.0?
> >  
> > I don't know.  I had 5.6.1 and went directly to 5.8.1 from there.
> 
> Well, you were claiming that 5.8.1 broke your program. And before anyone
> is looking at the new things in 5.8.1, or are put of upgrading from
> 5.8.0 to 5.8.1, it would be useful to find out how your program behaves
> in 5.8.0. Especially considering that 5.8.0 defaults to using 'perlio'
> instead of 'stdio' as default.

Well, I'm not building 5.8.0 just to see what happens.  I can just run the
program explicitly with 5.6.1 if necessary, I'd just like to know why it
works differently now.

Also, the new documentation misspelled "nitroglycerin".

> And you also might want to try setting the environment variable
> PERLIO to 'perlio' and 'stdio' repectively.

I did that, and it didn't seem to have any immediate (visible) effect.

-- 
Xaonon, EAC Chief of Mad Scientists and informal BAAWA, aa #1821, Kibo #: 1
http://xaonon.dyndns.org/  Guaranteed content-free since 1999.  No refunds.
"I am asking you a SERIOUS QUESTION about the LOCATION and CURRENT STATUS of
your pants." -- Penny-Arcade.com


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

Date: Wed, 01 Oct 2003 23:34:52 GMT
From: Sean O'Dwyer <notspam@spamfree.dud>
Subject: Re: Perl Book Recommendations
Message-Id: <notspam-1AEA75.19355201102003@news-server.nyc.rr.com>

In article <3F7B2065.E07A1C6C@acm.org>,
 "John W. Krahn" <krahnj@acm.org> wrote:

> Advanced Perl Programming
> Perl Cookbook
> Perl for System Administration
> Mastering Regular Expressions
> Mastering Algorithms with Perl
> Network Programming with Perl
> Learning Perl Objects, References & Modules
> Object Oriented Perl

That's great. Thanks a mil.

Sean


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

Date: 2 Oct 2003 12:38:21 +1000
From: Iain Truskett <ict@eh.org>
Subject: Re: Perl Book Recommendations
Message-Id: <slrnbnn4cu.p1m.ict@dellah.org>

* Sean O'Dwyer <notspam@spamfree.dud>:

[...]
> Now I'm looking for something more comprehensive, [...] I learn best
> from short examples.

> Any recommendations?

Definitely the Perl Cookbook (nice shiny 2nd edition came out last
month). http://books.perl.org/book/203

In general: http://books.perl.org/topx



cheers,
-- 
Iain.                                          <http://eh.org/~koschei/>


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

Date: Wed, 1 Oct 2003 18:08:22 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl CGI executing command line functions
Message-Id: <slrnbnmnj6.snr.tadmc@magna.augustmail.com>

Nick <kvetchv@yahoo.com> wrote:

> I am just starting out with Perl and am trying to figure out how to
> setup a CGI script 


You should learn Perl itself first, before moving on to a
complicated application area such as CGI programs.


> to perform some command line functions.  I work
> with some people that need to run some command line functions but we
> do not want to give them command line access.  


Why is it that you do not want to give them command line access?


> I thought that if I
> write a Perl CGI script that executes some of the commands for them,
> it would solve our problems.


It seems much more likely to me to _cause_ more problems
that it solves.

I think we have an XY problem.

If you can answer the question above, we will be in a much better
postion to give good advice...


> How would I get Perl to run that #ls command 



What is the "#ls" command?


> with the user's option


You better turn taint checking on (-T) and check the user's input
very very carefully. You have lots of chances of opening up a
security hole with your idea. Be careful.


> values (#ls -al) and display the end result of that command?
> Would it be something similar to 
> `ls` $commd;


Assuming that $commd has somehow gotten the corresponding value
from the form, hopefully by calling CGI::param():

   my $result = `ls $commd`;


> How would I show the end result?

   print $result;

If it is in a CGI program where the output is supposed to go
to STDOUT anyway, then you do not need to capture the output
at all:

   print "Content-type: text/plain\n\n";
   system "ls $commd";


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


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

Date: Thu, 02 Oct 2003 11:44:08 +1000
From: Peter Richards <jehoshua@my-deja.com>
Subject: Re: Perl script crashing at lockfile ?
Message-Id: <jc0nnv82megmmmpkh21s74opcihci2v846@4ax.com>

Hi Anno,

On 1 Oct 2003 08:50:48 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:

>Peter Richards  <jehoshua@my-deja.com> wrote in comp.lang.perl.misc:
>> Hi,
>> 
>> I've recently moved a website and one Perl script will not work. The
>> previous site had a Unix box with Perl 5.006 , and the new site has a
>> Linux box with Perl 5.006001
>
>Well, Linux is one kind of Unix.  What you're saying is like, "I used
>to have a car, but now I have a Chevy".
>
>> After inserting "print" statements all over the place, finally this
>> piece of code is where the script is stopping:
>> 
>> ----------------------------------------------------------------------
>> system ("lockfile -2 -r 5 $base_dir/.lock" ) == 0 or diehtml("Lock
>> error: ", $? >> 8, "\n" ); # TODO stop stderr of system
>> --------------------------------------------------------------------
>> 
>> There is no msg appearing (what happened to the "diehtml" ?), the
>> script just stops. I have checked all the path and file permissions,
>> and they are exactly the same s the previous website. The variable
>> $base_dir has a value of '/home/username/public_html/.orders' 
>
>The "lockfile" command you are using is not a standard Unix command.
>Some systems have it, some don't.  With those that have it, the
>behavior could differ.  See the documentation for "lockfile" on
>both systems.

Yes, I asked on PerlMonks, and "robartes" replied:

"File locking is a tricky field that is very susceptible to
portability issues. Your problem is most probably situated in
different behaviour of lockfile between your original and current
systems"

and "tachyon" supplied a pure Perl replacement:

----------------------------------------------------------------------
my $got_lock;
use Fcntl;   # to get constants for O_CREAT | O_EXCL | O_RDWR
for ( 0 .. 5 ) {
    if ( sysopen(my $fh, "$base_dir/.lock", O_CREAT | O_EXCL | O_RDWR,
+ 0600) ) {
        $got_lock = 1;
        close $fh;
      last;
    }
    sleep 2;
}
diehtml("Lock error $!\n") unless $got_lock;
----------------------------------------------------------------------

Thanks,

Peter


Peter Richards
peter_j_richards@nospamplease.com
 (but use hotmail to email)


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

Date: 1 Oct 2003 18:12:16 -0700
From: bansal2425@hotmail.com (Gaurav)
Subject: Problem using LWP::UserAgent
Message-Id: <42983cb.0310011712.58740354@posting.google.com>

Hello,

I have a perl script which fetches data from yahoo finance. I last
used it in Jan 2003 i guess. Now if i try to use it i get an error
message.

This is the error message i get if i try to run my script using a
makefile
**********************************
make
perl data.pl 4 1 2002 6 30 2002
Can't locate LWP/UserAgent.pm in @INC (@INC contains:
/usr/perl5/5.00503/sun4-so
laris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/sun4-solaris
/usr/perl5/site
_perl/5.005 .) at Web.pm line 12.
BEGIN failed--compilation aborted at data.pl line 10.
make: *** [run] Error 2  
*******************************                

My perl script is data.pl
***********************************
#! /usr/local/bin/perl
----
-----
# To run the script type      perl data.pl 3 01 00 3 01 02
#format is perl data.pl start_month start_day start_year end_month
end_day end_$

#importing package Web
use Web;  //THIS IS LINE 10
#creating an instance of Web module
$web = Web->new;                 
--------
-------
**********************************

My perl module is Web.pm
*******************************
--------
--------
package Web;

#LWP::UserAgent class implements WWW user agent in perl refer this
website
#for more details , http://www.perldoc.com/perl5.6/lib/LWP/UserAgent.html
require LWP::UserAgent;  //THIS IS LINE 12

----
----
********************************        

Can someone tell me why my script is not running anymore ?

Thank you in advance. 

Gaurav


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

Date: Wed, 1 Oct 2003 21:27:19 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem using LWP::UserAgent
Message-Id: <slrnbnn387.to7.tadmc@magna.augustmail.com>

Gaurav <bansal2425@hotmail.com> wrote:


> Can't locate LWP/UserAgent.pm in @INC (@INC contains:


> #creating an instance of Web module
> $web = Web->new;                 


You don't create instances of modules, you create instances of _objects_.


> Can someone tell me why my script is not running anymore ?


Because Perl cannot find the LWP::UserAgent module.

Is it under any of the @INC directories that were listed?

Is it installed? If so, where? (ask your sysadmin)


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


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

Date: Wed, 1 Oct 2003 22:20:28 GMT
From: "Michael P. Broida" <michael.p.broida@boeing_oops.com>
Subject: Re: regex behavior
Message-Id: <3F7B532C.7878A3BB@boeing_oops.com>

Abigail wrote:
> 
> Matija Papec (mpapec@yahoo.com) wrote on MMMDCLXXXIII September MCMXCIII
> in <URL:news:4bdmnvcb9or2nbm2ne1euvhqp1e64s84g7@4ax.com>:
> --
> --  I went through perldoc but didn't found similar regex,
> --  print join ',', 'a bb ccc dddd' =~ /(\w)+/g;
> --
> --  the question is, what it exactly matches and why?
> 
> /(\w)+/ matches a set of consecutive word characters, capturing
> the *last* one. //g in list context means, do this as often as
> possible (without overlap), returning a list of each of the submatches.
> 
> So, 'a bb ccc dddd' =~ /(\w)+/g; returns for each substring of
> consecutive word characters the last one, resulting in 'a', 'b', 'c' and 'd'.

	That tests out as you said, so it's MY thinking that's off.  :)
	Hopefully, you can clue me in.  :)

	I expected it to result in "a,bb,ccc,dddd". Now I realize that
	it's the positioning of the + that causes it to get a single
	character from each group.  If the + is inside the (), it
	prints what I expected.

	But...  What is causing the original /(\w)+/ to get the LAST
	character from each group instead of the FIRST character from
	each group?

	I changed the input string to 'a bc def ghij' and it printed
	"a,c,f,j" as you noted.  But I don't see why it's the LAST
	character per group.  At this point, I now expect "a,b,d,g".

	Ignoring the () to populate the result list, the \w+ matches a
	string of one or more characters.  On the second match, it will
	grab "bc".

	Now why isn't the () part of that getting the FIRST of those
	characters?

	And what regex would you use to get the FIRST char of each group
	since this one doesn't?

		Mike


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

Date: Wed, 1 Oct 2003 19:23:59 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: regex behavior
Message-Id: <Pine.SGI.3.96.1031001192048.1125566A-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On Wed, 1 Oct 2003, Michael P. Broida wrote:

>	But...  What is causing the original /(\w)+/ to get the LAST
>	character from each group instead of the FIRST character from
>	each group?

The location of the + modifier.

>	Ignoring the () to populate the result list, the \w+ matches a
>	string of one or more characters.  On the second match, it will
>	grab "bc".

DON'T ignore the (), they're important here.  (\w+) is seen by the regex
as something like this:

  OPEN $1
  PLUS
    ALNUM
  CLOSE $1

whereas (\w)+ is seen as

  PLUS
    OPEN $1
    ALNUM
    CLOSE $1

>	Now why isn't the () part of that getting the FIRST of those
>	characters?

It does... but then the + modifier causes $1 to be repopulated with the
NEXT character \w matches, and so on.

>	And what regex would you use to get the FIRST char of each group
>	since this one doesn't?

I'd use /(\w)\w*/g, or perhaps /\b\w/g (if there are no parens in a /.../g
regex, you get whatever the regex matches returned).

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: 1 Oct 2003 20:23:27 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: regex behavior
Message-Id: <239ce42f.0310011923.59202335@posting.google.com>

> 	Ignoring the () to populate the result list, the \w+ matches a
> 	string of one or more characters.  On the second match, it will
> 	grab "bc".
> 
> 	Now why isn't the () part of that getting the FIRST of those
> 	characters?
> 
> 	And what regex would you use to get the FIRST char of each group
> 	since this one doesn't?
> 
> 		Mike


from `perldoc perlre` :

By default, a quantified subpattern is "greedy", that is, it will
match as many times as possible (given a particular starting location)
while still allowing the rest of the pattern to match. If you want it
to match the minimum number of times possible, follow the quantifier
with a "?".


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

Date: Wed, 01 Oct 2003 22:09:42 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Saving html form into oracle database
Message-Id: <mbudash-8AE909.15094101102003@typhoon.sonic.net>

In article <eton0ckbpbo.fsf@wormtongue.emschwar>,
 Eric Schwartz <emschwar@pobox.com> wrote:

> Michael Budash <mbudash@sonic.net> writes:
> > In article <3db2b381.0310010704.665891ad@posting.google.com>,
> >  nick77074@hotmail.com (Nick) wrote:
> >> I'm new to perl programming. Just wanted to know if there is a way I
> >> could save the whole HTML FORM into database rather then saving it by
> >> individual fields.
> >> Someone mentioned it to me that it can be done. I just don't know how
> >> to do it.
> 
> One approach is to save off the form parameters into a hash, and stuff
> the hash into a BLOB with Data::Dumper or Storable or some such module.
> 
> > the problem i see is that a cgi script is not delivered a form, it's 
> > delivered the names/values _in_ a form when that form was submitted. one 
> > possibility: have your form handler read in the static html file 
> > containing the form, fill it in, and save it to your db in a blob field 
> > (ugh!)
> 
> Ick.  Just save the form parameters and values, and use CGI.pm to
> re-create the form along with the values you loaded from the
> database.  Why make things so needlessly complicated?
> 
> -=Eric

here's why:

the o.p. asked to save the _form_. forms are more than simply names and 
values. they involve input methods of indicating those values (text 
boxes, radio button, checkboxes, select's, etc.). your method does not 
allow the o.p. to recreate the form with those methods intact. 
admittedly, the o.p. did not specifically say that's what he wanted, but 
i assumed it.

-- 
Michael Budash


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

Date: Wed, 01 Oct 2003 23:20:29 GMT
From: "BG" <NOT@home.net>
Subject: Re: script help to update member profiles
Message-Id: <1jJeb.3965$Gb.3700@news2.central.cox.net>


> > First, I apologize if this is not the right group to be asking this
> > question, but I am EXTREMELY new to perl and MySql both and am at a
> > loss for where to go.
>
> perldoc perl at the command line is a good start :-)
> If you're using ActiveState Perl on a Windows system, they have all
> the documentation in HTML format -and- a little shortcut on ye old
> "Start" menu.

My website is run on a remote server running under Linux. I am in the
process of putting together a syatem here to load Linux/Perl/MySql etc so
that I can not only learn perl, but also test my scripts before I  FTP them
to the live site. While I do currently have ActiveState Perl loaded on my
local WinXP system and I am currently reading through documentation (you
have so kindly pointed out)  in an attempt to learn, it is obviously not
going to help come time to write and test some code. And I certainly do not
want to test some of my first code on a live database containing the records
for 3000+ members.


>
> <snip>
> > Could anyone please offer some assistance in how I can create a form
> > that will take the current username/password along with the
> > requested change password and/or email and update the appropriate
> > record/table in the MySql database.
>
> Read the documentation.  Start writing some code.  If you get stuck,
> post a specific question here.

>
> One thing I can tell you - you'll also need to read over the DBI
> documentation, as well as the DBD::mysql documentation.  These are
> Perl modules and can be found at http://search.cpan.org.  You should
> also look over the CGI module documentation - although our local troll
> will try to convince you otherwise.  However, if you are concerned
> more about security versus speed, use the CGI module.
>
> <snip>
>
> > Problem is while this is probably a simple task to those familiar
> > with perl, I am clueless to how to achieve this. While I am trying
> > to learn as time permits, this is still way beyond me.
>
> Start with the documentation.  Always a safe bet.  Tell your boss (if
> this is for work) to relax -or- to cough up some cash to send you to a
> class :-)  If it's just for you, relax, take your time, read the
> documentation, "Google" this newsgroup, and try writing some code.
>

Generally I did the HTML and my partner took care of the Perl. Due to his
accident (resulting in an unexpected absence from code writing) this left me
with attempting to complete some of the tasks on my own. I have googled the
web, the group and am reading documentation but again, this is one item that
is time critical and because it requires writing data to the database, one I
would prefer not to use as a learning tool.

Thanks anyway for your response.





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

Date: 1 Oct 2003 15:14:35 -0700
From: S. Housley <S._member@newsguy.com>
Subject: Software Marketing News
Message-Id: <blfjkb01hf9@drn.newsguy.com>

Hi All,
I'm not quite sure if this is an appropriate place to post this, but I assume
its a forum of developers and the newsletter might be of interest.

I just posted October's Software Marketing news. Some of the topics touched on
this month include RSS, an overview of the ISDEF conference, and some news from
Microsoft. The newsletter can be viewed online at -
http://www.softwaremarketingresource.com/author-resource-newsletter32.html

If you are interested in the information please subscribe by sending an email to
webmaster@softwaremarketingresource.com with subscribe as the subject line.

Thank you
Sharon Housley
Software Marketing Resource 
http://www.softwaremarketingresource.com



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

Date: Wed, 1 Oct 2003 19:38:59 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Software Marketing News
Message-Id: <slrnbnmst3.tj9.tadmc@magna.augustmail.com>

S. Housley <S._member@newsguy.com> wrote:

> I'm not quite sure if this is an appropriate place to post this,


Does your newsletter have an article regarding Perl in it?

If so, then you should have said so.

If not, then your post is off-topic.


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


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

Date: Thu, 2 Oct 2003 03:17:21 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: TZ cache on some Linux kernels
Message-Id: <slrnbnn661.o4c.efflandt@typhoon.xnet.com>

On 1 Oct 2003 10:27:46 -0700, Jon <jon18_uk2002@yahoo.co.uk> wrote:
> While doing some time/date functions I had to change the timezone used
> (by changing the ENV{TZ}) twice in one script.  However, it seems the
> kernel cached the last zone and failed to open or change to the new
> one.  I confirmed this using strace, as you could see it only opened
> the one file.  The code I used is as follows.
> 
> $ENV{TZ} = ':/usr/share/zoneinfo/Europe/London';
> 
> $time = time();
> 
> ($sec,$min,$hour,$day,$mon,$this_year,$wday,$yday,$isdst) =
> localtime($time);
> print "$hour:$min\n";
> 
> $ENV{TZ} = ':/usr/share/zoneinfo/Europe/Paris';
> 
> ($sec,$min,$hour,$day,$mon,$this_year,$wday,$yday,$isdst) =
> localtime($time);
> print "$hour:$min\n";
> 
> Is the code I used.  The times should be out by an hour (Paris is one
> hour ahead of London), however for me they both show the same time,
> which is within the London (GMT+1) timezone.  The results were
> different on another server.
> 
> Linux 2.4.20 complied from source, Perl 5.8.0 (RedHat RPM) - failed.
> Linux 2.4.7 RedHat supplied, Perl 5.6.0 (RedHat RPM) - worked.

man tzslect (to see what to use for TZ).  Try:

$ENV{TZ} = 'Europe/London';
$time = time();
print scalar localtime($time)."\n";
$ENV{TZ} = 'Europe/Paris';
print scalar localtime($time)."\n";

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Thu, 2 Oct 2003 03:57:19 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: TZ cache on some Linux kernels
Message-Id: <blg7mv$7uj$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Jon
<jon18_uk2002@yahoo.co.uk>], who wrote in article <83bd902f.0310010927.456738aa@posting.google.com>:
> While doing some time/date functions I had to change the timezone used
> (by changing the ENV{TZ}) twice in one script.  However, it seems the
> kernel cached the last zone and failed to open or change to the new
> one.  I confirmed this using strace, as you could see it only opened
> the one file.  The code I used is as follows.
> 
> $ENV{TZ} = ':/usr/share/zoneinfo/Europe/London';

Check whether tzset() is required on your system...  It is a Perl bug
that it does not call tzset() when/if required.

In principle, tzset() is available in POSIX.

Hope this helps,
Ilya



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

Date: Thu, 2 Oct 2003 03:12:52 +0200
From: Norbert Schmidt <me@privacy.net>
Subject: Using PerScript to write macros for VC6?
Message-Id: <e9j2pqvdctdz$.dlg@N.Schmidt-news-xxxx.gmx.de>

Hello,

I would like to customize VC6 with some macros. Unfortunately my BASIC days 
have been over for many years. I have installes ActiveState Perl/PerlScript 
and calling PerlScripts with wscript or cscript works fine. 

Is there any way to write macros for VC6 using PerScript instead of VBS?
If so: How do I call them and how do I access e. g. the currently selected 
text in the active source code window?


Regards, Norbert
-- 
Please post your replies to the news group only. Reply-To is only 
temporarily valid and aggressively filtered.
For questions concerning my address please read <http://www.privacy.net>.


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

Date: Thu, 02 Oct 2003 00:10:35 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Working with a line of text ???
Message-Id: <blfjdf$bjs22$1@ID-184292.news.uni-berlin.de>

Rodney wrote:
> I have a situation where I want to send portions of a line of text
> to a subroutine for processing.  The text line could look like
> this:
> 
> blah blah <!--Start-- blah blah blah--End--> blah blah blah
> <!--Start-- blah blah--End--> blah blah blah.
> 
> I only want to send the text that is NOT within the <!--Start-- and
> --End--> tags.  So example above would have 3 pieces of text the
> need to run through the subroutine.
> 
> After they go through the subroutine, the line of text needs to be
> regrouped in the same order it was before it was processed and the
> "Tags" have to be in tact.

This is one idea, assuming the text line is in $_:

     my $start = '<!-- Quoted Text Start QTS-->';
     my $end = '<!-- Quoted Text End QTE-->';

     sub myroutine {
         my $portion = shift;
         # do something with $portion;
         return $portion;
     }

     s/(^|$end)(.*?)($start|$)/$1 . myroutine($2) . $3/egs;

I don't know about the speed, though.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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


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