[28618] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9982 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 19 18:05:51 2006

Date: Sun, 19 Nov 2006 15:05:07 -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           Sun, 19 Nov 2006     Volume: 10 Number: 9982

Today's topics:
        Add numbers in a string abbyhoffman@gmail.com
    Re: Add numbers in a string <yankeeinexile@gmail.com>
    Re: Add numbers in a string abbyhoffman@gmail.com
    Re: Add numbers in a string <frnjze@freenet.de>
    Re: Add numbers in a string <wahab@chemie.uni-halle.de>
    Re: Add numbers in a string abbyhoffman@gmail.com
    Re: Add numbers in a string <john@castleamber.com>
    Re: Add numbers in a string <DJStunks@gmail.com>
    Re: Add numbers in a string <wahab@chemie.uni-halle.de>
        Array not getting updated <balaji.draj@gmail.com>
    Re: Array not getting updated <DJStunks@gmail.com>
        context sensitive grammar? <easy.lin@gmail.com>
    Re: Do I *have* to use 'OOP' to use modules? <asandstrom@accesswave.ca>
    Re: Do I *have* to use 'OOP' to use modules? <asandstrom@accesswave.ca>
    Re: Do I *have* to use 'OOP' to use modules? <abigail@abigail.be>
    Re: Do I *have* to use 'OOP' to use modules? anno4000@radom.zrz.tu-berlin.de
    Re: Do I *have* to use 'OOP' to use modules? <nospam-abuse@ilyaz.org>
        Fetching input character without newline? <anon40629@hotmail.com>
    Re: Fetching input character without newline? anno4000@radom.zrz.tu-berlin.de
    Re: How to compress a big file into many zip files with anno4000@radom.zrz.tu-berlin.de
    Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good? (Richard Williams)
    Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good? <john@castleamber.com>
        Storing objects in Session prabhu.subramaniam@gmail.com
    Re: Storing objects in Session <spamtrap@dot-app.org>
    Re: Storing objects in Session <spamtrap@dot-app.org>
    Re: Storing objects in Session <prabhu.sengal@gmail.com>
    Re: Storing objects in Session <spamtrap@dot-app.org>
        Template <lskatz@gmail.com>
    Re: Template <spamtrap@dot-app.org>
    Re: Template <news@lawshouse.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 19 Nov 2006 11:29:00 -0800
From: abbyhoffman@gmail.com
Subject: Add numbers in a string
Message-Id: <1163964540.131345.221880@j44g2000cwa.googlegroups.com>

Hello,

I'm a complete Perl newb, but I was wondering if there was a way to add
the numbers in a string together.  Ie

test 34bob 232 frank 1 

would add 34 + 232 + 1 to get 267

Thanks,

Abe



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

Date: 19 Nov 2006 13:45:49 -0600
From: Lawrence Statton XE2/N1GAK <yankeeinexile@gmail.com>
Subject: Re: Add numbers in a string
Message-Id: <87irhbi5jm.fsf@gmail.com>

abbyhoffman@gmail.com writes:
> test 34bob 232 frank 1 

#!/usr/bin/perl
use strict;
use warnings;

