[8609] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2226 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 1 15:07:28 1998

Date: Wed, 1 Apr 98 12:00:27 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 1 Apr 1998     Volume: 8 Number: 2226

Today's topics:
    Re: Automate Telnet Keystrokes <dfetter@shell4.ba.best.com>
        Complicated RegExp help (Mike Binkley)
    Re: Date manipulations? (felix k sheng)
    Re: Diddling with search engines via CGI <rootbeer@teleport.com>
        Error with Config.pm <dtwebb@encoredev.com>
        Fetching SSL pages chenw@dime.com
    Re: File Missing (Stuart McDow)
    Re: File::Find vs. File::Recurse (was Re: file trees) (Peter Scott)
    Re: File::Find vs. File::Recurse (was Re: file trees) <jdf@pobox.com>
        fork() and out-of-contol memory "leak": help! cabel@panic.com
        Forking/Children/Data <pat@weslink.ca>
    Re: How to read from keyboard without enter? (John Klassa)
    Re: newbie question:how to embed perl in html <karld@feklore.demon.co.uk>
    Re: newbie question:how to embed perl in html (Michael J Gebis)
        password input <rgoldber@eb.com>
    Re: problem to exec a "c:\Program Files\.." command on  <jdf@pobox.com>
    Re: problem to exec a "c:\Program Files\.." command on  (Gene Kaufman)
    Re: Question about Perl script and form submit buttons  <andrew@boothman.easynet.co.uk>
        REQ: algorithm for DES::encrypt/decrypt of text strings <Richard.Schofield@fmr.com>
        s/PATTERN/<how to concat here>/g <Robert.Lopez@abq.sc.philips.com>
    Re: s/PATTERN/<how to concat here>/g <jdf@pobox.com>
    Re: s/PATTERN/<how to concat here>/g <jim.michael@gecm.com>
    Re: s/PATTERN/<how to concat here>/g <jim.michael@gecm.com>
    Re: sending mail using perl (John Stanley)
    Re: Someone put my munged e-mail address on a spam list <seth@e-zcomputers.com>
    Re: Someone put my munged e-mail address on a spam list (John Stanley)
    Re: Sorting a Delimeted Text File? <rootbeer@teleport.com>
        String Manipulation Question <hayward@auracom.com>
    Re: Trouble with shebang line ... <jefpin@bergen.org>
        What modules are available on *your* computer. <jdf@pobox.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 1 Apr 1998 19:42:19 GMT
From: David Fetter <dfetter@shell4.ba.best.com>
Subject: Re: Automate Telnet Keystrokes
Message-Id: <6fu5ar$l90$1@nntp1.ba.best.com>

Joel Susser <Susser.Joel@ic.gc.ca> wrote:
> Hi,

> I'm looking for a way to automate the process of loging into another
> server with telnet and entering a series of keystrokes.  Some of the
> keystrokes will be variable coming from a file. One of the keystrokes is

> a <tab>.  Preferrably from my Linux Box.

> I'm currently using a pc running Windows 3.1 to do this with a macro
> language called Symatic Basic but after a hundred records the thing
> craps out because of a memory leak.

> Any help on this would be very much appreciated.

Try Net::Telnet or perl's Expect module :)

-- 
            David Fetter         888 O'Farrell Street Apt E1205
   shackle@ren.glaci.com          San Francisco, CA 94109-7089 USA
  http://www.best.com/~dfetter     +1 415 567 2690 (voice)
print unpack ("u*",q+92G5S="!!;F]T:&5R(%!E<FP@2&%C:V5R"@``+)

To fight and conquer in all our battles is not supreme excellence;
supreme excellence consists in breaking the enemy's resistance
without fighting.
                                       Sun-tzu
                                       The Art of War


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

Date: Wed, 01 Apr 1998 13:41:48 -0600
From: Zena_Goddess_Of_Fire@mindless.com (Mike Binkley)
Subject: Complicated RegExp help
Message-Id: <Zena_Goddess_Of_Fire-0104981341480001@magmysmac.lfc.edu>

Okay, I have some perl code that I want to clean up:


(note, this is actually done in a while loop from a text file, I'm just
assigning $_ a value here for simplicity's sake)


@tokens =  qw ( -- ( ) +  * / { } := .. .random. .in. to for  endloop 
   read write ## >= <= declare set integer ; , if then else fi - var cnst 
   < > = # loop end);

$_  = "this is an dendloop  endloop loop john.in.marc{.in.loop4 4:= 3+ 2test<=<5
      --hi there this is a comment";

for ($k = 0; $k < $#tokens - 8; $k++){
         if ($tokens[$k] !~ /[^a-z]/){
            $_ =~ s/([^a-z])\Q$tokens[$k]\E([^a-z])/ $tokens[$k] /g;
         }
         else {
            $_ =~ s/\Q$tokens[$k]\E/ $tokens[$k] /g;
         };
      };
      $_ =~ s/([^:<>])=/$1 = /g;
      $_ =~ s/>([^=])/ > $1 /g;
      $_ =~ s/<([^=])/ < $1 /g;
      $_ =~ s/([^end])loop/$1 loop /g;
      $_ =~ s/([^-])-([^-])/$1 - $2/g;
      $_ =~ s/([^#])#([^#])/$1 # $2/g;
      $_ = "\L$_";
      $_ =~ s/(--.*)//; 
   (@line) = (split);

Now this does exactly what I want it to do, namely it runs through the
string and puts spaces around all of the elements of the @tokens array
(hence forth referred to as "tokens"), except for the "--" token, which is
a comment so everything after and including a "--" should just be removed
from the string.

But it obviously isn't very pretty code.

So I've been trying to clean it up.  Currently, I'm working with this:

   foreach $value (@tokens){ $string =~ s/\b\Q$value\E\b/$1 $value $2/g};

But this doesn't quite do it. For example, running it on the string above
($_) produces this output:

this is an dendloop   endloop   loop  john .in. marc{.in.loop4 4:= 3+ 2test<=<5 

which is obviously not placing the spaces around the {, the second .in.,
the :=, the +, or the <= and <

So what can i do to fix this?

What I do know:
   in the case of the {, I'm pretty sure it's not working because the { is 
   followed by a ., so there's no \b and hence the regex fails.  Changing the 
   code to:

      $string =~ s/(\b|\W)\Q$value\E(\b|\W)/$1 $value $2/g;

   will correct this error, but it introduces the new problem of adding spaces
   between the : and = as well as the < and = (they should stay := and <=)


In case it isn't completely clear what I'm doing, I'm trying to run
through a string and put spaces around the tokens as long as they're
required.  For example, "dendloop" is a variable name and hence is not
considered a token, so it should _not_ turn into "d endloop ". The same
for "endloop4" or "45endlooplooploop" orany other alphanumeric token +
some other alphanumeric characters, keeping in mind that I need to be
careful of (for example) having "endloop" then looking for a "loop" and
accidentally turning the "endloop" into "end loop " when it should have
really been left alone.

If a token contains non alphanumeric characters, I'm going to want to
space it out from everything else so that "4:=5" turns into "4 := 5" and
so forth, keeping in mind that I need to be careful of (for example)
having "<=" then looking for a "=" and accidentally turning the "<=" into
"< = " when it should have really been left alone.

In terms of really short code, I'm pretty sure that something along these
lines would work:

   foreach $value (@tokens){ 
      $string =~ s/\b\Q$value\E(\b| (sometoken such that $value.sometoken is
         not another token itself))/$1 $value $2/g;
   };

But I don't know how to code this in properly.  If anybody has any ideas
as to how to get this specific code to work, or any other ideas as to how
to do this thing more elegantly, it would be much appreciated.

Sorry for the length of the post, but I wanted to be thorough.  :*)


-Bink.


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

Date: 1 Apr 1998 17:44:20 GMT
From: felix@chance.em.nytimes.com (felix k sheng)
Subject: Re: Date manipulations?
Message-Id: <slrn6i4v1k.qui.felix@chance.em.nytimes.com>

On 30 Mar 1998 23:39:40 GMT, Burt Lewis <burt@ici.net> wrote:
>I need to determine 2 dates based on today's date. 
>
>The first date I need to know is the prior Saturday and the 
>second date I need is the subsequent Saturday.
>
>My feeble attempt:
>
>if ($today eq "Monday")
>{
>$sata = ($mday -2);
>$satb = ($mday + 5);
>}
>if ($today eq "Tuesday")
>{
 ...
   
hello,

assuming that you have the unix time of the starting date (if it is
always today then you are set with time() ), you can use something
like this to give you the unix time for the previous and next dates.
given any arbitrary target date (in this case saturday):

#we are working in numeric day of week as returned by localtime
#thus we go from 0-6/sun-sat

$targ = 6;               #sat
$today = (localtime)[6]; #today

$diff = $targ - $today;
if( $diff >= 0 ) {
   $postOffset = $diff;
   $preOffset  = $diff - 7;
} else {
   $preOffset = $diff;
   $postOffset  = 7 + $diff;
}

$oneday = 60 * 60 * 24;

print "today: ";
print scalar localtime();
print "\nlast sat: ";
print scalar localtime(time + ($oneday * $preOffset));
print "\nnext sat: ";
print scalar localtime(time + ($oneday * $postOffset));

i think that should work. let me know if that helps, or doesn't work.

'lx



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

Date: Wed, 1 Apr 1998 09:46:43 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: John Russell <john13@interlog.com>
Subject: Re: Diddling with search engines via CGI
Message-Id: <Pine.GSO.3.96.980401094530.496C-100000@user1.teleport.com>

On Wed, 1 Apr 1998, John Russell wrote:

> - Is there a method to make the search engines return very long lists
> of results rather than a set of small pages with "next" links?  Which
> search engines are best or worst in this regard?

This has nothing to do with Perl.

> - Do all search engines use CGI-friendly ?-encoded URLs for their
> query results?

This has nothing to do with Perl.

> - Is there reusable code specifically for working with search engine
> results 

Yes, check out the Modules list on CPAN. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 01 Apr 1998 19:43:46 GMT
From: "DW" <dtwebb@encoredev.com>
Subject: Error with Config.pm
Message-Id: <SNwU.1575$SK2.12596961@news1.jacksonville.net>

I just installed PERL5.004 and when running my perl script I get the
following message:

Can't locate Config.pm in @INC (@INC contains:
/usr/local/lib/perl5/sun4-solaris/5.00401 /usr/local/lib/perl5 /usr
/local/lib/perl5/site_perl/sun4-solaris /usr/local/lib/perl5/site_perl .) at
/usr/local/lib/perl5/DynaLoader.pm li
ne 18.
BEGIN failed--compilation aborted at restartSSJS.pl line 4.

The thing is Config.pm does exist and in
/usr/local/lib/perl5/sun4-solaris/5.00401 which is one of the directories in
@INC.

Any clue as to why this message appears?

Please reply via email to dtwebb@encoredev.com

Thanks,
Dave Webb




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

Date: Wed, 01 Apr 1998 13:22:01 -0600
From: chenw@dime.com
Subject: Fetching SSL pages
Message-Id: <6fu3vc$e44$1@nnrp1.dejanews.com>

I'm managing an intranet site.  To make my life easiler, I usually have a
perl program go out and fetch other website and put them on our intranet site
as if coming from our intranet server.  Now things are getting more challenge
when i need to fetch SSL pages which are using https header. I want to know
if there are any way to using perl or any method to fetch web pages from SSL
sites???

Please Help!!!

KEn

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 1 Apr 1998 17:48:23 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: File Missing
Message-Id: <6ftul7$6ng$1@ns1.arlut.utexas.edu>

gorilla@elaine.drink.com (Alan Barclay) writes:
> 
> No, this is the wrong approach. You are leaving yourself open to
> race conditions here

Good point. I usually never have to worry about race conditions, hence
my erroneous approach. The open() || $var = 1 approach will cover race
conditions.

--
Stuart McDow                                     Applied Research Laboratories
smcdow@arlut.utexas.edu                      The University of Texas at Austin
  "It is obvious that about 750,000 people ago, Austin was a wonderful City."


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

Date: 1 Apr 1998 17:27:16 GMT
From: psf@euclid.jpl.nasa.gov (Peter Scott)
Subject: Re: File::Find vs. File::Recurse (was Re: file trees)
Message-Id: <6fttdk$k4p@netline.jpl.nasa.gov>

I should add that File::Recurse does not have a depth-first search
option, which eventually caused me to copy the routine into my
program and hack it becaused I needed depth-first.  Also, File::Find can
handle VMS and NT, and has a few optimizations; however, it requires
that you not modify $_ in the callback, and it won't follow symlinks.

Seems like there's an opportunity for someone to create something
that's the best of both...

-- 
This is news.  This is your      |  Peter Scott, NASA/JPL/Caltech
brain on news.  Any questions?   |  (psf@euclid.jpl.nasa.gov)

Disclaimer:  These comments are the personal opinions of the author, and 
have not been adopted, authorized, ratified, or approved by JPL.


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

Date: 01 Apr 1998 12:55:08 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: File::Find vs. File::Recurse (was Re: file trees)
Message-Id: <4t0djukj.fsf@mailhost.panix.com>

psf@euclid.jpl.nasa.gov (Peter Scott) writes:

> File::Find can handle VMS and NT

I've been using File::Recurse on NT; in what way might it bite me?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Wed, 01 Apr 1998 12:57:16 -0600
From: cabel@panic.com
Subject: fork() and out-of-contol memory "leak": help!
Message-Id: <6fu2g8$cpp$1@nnrp1.dejanews.com>

The problem:

I have a perl "server" that forks out processes as new connections come in.
However, after upgrading to 5.004_04, each new forked process takes up almost
double the amount of memory of the previously forked process, and so forth,
until all my memory is gone and all sorts of nasty things happen. Is this my
fault? Or is this Perl's? I've searched FAQ's and Dejanews and can't find
anything that relates exactly.

The skinny:

This is Perl 5.004_04, on Solaris 2.5. My current "top" shows that there's
"Memory: 58M real, 21M free, 37M swap, 133M free swap" in the system. I am
checking memory requirments by using top -- both the "SIZE" and "RES" increase
dramatically with each fork(). I found one suggested fix -- using "1 while
waitpid(-1, 0) != -1;" instead of my just plain wait() -- which has made the
problem more interrmittant and occasional, but still forks very large
processes.

The code fragment:

for($con = 1; ; $con++) {
  ($addr = accept(NS,S));
  unless (fork) {
      unless (fork) {
			# Whole bunch of code godes here
      } # End of fork
      exit 0;
   }
   # Now reap any zombies
   wait;
}

The request:

Help me! Please! =) Everything worked fine with my previous version of Perl
(perl5.00393)...

Also, if you could, please E-Mail me a copy (cabel @ panic.com) if you respond
because we have a notorious newsserver.

Best,
Cabel

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 01 Apr 1998 12:55:24 -0500
From: Patrick Toal <pat@weslink.ca>
Subject: Forking/Children/Data
Message-Id: <35227F8C.60ECF05@weslink.ca>

This is a multi-part message in MIME format.
--------------C927550F0A0589391D50533D
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I've had a look around, but I can't find an easy answer to this
question. I am rather new to the land of IPC, so please bear with me. 
If someone could help me out I'd appreciate it. :) 

What I want to do is fairly simple.  I am writing a perl script that
will monitor several devices, and grab data from them.  I want to run a
background scan every 60 seconds to check which devices are active
before I bother trying to get data from them. I want this scan to run in
a child process from the main program so I don't have to tie up the main
process waiting.  Here's the problem:  I need to pass an array back to
the parent process.  I would prefer doing it without the IPC routines,
and I thought that perhaps perl had some internal way of sharing a
variable accross processes.  I tried passing a reference to the child,
but that just creates another array in the child.

Any assistance would be appreciated.

-- 
----
Patrick J. Toal, 			 E-Mail:pat@weslink.ca
Systems & Network Administrator, 
Weslink Datalink Corp.
1603 Main St. W. Hamilton, Ontario, Canada
--------------C927550F0A0589391D50533D
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Patrick J. Toal
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Patrick J. Toal
n:              Toal;Patrick J.
org:            Weslink Datalink Corp.
adr:            1603 Main St. W;;;Hamilton;On;L8S 1E6;Canada
email;internet: pat@weslink.ca
title:          Systems Administrator
tel;work:       (905)522-4101
tel;fax:        (905)522-2123
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
version:        2.1
end:            vcard


--------------C927550F0A0589391D50533D--



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

Date: 1 Apr 1998 19:15:59 GMT
From: klassa@aursgh.aur.alcatel.com (John Klassa)
Subject: Re: How to read from keyboard without enter?
Message-Id: <6fu3pf$anh$1@aurwww.aur.alcatel.com>

On 1 Apr 1998 13:08:50 GMT, Gabor <gabor@vmunix.com> wrote:
->No kidding.  It's interesting that a question like 'why isn't there an
->odd function in Perl' generates all sorts of answers, but tougher
->questions go unanswered.
->This newsgroup is definitely not like one would expect from reading
->the Camel.

Can you give me a few examples of tough questions that go unanswered,
but which are not of the FAQ or "do my homework for me" or "I'm having
a CGI problem" (etc. etc. etc.) ilk?  I'd be surprised if there were
very many of these, if any.

-- 
John Klassa / Alcatel Telecom / Raleigh, NC, USA <><


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

Date: Wed, 1 Apr 1998 19:41:17 +0100
From: Karl Dyson <karld@feklore.demon.co.uk>
Subject: Re: newbie question:how to embed perl in html
Message-Id: <zB78JGANpoI1EwLh@feklore.demon.co.uk>


>> You need to use Server-Side includes.
>Wrong. That is exactly the wrong answer.
>Ever heard of CGI? 
Well let me see... Of course I've heard of CGI. And my response to the
posters question was based around getting the server to paste in the
output of a CGI proggy.

If that's not what he wanted then I appologise. But the wording was
"embed" CGI in the HTML and a SSI is probably what he wanted.

>Forms?
Require the user to click to activate the CGI - which doesn't sound like
what was asked.

Karl
-- 
Karl Dyson <karld@feklore.demon.co.uk>
"A look can be deceiving; a touch can be lethal."


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

Date: 1 Apr 1998 19:26:58 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: newbie question:how to embed perl in html
Message-Id: <6fu4e2$sd3@mozo.cc.purdue.edu>

John Porter <jdporter@min.net> writes:

}Karl Dyson wrote:
}> 
}> >I have a perl script for a discussion group that outputs html. if I type:
}> >perl script.pl it gives the desired html output in my shell account.
}> >Question: How do i call this script from a html page?
}> 
}> You need to use Server-Side includes.

}Wrong. That is exactly the wrong answer.

