[19287] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1482 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 10 00:06:53 2001

Date: Thu, 9 Aug 2001 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)
Message-Id: <997416309-v10-i1482@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 9 Aug 2001     Volume: 10 Number: 1482

Today's topics:
    Re: -w option changes filename variable <somewhere@in.paradise.net>
    Re: -w option changes filename variable (John J. Trammell)
    Re: automatic array elements <goldbb2@earthlink.net>
    Re: Can I make methods private/public? <goldbb2@earthlink.net>
        Can't Negate Regex /^8([0876])\1\d+$/ (Victor Araujo)
    Re: Can't Negate Regex /^8([0876])\1\d+$/ (Eric Bohlman)
    Re: Can't Negate Regex Nor Willing To Help Myself <godzilla@stomp.stomp.tokyo>
    Re: CGI.pm --> open FILE,">>file.txt"; (wade)
        compare Net::FTP and LWP ? <dan@nospam_dtbakerprojects.com>
    Re: Comparing data in two different files <godzilla@stomp.stomp.tokyo>
        error/question concerning MIME::Lite::HTML <aaronb@spamcop.net>
    Re: error/question concerning MIME::Lite::HTML <somewhere@in.paradise.net>
    Re: HTPASSWD <goldbb2@earthlink.net>
        I need help with one last thing. <viper16336@mindspring.com>
    Re: looking for script to edit config variables (Tad McClellan)
    Re: looking for script to edit config variables (Tad McClellan)
    Re: NET::SSH, NET::FTP, NET::POP3 (how to detect) (David Efflandt)
    Re: permuting extremely large string <ron@savage.net.au>
    Re: permuting extremely large string <godzilla@stomp.stomp.tokyo>
    Re: q: converting strings (Alan Barclay)
    Re: Sending e-mail from a script in MS windows <dan@nospam_dtbakerprojects.com>
        use module.pm on NT Platform <mdufault@dynamicservers.com>
    Re: use module.pm on NT Platform <friedman@math.utexas.edu>
    Re: use module.pm on NT Platform <bwalton@rochester.rr.com>
        || or OR <justin.devanandan.allegakoen@intel.com>
    Re: || or OR <bowman@montana.com>
    Re: || or OR (John J. Trammell)
    Re: || or OR (Eric Bohlman)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 10 Aug 2001 11:20:31 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: -w option changes filename variable
Message-Id: <gGGc7.11$iS3.217148@news.interact.net.au>


"Pete" <Peter@angeltec.NOTHISfsnet.co.uk> wrote in message
news:3b7319f7.11736563@news.freeserve.net...
> On Fri, 10 Aug 2001 09:11:57 +1000, "Tintin" <somewhere@in.paradise.net>
wrote:
> >Well, you've just managed to answer your question.
> hmmm, well I can't see it -  looks I'm missing something else then - apart
from
> a brain. Please expand.

Let's use a more obvious example.

If you invoke a script as:

/some/full/path/to/the/script

$0 will be set to /some/full/path/to/the/script

If you invoke a script as:

 ./script

$0 will be set to ./script

If you invoke a script as ../../script

$0 will be set to ../../script

if you invoke a script as:

script

$0 will be set to script


As you were invoking the script in different ways, you got different
results.  You need to compare apples with apples.




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

Date: 10 Aug 2001 03:46:09 GMT
From: trammell@bayazid.hypersloth.invalid (John J. Trammell)
Subject: Re: -w option changes filename variable
Message-Id: <slrn9n64fg.4qe.trammell@haqq.hypersloth.net>

On Fri, 10 Aug 2001 11:20:31 +1000, Tintin <somewhere@in.paradise.net> wrote:
> 
> "Pete" <Peter@angeltec.NOTHISfsnet.co.uk> wrote in message
> news:3b7319f7.11736563@news.freeserve.net...
> > On Fri, 10 Aug 2001 09:11:57 +1000, "Tintin" <somewhere@in.paradise.net>
> wrote:
> > >Well, you've just managed to answer your question.
> > hmmm, well I can't see it -  looks I'm missing something else then - apart
> from
> > a brain. Please expand.
> 
> Let's use a more obvious example.
[snip]

[ haqq ~/test/dollar-zero-001 ] cat foo.pl
#!/usr/bin/perl -w
use strict;
print "\$0: $0\n";
[ haqq ~/test/dollar-zero-001 ] ./foo.pl
$0: ./foo.pl
[ haqq ~/test/dollar-zero-001 ] ../dollar-zero-001/foo.pl
$0: ../dollar-zero-001/foo.pl
[ haqq ~/test/dollar-zero-001 ] /home/trammell/test/dollar-zero-001/foo.pl
$0: /home/trammell/test/dollar-zero-001/foo.pl
[ haqq ~/test/dollar-zero-001 ] perl -w foo.pl
$0: foo.pl
[ haqq ~/test/dollar-zero-001 ]