my @words = qw / test 34bob 232 frank 1 /;
my $sum;
$sum += $_ for grep { /^\d+$/ } map { tr /0-9//cd; $_ } @words;
print "$sum\n";

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
	Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.


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

Date: 19 Nov 2006 12:02:57 -0800
From: abbyhoffman@gmail.com
Subject: Re: Add numbers in a string
Message-Id: <1163966577.913039.289550@h48g2000cwc.googlegroups.com>

Lawrence,

That worked great for the example, but is there a way I can send a
generic string? ie

$text = "test 34bob 232 frank 1";
my @words = qw / $text /;
 ...

Thanks,

Abe
Lawrence Statton XE2/N1GAK wrote:
> abbyhoffman@gmail.com writes:
> > test 34bob 232 frank 1
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> my @words = qw / test 34bob 232 frank 1 /;
> my $sum;
> $sum += $_ for grep { /^\d+$/ } map { tr /0-9//cd; $_ } @words;
> print "$sum\n";
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> 	Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
> Computer  software  consists of  only  two  components: ones  and
> zeros, in roughly equal proportions.   All that is required is to
> sort them into the correct order.



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

Date: Sun, 19 Nov 2006 21:01:21 +0100
From: Joerg <frnjze@freenet.de>
Subject: Re: Add numbers in a string
Message-Id: <ejqd6f$t0s$00$1@news.t-online.com>

Am 19.11.2006 20:29 schrieb abbyhoffman@gmail.com:
> I'm a complete Perl newb, but I was wondering if there was a way to add
> the numbers in a string together.  Ie
> 
> test 34bob 232 frank 1 
> 
> would add 34 + 232 + 1 to get 267

Hi,
a short way:

my $sum=0;
my $string="test 34bob 232 frank 1";
$sum+=$1 while( $string=~/(\d+)/g );


-- 
Joerg


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

Date: Sun, 19 Nov 2006 21:07:57 +0100
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Add numbers in a string
Message-Id: <ejqdd9$osk$1@mlucom4.urz.uni-halle.de>

Thus spoke abbyhoffman@gmail.com (on 2006-11-19 20:29):

> Hello,
> I'm a complete Perl newb, but I was wondering if there was a way to add
> the numbers in a string together.  Ie
> test 34bob 232 frank 1 

There are 1001 variants in perl, eg.:

   use strict;
   use warnings;
   use re 'eval';

   ...
   my $string = 'test 34bob 232 frank 1';
   my ($sum, $addme);

   $sum = 0;                      # variant 1
   $addme = '(?{$sum+=$&})';
   () = $string =~ /\d+$addme/g;
   print $sum, "\n";
   ...

   $sum = 0;                      # variant 2
   $sum += $_ for $string =~ /(\d+)/g;
   print $sum, "\n";
   ...

Regards

Mirco


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

Date: 19 Nov 2006 12:15:34 -0800
From: abbyhoffman@gmail.com
Subject: Re: Add numbers in a string
Message-Id: <1163967334.390608.39800@j44g2000cwa.googlegroups.com>

Hey Guys,

Thanks for all of your help!  I think I'm going to like Perl!

Abe
abbyhoffman@gmail.com wrote:
> Hello,
>
> I'm a complete Perl newb, but I was wondering if there was a way to add
> the numbers in a string together.  Ie
>
> test 34bob 232 frank 1
> 
> would add 34 + 232 + 1 to get 267
> 
> Thanks,
> 
> Abe



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

Date: 19 Nov 2006 20:58:08 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Add numbers in a string
Message-Id: <Xns9880984524473castleamber@130.133.1.4>

Lawrence Statton XE2/N1GAK <yankeeinexile@gmail.com> wrote:

> abbyhoffman@gmail.com writes:
>> test 34bob 232 frank 1 
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> my @words = qw / test 34bob 232 frank 1 /;
> my $sum;
> $sum += $_ for grep { /^\d+$/ } map { tr /0-9//cd; $_ } @words;
> print "$sum\n";

Way to weird :-)


use strict;
use warnings;

my $string = 'test 34bob 232 frank 1';
my $sum = 0;
# add numbers to the sum while we find numbers in the string
$sum += $1 while $string =~ /(\d+)/g;
print "$sum\n";

C:\Documents and Settings\John\My Documents>sum.pl
267

A sig starts with -- followed by exactly one space on a line on itself.

> Computer  software  consists of  only  two  components: ones  and
> zeros, in roughly equal proportions.   All that is required is to
> sort them into the correct order.



-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


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

Date: 19 Nov 2006 13:11:23 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Add numbers in a string
Message-Id: <1163970683.601399.47540@e3g2000cwe.googlegroups.com>

John Bokma wrote:
> use strict;
> use warnings;
>
> my $string = 'test 34bob 232 frank 1';
> my $sum = 0;
> # add numbers to the sum while we find numbers in the string
> $sum += $1 while $string =~ /(\d+)/g;
> print "$sum\n";
>
> C:\Documents and Settings\John\My Documents>sum.pl
> 267

no need to capture in the regex.  and how about adding them all up at
once?

  #!/usr/bin/perl

  use strict;
  use warnings;

  use List::Util qw{ sum };

  my $string = 'test 34bob 232 frank 1';
  print sum $string =~ m{ \d+ }xg;
  
  __END__

-jp



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

Date: Sun, 19 Nov 2006 22:34:34 +0100
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Add numbers in a string
Message-Id: <ejqifm$qd0$1@mlucom4.urz.uni-halle.de>

Thus spoke DJ Stunks (on 2006-11-19 22:11):
> John Bokma wrote:
>> ...
>> $sum += $1 while $string =~ /(\d+)/g;
> no need to capture in the regex.  and how about adding them all up at
> once?
> 
>  use List::Util qw{ sum };
>  ...
>  print sum $string =~ m{ \d+ }xg;

maybe there's no need for direct string =~ match,
modules or anything else,

  ...
  $sum = 0;
  $sum += /\d/&&$_ for split /\D+/, $string;
  ...


Regards

Mirco


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

Date: 19 Nov 2006 09:46:22 -0800
From: "IJALAB" <balaji.draj@gmail.com>
Subject: Array not getting updated
Message-Id: <1163958382.637591.228700@m73g2000cwd.googlegroups.com>

Hi All,

I am new to Perl.


My problem is:


I have a log file that has lot of data and every line is identified by
its first character and then processed accordingly.


so, for example, I have a line starting with 2, from which i am
printing some data and then proceeding.....in a certain i have some
data in one line (say 3), which also lists the 3
elements...(12,14,15)...
ANother line(s) continuosly prints several elements one by one of which

my need is to check if these elements (12,14,15) are available in any
of these lines and print relevant info.


I created an


$data (stored the number of elements) and accordingly created an
array(@data) and stored those elements in that array.


when the next line is encountered i tried to pick every element from
@data and compare with those line data, i am not getting the array
elements?


is there a simpler way to handle this situation?? where am i going
wrong? 


need ur help. 


thanks 
bala



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

Date: 19 Nov 2006 13:19:38 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Array not getting updated
Message-Id: <1163971178.571505.22170@f16g2000cwb.googlegroups.com>

IJALAB wrote:
> <snip>

Steps toward a fulfilling Usenet experience:

1) Don't multipost;
2) Provide code, not descriptions;
3) Provide sample input, not descriptions;
4) Provide desired output, not descriptions;
5) Don't post anything that doesn't run silently with warnings and
strictures enabled.

