[24425] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6611 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 26 14:06:14 2004

Date: Wed, 26 May 2004 11:05:07 -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, 26 May 2004     Volume: 10 Number: 6611

Today's topics:
        [ANN] Unix::Statgrab 0.01 <tassilo.parseval@rwth-aachen.de>
    Re: create directory ... <jtc@shell.dimensional.com>
        How do I interpret debugger text representation? (Sara)
    Re: How do I interpret debugger text representation? (Peter Scott)
    Re: How to remove ^M using perl ? (John W.)
    Re: iterating over arrays with map - problem <remorse@partners.org>
        line wrap with encode('MIME-Header', "foo") <axel_REMOVE_THIS_FIRST_@magmar.de>
    Re: Map or Regex and Sorting <uri@stemsystems.com>
    Re: newbie question <jtc@shell.dimensional.com>
    Re: noob: Trying perl, and decoding MIME attachments..s (cayenne)
    Re: noob: Trying perl, and decoding MIME attachments..s <nobull@mail.com>
    Re: Password scheme/Persistent session... (krakle)
    Re: Perl work? chris-usenet@roaima.co.uk
    Re: Perl work? (krakle)
    Re: Perl work? <peter@semantico.com>
    Re: Perl work? <postmaster@castleamber.com>
    Re: printing all possible permutations of a set of char <dwall@fastmail.fm>
    Re: printing all possible permutations of a set of char (Bill)
        SQL::Abstract - generating q(like "%?%")? <dwall@fastmail.fm>
    Re: Telnet module (Robert Snabel-Bulka)
    Re: Telnet module (Robert Snabel-Bulka)
    Re: Unpack and checksums <obeseted@yahoo.com>
    Re: Unpack and checksums <fifo@despammed.com>
    Re: Unpack and checksums (Greg Bacon)
        Use contents of variable for search and replace (wappel)
    Re: Use contents of variable for search and replace <usenet@morrow.me.uk>
    Re: Use contents of variable for search and replace <ittyspam@yahoo.com>
    Re: Using Cookies With Perl (krakle)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 26 May 2004 05:12:35 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: [ANN] Unix::Statgrab 0.01
Message-Id: <HyBu0M.FJ6@zorch.sf-bay.org>

Hi,

I'd like to announce the arrival of a new module at the CPAN. From the
perldocs:


NAME
       Unix::Statgrab - Perl extension for collecting information about the
       machine

SYNOPSIS
           use Unix::Statgrab;

           local $, = "\n";

           my $host = get_host_info or
               die get_error;

           print $host->os_name,
                 $host->os_release,
                 $host->os_version,
                 ...;

           my $disks = get_disk_io_stats or
               die get_error;

           for (0 .. $disks->num_disks - 1) {
               print $disks->disk_name($_),
                     $disks->read_bytes($_),
                     ...;
           }

DESCRIPTION
       Unix::Statgrab is a wrapper for libstatgrab as available from
       <http://www.i-scream.org/libstatgrab/>. It is a reasonably portable
       attempt to query interesting stats about your computer. It covers
       information on the operating system, CPU, memory usage, network inter-
       faces, hard-disks etc.

[...]

COPYRIGHT AND LICENSE
       Copyright (C) 2004 by Tassilo von Parseval

       This library is free software; you can redistribute it and/or modify it
       under the terms of the GNU Lesser General Public License as published
       by the Free Software Foundation; either version 2.1 of the License, or
       (at your option) any later version.


Prerequisite for this module is the libstatgrab C-library, so obviously
you need to have this installed plus a C compiler. The library itself
claims to be portable across various Unices (Linux, *BSD, Solaris). I
haven't verified this so I trust its authors on that.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval




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

Date: 26 May 2004 08:28:59 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: create directory ...
Message-Id: <slrncb9adh.8oh.jtc@shell.dimensional.com>

In article <slrncb8f26.mhn.mgjv@verbruggen.comdyn.com.au>, Martien Verbruggen wrote:
> On 25 May 2004 18:15:48 -0600,
> 	Jim Cochrane <jtc@shell.dimensional.com> wrote:
>> In article <40b3c041$1@news.wineasy.se>, Rickard wrote:
> 
>>> Are there any other command to use to create an directory?
> 
> [snippage]
> 
>> Creating directories is also quite easy - e.g., system("mkdir $dir"), or
>> find the right module.
> 
> What's wrong with the builtin function mkdir?

Nothing.  I'm still working on mastering Perl and that one wasn't in my
"database" yet. :-)

Using builtin functions is almost always preferable to using 'system', of
course.
-- 
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]


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

Date: 26 May 2004 07:59:43 -0700
From: genericax@hotmail.com (Sara)
Subject: How do I interpret debugger text representation?
Message-Id: <776e0325.0405260659.1a9254d9@posting.google.com>

I have a scalar, which according to the debugger, has some weird stuff
in it:

DB<28> x $_
0  "\c@\c@mm18-wr1.1\cC\c@\c@T25\cH\c@\c@mm18-mn1\cC\c@\c@T2"

I'm not entire sure how this is delimited, but I tried a number of
ways to carve it up:

   @v = split /\[A-Z]/