-- 
and how does it feel like/to let forever be


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

Date: Fri, 10 Aug 2001 00:07:27 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: automatic array elements
Message-Id: <3B735DFF.AE0D6938@earthlink.net>

Les Ander wrote:
> 
> Hi,
> i would like to build an array automatically.
>  i know that @arr=(1..10) fills the @arr with elements 1 to 10.
> 
> But i want to fill @arr with elements from 10..100 with every 10th
> elements. For example in matlab i can say a=[10:10:100]
> which will make a=(10, 20, 30, ..,100)
> 
> Can i do some thing similar with perl (i.e. can i give an arbitrary
> increment to fill up the array?)
> 
> I guess i can write a small function to do this but was wondering
> if perl has some inbuilt functionality such as this..

You can use map and 1..10 to create such an array, as others have said,
but this has the disadvantage of requiring all 10 elements be
precomputed (not a problem here, but it certainly would be one for
bigger lists).  What you really want is deferred creation, which will I
believe will be builtin for perl6, as described in
<http://dev.perl.org/rfc/81.pod>

I've also created a Tie::Array::Deferred module [not ready for general
release] which I will mail to anyone who wants, which implements
functionality similar to that listed in rfc81.

tie my @by_fours, "Tie::Array::Deferred", 0, 10000, 4;
tie my @by_fives, "Tie::Array::Deferred", sub { $_[0] * 5 }, 10000;
tie my @fib, "Tie::Array::Deferred",
	[1,1], sub { $_[1] + $_[2] }, 1000, "recursive";

-- 
I need more taglines. This one is getting old.


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

Date: Thu, 09 Aug 2001 22:37:28 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Can I make methods private/public?
Message-Id: <3B7348E8.5544272E@earthlink.net>

Ilya Martynov wrote:
> 
> t> Is there a way to change the visibility of a sub (method) in a
> t> package (class)?
> 
> Short answer: no
> 
> Long answer: if you really want it you can simulate private subs with
> private package variables:
> 
>     package SomePackage;
> 
>     my $private = sub {
>         ....
>     };
> 
>     sub public {
>         ....
>         $private->(@some_args);
>         ....
>     }

You can also use local.

package SomePackage;

local *private = sub {
	....
}
sub public {
	private(@some_args);
}
__END__

At the end of the file, the local *private goes out of scope, so it
dissapears from the namespace then;  Things outside of the package can't
see it.  Well, sort of -- if they're called from within public(), they
can see private().  Hmm, I suppose this isn't as good as I thought.

Well, if/when we can make lexical aliases, we'll be able to make true
private subroutines.  Ie, if and when someone changes my so I can do:

	my \$x = \$y;
	# This should be like "for my $x ($y) { ... }"
	# except within the current scope.

We'll almost surely also be able to do:

	my \&x = sub { ... };
	# like local *x = sub {...}, except that if we call
	# some other sub or method from here, it can't see $x.

Other useful things such syntax might allow:

	my \(@a, @b) = \( (1, 2, 3), (4, 5, 6) );
	my \($pi, $e) = \( atan2(1,0)*2, exp(1) );
	my \($a, $b, $c, $d) = \( @_ );

-- 
I need more taglines. This one is getting old.


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

Date: 9 Aug 2001 20:36:40 -0700
From: victor@t-net.net (Victor Araujo)
Subject: Can't Negate Regex /^8([0876])\1\d+$/
Message-Id: <d5f0afba.0108091936.c9ec076@posting.google.com>

I am trying to negate the following regex which I am using
to filter toll free numbers. The regex seems to work fine as
is but when I try to negated it won't work.

$regex =~ /^8([0876])\1\d+$/;

even though I have tried many different combinations like

/^[^8([0876])\1]\d+$/
/^[^8([0876])]\1\d+$/

I can't get it to work properly. Any help is welcome.


--------------------------------------------------------------------------------
Victor Araujo


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

Date: 10 Aug 2001 03:57:34 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Can't Negate Regex /^8([0876])\1\d+$/
Message-Id: <9kvm3e$k81$3@bob.news.rcn.net>

Victor Araujo <victor@t-net.net> wrote:
> I am trying to negate the following regex which I am using
> to filter toll free numbers. The regex seems to work fine as
> is but when I try to negated it won't work.

> $regex =~ /^8([0876])\1\d+$/;