-jp



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

Date: 19 Nov 2006 12:54:44 -0800
From: "easy" <easy.lin@gmail.com>
Subject: context sensitive grammar?
Message-Id: <1163969684.827486.258680@k70g2000cwa.googlegroups.com>

It is said that Perl has context-sensitive grammar.

but I can not find any syntax rule in src/perly.y like so..

Nonterminal terminal : some rule
                              | another rule;

or is the "context-sensitive" logic is written indirectly in code?



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

Date: Sun, 19 Nov 2006 21:54:48 GMT
From: "Arved Sandstrom" <asandstrom@accesswave.ca>
Subject: Re: Do I *have* to use 'OOP' to use modules?
Message-Id: <Io48h.6203$rB6.3812@clgrps13>

"Abigail" <abigail@abigail.be> wrote in message 
news:slrneluumh.bt.abigail@alexandra.abigail.be...
> Arved Sandstrom (asandstrom@accesswave.ca) wrote on MMMMDCCCXXVII
> September MCMXCIII in <URL:news:w6D7h.11870$gy2.6058@edtnps90>:
> ()
> ()  I'd be interested to hear why you think OO Perl is not worth bothering 
> with.
>
>
> OOP doesn't have object attributes natively. The programmer has to
> build this him/herself.
>
> And that's the root of evilness in Perls OO.

I cringe a bit when the term "native" comes up, because it means so many 
different things in programming. But I will assume that by "native" object 
attributes you mean that there is a way, in the language, of syntactically 
distinguishing the fields of the object that are logical attributes from 
those that are not (and are just implementation details).

In other words, how much built-in support is there in the language for 
encapsulation. Which in turn leads to so much else in OOP.

Am I reading you correctly?

AHS 




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

Date: Sun, 19 Nov 2006 22:23:53 GMT
From: "Arved Sandstrom" <asandstrom@accesswave.ca>
Subject: Re: Do I *have* to use 'OOP' to use modules?
Message-Id: <ZP48h.6228$rB6.1433@clgrps13>

"Merrilee Larson" <merrile@telus.net> wrote in message 
news:qzQ7h.17438$C94.12365@edtnps82...
[ SNIP ]

> Thanks for the encouraging post. Perl4 was "my first love", and it seems 
> to me
> that Perl's "Golden Years" occured during Perl4's reign. Just my 
> impression,
> but I could be wrong.

Well, I think you're wrong. :-) My start with Perl occurred when Perl 4 was 
all there was. Perl 5 was on the horizon, but I predated it by a few years. 
Perl's "Golden Years" most definitely were not those of Perl 4.

> But if I'm correct, it sure says a lot about procedural
> Perl. Thanks again. I'm off to look at Tcl/Tk and Scheme/Lisp. Later...

It seems to me that you don't know what it is that you need from a language. 
I say that without trying to be an ass. Considering that your stated goal is 
to develop websites, and you've rejected PHP, C, C++, Java...I'm starting to 
wonder what's left. You'll certainly reject C#, I see no particular reason 
why you'd like Python or Ruby or Tcl a great deal more, I can't imagine 
you'll be enraptured with XSLT...

I don't even understand some of the objections - PHP too verbose? How 
exactly? Considering what PHP does for you it's unclear to me how it could 
be less verbose. Do you want method names to be like those of J?

I am fairly language neutral when it comes to website development, mainly 
because I dislike doing websites. But I've done a fair bit of it - most 
programmers have - and used ASP + a M$ language, PHP, JSP, ColdFusion, 
XML+XSLT, Perl CGI, and who knows what else. And IMHO any of the above (with 
the exception of XSLT) are high productivity approaches, not difficult to 
understand, all fairly maintainable, and well supported. So again I wonder 
what it is that you're looking for in a language to support your web 
development efforts.

AHS 




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

Date: 19 Nov 2006 22:25:19 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Do I *have* to use 'OOP' to use modules?
Message-Id: <slrnem1mdb.bt.abigail@alexandra.abigail.be>