(didn't work)
   @v = split /\\[A-Z]/
(didn't work)
   @v = split /\\./
(didn't work)
   @v = split /\./
(didn't work)

How can I split up this scalar on \c*anything* ? What IS \c*something*
anyhow? Control-*something* ?

Tanx


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

Date: Wed, 26 May 2004 15:48:12 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: How do I interpret debugger text representation?
Message-Id: <0%2tc.595527$oR5.27109@pd7tw3no>

In article <776e0325.0405260659.1a9254d9@posting.google.com>,
 genericax@hotmail.com (Sara) writes:
>I have a scalar, which according to the debugger, has some weird stuff
>in it:
>
>DB<28> x $_
>0  "\c@\c@mm18-wr1.1\cC\c@\c@T25\cH\c@\c@mm18-mn1\cC\c@\c@T2"
>
>I'm not entire sure how this is delimited, but I tried a number of
>ways to carve it up:
>
>   @v = split /\[A-Z]/
>(didn't work)
>   @v = split /\\[A-Z]/
>(didn't work)
>   @v = split /\\./
>(didn't work)
>   @v = split /\./
>(didn't work)
>
>How can I split up this scalar on \c*anything* ? What IS \c*something*
>anyhow? Control-*something* ?

Yes.

@v = split /[[:cntrl:]]/

I don't see what splitting that string on control characters is going to
achieve.  You need to know more about how it got created.

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/


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

Date: 26 May 2004 10:17:26 -0700
From: jwagenleitner@yahoo.com (John W.)
Subject: Re: How to remove ^M using perl ?
Message-Id: <a4c755ee.0405260917.22d30060@posting.google.com>

Abhinav <matrix_calling@yahoo.dot.com> wrote in message news:<Mj_sc.7$Bk6.41@news.oracle.com>...
> Hi,
> 
> I have a sscript which reads in a set of lines from a windows text file, 
> and concatenates it and stores in a string.
> 
> I chomp the string after reading it, and do
> 
> $_ =~ s/^V<^Enter>//g;  # i.e., I press cntrl -V and then cntrl - Enter
> 
> This does not seem to work and I still find ^M charactes when i wtite 
> the lines to a file.
> 
> What is the way to remove them ?
> 
> Thanks
> AB

You need to just do "ctrl+v" then Enter.  Don't do ctrl+Enter.  In
your script you should actually see...

$_ =~ s/^M//g;

 ...after doing that.

John


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

Date: Wed, 26 May 2004 11:37:49 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: iterating over arrays with map - problem
Message-Id: <remorse-25923E.11374926052004@plato.harvard.edu>

In article <txZsc.3632$Ly.202@attbi_s01>,
 Joe Smith <Joe.Smith@inwap.com> wrote:

> Richard Morse wrote:
> >          while ($temp =~ s/$sub_let/$sub_matrix{$sub_let}/) {
> 
> For 's', that will produce "pa5sword" and "pa55word" but not "pas5word".

Thanks -- someone already replied with much better code, but I'm glad to 
know where I went wrong...

Ricky

-- 
Pukku


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

Date: Wed, 26 May 2004 16:13:24 +0200
From: Axel Hanusch <axel_REMOVE_THIS_FIRST_@magmar.de>
Subject: line wrap with encode('MIME-Header', "foo")
Message-Id: <2hjn14Fdnat0U1@uni-berlin.de>

Hi,
when I do this

use Encode "encode";
print encode('MIME-Header', 'Subject: blah blah blah blah blah blah \
blah blah blah blah blah foo@bar.org blah')."\r\n";

I get this result:

Subject: blah blah blah blah blah blah blah blah blah blah blah foo@bar.
  org blah

The line is folded after the '.' and when the receiving email client 
unfolds it according to RFC 822 (Section 3.1.1.), the result is "...blah 
foo@bar. org blah" instead of "...blah foo@bar.org blah".

Why are lines folded at characters like ()<>@,;:"'/[]?.= and not at 
whitespaces?


Thanks in advance,

Axel



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

Date: Wed, 26 May 2004 14:24:18 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Map or Regex and Sorting
Message-Id: <x765ajjmgd.fsf@mail.sysarch.com>

>>>>> "JWK" == John W Krahn <krahnj@acm.org> writes:

  >> for payment, i expect you to test Sort::Maker before its public release.

  JWK> I couldn't find it on CPAN or your web site.

i posted the location in another recent thread on sorting. i would
expect someone who knows how to write a GRT to follow all sort threads!

anyhow, it is at stemsystems.com/sort/Sort-Maker-0.01.tar.gz

i am coding up some late changes and improvements now and i will
announce the next beta as soon as that is done. my goal is to release it
before yapc::na since i am giving a talk about it there.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 26 May 2004 08:37:57 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: newbie question
Message-Id: <slrncb9aub.8oh.jtc@shell.dimensional.com>

In article <zJZsc.5$Bk6.98@news.oracle.com>, Abhinav wrote:
> Hi,
> 
> I have the following piece of code which checks for a word within <> . 
> What I want to do is, if this matches, I want to change the value of a 
> variable, which is having an integer value, and whose name is same as 
> the matched string, to 1.
> 
> Thus, if i match <x>
> I need to do
> $x = 1 ;

You'll greatly increase your chances of getting useful help by summarizing
your question in the subject field - 'newbie question' is way too general.
Many experts will just ignore such subjects.

You're lucky Anno is so patient :-)

> 
> Is there any way i can use the value of the matched text ($1) to create 
> the variable name ?
> 
> The code is :
> 
> if (/<(\w+)>/)
> {
> # What to put here , so that the corresponding variable gets declared
> # and initialized ?
> #something like,
> 
> my '$'.$1 = 1 ; # I know it is wrong, but just to signify what i want ..
> }
> 
> 
> 
> Thanks
> AB
> 


-- 
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]


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

Date: 26 May 2004 07:27:47 -0700
From: chilecayenne@yahoo.com (cayenne)
Subject: Re: noob: Trying perl, and decoding MIME attachments..stuck in my code..can someone take a look?
Message-Id: <2deb3d1.0405260627.4bf17b3e@posting.google.com>

You might want to check your newsreader...you seem to have a bug that
causes massive repetition in your posts..."Have you seen the posting
guidelines that are posted here frequently?"

Yes, I read them...and not sure what I did that upset you so much. I
also read in them that not following them super strictly is not a
reason to berrate someone over it..
:-)

That being said, thanks for the reply. I'm trying to write something
while reading and learning at the same time...time constraints on me
don't allow for slow learned study on this one...will go back to that
after I get this running. Thanks for the use strict suggestion...I'll
go look up what that means and does..


The part that it dies on is in the else part of the statement:

} else {

        $msg_body = new MIME::Decoder 'base64' or die 'unsupported';
        $filename = $rec_filename;
        open (outfile,">$dir_path/$dir_name/$filename");
        $msg_body->decode ($part,outfile);
        close (outfile);

        }

The error message I get is:

(Command died with status 21: "/home/testmail/scripts/mail_mime.pl".
Command output: Can't use an undefined value as a symbol reference at
/usr/lib/perl5/site_perl/5.8.0/IO/Wrap.pm line 35, <STDIN> line 1958.
)

I'm not sure what is not declared here...?? This is just a snippet of
a down and dirty script I'm putting together from reading of examples
on the web and the books I have.

I'm basically interested if someone can enlighten me on the MIME::
Decode module how to write out a file you decode?

Thanks for the help...
Help and constructive criticism appreciated...but, please don't
berrate. I'm just under the gun, and trying to learn and get something
working at the same time...and its not like I've not been doing
research...I'm looking all over and have not seem much out there to
work from...

TIA,

CC

Brian McCauley <nobull@mail.com> wrote in message news:<u9ekp8sav7.fsf@wcl-l.bham.ac.uk>...
> chilecayenne@yahoo.com (cayenne) writes:
> 
> > I'm trying to learn Perl,
> 
> You should always declare all variables as lexically scoped in the
> smallest applicable lexical scope unless you have a positive is a
> reason to do otherwise. BTW: this is not perculliar to Perl, it
> applies in all programming languges - allowing that a languge not
> having lexical variables is a positive reason :-).
> 
> For Perl this means that most of the time the declaration should be
> combined with the first assignment. BTW: this to is not perculliar to
> Perl, it also applies in other programming languges where assignment
> and declaration can be combined.
> 
> By following this convention you will be able to get maximum beniefit
> out of putting "use strict" at the top of all your scripts.
> 
> Try to get into this habit now, do not wait for your failure to do so
> to cause you the unecessary distress of wasting your own time and that
> of other people.  The longer you leave it the harder you will find it
> to adjust.  Worse still, if you leave it too long you may never adjust
> and may mutate into a bitter and twisted troll.
> 
> The "use warnings" pragma can also be a lot of help when programming in Perl.
> 
> Have you seen the posting guidelines that are posted here frequently?
> 
> > and do something fairly difficult at the  same time for work.
> >  I'm trying to use the MIME tools modules...and
> > the examples there on the docs are kinda sparse...and I'm confused how
> > to decode things to a directory on my harddrive.
> > 
> > At this point, just to learn how it works...I'm sending the perl
> > script a simple email with text message...and one .jpg image that is
> > encoded in base64. I'm trying to write these out to a spot on my
> > harddrive.
> 
> Is it failing?  If so what error code is it returning when it fails?
> 
> Have you seen the posting guidelines that are posted here frequently?
> 
> > I'm posting just the part
> 
> You should always try to reduce your problem to a minimal but complete
> script.
> 
> Have you seen the posting guidelines that are posted here frequently?
> 
> 
> > where it is looping through the
> > mime message, and trying to split off the plain text part (which does
> > work), but, blows up on messages with a base64 attachment.
> 
> I'm sure it doesn't blow up.  It probably fails in some way.
> 
> Have you seen the posting guidelines that are posted here frequently?
> 
> > 
> > Code snippet:
> 
> [ snip ]
> 
> I won't do the job of a machine.  Please post code that's already
> strict/warnings clean if you want sentient entities to take the time
> to look at it.
> 
> > And the dir_path, dir_name are all being set correctly earlier in the
> > code..but, I'm having difficulty in decoding the attachment to the
> > disk...
> 
> Can you describe the form that difficulty takes?
> 
> Have you seen the posting guidelines that are posted here frequently?
> 
> > Can someone give me an example or describe what I'm doing wrong
> > here...? 
> 
> Have you seen the posting guidelines that are posted here frequently?
> 
> > Thanks in advance for any advice, pointers, links...
> 
> Have you seen the posting guidelines that are posted here frequently?


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

Date: 26 May 2004 18:19:14 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: noob: Trying perl, and decoding MIME attachments..stuck in my code..can someone take a look?
Message-Id: <u93c5nrtrh.fsf@wcl-l.bham.ac.uk>

chilecayenne@yahoo.com (cayenne) vomits TOFU in my face:

> You might want to check your newsreader...you seem to have a bug that
> causes massive repetition in your posts..."Have you seen the posting
> guidelines that are posted here frequently?"
>
> Yes, I read them...and not sure what I did that upset you so much. I
> also read in them that not following them super strictly is not a
> reason to berrate someone over it..

But you evidently missed the bit about how rude top-posting is
considered.  Or are you intending to be perceived as rude?

> That being said, thanks for the reply. I'm trying to write something
> while reading and learning at the same time...time constraints on me
> don't allow for slow learned study on this one...

There are certain bits of "learned study" where the payoff is so great
and so soon that they are actually worth taking the time out even when
you are short of time.  An analogy I like is that what you are saying
is "I'm a novice climber - I don't have time to figure out these ropes
I need to get the the top as quickly as possible".  If you are
exeptionally lucky you'll get there without a serious slip.  But only
if you are exeptionally lucky.  Even a single fall that could have
been avoided by the ropes will often cost you an order of magnitude
more time than getting a basic idea of using the ropes would have
cost.

> The part that it dies on is in the else part of the statement:
> 
> } else {
> 
>         $msg_body = new MIME::Decoder 'base64' or die 'unsupported';
>         $filename = $rec_filename;
>         open (outfile,">$dir_path/$dir_name/$filename");
>         $msg_body->decode ($part,outfile);
>         close (outfile);
> 
>         }
> 
> The error message I get is:
> 
> (Command died with status 21: "/home/testmail/scripts/mail_mime.pl".
> Command output: Can't use an undefined value as a symbol reference at
> /usr/lib/perl5/site_perl/5.8.0/IO/Wrap.pm line 35, <STDIN> line 1958.
> )
> 
> I'm not sure what is not declared here...??

What makes you think there's a declaration problem?
 
> I'm basically interested if someone can enlighten me on the MIME::
> Decode module how to write out a file you decode?

At a guess (having never used MIME::Decoder) I'd say you do it as per
the documentation.

But I expect that's not your problem.  I'll guess[1] that your problem is
how to pass an IO as handle as argument to a subroutine (which, of
course, as nothing to do with MIME::Decoder).  BTW this is FAQ: "How
can I pass/return a {Function, FileHandle, Array, Hash, Method,
Regex}?"

         $msg_body->decode($part,\*outfile);

[1] I have to guess - you've not given my a minimal but complete
script with which to check.

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


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

Date: 26 May 2004 08:42:25 -0700
From: krakle@visto.com (krakle)
Subject: Re: Password scheme/Persistent session...
Message-Id: <237aaff8.0405260742.2ef1e683@posting.google.com>

Uri Guttman <uri@stemsystems.com> wrote in message news:<x7isekks2a.fsf@mail.sysarch.com>...
> >>>>> "k" == krakle  <krakle@visto.com> writes:
> 
>   k> Uri Guttman <uri@stemsystems.com> wrote in message news:<x77jv1noc0.fsf@mail.sysarch.com>...
>   >> i would pursue another profession
> 
>   k> Yes I will pursue another profession because I posted a question
>   k> that I THOUGHT was on topic in this newsgroup... Yet i'm the dense
>   k> one.  psssf. Complete morons here...
> 
> hahaha!!!
> 
> now go away already. you have stuck your nose into other threads

I don't have to go away same as you don't have to read my posts.
And, I reply in other threads simply because this IS Usenet. I thought
replying was allowed? However, I am so wrong. Where are my morals..
where are they...


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

Date: Wed, 26 May 2004 14:50:56 +0100
From: chris-usenet@roaima.co.uk
Subject: Re: Perl work?
Message-Id: <0vjeo1-gpj.ln1@moldev.cmagroup.co.uk>

krakle <krakle@visto.com> wrote:
> hmm.. Must be nice to live in one of these backward countries... Live
> in tents, 'drive' camels, eat rice oh and work as a Perl programmer on
> your personal computer with high speed access from the comfort of your
> cozy cave...

Oh now, I really can't sit back and just watch this any longer. A
number of years ago, I lived in Guyana for six months. A good teacher's
(admittedly lousy) wage was GYD $30,000 a month. IIRC in strict
monetary terms this then equated to about GBP 100. However, in Guyana
it was just about enough to live on. At one point I did some extra
programming/consultancy for a company out there and charged "a small
fortune" in local terms, which worked out at approximately USD $1000. I
had internet access (yes, even back in 1997).

There is a strangeness living in one of these developing countries that
cannot easily be understood unless you have experience it. You live in
(relatively) poor surroundings and yet have access to some of the most
advanced technologies available to the developed world. Yes it's a bit
of an oxymoron but that really is how it is.

Chris


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

Date: 26 May 2004 08:40:07 -0700
From: krakle@visto.com (krakle)
Subject: Re: Perl work?
Message-Id: <237aaff8.0405260740.72ad7e13@posting.google.com>

Peter Hickman <peter@semantico.com> wrote in message news:<40b45576$0$2285$afc38c87@news.easynet.co.uk>...
> krakle wrote:
> > hmm.. Must be nice to live in one of these backward countries... Live
> > in tents, 'drive' camels, eat rice oh and work as a Perl programmer on
> > your personal computer with high speed access from the comfort of your
> > cozy cave...
> 
> Your ignorance and racism are unbounded, just a few facts to set you straight:

Do you know what sarcasm is?
 
> 1) A tent is not a cave. 'Live in tents' and 'your cozy cave'
> 2) Rice is not grown where camels live
> 3) Not all Internet access is high speed

Well then, you surely set me straight since I was speaking factual.....

> 
> Sounds like you come from a backward country yourself given your level of education.

Yep. US.


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

Date: Wed, 26 May 2004 17:08:32 +0100
From: Peter Hickman <peter@semantico.com>
Subject: Re: Perl work?
Message-Id: <40b4c100$0$2273$afc38c87@news.easynet.co.uk>

krakle wrote:
> Do you know what sarcasm is?

Yes. I also know what bigotry is.

Making a racist slur and then trying to pass it off as some form of humor will not get you off the hook. Maybe you are a sensible person who just happens to spout bullshit but I am 
not giving you the benefit of the doubt. There are too many assholes out there for me to bother getting to know the 'real you'.


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

Date: Wed, 26 May 2004 11:25:52 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Perl work?
Message-Id: <40b4c513$0$209$58c7af7e@news.kabelfoon.nl>

Peter Hickman wrote:

> krakle wrote:
> 
>> hmm.. Must be nice to live in one of these backward countries... Live
>> in tents, 'drive' camels, eat rice oh and work as a Perl programmer on
>> your personal computer with high speed access from the comfort of your
>> cozy cave...
> 
> 
> Your ignorance and racism are unbounded, just a few facts to set you 
> straight:
> 
> 1) A tent is not a cave. 'Live in tents' and 'your cozy cave'
> 2) Rice is not grown where camels live