Actually, this is exactly the wrong group for the question.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Wed, 1 Apr 1998 12:09:52 -0600
From: RayG <rgoldber@eb.com>
Subject: password input
Message-Id: <Pine.SOL.3.95.980401120735.18214B-100000@DonDiego>

I have a script that prompts for a username and password. It would
obviously be a good idea if the password were not echoed to the screen. Is
there a function or module out there that will echo your choice of
character whenever a character is input? I know there are at least two
different modules that let you turn echoing off, but I want to echo *'s
instead.

Ray Goldberger
rgoldber at eb dot com
http://rayg.home.ml.org



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

Date: 01 Apr 1998 12:40:16 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: problem to exec a "c:\Program Files\.." command on Windows NT
Message-Id: <67ktjv9b.fsf@mailhost.panix.com>

WenWey Hseush <wenwey@webmantech.com> writes:

>    exec "c:\Program Files\JavaSoft\jre\1.1\jre", "TestJava",
> "-classpath", ...

Two suggestions:

   1) Use single-quotes, which eliminates double-quotish
      interpretation of backslash escapes.

   2) Try 'c:\PROGRA~1\JavaSoft\jre\1.1\jre'

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Wed, 1 Apr 1998 13:27:04 -0500
From: kaufmanNOSPAM@redrose.net (Gene Kaufman)
Subject: Re: problem to exec a "c:\Program Files\.." command on Windows NT
Message-Id: <MPG.f8c5107dd173853989686@news.redrose.net>