Just change the =~ to !~ (note that this works because your regex is 
anchored at both ends and therefore covers the entire string you're trying 
to match.  You have to be careful when inverting the sense of the match 
operator if your regex can match only a portion of the target string).

> even though I have tried many different combinations like

> /^[^8([0876])\1]\d+$/
> /^[^8([0876])]\1\d+$/

You can't use a character class to match a multi-character pattern; I 
suggest you (re)read perlre.


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

Date: Thu, 09 Aug 2001 20:50:17 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Can't Negate Regex Nor Willing To Help Myself
Message-Id: <3B7359F9.ED3CD73D@stomp.stomp.tokyo>

Victor Araujo wrote:
 
> I am trying to negate the following regex which I am using
> to filter toll free numbers. The regex seems to work fine as
> is but when I try to negated it won't work.
 
> $regex =~ /^8([0876])\1\d+$/;
 
> even though I have tried many different combinations like
 
> /^[^8([0876])\1]\d+$/
> /^[^8([0876])]\1\d+$/
 
> I can't get it to work properly. Any help is welcome.


http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html#perlfaq6_Regexps_Revision_1



Godzilla!


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

Date: 9 Aug 2001 18:31:36 -0700
From: jjchen@alumni.ice.ntnu.edu.tw (wade)
Subject: Re: CGI.pm --> open FILE,">>file.txt";
Message-Id: <4259465b.0108091731.e73294b@posting.google.com>

ebohlman@omsdev.com (Eric Bohlman) wrote in message news:<9kv4fu$54g$4@bob.news.rcn.net>...
> Stephen Edelblut <viper16336@mindspring.com> wrote:
> > My cgi script saves data entered on a form to file.txt (using CGI.pm). It
> > works fine, but it only sends it to /cgi_bin/file.txt where the cgi script
> > is located. I want it to send it to a file.txt in my root directory (or some
> > other folder other that my cgi_bin directory). The code I'm using is:
> > open FILE,">>file.txt";
> > How do I change ">>file.txt" if I want it to open
> > www.mysite.com/textfile/file.txt? Currently file.txt is in my cgi_bin
> > directory. Whatever I try never works.
> 
> You find out what actual *directory* the *URL* you gave maps to, and then 
> include its path in the filename.  Remember that URLs are *not* filesystem 
> paths.

Note that subdirectory's permition...
1. the "User", "Group" in apache's config file(EX: /etc/httpd/conf/httpd.conf)
2. use chown/chmod to change the permition.


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

Date: Fri, 10 Aug 2001 03:47:55 GMT
From: Dan Baker <dan@nospam_dtbakerprojects.com>
Subject: compare Net::FTP and LWP ?
Message-Id: <3B7359B0.74B83CD8@nospam_dtbakerprojects.com>

I am trying to decide which module to start experimenting with to code a
web-driven administrative interface that will be used to "sync" files
from a local PC to a remote domain. I am having trouble determining
which module would be best for:
- getting the file info to determine last_modified dates
- pushing files from local PC to remote domain
- (possibly) pulling new files from remote domain to local PC

Can someone give an overview of what factors might be important in
determining to use one over the other? Or some other module that might
be better suited?

thanx,

D


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

Date: Thu, 09 Aug 2001 19:09:54 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Comparing data in two different files
Message-Id: <3B734272.E767081F@stomp.stomp.tokyo>

shaz wrote:
 
> I have a program which reads in some a txt file and counts each word.
> There are some words which I do not want counted. I have put these into a
> seperate file (called list.txt).
 
> I have created a hash, called %words which contains $word and $no.
 
> How do I change the code below to remove all the words in the hash, which
> are also present in the list.txt file?
 

Posted through  inktomi2-car.server.ntl.com  via google.com
using a yahoo email address. Such a surprise.


Below my signature you will find two rogue methods.

   length ($_) + 1

This use of plus one from my substring code, clears excess spaces.


Godzilla!
--
Watch word wrap. My longer lines should be one line.

TEST SCRIPT:
___________

#!perl


$list_to_clean = "Sissified Geeks Do Not Godzilla Rocks And Rolls! Sissified Geeks Do Not";
@Unwanted_Words = qw (Sissified Geeks Do Not);

for (@Unwanted_Words)
 {
  do
   { substr ($list_to_clean, index ($list_to_clean, $_), length ($_) + 1, "") }
  until (index ($list_to_clean, $_) == -1);
 }

print $list_to_clean;


print "\n\n";


@List_To_Clean = qw (Sissified Geeks Do Not Godzilla Rocks And Rolls! Sissified Geeks Do Not);
$unwanted_words = "Sissified Geeks Do Not";