AFAIK camels are used in India :-D. And you can eat rice where camels 
live :-D

> 3) Not all Internet access is high speed

And even if it's high speed, it can be amazing expensive, especially 
compared to local prices, and often not working. I pay 6 times the 
amount I would have paid in the Netherlands compared to Dutch 
speed/price. So compared to where I live now, Mexico, that is extremely 
expensive. I can dine every night in a restaurant, for 14 days, for what 
I pay for "one" [1] month 512 kbps.

[1] including days/hours it doesn't work.

-- 
John                               MexIT: http://johnbokma.com/mexit/
                            personal page:       http://johnbokma.com/
    Experienced Perl programmer available:     http://castleamber.com/


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

Date: Wed, 26 May 2004 15:24:54 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: printing all possible permutations of a set of characters
Message-Id: <Xns94F5741E2B8ABdkwwashere@216.168.3.30>

OL/2 <_> wrote:

> Hi everyone. By counting up from 0, it is possible to print all
> permutations of an n-digit number, but what if I want to include
> certain characters in that range? How can I print all n-length
> permutations of an arbitrary set of characters?

perldoc -q permute

You are expected to check the FAQ before you post. 

Have you seen the Posting Guidelines that are posted here frequently?

(Preceding question is plagiarized, because I was too lazy to find 
another way to say it.)


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