In article <6ftn6v$him$1@earth.superlink.net>, wenwey@webmantech.com 
says...
> We have a Perl script running on both Windows NT and Unix environments.
> The script basically invokes (i.e. exec ) a Java program. It works in
> most cases except for the path name containing spaces, which only
> happens on Windows NT.
> 
>    1. works.
> 
>    exec "c:\jdk1.1.4\bin\java", "TestJava", "-classpath", ....
> 
>    2. doesn't work.
> 
>    exec "c:\Program Files\JavaSoft\jre\1.1\jre", "TestJava",
> "-classpath", ...
>                             ^
>                           a space here
> 
>    It reports "Class not found: Files\JavaSoft\jre\1.1\bin\jre". The
> Java VM
>    (c:\Program Files\JavaSoft\jre\1.1\jre) started, but it seemed to
> take    "Files\JavaSoft\jre\1.1\bin\jre" as its argument.
> 
> If anyone knows a solution to this problem, please reply and also email
> to wenwey@webmantech.com. Thanks.

use c:\progra~1\ instead of c:\Program Files\

-- 
===================================================
Gene Kaufman
kaufmanNOSPAM@alpha.fiorill.com
Terrik Software: http://alpha.fiorill.com/~kaufman


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

Date: Tue, 31 Mar 1998 18:35:48 +0100
From: Andrew Boothman <andrew@boothman.easynet.co.uk>
Subject: Re: Question about Perl script and form submit buttons !!!!
Message-Id: <35212974.B6493353@boothman.easynet.co.uk>