$original_array = $#List_To_Clean;

for ($iterate = 0; $iterate <= $original_array; $iterate++)
 {
  $_ = shift (@List_To_Clean);
  if (index ($unwanted_words, $_) == -1)
   { push (@List_To_Clean, $_); }
 }

print "@List_To_Clean";


exit;

PRINTED RESULTS:
________________

Godzilla Rocks And Rolls!

Godzilla Rocks And Rolls!


BENCHMARK TESTS:
________________

#!perl

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

use Benchmark;

print "Run One:\n\n";
&Time;

print "\n\nRun Two:\n\n";
&Time;

print "\n\nRun Three:\n\n";
&Time;


sub Time
 {
  timethese (100000,
  {

   'name1' =>
   '$list_to_clean = "Sissified Geeks Do Not Godzilla Rocks And Rolls! Sissified Geeks Do Not";
    @Unwanted_Words = qw (Sissified Geeks Do Not);
    for (@Unwanted_Words)
     {
      do
       { substr ($list_to_clean, index ($list_to_clean, $_), length ($_) + 1, "") }
      until (index ($list_to_clean, $_) == -1);
     }',

   'name2' =>
   '@List_To_Clean = qw (Sissified Geeks Do Not Godzilla Rocks And Rolls! Sissified Geeks Do Not);
    $unwanted_words = "Sissified Geeks Do Not";
    $original_array = $#List_To_Clean;
    for ($iterate = 0; $iterate <= $original_array; $iterate++)
     {
      $_ = shift (@List_To_Clean);
      if (index ($unwanted_words, $_) == -1)
       { push (@List_To_Clean, $_); }
     }',

  } );
 }

exit;


PRINTED RESULTS:
________________

Run One:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  5 wallclock secs ( 4.72 usr +  0.00 sys =  4.72 CPU) @ 21186.44/s
 name2:  9 wallclock secs ( 8.13 usr +  0.00 sys =  8.13 CPU) @ 12300.12/s


Run Two:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  4 wallclock secs ( 4.72 usr +  0.00 sys =  4.72 CPU) @ 21186.44/s
 name2:  7 wallclock secs ( 8.18 usr +  0.00 sys =  8.18 CPU) @ 12224.94/s


Run Three:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  5 wallclock secs ( 4.73 usr +  0.00 sys =  4.73 CPU) @ 21141.65/s
 name2:  8 wallclock secs ( 8.24 usr +  0.00 sys =  8.24 CPU) @ 12135.92/s


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

Date: Fri, 10 Aug 2001 01:38:41 GMT
From: "AB" <aaronb@spamcop.net>
Subject: error/question concerning MIME::Lite::HTML
Message-Id: <BWGc7.6649$JK4.1719055544@newssvr15.news.prodigy.com>

I am trying to use MIME::Lite::HTML but am receiving an error when I run my
program. I am trying to feed the module a variable, but it won't accept it.

It is supposed to be set up like example at the botom of this email (this is
straight from the docs), I am trying to feed it an email address in the form
of $emailAddy  (where I have already set the variable equal to an email
address). So instead of

 To       => 'alian@saturne', ---------------   as it is below, I would like
to use


To   => '$emailAddy',

But when I do that I get the following error

"Reference found where even-sized list expected at
/usr/lib/perl5/site_perl/5.005/MIME/Lite.pm line 917, <GEN0> chunk 33.
No recipient addresses found in header"

Does anybody have any ideas? I am not familiar with object oriented
programing, so this is quite cryptic to me. I would like to be able to feed
the module email addresses using some type of variable scheme. I am parsing
the email addresses from a file.

Thank you!

Aaron Bazar




  use MIME::Lite::HTML;


  my $mailHTML = new MIME::Lite::HTML
     From     => 'MIME-Lite@alianwebserver.com',
     To       => 'alian@saturne',
     Subject => 'Mail in HTML with images';


  $MIMEmail = $mailHTML->parse('http://www.alianwebserver.com');
  $MIMEmail->send; # or for win user : $mail->send_by_smtp('smtp.fai.com');


--
Aaron B.
http://www.cauce.org (help stop spam)




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

Date: Fri, 10 Aug 2001 12:07:54 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: error/question concerning MIME::Lite::HTML
Message-Id: <ImHc7.19$ZG3.59451@news.interact.net.au>