Date: 26 May 2004 09:06:59 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: printing all possible permutations of a set of characters
Message-Id: <239ce42f.0405260806.2a62cae0@posting.google.com>

"OL/2" <_> wrote in message news:<40b46ac6$0$3035$afc38c87@news.optusnet.com.au>...
> Hi everyone. By counting up from 0, it is possible to print all permutations
> of an n-digit number, but what if I want to include certain characters in
> that range? How can I print all n-length permutations of an arbitrary set of
> characters?
> 
> cheers

http://search.cpan.org/~edpratomo/Algorithm-Permute-0.06/Permute.pm


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

Date: Wed, 26 May 2004 17:04:27 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: SQL::Abstract - generating q(like "%?%")?
Message-Id: <Xns94F584FEF26D5dkwwashere@216.168.3.30>

I've been playing with SQL::Abstract, but I can't seem to get it to 
generate the SQL I want.  I want the following, with wildcards around 
the placeholder:

     WHERE ( DB_FIELD LIKE "%?%" ) 
        OR ( DB_FIELD LIKE "%?%" ) 
        OR ( DB_FIELD LIKE "%?%" )

The closest I've been able to get to it is this:

    use SQL::Abstract;
    my $test = SQL::Abstract->new( cmp => 'like' );
    my ($stmt, @bind) = $test->where( 
                            { DB_FIELD => [qw(word1 word2 word3)] }
                        );
    print $stmt;