Would it be possible to construct something in Javascript that would
prevent someone clicking twice.

Or perhaps printing "CLICK ONLY ONCE" above the button!?! :-)

Mike Hitchcock wrote:
> 
> 
> Anyone else have any luck/suggestions?
> 

--
Andrew Boothman : andrew@boothman.easynet.co.uk 
(http://easyweb.easynet.co.uk/~boothman/andrew/)
"Yahoo is a search engine.
 Netanyahoo is an Israeli search engine"
            -Robin Williams



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

Date: Wed, 01 Apr 1998 13:13:13 -0500
From: Rick Schofield <Richard.Schofield@fmr.com>
Subject: REQ: algorithm for DES::encrypt/decrypt of text strings
Message-Id: <352283B9.24A7736D@fmr.com>

Howdy,

   I need to encrypt/decrypt text strings and want to use
DES::en[de]crypt to do it. The problem I'm having is how to
pack the string data into a form acceptible to DES.

    I'm assuming I want to separate the string into 8 character
segments, pack them into 8 byte data and pass the to encrypt.
That seems easy enough to do, but I seem to be unable to get
data in the right form.  Here's an outline of what I'm trying:

    use Crypt::DES;
    my $cipher = new DES $key;

    $in = "zyxwvuts";
    $packin = pack ("C8", $in);
    $enc = $cipher->encrypt($in);
    $dec = $cipher->decrypt($enc);
    print unpack ("C8", $dec);

When I run this, I get the "usage" message from DES::encrypt. Has
anyone done anything similar to this?  What am I missing (besides
an adequate supply of functional brain cells)?

    Rick



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

Date: 01 Apr 1998 10:38:12 -0700
From: Robert Lopez <Robert.Lopez@abq.sc.philips.com>
Subject: s/PATTERN/<how to concat here>/g
Message-Id: <jc6hg4do323.fsf@abqn07.ato.sca.philips.com>


How is string concatenation done on
the left side of substitution?

This is what I am trying to do:
   $_ = "STT,31-Mar-98";
   s/(STT,\d\d*\-\w\w*\-)(\d\d)/$1.19.$2/g; #1
   s/\.//g;                                 #2
   $_.="\n";
   print $_;

I can not figure how to do #1 and #2 in one line.

-- 
Robert Lopez                    <Robert.Lopez@abq.sc.philips.com>
Philips Semiconductors,   9201 Pan American Fwy. N.E.,   ms 20,
Albuquerque, New Mexico 87113 USA  [P: (505)822-7112  F: x7237]


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

Date: 01 Apr 1998 13:04:58 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: s/PATTERN/<how to concat here>/g
Message-Id: <3efxju45.fsf@mailhost.panix.com>

Robert Lopez <Robert.Lopez@abq.sc.philips.com> writes:

>    s/(STT,\d\d*\-\w\w*\-)(\d\d)/$1.19.$2/g; #1
>    s/\.//g;                                 #2

> I can not figure how to do #1 and #2 in one line.

In general, when you need to spell an identifier that may look to perl
as if it's running into another identifier, you may use braces, like
so:

    my $fruit = 'lime';
    print "${fruit}ade is delicious!\n";

    s/(blah)(blah)/${1}19${2}/g;

Also, though you didn't ask, I'll tell you that your regex could be
spelled a bit more clearly:

    s/(STT,\d+-\w+-)(\d\d)/ etc.

Notice that "foo" followed by "foo*" means precisely "foo+", and that
"-" is not a regex metacharacter (except when found in a character
class), and therefore needn't be escaped.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Wed, 01 Apr 1998 13:10:56 -0500
From: Jim Michael <jim.michael@gecm.com>
Subject: Re: s/PATTERN/<how to concat here>/g
Message-Id: <35228330.29E8@gecm.com>

Robert Lopez wrote:
> 
> How is string concatenation done on
> the left side of substitution?
> 
> This is what I am trying to do:
>    $_ = "STT,31-Mar-98";
>    s/(STT,\d\d*\-\w\w*\-)(\d\d)/$1.19.$2/g; #1
>    s/\.//g;                                 #2
>    $_.="\n";
>    print $_;
> 
> I can not figure how to do #1 and #2 in one line.

OWTDI:

  $_ = "STT,31-Mar-98";
   s/(STT,\d\d*\-\w\w*\-)(\d\d)/$1 \cH19$2/g;
   $_.="\n";
   print $_;

Cheers,

Jim


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

Date: Wed, 01 Apr 1998 13:19:17 -0500
From: Jim Michael <jim.michael@gecm.com>
Subject: Re: s/PATTERN/<how to concat here>/g
Message-Id: <35228525.5068@gecm.com>

Jim Michael wrote:
>    s/(STT,\d\d*\-\w\w*\-)(\d\d)/$1 \cH19$2/g;

Which I just realized has the nasty effect of leaving ' ^H' in the
string, even if if prints OK.


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

Date: 1 Apr 1998 19:43:10 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: sending mail using perl
Message-Id: <6fu5ce$dpb$1@news.orst.edu>

In article <6fsvoq$334s@yuma.ACNS.ColoState.EDU>,
Aaron Propst <abp@holly.colostate.edu> wrote:
>using the following code, I can successfully send an e-mail, but it isn't
>turning out the way I want it.
>Problems:
>
>1.  The Reply-to address and the Subject show up in the message text.

You are putting a faux Reply-To header and the Subject in the message
text. It isn't surprising they show up there at the other end.

>2.  The rest of the message body has no returns for separate lines.

You are not putting any "returns" into the message, so, once again, it
isn't surprising that they aren't there at the other end.

>open (MAIL, "|$mailprog $advisormail") || die "Can't open $mailprog! \n";

I am surprised that you don't get the "die" error message. You define
$mailprog to be the directory "/usr/mail/". How exactly does one open a
directory for piping into?

>print MAIL "The following information has been directed to you because you
>have been named as the advisor for $firstname $lastname.  Please look over
>the registration request, and respond to: $replyaddy";
>print MAIL "thank you for your co-operation";
>print MAIL "CSU, International Education";

Not a single "\n" in what you print. 

>I'm very new to the language, and am open to new ways of achieving the same
>goal.  does anyone have a better method of sending e-mail?

There is a CPAN module available for mail, if you do not wish to speak
to sendmail directly. Speaking to sendmail is not that hard.

>if this is the best method, are there ways I can define returns, and
>formatting?

By putting \n in your text every so often?



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

Date: 1 Apr 1998 18:01:40 GMT
From: Seth Holcomb <seth@e-zcomputers.com>
To: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Someone put my munged e-mail address on a spam list
Message-Id: <352280DE.57E41DF1@e-zcomputers.com>

Tom Christiansen wrote:

>  [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
>     Russell Schulz <Russell_Schulz@locutus.ofB.ORG> writes:
> :Tom Christiansen (co-author of Perl) also used to (still does?)
> :demunge and put them on a special web page (and posts them).
>
> I do still demunge them, and add them to a special table so that next
> time I reply, it can automatically fix it.

I got a kick out of your post (as I usually do). I'm writing a POP3 client script
in Perl5 for the learning experience. For those of use with the luxury of running
a CHRON job on our own POP account, making your own spam blocker is fun..

If you have a library of spam-block functions that I could look at I'd be
interested. Hey, it's not that hard to kick those munged addresses into a
separate file (or even demunge them... and send them to "Electric Email" :-) or
Pamleevideos.com ROFL! )

> Usenet is a public forum.  Cope.  I hate having to go out of the way to
> send the private response that netiquette suggests.  It's quite rude.
> But no, I don't send this table to spammers.  I don't know who the
> spammers are, and even if I did, wouldn't go out of my way to send it
> to them.

> Whether, when, and why I reveal that table or its Perl code to others
> is a different matter.  Currently, I favor doing so, and rude arguments
> to the contrary will only hasten its publication. :-)