Arved Sandstrom (asandstrom@accesswave.ca) wrote on MMMMDCCCXXVIII
September MCMXCIII in <URL:news:Io48h.6203$rB6.3812@clgrps13>:
**  "Abigail" <abigail@abigail.be> wrote in message 
**  news:slrneluumh.bt.abigail@alexandra.abigail.be...
** > Arved Sandstrom (asandstrom@accesswave.ca) wrote on MMMMDCCCXXVII
** > September MCMXCIII in <URL:news:w6D7h.11870$gy2.6058@edtnps90>:
** > ()
** > ()  I'd be interested to hear why you think OO Perl is not worth bothering 
** > with.
** >
** >
** > OOP doesn't have object attributes natively. The programmer has to
** > build this him/herself.
** >
** > And that's the root of evilness in Perls OO.
**  
**  I cringe a bit when the term "native" comes up, because it means so many 
**  different things in programming. But I will assume that by "native" object 
**  attributes you mean that there is a way, in the language, of syntactically 
**  distinguishing the fields of the object that are logical attributes from 
**  those that are not (and are just implementation details).
**  
**  In other words, how much built-in support is there in the language for 
**  encapsulation. Which in turn leads to so much else in OOP.
**  
**  Am I reading you correctly?


What I mean is that the language Perl does not have object attributes.
It's not there in the language, in the same way that C doesn't have
regular expressions.

That doesn't mean you can't do regular expressions in C. They are just
natively not in the language. If you want them, you as the programmer
have to do all the work yourself. 

I'm just amazed that people call the absence of elementary construct
(given that you've decided to support OO in the language) a *feature*.
I've never heard anyone advocate Java or C for their lack of native
support for regular expressions or hashes, but people keep considering
the lack of support for object attributes as the best thing since sliced
bread.


Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s};;;
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};                # Perl 5.6.0 broke this...
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


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

Date: 19 Nov 2006 22:27:00 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Do I *have* to use 'OOP' to use modules?
Message-Id: <4sc41kFv2m3pU1@mid.dfncis.de>

Arved Sandstrom <asandstrom@accesswave.ca> wrote in comp.lang.perl.misc:
> "Abigail" <abigail@abigail.be> wrote in message 
> news:slrneluumh.bt.abigail@alexandra.abigail.be...
> > Arved Sandstrom (asandstrom@accesswave.ca) wrote on MMMMDCCCXXVII
> > September MCMXCIII in <URL:news:w6D7h.11870$gy2.6058@edtnps90>:
> > ()
> > ()  I'd be interested to hear why you think OO Perl is not worth bothering 
> > with.
> >
> >
> > OOP doesn't have object attributes natively. The programmer has to
> > build this him/herself.
> >
> > And that's the root of evilness in Perls OO.
> 
> I cringe a bit when the term "native" comes up, because it means so many 
> different things in programming. But I will assume that by "native" object 
> attributes you mean that there is a way, in the language, of syntactically 
> distinguishing the fields of the object that are logical attributes from 
> those that are not (and are just implementation details).
> 
> In other words, how much built-in support is there in the language for 
> encapsulation.

The answer is "none".  

The problem with that isn't so much that you can't natively (sorry)
restrict access to fields.  Simply telling users what they are and
aren't supposed to do with a field works fine.  The real problem is
that users have to know and take into account implementation details
of a class they're merely using.

The typical case is a hash based class you want to inherit from.
If you want your subclass to have additional fields, you must know
which hash keys the base class uses to store its fields (clearly an
implementation detail).  If you don't there's no way to avoid conflicts.

Inside-out classes deal satisfactorily with that problem. They are
much easier to use (especially to subclass) than traditional classes,
but the measures to ensure encapsulation make them harder to write.
It can be argued that this should be part of the language.

Perl 5.10 will offer a special kind of hash (through the module
Hash::Util::FieldHash) that takes some of the burden off the programmer.

Anno


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

Date: Sun, 19 Nov 2006 22:58:28 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Do I *have* to use 'OOP' to use modules?
Message-Id: <ejqnik$1528$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to

<anno4000@radom.zrz.tu-berlin.de>], who wrote in article <4sc41kFv2m3pU1@mid.dfncis.de>:

> The real problem is that users have to know and take into account
> implementation details of a class they're merely using.

> The typical case is a hash based class you want to inherit from.

I'm a little bit confused here: do you discuss "users" of the class,
or "developers" of derived classes?

AFAIU, having attributes in the language would bring absolutely no
benefits to the "merely users".  The "developers", of course, are in a
very different situation...

Yours,
Ilya


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

Date: Sun, 19 Nov 2006 14:18:02 -0800
From: "Mark" <anon40629@hotmail.com>
Subject: Fetching input character without newline?
Message-Id: <1163974679.673525@bubbleator.drizzle.com>

Good afternoon.

I am attempting to solicit user input using the following:

while ()
{
print "Enter your response here (1-5): ";
$ret = <STDIN>;
if ($ret =~ /^([1-5])$/)
 {print "\nUser chose $1\n";
  last;
 }
}

This code reprints the prompt string on the next line each time
the user responds incorrectly. I would _like_ to handle an incorrect
response by erasing the user's entry and leaving the prompt in place
on the current line.

Any suggestions on how to do this?

Thanks
-Mark




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

Date: 19 Nov 2006 22:32:40 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Fetching input character without newline?
Message-Id: <4sc4c8Fv2m3pU2@mid.dfncis.de>

Mark <anon40629@hotmail.com> wrote in comp.lang.perl.misc:
> Good afternoon.
> 
> I am attempting to solicit user input using the following:
> 
> while ()
> {
> print "Enter your response here (1-5): ";
> $ret = <STDIN>;
> if ($ret =~ /^([1-5])$/)
>  {print "\nUser chose $1\n";
>   last;
>  }
> }
> 
> This code reprints the prompt string on the next line each time
> the user responds incorrectly. I would _like_ to handle an incorrect
> response by erasing the user's entry and leaving the prompt in place
> on the current line.
> 
> Any suggestions on how to do this?

perldoc -q 'single character'

Anno


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

Date: 19 Nov 2006 21:48:32 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: How to compress a big file into many zip files with Archive::Zip?
Message-Id: <4sc1pgFus8j4U1@mid.dfncis.de>

Martijn Lievaart  <m@remove.this.part.rtij.nl> wrote in comp.lang.perl.misc:
> On Sun, 19 Nov 2006 10:05:41 +0000, anno4000 wrote:
> 
> >> And I have read the Archive::Zip document, and didn't
> >> find any stuff about that.
> > 
> > That's because Archive::Zip is about compressing files, not
> > splitting them.
> 
> However, zip has options for multivolume archives, Archive::Zip just
> doesn't support it. So the expectation is not unreasonable.

Multivolume archives are meant to handle the case when a an archive
doesn't fit on a single volume (of tape, usually).  It may be possible
to press the mechanism into service for splitting a single file into
smaller chunks, but that isn't what it's there for.

Unix (and presumably Cygwin) has the split command to do this.
Splitting is still not the right way to transfer a file that is
too big for mail.

Anno


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

Date: 19 Nov 2006 17:08:18 GMT
From: rdwillia@anon.example.net (Richard Williams)
Subject: Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good?
Message-Id: <ejq322$koq$1@newsserver.cilea.it>

Oh well, whatever the reason it's a real shame (O'Reilly has also 
confirmed by email that the series has been axed). Plain HTML is pretty 
much an ideal format for reference material like this (how many of us are 
guilty of cutting and pasting recipes straight from the Cookbook?), and 
having the whole thing in a nicely indexed format was a great complement 
to perldoc. Safari doesn't really do it for me - I don't like the idea of 
depending on rented information, often work offline, and can't really 
justify the price of a subscription for the number of books I'm likely to 
use. But then I'm one of those people who still buys CDs in preference to 
DRM'd downloads (Safari is rather like the current Napster basic monthly 
subscription, where access to the whole library ceases when you stop 
paying). Hopefully they'll keep printing the paperbacks for a while yet...

I can understand piracy being a real issue for the Bookshelves - it's got 
to the stage where the first page of Google hits for many common Perl 
seaches features at least one pirate site. Dig a little deeper, and you'll 
find pages from (e.g.) major universities (and at least one competing 
publisher!) including pirate sites in their external Perl and Linux links 
(quite possibly without even realising that the sites aren't legitimate). 
Pirated material from other sources (e.g. OCR'd books or ebooks with 
cracked DRM) isn't as blatantly accessible, and is hard to run into by 
accident. But it's still a shame O'Reilly bowed to this pressure.

I don't really see legitimate online resources as direct competitors to 
the Bookshelves - Perl has had good free literature for a long time (both 
in the core docs and in articles on sites like Stonehenge), much of it 
written by the same people who write the books. But the books still have 
enough added value to make them well worth buying, though this would 
change for me if they ever became 'subscription only' (e.g., Safari with 
no paper alternative). 

Richard.


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

Date: 19 Nov 2006 18:02:46 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good?
Message-Id: <Xns98807A896BEBEcastleamber@130.133.1.4>

rdwillia@anon.example.net (Richard Williams) wrote:

> Oh well, whatever the reason it's a real shame (O'Reilly has also 
> confirmed by email that the series has been axed). Plain HTML is
> pretty much an ideal format for reference material like this (how many
> of us are guilty of cutting and pasting recipes straight from the
> Cookbook?), and having the whole thing in a nicely indexed format was
> a great complement to perldoc.

CHM does the same. What's in my not so humble opinion really crazy is 
that *buying* an e-book in CHM format is next to impossible (if not, 
please give me a site). Moreover, e-books have been protected, so I am 
afraid it's impossible to convert, say, LIT to CHM (which I understand 
should be no big deal), or LIT to PDF.