"AB" <aaronb@spamcop.net> wrote in message
news:BWGc7.6649$JK4.1719055544@newssvr15.news.prodigy.com...
> I am trying to use MIME::Lite::HTML but am receiving an error when I run
my
> program. I am trying to feed the module a variable, but it won't accept
it.
>
> It is supposed to be set up like example at the botom of this email (this
is
> straight from the docs), I am trying to feed it an email address in the
form
> of $emailAddy  (where I have already set the variable equal to an email
> address). So instead of
>
>  To       => 'alian@saturne', ---------------   as it is below, I would
like
> to use
>
>
> To   => '$emailAddy',
>
> But when I do that I get the following error
>
> "Reference found where even-sized list expected at
> /usr/lib/perl5/site_perl/5.005/MIME/Lite.pm line 917, <GEN0> chunk 33.
> No recipient addresses found in header"
>
> Does anybody have any ideas? I am not familiar with object oriented
> programing, so this is quite cryptic to me. I would like to be able to
feed
> the module email addresses using some type of variable scheme. I am
parsing
> the email addresses from a file.

Nothing to do with oo programming and everything to do with quotes.  Use "
instead of '




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

Date: Thu, 09 Aug 2001 21:33:12 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: HTPASSWD
Message-Id: <3B7339D8.B14670F1@earthlink.net>

Sebastian Young wrote:
> 
> This is the script:
> 
>   @abc = (a..z, A..Z, 0..9);
>   srand;
>   s/(.*)=(.+?)$/$2/;
>   $cryptpass = crypt($input{'password'}, $abc[rand(@abc)].$abc[rand(@abc)]);
> 
>   open (htpasswd, ">.htpasswd");
>       print htpasswd "$acnum:$cryptpass\n";
>     }
>   close (htpasswd);
> 
> It's generating the correct password that can be read by .htaccess but I'm
> getting those black squares, which are stopping the htaccess file from
> reading the htpasswd file correctly.

First, this is not a complete program; show us a small, complete, perl
program which demonstrates what you want to do, and the problem you
have when running it -- specifically, show the resulting file, too.

Second, write your code such that it runs with -w and 'use strict' 

-- 
I need more taglines. This one is getting old.


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

Date: Thu, 9 Aug 2001 22:35:35 +0100
From: "Stephen Edelblut" <viper16336@mindspring.com>
Subject: I need help with one last thing.
Message-Id: <9kvl2n$1ga$1@slb4.atl.mindspring.net>

My form works, all I need it to do is after it loads the cgi file it:
open FILE,">>../www/file.txt";
print FILE "$name: $message\n";
close FILE;

print $q->header("text/html"),
$q->start_html("results"),
$q->p("Done."),
$q->end_html;

displays "done". How do I get it to redirect the window to my 'file.txt'? It
wont work if I use regular html. Thanks




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

Date: Thu, 9 Aug 2001 20:57:14 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: looking for script to edit config variables
Message-Id: <slrn9n6cba.tn3.tadmc@tadmc26.august.net>

Dale Henderson <projectobjects@earthlink.net> wrote:

>Looking for 


Please use a search engine for searching.

This here is a newsgroup, not a search engine.


>module or open source script that can edit config variables from
>a file in the following format -
>
>$varname = "value";


Perl FAQ, part 5:

   "How do I change one line in a file/delete a line in a
    file/insert a line in the middle of a file/append to the
    beginning of a file?"


If you are having trouble _writing_ a Perl program to do what
you want, then post a question about it here. (code would be
good too)


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


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

Date: Thu, 9 Aug 2001 20:58:39 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: looking for script to edit config variables
Message-Id: <slrn9n6cdv.tn3.tadmc@tadmc26.august.net>

Dale Henderson <projectobjects@earthlink.net> wrote:
>Looking for module or open source script that can edit config variables from
>a file in the following format -
>
>$varname = "value";


   perl -p -i -e 's/"value"/"some other value"/' config.file


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


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

Date: Fri, 10 Aug 2001 03:37:53 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: NET::SSH, NET::FTP, NET::POP3 (how to detect)
Message-Id: <slrn9n6log.6qj.see-sig@typhoon.xnet.com>

On Thu, 09 Aug 2001 16:06:54 -0700, William Crites <wcrites@cis.ctc.edu> wrote:
> I want to know how to detect the service/activity/status that has SSH,
> FTP, POP3 remotely. It is for monitoring purpose that I want to make
> sure they are up instead down.   One major problem I have, I don't want
> to use account or authentication in my own program.
> 
> Please reply back email back to me too in case because I plan to taking
> a week vacation starts Saturday.

Determining whether sshd, ftpd or pop3d are up and running does not even
require those modules (which you show with improper case).  It can be done
with the Socket module (or maybe IO::Socket) by simply opening a port to
the socket and grabbing one line from it.  See perldoc perlipc.  For
example on my box this is what they return:

ssh:
SSH-1.99-OpenSSH_2.9p1

ftp:
220 ProFTPD 1.2.2rc2 Server (powered by SuSE Linux) [compaq.localdomain]

pop3 (I don't do pop3):
Connection refused! (value of $! when it dies opening the socket)

-- 
David Efflandt  (Reply-To is valid)  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: Fri, 10 Aug 2001 12:28:10 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: permuting extremely large string
Message-Id: <5IHc7.1888$813.100366@ozemail.com.au>

Les

See below.

--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html

Les Ander <citykid@nospam.edu> wrote in message news:Pine.LNX.4.33.0108091115180.2586-100000@schewanella.stanford.edu...
> Hi,
> i need to permute a string which is about 4 Mb!
> I experience  memory problems if i convert it to an array (the program
> crashes). So I need to permute the string inplace without converting
> it into an array.

See chapter 7 of

Combinatorial Algorithms
A. Nijenhuis and H. S. Wilf
Academic Press
0-12-519260-6







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

Date: Thu, 09 Aug 2001 20:24:54 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: permuting extremely large string
Message-Id: <3B735406.6A16FD5F@stomp.stomp.tokyo>

John W. Krahn wrote:
 
> Les Ander wrote:

(snipped a lot)

> > i need to permute a string which is about 4 Mb!

> I don't know if this is faster but it's shorter.
 
> sub perm_string {
>     my $str_ref = shift;
>     my $len = length $$str_ref;


You need to add  $$str_ref = \$str_ref  in an appropriate
code line position. Doing this just might enable your code
to work correctly rather than producing all zeroes and
no references. Use of shift @_ would be helpful as well.

For the originating author, the same save for shift @_ as above.


It is prudent to test code before posting.


Godzilla!  Queen Of Xyroes.
--

#!perl

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


print "Original Author Method:\n\n";

@_ = qw (G o d z i l l a R o c k s!);

my $str_ref=shift @_;
my $len=length $$str_ref;
for (1 .. 5)
 {
  my $start=int rand($len-1);
  my $size=int rand($len-$start-1);
  my $temp_str=substr($$str_ref, $start,$size);
  substr($$str_ref, $start, $size)='';
  $$str_ref.=$temp_str;

  print "Start: $start\nSize: $size\nLength: $len\nStr Ref: $$str_ref\n";
 }


print "\n\nJohn Krahn Method:\n\n";

@_ = qw (G o d z i l l a R o c k s!);

my $str_ref = shift @_;
my $len = length $$str_ref;
for ( 1 .. 5 ) 
 {
  my $start = int rand( $len - 1 );
  my $size = int rand( $len - $start - 1 );
  substr( $$str_ref, $len - $size, 0 ) = substr( $$str_ref, $start, $size, '' );

  print "Start: $start\nSize: $size\nLength: $len\nStr Ref: $$str_ref\n";
 }


print "\n\nGodzilla Method:\n\n";

@_ = qw (G o d z i l l a R o c k s!);

my $str_ref = shift @_;
my $$str_ref = \$str_ref;
my $len = length $$str_ref;
for ( 1 .. 5 ) 
 {
  my $start = int rand( $len - 1 );
  my $size = int rand( $len - $start - 1 );
  substr( $$str_ref, $len - $size, 0 ) = substr( $$str_ref, $start, $size, '' );

  print "Start: $start\nSize: $size\nLength: $len\nStr Ref: $$str_ref\n";
 }




PRINTED RESULTS:
________________

Original Author Method:

Start: 0
Size: 0
Length: 0
Str Ref: 
Start: 0
Size: 0
Length: 0
Str Ref: 
Start: 0
Size: 0
Length: 0
Str Ref: 
Start: 0
Size: 0
Length: 0
Str Ref: 
Start: 0
Size: 0
Length: 0
Str Ref: 


John Krahn Method:

Start: 0
Size: 0
Length: 0
Str Ref: 
Start: 0
Size: 0
Length: 0
Str Ref: 
Start: 0
Size: 0
Length: 0
Str Ref: 
Start: 0
Size: 0
Length: 0
Str Ref: 
Start: 0
Size: 0
Length: 0
Str Ref: 


Godzilla Method:

Start: 13
Size: 0
Length: 17
Str Ref: SCALAR(0x1a8f180)
Start: 12
Size: 1
Length: 17
Str Ref: SCALAR(0x1a8180)f
Start: 11
Size: 0
Length: 17
Str Ref: SCALAR(0x1a8180)f
Start: 4
Size: 9
Length: 17
Str Ref: SCAL80)fAR(0x1a81
Start: 3
Size: 1
Length: 17
Str Ref: SCA80)fAR(0x1a81L


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

Date: 10 Aug 2001 01:09:52 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: q: converting strings
Message-Id: <997405793.366820@elaine.furryape.com>

In article <3B72EA5D.C25BD194@acm.org>, John W. Krahn <krahnj@acm.org> wrote:
>Tad McClellan wrote:
>> For a significant portion of the world's population, that does not
>> look like a number.
>> 
>> "12" looks like a number in (nearly?) all the world.
>
>Except in Egypt (and other arabic countries?) where the numerals are
>completely different.

Far more than you need to know follows...

Until 771 the Egyptians, Greeks, Romans and other cultures used numerals
similar to Roman numerals, where each symbol had a fixed value, eg
I for 1 and C for 100.

In India, Starting at about 250 BCE, a new method evolved, and in the
8th C this method was transmitted to the Arabic world, possibly through
an Indian Scholar who travelled to Baghdad in 771.

The new idea was the idea of using symbols where their value depended
on the position, eg 1 means both 1 or 100, depending on the column.

There were two seperate sets of gymphs used at this time, called
'East Arabic' and 'West Arabic'

In the 10th C, an Arabic paper was translated into Spanish, and
the new method of counting was called in the west 'Arabic numerals',
though it took until the 16th C before Europe fully adopted the new
method. The paper used the West Arabic numerals, and thus Europe
adopted gymphs very similar to the West Arabic numerals.

With the colonization efforts of the 18th and 19th C, Europeans
spread their culture into much of the world, which is where
the rest of the world picked up it's use of Arabic numbers.

Modern West Arabic and East Arabic now use similar gymphs for
some characters:

West          East
2             Similar to 2
3             Similar to 3
4             Similar to 5
8             Similar to 4
0             0

In addition, the East Arabic gymph for 6 looks like a reversed 3,
8 looks like a 2 rotated through 180 degrees, and 9 looks like
a S.


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

Date: Fri, 10 Aug 2001 03:27:06 GMT
From: Dan Baker <dan@nospam_dtbakerprojects.com>
Subject: Re: Sending e-mail from a script in MS windows
Message-Id: <3B7354CF.2A6D8260@nospam_dtbakerprojects.com>



Tintin wrote:
(snip...)
> > This was a while ago.... I don't remember any error messages, just that
> > CC and BCC addresses never got sent any mail in my tests. In the
> > specific case I was doing I only needed to send to 2 addresses, so i
> > just looped and didn't spend any more time trying to figure it out.
> 
> You must have been using MIME::Lite quite a while ago.  The Change log
> mentions:
> 
> Version 1.140 (2000/04/27)
> Fixed bug in support for "To", "Cc", and "Bcc" in send_by_smtp(): multiple
> (comma-separated) addresses should now work fine. We try real hard to
> extract addresses from the flat text strings. Thanks to John Mason for
> motivating this change.
---------

this looks like the most plausible reason. On the pc I pulled the module
from ActiveState in 08/00, but the version number I see in the code is
2.102 which looks like the Cc and BCC issue *should* have been fixed in
the previous patch. Like I said I really am not sure, but it might be a
problem only when sending with SMTP rather than the more popular
sendmail. I will check for a newer version and retest one of these days.

D


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

Date: Fri, 10 Aug 2001 02:06:44 GMT
From: "Mark W. Dufault" <mdufault@dynamicservers.com>
Subject: use module.pm on NT Platform
Message-Id: <UkHc7.231302$v5.23811253@news1.rdc1.ct.home.com>

I was trying to use the statement:

use ping

I get compiling errors because it looks in C:\perl\lib and c:\perl\site\lib
The module is in C:\perl\lib\net  ping.pm
The error is reported with the unix type slashes for the path and I have not
been able to come up with
the right combination for it to work. I tried the command
line -MC:\perl\lib\net to no luck

Anyone know how to do this?
Thanks,
Mark




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

Date: Thu, 9 Aug 2001 22:07:54 -0500
From: "Chas Friedman" <friedman@math.utexas.edu>
Subject: Re: use module.pm on NT Platform
Message-Id: <3b7352bd_2@feed1.realtime.net>


Mark W. Dufault <mdufault@dynamicservers.com> wrote in message
news:UkHc7.231302$v5.23811253@news1.rdc1.ct.home.com...
> I was trying to use the statement:
>
> use ping
>
> I get compiling errors because it looks in C:\perl\lib and
c:\perl\site\lib
> The module is in C:\perl\lib\net  ping.pm
> The error is reported with the unix type slashes for the path and I have
not
> been able to come up with
> the right combination for it to work. I tried the command
> line -MC:\perl\lib\net to no luck
>
> Anyone know how to do this?
> Thanks,
> Mark
>
Try
use Net::Ping;
(Don't forget the ; )
               cf




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

Date: Fri, 10 Aug 2001 03:18:21 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: use module.pm on NT Platform
Message-Id: <3B7352C1.910EEBAB@rochester.rr.com>

"Mark W. Dufault" wrote:
> 
> I was trying to use the statement:
> 
> use ping

That's:

   use Net::Ping;

The module is a standard module, and should already be preinstalled on
your hard drive.

> 
> I get compiling errors because it looks in C:\perl\lib and c:\perl\site\lib
> The module is in C:\perl\lib\net  ping.pm

Surely you mean C:\Perl\lib\Net\Ping.pm ?

> The error is reported with the unix type slashes for the path and I have not
> been able to come up with
> the right combination for it to work. I tried the command
> line -MC:\perl\lib\net to no luck

-M is a command-line-switch version of use, and specifies a module name
-- it is not a method of adding a path to @INC.  Maybe -I is what you
are thinking of?

> 
> Anyone know how to do this?

If you really want to add a path to @INC, 

     use lib '/path/to/library';

is one way.  But referring to the module name given in the docs
(Net::Ping) works better and is much easier.  And in the case of
standard modules, adding extra standard directories to @INC is
ill-advised (probably won't work, at least for most of them).
 ...
> Mark
-- 
Bob Walton


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

Date: Fri, 10 Aug 2001 11:06:15 +0800
From: "Just in" <justin.devanandan.allegakoen@intel.com>
Subject: || or OR
Message-Id: <9kvj39$o2@news.or.intel.com>

Hello,

I remember reading somewhere that doing this :-

Some logic || die Some error

has a different effect than this (if it fails for the logic):-

Some logic OR die Some error

If I remember correctly the precedence of  the || operator will be
prioritised
over the OR, and for this alone it is better to use the OR.

Does it depend on the logic you're executing? What if you're doing an open
file?

perlop talks about control flow, but I didnt understand . . .




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

Date: Thu, 9 Aug 2001 21:46:45 -0600
From: "bowman" <bowman@montana.com>
Subject: Re: || or OR
Message-Id: <JOIc7.267$Kx4.159869@newsfeed.slurp.net>


"Just in" <justin.devanandan.allegakoen@intel.com> wrote in message
news:9kvj39$o2@news.or.intel.com...
>
> If I remember correctly the precedence of  the || operator will be
> prioritised
> over the OR, and for this alone it is better to use the OR.

while the difference in precedence can be useful, imnsho a few parens
discretely spread around are a lot handier than remembering precedence
rules, especially if you program in more than one language.




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

Date: 10 Aug 2001 03:49:52 GMT
From: trammell@bayazid.hypersloth.invalid (John J. Trammell)
Subject: Re: || or OR
Message-Id: <slrn9n64mg.4qe.trammell@haqq.hypersloth.net>

On Fri, 10 Aug 2001 11:06:15 +0800, Justin wrote:
> Hello,
> 
> I remember reading somewhere that doing this :-
> 
> Some logic || die Some error
> 
> has a different effect than this (if it fails for the logic):-
> 
> Some logic OR die Some error
[snip]

A good article on this is available at perl.plover.com; look for
"Precedence Problems".

Good luck!

-- 
Just Another Perl Hacker.


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

Date: 10 Aug 2001 03:49:14 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: || or OR
Message-Id: <9kvljq$k81$2@bob.news.rcn.net>

Just in <justin.devanandan.allegakoen@intel.com> wrote:
> I remember reading somewhere that doing this :-

> Some logic || die Some error

> has a different effect than this (if it fails for the logic):-

> Some logic OR die Some error

> If I remember correctly the precedence of  the || operator will be
> prioritised
> over the OR, and for this alone it is better to use the OR.

> Does it depend on the logic you're executing? What if you're doing an open
> file?

It depends on what's in the "some logic."  To take the example of opening 
a file,

open(FILE,"myfile") or die $!;

and

open(FILE,"myfile") || die $!;

are identical, because the parentheses determine the precedence.

open FILE,"myfile" or die $!;

is identical to the above, but

open FILE,"myfile" || die $!;

is incorrect, because it's parsed as if it were

open(FILE,("myfile" || die($!)));

which, during compilation, gets translated the same as

open(FILE,"myfile");

because the compiler can see that the first term of the || expression will 
always be true and therefore the || operator will always short-circuit and 
the die() will never be reached.




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

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


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