Perl is the answer that these poor lost souls are looking for.Hey, if a Perl
intermediate like me can do it...

--Seth Holcomb
PS: Is there a big e-mail trash can out there I can forward mail to with an
e-mail alias? (smack)

> --tom, who finds "co-author of Perl" is a bit too hubristic even for him  :-)
> --
>         Tom Christiansen        tchrist@jhereg.perl.com
>
> "Patriotism is the virtue of the vicious."
>  - Oscar Wilde





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

Date: 1 Apr 1998 19:36:26 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Someone put my munged e-mail address on a spam list
Message-Id: <6fu4vq$9gk$1@news.orst.edu>

In article <3522e7fd.3383874@news.tornado.be>,
Bart Lateur <bart.mediamind@tornado.be> wrote:
>John Stanley wrote:
>
>>Address munging avoids the costs incurred by spam, and it causes the
>>spammers to waste time sending mail to invalid addresses.
>
>It hardly costs any time to the spammer, since it's a fully automated
>process. 

Yes, it is automated, and if the automaton is busy trying to send mail
to a bogus address it is 1) not sending it to a real address, perhaps
yours, and 2) wasting time. Since the automaton belongs to the spammer,
the waste belongs to the spammer, too. 

Did I really need to specify that the spammer himself wasn't wasting
his time but his system was?