which produces (formatted for usenet)

    WHERE ( ( ( DB_FIELD LIKE ? ) 
        OR ( DB_FIELD LIKE ? ) 
        OR ( DB_FIELD LIKE ? ) ) )

I don't care about the extra parentheses one way or another.

Any ideas?


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

Date: 26 May 2004 07:15:17 -0700
From: rbulka@tesco-europe.com (Robert Snabel-Bulka)
Subject: Re: Telnet module
Message-Id: <99ba87d7.0405260615.65d73a17@posting.google.com>

"Indigo5" <abc@microsoft.com> wrote in message news:<Hy19oA.CrC@news.boeing.com>...
> Is there a way to open several telnet objects simultaneously?  I have a
> program that takes 10 hours to run and I have to run it for 200 datasets.  I
> would like to use the Telnet module to do this.  However,  I can't figure
> out how to return back to the main program after I launch the process. In
> other words, I want to do some parallel processing with 36 different
> machines.  Can this be done? In other words something like this currently
> only works as serial proceessing:
> 
>    $matt1 = new Net::Telnet( Timeout => 36000,
>                               Errmode => sub { main::defaultterm()},
>                                Prompt => '/\$$/i'),
> 
>    $matt2 = new Net::Telnet( Timeout => 36000,
>                              Errmode => sub { main::defaultterm()},
>                              Prompt  => '/\$$/i'),
> 
>    $matt1->open($nodename{1});
> 
>    $matt2->open($nodename{2});
> 
> 
>    $matt1->login("$uname\n","$upw\n");
> 
>    $matt2->login("$uname\n","$upw\n");
> 
> 
>    $matt1->cmd("cd \/project\//$Runs{1}\/");
> 
>    $matt1->cmd("../main.pl . $Runs{1} -W");
> 
> 
>    $matt2->cmd("cd \/project\/cafbeam\/SRM_RUNS\/$Runs{2}\/");
> 
>    $matt2->cmd("../main.pl . $Runs{2} -W");