It's like going to a book store, picking a book, and having to decide if 
you're going to read it in a chair, in bed, or behind a desk, and are 
not allowed to read it somewhere else.

(But I might be wrong here)

By dowloading via Usenet / BitTorrent, there is no such problem. Not 
that I recommend the latter, but book publishers shouldn't join the 
music and video industry and accuse everybody of piracy (which is 
probably not far from the true), and then waste money on measurements 
like everybody is a dangerous criminal.

Also, I forgot the actual price, but getting a book by mail here (I live 
in Mexico) is about 1/4th of the price of a book. Books are not cheap, 
and sending them neither (and it takes 2-5 weeks). I am all for e-books, 
withouth DRM (silly, people can remove that in no time, waste of money).

I can read a normal book in the library, take it from the library, copy 
50 pages (or under Dutch law, all), and use the copy. I can give it to a 
friend for a month, and he can make copies. Why are e-books less 
compared to normal books (printing might be disabled, copy paste ditto).

Because of the pirates? Come on, books are already on Usenet and various 
torrents *before* they have been printed.


> Safari doesn't really do it for me - I
> don't like the idea of depending on rented information, often work
> offline, and can't really justify the price of a subscription for the
> number of books I'm likely to use.

I can afford it, but I agree with you. My PDA has Wi-Fi, but that drains 
batteries, so I prefer to upload documentation to it, and be able to 
read where ever I want.

> But then I'm one of those people
> who still buys CDs in preference to DRM'd downloads (Safari is rather

Ditto, and DVDs for that matter. I still buy, despite nowadays it's 
easier to just download (DRM free that is)

> like the current Napster basic monthly subscription, where access to
> the whole library ceases when you stop paying). Hopefully they'll keep
> printing the paperbacks for a while yet...

If they don't I am sure number #1 cause will be the pirates, those 
pirates. 

> I can understand piracy being a real issue for the Bookshelves - it's

I doubt it is. Printed books are also pirated. Like I wrote earlier, I 
use more and more often either perldoc or Google to solve issues. I am 
sure I am not alone with this. Also, more and more publishers seem to be 
publishing computer related books. I recall there was a time there where 
2 books for years. Now there are several published a year as far as I 
can see, (even bad ones, or not worth the money ones). Reprints and new 
books (I once had 3 Perl Cookbooks, which is about 120 USD (!)).

> got to the stage where the first page of Google hits for many common
> Perl seaches features at least one pirate site.

I used to report this but got the idea that they are not really 
interested. Tracking piracy probably costs more then the actuall loss. 
Via bit torrent people download hundreds of books. Wouldn't amaze me if 
publishers count each of those books as a major loss. Instead of doing 
that, they *should* look into real causes that maybe can be handled. 


> Dig a little deeper,
> and you'll find pages from (e.g.) major universities (and at least one
> competing publisher!) including pirate sites in their external Perl
> and Linux links (quite possibly without even realising that the sites
> aren't legitimate). Pirated material from other sources (e.g. OCR'd
> books or ebooks with cracked DRM) isn't as blatantly accessible, and

Really, like many others, you're looking in the wrong places. The real 
thing happens on Usenet and Bittorrent.

<http://btjunkie.org/torrent?do=stat&id=
3782dc2f43b0c6e2bd6a183298d79e85a588e92b0158>

353 O'Reilly books. You really think that everybody downloading those 
should have bought all those books? I own a lot of O'Reilly books, but I 
don't even come close to that figure.

You really think that each download should be booked as: minus 353 x (40 
USD - costs USD) USD? Wouldn't amaze me if publishers will use it like 
that, record companies seem no to have problems with it, so why not?

I called it earlier propaganda: "The systematic propagation of a 
doctrine or cause or of information reflecting the views and interests 
of those advocating such a doctrine or cause." (source:
http://www.answers.com/topic/propaganda )

> is hard to run into by accident. But it's still a shame O'Reilly bowed
> to this pressure. 

Again, I doubt this is the major cause.

> I don't really see legitimate online resources as direct competitors

CPAN, perldoc, and the hundreds and hundreds of well written articles, a 
lot standing far, far above some books I bought. Also documentation that 
comes with programs seem to have improved. In the '90s this was often 
"use the source, Luke".

I mean, when I used a web server for the first time, documentation was 
hard to find. Now one can find countless good articles on how to 
configure such a program, hints, tips, etc. 

> to the Bookshelves - Perl has had good free literature for a long time
> (both in the core docs and in articles on sites like Stonehenge), much
> of it written by the same people who write the books.

I am quite sure it's much more, and growing. The Internet is an 
extremely easy publishing platform. I get about 14,000 visitors. I doubt 
that if I published a book I would even get that many buyers in total, 
and I am sure I will make more money in the end with it. :-D.

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


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