>It wastes a lot of OUR bandwidth though.

I have yet to have a munged address waste any of my bandwidth. The only
time YOU waste bandwidth is 1) when you decide to send mail, which is
your own decision, not mine, and 2) when you try to defend the
ridiculous concept that munged addresses are evil.



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

Date: Wed, 1 Apr 1998 09:48:19 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Anthony F. Sanchez" <ncadmin@nova-creations.com>
Subject: Re: Sorting a Delimeted Text File?
Message-Id: <Pine.GSO.3.96.980401094743.496D-100000@user1.teleport.com>

On Tue, 31 Mar 1998, Anthony F. Sanchez wrote:

> Does anyone know of a simple way to "sort" a field or fields in a
> delimited text file?

Yes. Some of them are in the Perl docs, FAQs, and in the FMTEYEWTK about
sorting, all of which can be found on CPAN. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 01 Apr 1998 15:28:52 -0400
From: Neil Trenholm <hayward@auracom.com>
Subject: String Manipulation Question
Message-Id: <35229573.BD21734B@auracom.com>

Hi,

I am developing a perl-CGI based website at http://www.ckdh.net 

One problem I have, and can't seem to find the answer to after checking
out the man pages and newsgroups, is this....

The cgi program recieves some text data from a POST command. Before
saving it to a flat database I need to strip out carriage returns
(primarily) as well as other (less important) characters. 