Best is run the cmd with: 'nohup execute_script.sh &' due the SIGHUP,
FQDN of servers is stored in: 'allservers'.

#!/usr/bin/perl -w

use Net::Telnet;

my $server_file = "allservers";
my $username = "admin16";
my $passwd = "test123";
my $prompt = '/admin16 \>/';
my $kcmd = "nohup execute_script.sh &";


open (INFILE, $server_file) || die ("Couldn`t open file: $server_file
!");
 @servers = <INFILE>;
close (INFILE);

foreach $host (@servers) {
        chomp($host);
        &telnet_connect;
        }

sub telnet_connect {

$t= new Net::Telnet (Host => $host,
                             Timeout => 10,
                             Prompt => '/admin16 \>/');

$t->open($host);
        $t->waitfor('/login:/i');
        $t->print($username);

        $t->waitfor('/Password:/i');
        $t->print($passwd);

        $t->waitfor('/continue/i');
        $t->print("");

        $t->waitfor($prompt);

                @cmd=$t->cmd("$kcmd");
                print @cmd;
$t->close;

}


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

Date: 26 May 2004 08:25:54 -0700
From: rbulka@tesco-europe.com (Robert Snabel-Bulka)
Subject: Re: Telnet module
Message-Id: <99ba87d7.0405260725.31625000@posting.google.com>

"Indigo5" <abc@microsoft.com> wrote in message news:<Hy19oA.CrC@news.boeing.com>...
> Is there a way to open several telnet objects simultaneously?  I have a
> program that takes 10 hours to run and I have to run it for 200 datasets.  I
> would like to use the Telnet module to do this.  However,  I can't figure
> out how to return back to the main program after I launch the process. In
> other words, I want to do some parallel processing with 36 different
> machines.  Can this be done? In other words something like this currently
> only works as serial proceessing:
> 
>    $matt1 = new Net::Telnet( Timeout => 36000,
>                               Errmode => sub { main::defaultterm()},
>                                Prompt => '/\$$/i'),
> 
>    $matt2 = new Net::Telnet( Timeout => 36000,
>                              Errmode => sub { main::defaultterm()},
>                              Prompt  => '/\$$/i'),
> 
>    $matt1->open($nodename{1});
> 
>    $matt2->open($nodename{2});
> 
> 
>    $matt1->login("$uname\n","$upw\n");
> 
>    $matt2->login("$uname\n","$upw\n");
> 
> 
>    $matt1->cmd("cd \/project\//$Runs{1}\/");
> 
>    $matt1->cmd("../main.pl . $Runs{1} -W");
> 
> 
>    $matt2->cmd("cd \/project\/cafbeam\/SRM_RUNS\/$Runs{2}\/");
> 
>    $matt2->cmd("../main.pl . $Runs{2} -W");

Best way is run the command with 'nohup execute_script.sh  &' due
SIGHUP on UNIX or with 'at' on Win$hit ...

#!/usr/bin/perl -w

use Net::Telnet;

my $server_file = "my_allservers"; 
my $username = "admin16";
my $passwd = "test123";
my $prompt = '/admin16 \>/';
my $kcmd = "nohup execute_script.sh &";
#my $kcmd = "at TIME execute_script";

open (INFILE, $server_file) || die ("Couldn`t open file: $server_file
!");
 @servers = <INFILE>;
close (INFILE);

       foreach $host (@servers) {
               chomp($host);
               &telnet_connect;
              }



sub telnet_connect {

$t= new Net::Telnet (Host => $host,
                             Timeout => 10,
                             Prompt => '/admin16 \>/');

$t->open($host);
        $t->waitfor('/login:/i');
        $t->print($username);

        $t->waitfor('/Password:/i');
        $t->print($passwd);

        $t->waitfor('/continue/i');
        $t->print("");

        $t->waitfor($prompt);

                @cmd=$t->cmd("$kcmd");
                print @cmd;
$t->close;

}

Robert


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

Date: Wed, 26 May 2004 15:41:56 +0200
From: Fatted <obeseted@yahoo.com>
Subject: Re: Unpack and checksums
Message-Id: <2hjl7bFd80cgU1@uni-berlin.de>

fifo wrote:

> I agree that there's a bug with "%H*".  The point I was trying to make
> was that "%H*" doesn't do anything useful over "H*" anyway, since it's
> just 'summing' a single value.  I was thinking maybe the OP really meant
> to use "%C*"?

What I was looking for was the unpack equivalent of:
####
my $string = 'ThisIsAString';
my $chksum = 0;

for( split(//,$string) )
{
	$chksum += ord;
}

print sprintf("%X",$chksum)."\n";
####

I thought "%H*" would handle that (if "H*" gives a concat of the hex 
values then "%H*" should give sum, right?), but then comparing "H*" with 
"C*":

"H*" returns the concatentation of the hex values of the string
whereas
"C*" returns the decimal value of the first value.

On the other hand "%C*" *does* return the checksum (in decimal).

I've read and reread the perlfunc for pack and unpack and I'm now pretty 
confused.


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

Date: Wed, 26 May 2004 15:04:36 +0100
From: fifo <fifo@despammed.com>
Subject: Re: Unpack and checksums
Message-Id: <20040526140432.GC2750@fleece>

At 2004-05-26 15:41 +0200, Fatted wrote:
> What I was looking for was the unpack equivalent of:
> ####
> my $string = 'ThisIsAString';
> my $chksum = 0;
> 
> for( split(//,$string) )
> {
> 	$chksum += ord;
> }
> 
> print sprintf("%X",$chksum)."\n";
> ####
> 
> I thought "%H*" would handle that (if "H*" gives a concat of the hex 
> values then "%H*" should give sum, right?), but then comparing "H*" with 
> "C*":
> 
> "H*" returns the concatentation of the hex values of the string
> whereas

It returns a single string of hexadecimal digits.

> "C*" returns the decimal value of the first value.

No it returns a _list_ of the char values of each byte in the string:

$ perl -le'print join ":", unpack "C*", "ThisIsAString"'
84:104:105:115:73:115:65:83:116:114:105:110:103


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

Date: Wed, 26 May 2004 14:29:01 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Unpack and checksums
Message-Id: <10b9addal79noc2@corp.supernews.com>

In article <2hjl7bFd80cgU1@uni-berlin.de>,
    Fatted  <obeseted@yahoo.com> wrote:

: What I was looking for was the unpack equivalent of:
: ####
: my $string = 'ThisIsAString';
: my $chksum = 0;
: 
: for( split(//,$string) )
: {
: 	$chksum += ord;
: }
: 
: print sprintf("%X",$chksum)."\n";
: ####

You're right there!  Well, sort of.  See below.

    $ cat try
    #!/usr/local/bin/perl -w

    use strict;
    use warnings;

    sub explicit_checksum {
        my $str = shift;

        my $sum = 0;
        $sum += ord for split // => $str;

        $sum;
    }

    sub unpack_checksum {
        unpack "%16C*", shift;
    }

    my $string = 'ThisIsAString';
    my $chksum = 0;

    for (split //, $string) {
        $chksum += ord;
    }

    my @method = (
        [ explicit => \&explicit_checksum ],
        [ unpack   => \&unpack_checksum   ],
    );

    for (@method) {
        my($name,$code) = @$_;

        printf "%-10s %X\n", $name . ":", $code->($string);
    }

    $ ./try
    explicit:  50C
    unpack:    50C

These results match coincidentally.  Given a long enough $string, i.e.,
one whose ASCII values sum greater than 0xFFFF, only the least
significant sixteen bits would match.

For example:

$ cat try
[...]
open my $fh, '/etc/lynx.cfg' or die "$0: open /etc/lynx.cfg: $!";
my $string = join '', <$fh>;
[...]

$ ./try
explicit:  ADA3B4
unpack:    A3B4

The unpack isn't equivalent, but that's because the checksum your code
computes doesn't follow the convention of producing a result clamped
to a certain number of bits, e.g., $sum & 0xFFFF for a 16-bit checksum.

: I thought "%H*" would handle that (if "H*" gives a concat of the hex
: values then "%H*" should give sum, right?), but then comparing "H*"
: with "C*":

Remember that H returns hex strings, but C returns unsigned char
values.  Which of these matches the values returned from Perl's ord
operator?

: On the other hand "%C*" *does* return the checksum (in decimal).

No, it doesn't return a value in a particular base, just a number.
Base is a representation, e.g., input and output, issue.  Yes, I
realize it's almost certainly a twos-complement bitpattern in some
register in your machine, but we're speaking at the level of
abstraction of the Perl programming language, not the bare metal.

: I've read and reread the perlfunc for pack and unpack and I'm now
: pretty confused.

I hope this helps you through the confusion.

Greg
-- 
'Necessity' is the plea for every infringement of human liberty.  It is
the argument of tyrants; it is the creed of slaves.
    -- William Pitt


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

Date: 26 May 2004 08:32:09 -0700
From: wappel@wolters-kluwer.de (wappel)
Subject: Use contents of variable for search and replace
Message-Id: <9c83c769.0405260732.3a603601@posting.google.com>

I have the following problem:

I have an XML text which consists of several chapters that have a
number-Attribute
<xmltext>
<chapter number="345">
   ...searchtext...
</chapter>
<chapter number="446">
  ...searchtext...
</chapter>
</xmltext>

Now I want to replace the ...searchtext... by <search
number="xxx">...searchtext...</search>, where xxx is the value of
number-Attribute of the chapter in which the ...searchtext... stands:
<chapter number="345>
   <search number="345">...searchtext</search>
<chapter>
<chapter number="446">
   <search number="345">...searchtext</search>
</chapter>
 ..searchtext... could be a regular expression.

Maybe it is possible to do it with 
    s/(...searchtext...)/<search number="$variable">$1</search>/gs;
???
But how do I get the right value into the variable?


Thanks for your help

Wolfgang


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

Date: Wed, 26 May 2004 16:13:41 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Use contents of variable for search and replace
Message-Id: <c92fnl$pgh$1@wisteria.csv.warwick.ac.uk>


Quoth wappel@wolters-kluwer.de (wappel):
> I have the following problem:
> 
> I have an XML text which consists of several chapters that have a
> number-Attribute
> <xmltext>
> <chapter number="345">
>    ...searchtext...
> </chapter>
> <chapter number="446">
>   ...searchtext...
> </chapter>
> </xmltext>
> 
> Now I want to replace the ...searchtext... by <search
> number="xxx">...searchtext...</search>, where xxx is the value of
> number-Attribute of the chapter in which the ...searchtext... stands:
> <chapter number="345>
>    <search number="345">...searchtext</search>
> <chapter>
> <chapter number="446">
>    <search number="345">...searchtext</search>
> </chapter>
> ..searchtext... could be a regular expression.
> 
> Maybe it is possible to do it with 
>     s/(...searchtext...)/<search number="$variable">$1</search>/gs;
> ???
> But how do I get the right value into the variable?

Use an XML-parsing module: try XML::Simple or XML::Twig.

Ben

-- 
And if you wanna make sense / Whatcha looking at me for?          (Fiona Apple)
                            * ben@morrow.me.uk *


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

Date: Wed, 26 May 2004 12:45:11 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Use contents of variable for search and replace
Message-Id: <20040526123903.S3804@dishwasher.cs.rpi.edu>

On Wed, 26 May 2004, wappel wrote:

> I have the following problem:
>
> I have an XML text which consists of several chapters that have a
> number-Attribute
> <xmltext>
> <chapter number="345">
>    ...searchtext...
> </chapter>
> <chapter number="446">
>   ...searchtext...
> </chapter>
> </xmltext>
>
> Now I want to replace the ...searchtext... by <search
> number="xxx">...searchtext...</search>, where xxx is the value of
> number-Attribute of the chapter in which the ...searchtext... stands:
> <chapter number="345>
>    <search number="345">...searchtext</search>
> <chapter>
> <chapter number="446">
>    <search number="345">...searchtext</search>
> </chapter>
> ..searchtext... could be a regular expression.
>
> Maybe it is possible to do it with
>     s/(...searchtext...)/<search number="$variable">$1</search>/gs;
> ???
> But how do I get the right value into the variable?

Ideally, you would be far far better off using one of the XML Parsing
modules on CPAN.  Failing that, however, this would be my initial
(untested) attempt:

s[(<chapter number="(\d+)">)(.*?)(</chapter>)]
 [$1\n<search number="$2">$3</search>\n$4]gs;

Again, however, it would be far preferred to use one of the modules
specifically designed for this task.

Paul Lalli


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

Date: 26 May 2004 08:44:50 -0700
From: krakle@visto.com (krakle)
Subject: Re: Using Cookies With Perl
Message-Id: <237aaff8.0405260744.3598f234@posting.google.com>

Tore Aursand <tore@aursand.no> wrote in message news:<pan.2004.05.26.05.54.43.600025@aursand.no>...
> On Tue, 25 May 2004 16:25:31 -0700, krakle wrote:
> >> Cookies have nothing to do with sessions, other than the fact that you
> >> can use cookies to obtain session-like states across the HTTP protocol.
>  
> > He brought up a continueing bicker from another thread into this thread.
> 
> That really doesn't matter, as long as the OP asks how to do "it" in Perl.
> 
> I could easily have been quite on-topic and asked how to create chocolate
> cookies with Perl.

I wasn't referring to the original poster.....


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

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


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