Date: 19 Nov 2006 08:42:35 -0800
From: prabhu.subramaniam@gmail.com
Subject: Storing objects in Session
Message-Id: <1163954555.825629.266960@h54g2000cwb.googlegroups.com>

Hi,
  I am trying to store an object (WWW::Mechanize) in
session(CGI::Session) and trying to retrieve it, but I am encountering
the following problem:

Prog:

my $mech = WWW::Mechanize->new ( );

if(request is from pagel)
{
   $session = new CGI::Session("driver:File", undef,
{Directory=>'/tmp'});
   $mech->get("www.someurl.com"); #works fine
   $session->param('Mech', $mech);
}
elseif(request is from page2)
{
   $sid = param('CGISESSID') || undef;
    $session = new CGI::Session("driver:File", $sid,
{Directory=>'/tmp'}); #able to get other data passed from page1
   $mech = $session->param('Mech');
   $mech->get("www.someotherurl.com");
}

When I am in first page things are fine. In second page, I get
"Can't locate object method "get" via package "WWW::Mechanize" at
C:\Inetpub\Scripts\somescript.pl line 100."

I am a beginner to Perl and I am not able to find any resources to
solve my problem. It is important that I reuse the same object($mech
from page1's call). Your help on this is greatly appreciated. Thanks.

Regards,
Prabhu



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

Date: Sun, 19 Nov 2006 12:07:10 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Storing objects in Session
Message-Id: <m21wnzv001.fsf@Sherm-Pendleys-Computer.local>

prabhu.subramaniam@gmail.com writes:

> my $mech = WWW::Mechanize->new ( );
>
> if(request is from pagel)

That's not Perl - please post real code.

Have you read the posting guidelines that appear here frequently?

> {
>    $session = new CGI::Session("driver:File", undef,
> {Directory=>'/tmp'});
>    $mech->get("www.someurl.com"); #works fine
>    $session->param('Mech', $mech);
> }
> elseif(request is from page2)

That's not Perl either.

> {
>    $sid = param('CGISESSID') || undef;
>     $session = new CGI::Session("driver:File", $sid,
> {Directory=>'/tmp'}); #able to get other data passed from page1
>    $mech = $session->param('Mech');

Here, you're assigning a new value to $mech, so it no longer refers to the
WWW::Mechanize instance you created earlier.

>    $mech->get("www.someotherurl.com");
> }
>
> When I am in first page things are fine. In second page, I get
> "Can't locate object method "get" via package "WWW::Mechanize" at
> C:\Inetpub\Scripts\somescript.pl line 100."

Of course you do - you're trying to call an object method on something that
is not an object.

> It is important that I reuse the same object($mech
> from page1's call).

So reuse it then, instead of overwriting it with something else.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Sun, 19 Nov 2006 12:16:41 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Storing objects in Session
Message-Id: <m2wt5rtkzq.fsf@Sherm-Pendleys-Computer.local>

prabhu.subramaniam@gmail.com writes:

>   I am trying to store an object (WWW::Mechanize) in
> session(CGI::Session) and trying to retrieve it

Why? WWW::Mechanize is for writing HTTP clients. CGI::Session is used on a
server to manage client sessions. They're completely unrelated.

What are you actually trying to accomplish?

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: 19 Nov 2006 12:02:09 -0800
From: "Prabhu" <prabhu.sengal@gmail.com>
Subject: Re: Storing objects in Session
Message-Id: <1163966529.152767.306440@m73g2000cwd.googlegroups.com>

Hi,
@Sherem - Sorry I am new to this forum. I am not familiar with the
posting guidelines. Anyway, my question is on how to store objects into
a session retrieve it back. The code I pasted qas more of a pseudocode
than the real program. What I am trying to do is to contact a website,
authenticate myself and request a file whose name will be entered by
the user upon successful login. So, it requires 2 inputs and hence the
if..else part. I figured I need to use the same www::Mechanize object
for both the requests. I am trying to store this $mech object in
session and use  it again when the request comes back with the name of
the file needed. Any suggestions? Thanks.

use strict;
use WWW::Mechanize;
use HTML::TokeParser;
use HTTP::Cookies;
use IO::File;
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use CGI::Session;
use CGI;

my $email = "";

my $mech = WWW::Mechanize->new ( cookie_jar => {} );

	if(param('FormName') eq 'Auth')
	{
		my $session = new CGI::Session("driver:File", undef,
{Directory=>'/tmp'});
		my $sid = $session->id();

		$email = param('Email');

		$session->param('Email', $email);

                #something I tried, it works
                #$session->param('Mech', $mech);
                #$mech = "";
                #$mech = $session->param('Mech');

		$mech->agent_alias('Windows IE 6');
		$mech->get("www.somesite.com");
                #do operations here
		$session->param('Mech', $mech);

		print 'Status: 302 Moved', "\r\n", "Location:
http://localhost/testsite/Confirmation.html?id=someid&CGISESSID=$sid","\r\n\r\n";

	}
	else
	{
		my $sid = param('CGISESSID') || undef;
    		my $session = new CGI::Session("driver:File", $sid,
{Directory=>'/tmp'});

		$email = $session->param('Email'); #works

		$mech = $session->param('Mech'); #at this point error : Can't locate
object method "get" via package "WWW::Mechanize" at
C:\Inetpub\Scripts\somescript.pl line 100.

		$mech->get("www.somesite.com");
               #do operations here
	}

Regards,
Prabhu

On Nov 20, 1:16 am, Sherm Pendley <spamt...@dot-app.org> wrote:
> prabhu.subraman...@gmail.com writes:
> >   I am trying to store an object (WWW::Mechanize) in
> > session(CGI::Session) and trying to retrieve itWhy? WWW::Mechanize is for writing HTTP clients. CGI::Session is used on a
> server to manage client sessions. They're completely unrelated.
>
> What are you actually trying to accomplish?
>
> sherm--
>
> --
> Web Hosting by West Virginians, for West Virginians:http://wv-www.net
> Cocoa programming in Perl:http://camelbones.sourceforge.net



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

Date: Sun, 19 Nov 2006 16:13:27 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Storing objects in Session
Message-Id: <m2slgfta14.fsf@Sherm-Pendleys-Computer.local>

"Prabhu" <prabhu.sengal@gmail.com> writes:

> @Sherem - Sorry I am new to this forum.

My name is Sherm, and there's only one of me - I'm not an array. :-)

> I am not familiar with the posting guidelines.

As I said, they're posted here often - twice weekly at least.

> Anyway, my question is on how to store objects into
> a session retrieve it back. The code I pasted qas more of a pseudocode
> than the real program. What I am trying to do is to contact a website,
> authenticate myself and request a file whose name will be entered by
> the user upon successful login. So, it requires 2 inputs and hence the
> if..else part. I figured I need to use the same www::Mechanize object
> for both the requests.

You can - but you don't need to use CGI::Session to do it.

As I said before, CGI::Session is for maintaining session state on the
*server* - but you're writing a client.

> I am trying to store this $mech object in
> session and use  it again when the request comes back with the name of
> the file needed. Any suggestions?

Yes: Don't do that. If you want to reuse $mech, just reuse it. There's no
need at all to store it in a separate session object.

Session objects are needed on the server because each request for a CGI is
handled by a separate run of the script. Each run of the script knows
nothing at all about any previous runs. So, a module like CGI::Session is
used to "persist" data from request to request, tying it together into a
multi-request "session".

A client, on the other hand, can make as many requests as it wants, without
needing any special pain to maintain a "session" between them. Just keep
using $mech as-is to make as many requests as you want.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: 19 Nov 2006 12:40:45 -0800
From: "Lee" <lskatz@gmail.com>
Subject: Template
Message-Id: <1163968845.667301.101690@m73g2000cwd.googlegroups.com>

Hi,
I have this template file that I am opening in my script.

<tr>
  <td>{var1}</td>
  <td>{var2}</td>

  <td>
    <table>
      <tr>
        <td>Name: {name3}</td>
        <td>Age: {age3}</td>
      </tr>
    </table>
  </td>

</tr>

Are there any good regular expressions to grab each tag and its
contents?  I'm doing this in javascript, but I'm guessing that there
are some really good regex experts in this group.
If there are any perl, php, or javascript libraries out there for this
sort of thing, I'd like to know about it!



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

Date: Sun, 19 Nov 2006 16:32:58 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Template
Message-Id: <m2odr3t94l.fsf@Sherm-Pendleys-Computer.local>

"Lee" <lskatz@gmail.com> writes:

> Are there any good regular expressions to grab each tag and its
> contents?  I'm doing this in javascript

Then you've lost your way and wandered into the wrong group. Comp.lang.
javascript is over there --->.

>, but I'm guessing that there
> are some really good regex experts in this group.

Maybe so, but the experts you find here will be experts with Perl-flavor
regexes. JavaScript regexes aren't the same.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Sun, 19 Nov 2006 21:32:44 +0000
From: Henry Law <news@lawshouse.org>
Subject: Re: Template
Message-Id: <1163971960.66552.0@despina.uk.clara.net>

Lee wrote:
> Hi,
> I have this template file that I am opening in my script.
> 
> <tr>
 ...
> </tr>
> 
> Are there any good regular expressions to grab each tag and its
> contents?  

General advice here is not to try to parse HTML or XML with regexes; 
it's a great deal harder than it looks and there are much better ways to 
do it.

> If there are any perl, php, or javascript libraries out there for this
> sort of thing, I'd like to know about it!

Here's one: http://search.cpan.org/search?query=parse+html&mode=all

And another you might find useful, in the context of your post:
http://search.cpan.org/search?query=html+template&mode=all

-- 

Henry Law       <><     Manchester, England


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9982
***************************************


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