I would prefer to replace the carriage returns with a <BR><BR> before
writing to the database.

Did I miss this in the man pages or newsgroup ? If so - chastize me at
your leisure - otherwise - please point me in the right direction !

Thanks and sincerity,
Neil Trenholm


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

Date: Wed, 1 Apr 1998 08:27:15 -0500
From: "I have a life, and I can prove it!" <jefpin@bergen.org>
To: Craig Robert Briese <cbriese@earthlink.net>
Subject: Re: Trouble with shebang line ...
Message-Id: <Pine.SGI.3.95.980401082620.18265C-100000@vangogh.bergen.org>

>	% perlscript.pl
>
>i get perlscript.pl: Command not found.  Yes, the file is executable,
>and Yes,  i have the correct path for the interpreter.  If anyone has
>any suggestions as to what it might be that i am over-looking, they
>would be appreciated.  

Try this:
	% ./perlscript.pl

Chances are your path is set up NOT to include ., which is your current
directory... it is often overlooked, and is the cause of this error (most
likely).

--
When the only tool you own is a hammer, every problem begins to
resemble a nail.
	                                         - Abraham Maslow
Jeff Pinyan | users.bergen.org/%7Ejefpin | techmaster@bergen.org
ICQ# 10222129 | 10222129@pager.mirabilis.com | qw[jeff] on EFnet
&jp('"($``','','$)EDF8```','$*52J4```','$+E1G4```','#J``@','#2__`');sub
  jp{for$w(@_){$_=unpack('B48',unpack('u',$w));$c=~tr/10/# /;print;}}



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

Date: 01 Apr 1998 12:36:39 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: What modules are available on *your* computer.
Message-Id: <7m59jvfc.fsf@mailhost.panix.com>

Here's a program that prints a list of all of the modules that can be
found in @INC.  It reflects the idiosyncrasies of my OS, but it should
give you a good idea of your module situation, and without the
verbosity of "perldoc perllocal."  Please post corrections here, since
this is intended to be didactic as well as useful.

   #!/c/perl/bin/perl -w
   use strict;
   use File::Recurse;  # available at your local CPAN mirror

   # the following kludge translates stoopid Win32 backslashes
   # into regular slashes, and eliminates duplicates in @INC
   do {
     my %seen = ();
     @INC = map { tr!\\!/!; $_ } grep { not $seen{$_}++ } @INC;
   };

   my @mods = ();
   foreach my $dir (@INC) {
     recurse {
       my $file = shift;
       return -1 if -d $file and grep {$_ eq $file} @INC;
       return 1 unless $file =~ s/\.pm$//;
       return 1 if $file eq lc $file;
       $file =~ s!^$dir/!!;
       $file =~ s!/!::!g;
       push @mods, $file;
     } $dir;
   }
   print join("\n", sort @mods), "\n";
   __END__

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 2226
**************************************

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