[6830] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 455 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 9 06:17:19 1997

Date: Fri, 9 May 97 03:00:21 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 9 May 1997     Volume: 8 Number: 455

Today's topics:
     Re: > 2GB "file too large", AIX 4.2, perl 5.001, not "u (Kent Perrier)
     [Q] Getting the pid of an execed process. (Andrew)
     Re: A Perl Question (Tad McClellan)
     Re: A Perl Question (Tad McClellan)
     Re: a question on striping characters (Mark Mills)
     ANNOUNCE: DB_File-1.50 Beta (Paul Marquess)
     article: writing a chat server (Brian Slesinsky)
     Re: canned reply?? (Chipmunk)
     Re: Dates (Billy Chambless)
     Re: Dups in a array.. how to clear? <rmcvay@acm.org>
     Re: Have a question? Post it here at the CGI Discussion (Tad McClellan)
     Re: HTML question (Abigail)
     htpasswd & PERL silver@silverbergcom.com
     Re: htpasswd & PERL (brian d foy)
     Incorrect warning? (Dave Steffen)
     Re: Novice needs help pulling pattern to match as a var (Tad McClellan)
     Optimizing Perl execution. <riaz@ica.net>
     Re: Perl/HTML/Win 3.1 Newbie question... <gordon.leslie.mcdorman@sap-ag.de>
     Re: Problem with "print <<EOM; " statement (Tad McClellan)
     Re: REQ: Perl obfuscator (Chipmunk)
     Re: scrambling the elements of any array?? (Brooks Davis)
     Re: Sending e-mail from within a perl script - help <a.aitken@unl.ac.uk>
     Re: split problem (Chipmunk)
     Re: Win32 Perl (Nathan V. Patwardhan)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 08 May 1997 22:50:04 -0500
From: kperrier@Starbase.NeoSoft.COM (Kent Perrier)
Subject: Re: > 2GB "file too large", AIX 4.2, perl 5.001, not "ulimit"
Message-Id: <cssozxmhhv.fsf@Starbase.NeoSoft.COM>

In article <5ks2u4$ort@nike.volvo.se> peter@cyklop.volvo.se 
(peter hakanson) writes:

>
>Kent, 
>if You have read the original post then you understand
>WHY aix4.2 (or any 32 bit machine has this limitation)
>
>Even if one could (like in BSD) use a struckt for this, then
>any application compiles has to use this correct.
>

AIX 4.2 uses a 64 bit file system therefore breaking the 2 gig filesize
limit.  Next time why don't you learn a bit about the OS you are trying
expound upon.

Kent
-- 
Kent Perrier           If Bill Clinton is the answer, then it must
kperrier@neosoft.com    have been a really stupid question.
Corporations don't have opinions, people do.  These are mine.
PGP 2.6 Public Key available by request and on key servers
PGP encrypted mail preferred!



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

Date: Fri, 09 May 1997 13:35:56 +1100
From: andrew@ugh.net.au (Andrew)
Subject: [Q] Getting the pid of an execed process.
Message-Id: <andrew-0905971335560001@lab504.tuu.utas.edu.au>

Hi,

I am trying to exec another program from a perl script and keep track of
its pid.

I fork my perl script and have the child exec. I have the PID of the child
but exec gives a new PID to the execed process (I want to send a kill to
the process later).

Does anyone have any ideas?

Andrew


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

Date: Thu, 8 May 1997 22:21:52 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: A Perl Question
Message-Id: <g85uk5.392.ln@localhost>

Ali Ranjbar (ranjbar@cig.mot.com) wrote:
: Hello there;

: I am new to Perl. I am trying to search for parentheses in a string and
: then get read of them. Getting read of them should not be difficult.

I can't tell what you want. Do you want to delete all parenthesis in
the string? Do you want to delete all parenthesis and their contents
from the string?

You could have described this problem very succinctly by supplying
one line of input and one line of desired output:

--------------
$summary = "this has (parenthesis) in it";

How can I get it to be equal to ""this has parenthesis in it"??
--------------

Giving example data is nearly always easier to do AND more clear
that trying to describe it with natural language...


: However; sounds like Perl is using () for memory in regular expressions.
: How do I do that. I tried:
: if ($summary=~ /\(/{ # where $summary has the string I am searching in.
     ^
This in unbalanced (where is the close paren that corresponds to it?)

if ($summary=~ /\(/) {  # ahhh, much better


: I also tried:
: if ($summary=~ /(/{ # where $summary has the string I am searching in.
     ^
unbalanced...

: and
: if ($summary=~ /(|)/{ # where $summary has the string I am searching in.
     ^^^^^^^^^^^^^^^^
Now this one has the // for the pattern match unbalanced (the second
one is outside of the if() expression...


: Every time I get a syntax error.

You're getting syntax errors because you don't have a closing
parenthesis for the if():  if(...{


-------------------------
#! /usr/bin/perl -w

$summary = "I have (parenthesis) in me that I (don't) want\n";
$summary =~ s/[()]//g; # use character class
print $summary;

$summary = "I have (parenthesis) in me that I (don't) want\n";
$summary =~ s/\(|\)//g; # escape the parenthesis
print $summary;

$summary = "I have (parenthesis) in me that I (don't) want\n";
$summary =~ s/\Q(//g;  # get rid of open paren
$summary =~ s/\Q)//g;  # get rid of close paren
print $summary;

$summary = "I have (parenthesis) in me that I (don't) want\n";
$summary =~ tr/()//d;  # this is the fastest way to get rid of characters
print $summary;

$summary = "I have (parenthesis) in me that I (don't) want\n";
$summary =~ s/\([^)]*\)//g;  # delete contents too
print $summary;
-------------------------



--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Thu, 8 May 1997 22:56:02 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: A Perl Question
Message-Id: <i87uk5.ee2.ln@localhost>

William Stranathan (stranw@gte.net) wrote:
: try:

: $summary =~ s/(.*)\((.*)/\1\2/;
                           ^^^^

You should always use the -w command line switch...


: I know that's weird looking, but...

perl thinks so too ;-)


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Fri, 09 May 1997 04:39:50 GMT
From: mark@ntr.net (Mark Mills)
Subject: Re: a question on striping characters
Message-Id: <3372a87d.8121224@news.ntr.net>

On 7 May 1997 21:16:42 GMT, lparillo@newshost.li.net (Parillo) wrote:

>I prefer the second because it is more clear.
>Is there a reason why the first is better?
>
>my ($foo, $bar);
>
>$bar = "79I_LIKE_TH79E_NUMBER_9";
>$bar =~ s/[^\d]+//g;
>print $bar, "\n";
>
>$foo = "79I_LIKE_TH79E_NUMBER_9";
>$foo =~ s/\D//g;
>print $foo, "\n";
>
>Abigail (abigail@fnx.com) wrote:
>
>: $foo = "I_LIKE_THE_NUMBER_9";
>: $bar =~ s/[^\d]+//g;
>
>: strips out all non numbers.

I wondered the same thing so:

#!/usr/local/bin/perl
use Benchmark;
srand;

for ($i=0;$i<10000;$i++)
        {$string.=(0..9,a..z)[rand(36)];}


### loop until the numbers are gone

timethese (2000 ,{
bigd => '($string1=$string)=~s/\D//g;',
bigdplus => '($string1=$string)=~s/\D+//g;',
littled => '($string1=$string)=~s/[^\d]//g;',
littledplus => '($string1=$string)=~s/[^\d]+//g;',
});

for ($i=0;$i<90000;$i++)
        {$string.=(0..9,a..z)[rand(36)];}

timethese (200 ,{
bigd => '($string1=$string)=~s/\D//g;',
bigdplus => '($string1=$string)=~s/\D+//g;',
littled => '($string1=$string)=~s/[^\d]//g;',
littledplus => '($string1=$string)=~s/[^\d]+//g;',
});

#### results
Benchmark: timing 2000 iterations of bigd, bigdplus, littled,
littledplus...
      bigd: 83 secs (53.15 usr  0.22 sys = 53.37 cpu)
  bigdplus: 25 secs (21.17 usr  0.07 sys = 21.24 cpu)
   littled: 71 secs (52.05 usr  0.18 sys = 52.23 cpu)
littledplus: 25 secs (19.94 usr  0.08 sys = 20.02 cpu)
Benchmark: timing 200 iterations of bigd, bigdplus, littled,
littledplus...
      bigd: 74 secs (53.41 usr  0.19 sys = 53.60 cpu)
  bigdplus: 26 secs (21.49 usr  0.08 sys = 21.57 cpu)
   littled: 76 secs (61.06 usr  0.18 sys = 61.24 cpu)
littledplus: 28 secs (21.18 usr  0.08 sys = 21.26 cpu)

-- 
[Hopper, Dennis]: There's mines over there, there's mines over 
there, and watch out those goddam monkeys bite, I'll tell ya.
==Apocalypse Now==


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

Date: 9 May 1997 03:56:57 GMT
From: pmarquess@bfsec.bt.co.uk (Paul Marquess)
Subject: ANNOUNCE: DB_File-1.50 Beta
Message-Id: <5ku7a9$iaa$1@nadine.teleport.com>
Keywords: Perl DB_File 1.14 1.50 Berkeley DB

I've uploaded both DB_File 1.14 and 1.50 Beta onto CPAN.


    file: $CPAN/authors/id/PMQS/DB_File-1.14.tar.gz
    byte: 30168
     md5: d3885eb37840bddb1033d4e0f8a97ab8


    file: $CPAN/authors/id/PMQS/DB_File-1.50Beta.tar.gz
    byte: 33205
     md5: 5e1d2c941122b55407ab25fc8deafe90


The 1.14 release is identical to the version of DB_File that is
included with Perl 5.003_99.

The 1.50 release is beta code which can build with either Berkeley DB
version 1 or version 2 (but not both simultaneously). When built with
DB 2.0 it only supports the functionality available in DB 1.x.
Anywhere the version 2 interface differs, DB_File arranges for it to
work like version 1. This feature allows DB_File scripts that were
built with version 1 to be migrated to version 2 without any changes.

A future version of DB_File which will support the new features
available in Berkeley DB 2.x is currently under construction.


Paul




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

Date: 9 May 1997 04:01:58 GMT
From: bslesins-usenet@hotwired.com (Brian Slesinsky)
Subject: article: writing a chat server
Message-Id: <5ku7jm$iff$1@nadine.teleport.com>

Hi, I wrote an article about writing a chat server that illustrates
using IO::Socket and IO::Select.  It's available at:

  http://www.webmonkey.com/webmonkey/code/

(Also, in the archives there's an article about writing a search page
for a web site.)

(Comments welcome...)

Brian Slesinsky -- bslesins-usenet@hotwired.com




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

Date: 9 May 1997 03:56:44 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: canned reply??
Message-Id: <5ku79s$o2$3@dartvax.dartmouth.edu>

In article <3370A0B6.67C4@iie.org>
George Kurian <gkurian@iie.org> writes:

> Does anyone know where I can get a perl script that generates canned
> replies?

Dear gkurian@iie.org,

Thank you for your post to comp.lang.perl.misc.  Because the newsgroup
has received an unprecedented number of posts in the past few days, we
are unable to respond right now.  Rest assured that we will reply to
your post as soon as we are able.  We apologize for any inconvenience
caused by this delay.  Thank you for your understanding in this matter.

Sincerely,
canned_reply.pl


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

Date: 9 May 1997 05:28:10 GMT
From: billy@cast.msstate.edu (Billy Chambless)
Subject: Re: Dates
Message-Id: <5kucla$id8$3@NNTP.MsState.Edu>

In article <33710636.576D@us.oracle.com>, "Dipti V. Sonak" <dsonak@us.oracle.com> writes:

|> $month = `date +'%m'`;
|> $day   = `date +'%d'`;
|> $year  = `date +'%y'`;
 

If God had meant for us to use three processes to get the month, day,
and year, he wouldn't have created the localtime() function.

Hallelujah.

man perlfunc

 ....

      localtime EXPR
	     Converts a time as returned by the time function
       	     to a 9-element array with the time analyzed for
	      the local timezone.  Typically used as follows:


	   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
						   localtime(time);

  All array elements are numeric, and come straight out of
  a struct tm.  In particular this means that $mon has the range
  0..11 and $wday has the range 0..6.  If EXPR is omitted, does
  localtime(time).

 In a scalar context, prints out the ctime(3) value:

 $now_string = localtime; # e.g.  "Thu Oct 13 04:54:34 1994"

 ....

|> Robert Saunders wrote:

|> > I am trying to use the date function. but I don't need all the
|> > information that it returns.. I would like to parse the information so
|> > I could get just the Month and the Day out of the date function.

-- 
*    "We all agree on the necessity of compromise.  We just can't agree on
*     when it's necessary to compromise."
*                --Larry Wall in  <1991Nov13.194420.28091@netlabs.com>



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

Date: Thu, 08 May 1997 22:29:14 -0500
From: Ray McVay <rmcvay@acm.org>
Subject: Re: Dups in a array.. how to clear?
Message-Id: <33729A0A.503E@acm.org>

Tony Reeves wrote:
> 
> I have a large arrray..
> @ALLUSERS - about 9,000 records.
> 
> I'd like to know a simple way to remove any duplicates that might be in the
> file. that is if the file has:
> 
> 0098456,Jones,Smith
> 0098657,Patton,George
> 0097693,Bradley,Jim
> .
> .
> .
> 0098456,Jones,Smith
> 
> what routine can I use to look at this HUGE file and remove the dups, like
> Jones,Smith.
> I looked at grep, but not sure it will work, or will it?

Well yes, grep works. ;-)  I'd just throw the lot of 'em into a hash and
let IT do the dirty work.


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

Date: Thu, 8 May 1997 23:05:13 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Have a question? Post it here at the CGI Discussion Forum.
Message-Id: <pp7uk5.ee2.ln@localhost>

brian d foy (comdog@computerdog.com) wrote:
: [redirected to comp.infosystems.www.authoring.cgi]

: In article <337538b9.6505373@news.enterprise.net>, sorry@no.can.do (TOTO) wrote:

: > For any questions regarding CGI & PERL, please refer to the new
: > message board at 
: > 
: > http://www.netforward.com/cryogen/?toto
: > 
: > Please pass the word around and lets see if we can all help each
: > other.


: let's see, besides the JavaScript errors, annoyingly long loading
: graphics, small type (why mess with my choice of font size?), and
: poor use of frames, how is this better than usenet?  (btw, i find it
: rather ironic that a "CGI Board" would use one of Matt Wright's 
: scripts...)


I didn't even have to go to the site to know that is was silly.

Because in the original post:

No usable address in the From:

No Reply-to:

No email address in the .sig



Anonymous postings are a dead giveaway...



: oh yeah, i learned to chmod 777 my cgi-bin directory [1].  i hadn't
: realized i should do that.  in fact, i've been telling people not
: to. ;)


Oh silly you. The poor crackers have to make a living too, ya know  ;-)


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Fri, 9 May 1997 01:54:55 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: HTML question
Message-Id: <E9w5BJ.7n6@nonexistent.com>

On 8 May 1997 23:54:09 GMT, Rick Klainer wrote in comp.lang.perl.misc
URL: news:01bc5c24$177edf60$79921ece@rick1234.imperium.net:
++ I have these files on my UNIX box that are created from an SQR report that
++ are in PCL5
++ format. This is an HP print format. What I want to is convert this format
++ (PCL5) to 
++ HTML. Has anyone done that or can you at least point me in the right
++ direction. Please email at rklainer@calibersys.com.  Thanks

I think the right direction is left.

("PCL5" =~ /p.../i && "perl" =~ /p.../ that must be it)


Abigail


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

Date: Thu, 08 May 1997 21:18:41 +0100
From: silver@silverbergcom.com
Subject: htpasswd & PERL
Message-Id: <337234EB.3C74@silverbergcom.com>

Does anyone know how to generate an .htpasswd file with perl? I tried to
use the crypt() function, but I don't think I did it correctly. The
HTACCESS program also seems to generate different strings for the same
password if you generate it at different times.

Thanks,

Eric Silverberg


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

Date: Fri, 09 May 1997 00:32:55 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: htpasswd & PERL
Message-Id: <comdog-0905970032550001@nntp.netcruiser>

In article <337234EB.3C74@silverbergcom.com>, silver@silverbergcom.com wrote:

> Does anyone know how to generate an .htpasswd file with perl? I tried to
> use the crypt() function, but I don't think I did it correctly. The
> HTACCESS program also seems to generate different strings for the same
> password if you generate it at different times.

if you give crypt() a different salt you get a different result.

here is the step by step (sorry that i can't provide source):

* get a user name and a password

* ensure that the user name is unique (for new ones - a bit different
if you want to change an existing password but i won't go into that)

* choose a salt and crypt() the password with it.

* concatenate the user name and the encrypted password with a colon.

* append that to the htpasswd file.

-- 
brian d foy                              <URL:http://computerdog.com>                       
unsolicited commercial email is not appreciated


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

Date: 9 May 1997 04:17:03 GMT
From: steffend@lamar.colostate.edu (Dave Steffen)
Subject: Incorrect warning?
Message-Id: <5ku8fv$15nm@yuma.ACNS.ColoState.EDU>

Howdy Folks!

	I'm running Perl 5.003 on HP-UX 9.05, and using the -w switch
I'm getting messages that I assume are incorrect:

#!/usr/bin/perl -w

use Getopt::Std;
getopts ('x:y:w:');
print "$opt_x $opt_y $opt_w\n"; # these are set in the getopt module

Executing `testbug -x1 -y2 -w3` gives

Identifier "main::opt_w" used only once: possible typo at testbug line 12.
Identifier "main::opt_x" used only once: possible typo at testbug line 12.
Identifier "main::opt_y" used only once: possible typo at testbug line 12.
1 2 3

	Now, it's clear that the $opt_n variables are getting used
twice (once when they're set and once when they're printed), but
apparently the -w switch can't catch that.

	The program works fine, and AFAIKT is correctly written. If I
don't use the -w switch, all is well... except that I dislike _not_
using the -w switch. Perl seems to think there's a possible error
here, and I'm inclined to think that Perl knows more about Perl than I
do! ;-) ;-)

	So the question is: why am I getting this warning, and is
there really something wrong with my code?

THANKS!!

Dave Steffen                      Wave after wave will flow with the tide
Dept. of Physics                    And bury the world as it does
Colorado State University         Tide after tide will flow and recede
steffend@lamar.colostate.edu        Leaving life to go on as it was...
							- Peart / RUSH
"The reason that our people suffer in this way.... 
is that our ancestors failed to rule wisely".   -General Choi, Hong Hi





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

Date: Thu, 8 May 1997 22:53:56 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Novice needs help pulling pattern to match as a variable from another file
Message-Id: <k47uk5.ee2.ln@localhost>

tnoto@interramp.com wrote:
: I am a perl novice writing my second script,  I have seemingly run
                                                                 ^^^
: into  wall, and was hoping to get some help from above from the
  ^^^^^^^^^^                             ^^^^^^^^^^^^^^^
: experts..


Most here would agree that Wall _is_ the expert from above  ;-)

(or at least the Creator)


: I am trying to write a perl script that pulls a line from a sorted
: list and uses it as a pattern to match against strings that occur
: multiple times in another (larger) file. The lines in the sorted list
: may or may not contain characters that are also used as perl regular
: expression codes.

: I am trying to pull these text strings into my script so that I can
: pattern match them against my input file line by line. The lines in
: the input file contain other text than the exact string contained in
: "errorfile".

: The problem is that  I can't seem to get the string from "errorfile"
: to act as a regular expression once I have pulled it into my script.

: Here is the specific line that I believe is causing the problem:

: If ($line =~ /$error/) {


That looks fine.


: where $line is the line from my input file and $error is the pattern
: to find in $line, coming from the errorfile.  This line will not 'hit'
: or execute.


[ snip sample patterns and strings ]


: Here is my entire script:

: #! usr/bin/perl

: open (LST101, "wincafc.o02");
: open (OUT101, ">wincafc.o03");
: $Line = <LST101>;

: do {

: 	open (ERRORS, "errors.o02");
: 		
: 	$error = <ERRORS>;


chomp($error);   # no pesky newlines in the pattern please ;-)


As you mention you are a novice Perl programmer, when something isn't
doing what you expect, print out some variable values. Mark the start
and end so you can see whitespace too:


print "error: '$error'\n";  # adding this one line would have clued you in
                            # to the problem


: 	
: 	do {

: #		$position = index($Line, "Group 19 cfr 22");
: #		if ($position >= 0) { 
: 		if ($Line =~ /"$error"/) {
                              ^      ^

No double quotes either.

[snip rest of script]


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Thu, 08 May 1997 23:23:43 -0400
From: Riaz <riaz@ica.net>
Subject: Optimizing Perl execution.
Message-Id: <337298BF.342B@ica.net>

Hi all,
		 I have a Perl script that I want to run on an Windows NT box but
don't want to incur the performance penalty of the perl interpreter... I
have heard that I can compile perl to C and then compile that but the
only compiler that I have seen is in ALPHA 3... Anyone know of a stable
product to use for production quality??? What about Perl with ISAPI
anyone tried that out???

Riaz Khan
Royal Bank of Canada
riaz@ica.net


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

Date: Fri, 9 May 1997 09:20:31 GMT
From: Gordon McDorman <gordon.leslie.mcdorman@sap-ag.de>
To: mberry@xmission.com 
Subject: Re: Perl/HTML/Win 3.1 Newbie question...
Message-Id: <ulo5p80io.fsf@sap-ag.de>

>>>>> "Michael" == Michael J Berry <mberry@xmission.com> writes:

    Michael> Can anyone help me?  I'm trying to simply execute a PERL
    Michael> script on a Win 3.1 machine via webbrowser.
[...]

    Michael> So, I have tried refrencing "PERL.EXE PerlScript.pl"
    Michael> which doesn't work because command line arguments are not
    Michael> passed.  So, I tried associating my .pl files with the
    Michael> PERL.EXE.  This doesn't seem to work.  So, I wrote a
    Michael> Delphi .EXE which executes "PERL.EXE PerlScript.pl"
[...]

1. Be careful how you do this: make sure web visitors cannot access an
executable which will pass arbitrary parameters to Perl. This is a
security hole.

See:

<URL:http://www.perl.com/perl/news/latro-announce.html>

<URL:http://www.perl.com/perl/faq/cgi/www-security-faq.html>

2. In order to run Perl scripts through CGI under Win 3.1, you must
"wrap" your script in a batch file (or similar). In any case, be
careful with security.

See question 5.3 in:
<URL:http://www.perl.com/perl/faq/cgi/perl-cgi-faq.html>

Or look at some of the resources in

<URL:http://www.netaxs.com/~joc/perlwin32.html>

(not all of which may be applicable to Win 3.1)

3. I hope you have some kind of Web server on your Win 3.1 machine,
and it is correctly configured.

See section 6 in:
<URL:http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html>



-- 
-------------------------------------------------------------- 
The opinions expressed above are mine, not my employer's.
      
gordon.leslie.mcdorman@sap-ag.de                               


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

Date: Thu, 8 May 1997 22:24:26 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Problem with "print <<EOM; " statement
Message-Id: <ad5uk5.392.ln@localhost>

Scott Wiersum (scott@smartgate.com) wrote:
: I'm running perl v4 on a BSD machine and experiencing the following
: error:

: 	print <<EOM;
: 	print "hello";
: 	EOM;

: unix# perl test.pl
: EOF in string at test.pl line 1.

: What am I doing wrong?
  ^^^^^^^^^^^^^^^^^^^^^

putting a semicolon after the second EOM...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 9 May 1997 03:43:21 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: REQ: Perl obfuscator
Message-Id: <5ku6gp$o2$1@dartvax.dartmouth.edu>

In article <5kqat4$3un@due.unit.no>
Salve J Nilsen <sjn@pvv.ntnu.no> writes:

> ==================================< arghify.pl >==
> #!/store/bin/perl
 ...
> 
> require 5.003;
> 
> # It's quite important to unset the input record seperator here :)
> $/ = undef;
> $_ = <>;
> 
> # Ideally our MetaSyntactical Variable of Choice should be 
> # qw(foo bar baz quux quuux quuuux quuuuux) etc - but for simplicity,
> # our MetaSyntactical Variable of Choice Today is:
> $msv = "foo00";
> 
> study;
> 
>         # single out the first line - if it begins with #!
>         # and save it for later use...
> s/^(\#\!.*?[\n\r])/\n/s;
> $head = $1;
> 
>         # get rid of comments
> s/(([\"\'])[^\1]*[^\\]\1)|[^\\]\#.*?$//gm;
>         # still buggy!

I think you want \2 here, not \1.  Note that the first paren block
contains the \1s.
Concatenation binds more tightly than disjunction.  So, your regex is
essentially equivalent to /(([\"\'])[^\1]*[^\\]\1)|([^\\]\#.*?$)/. 
You're deleting either quoted blocks of text or comments.  Is that what
you mean to do?
Don't forget to check for $#foo.

>         # strip away exess space and newlines
> s/(([\"\'])[^\1]*[^\\]\1)|\s+/ $1/gs;
>         # bugs  h^e^r^e  too :)

See above comment about \1 and \2.
If the part in parentheses matches, you're adding a space.

>         # here we are supposed to swap (Good) variable names 
>         # with (Bad) generic variable names (foo01 foo02 etc).
>         # - but i can't seem to get it to work :/
> # s/([\$\@\%]+)([\w_][\d\w_]*)/$1&foo($2)/gmei;
>         # My problem lies here ^^^^^^^^^^, I believe.

[\w_] and [\d\w_] are both redundant.  \w is defined as [0-9a-z_A-Z].
Why do you bother to match multiple @s and $s and %s? You only need to
match the one right before the variable name.
Your regex will change the name of $_ and @_.  That could break the
code.
Don't forget to check for $#foo. 
s/([\$\@\%]|\$#)([a-zA-Z]\w*|_\w+)/$1&foo($2)/gme; is closer to what
you want.
The second part of the substitution looks okay to me.

> print $head.$_."\n";

Why not just use
print "$head$_\n";

> sub foo {
>     $_{$_[0]}=$msv++ unless $_{$_[0]} && return $_{$_[0]};
> }

Looks like you won't need to run the obfuscater on your own code.  This
function is pretty obfuscated already.  ;-)
You might to parenthesize that statement to make sure it binds the way
you want it to.  Or even break it down into multiple lines (gasp!).


If you clarify exactly how your code isn't working, I'll see if I can
offer more help.

Chipmunk


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

Date: 9 May 1997 02:03:48 GMT
From: brdavis@orion.ac.hmc.edu (Brooks Davis)
Subject: Re: scrambling the elements of any array??
Message-Id: <5ku0m4$rch$1@cinenews.claremont.edu>

This question is answered twice in the FAQ under the title "How do I
shuffle an array randomly?"  If you have a split up version of the FAQ,
you'll find this topic under perlfaq4 (Data Manipulation).

-- Brooks


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

Date: Fri, 09 May 1997 10:04:20 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: Sending e-mail from within a perl script - help
Message-Id: <3372E894.D21@unl.ac.uk>

John Sheehy wrote:

> For some unknown reason (at least to me) /bin/mail starts reading from
> standard input. This results in the script hanging and waiting for keyboard
> input. I have verified this by sending a message to myself. I also replaced
> /bin/mail with the cat command and watched the lines bounce back at me as I
> typed.
> 
> What am I doing wrong?
> 
> sub SendMessage
> {
>         open(MAILPIPE, "|/bin/mail -s \"Overdue Notification\" $_[0]" ) || die
> "
> Can't open pipe to /bin/mail !\n";
>         print MAILPIPE "\nOverdue item(s) :- \n\n";
>         print MAILPIPE @Message;
>         print MAILPIPE "\nPlease return at your earliest convenience.\n";
>         close MAILPIPE;
> }
> 
> Is there an alternative to this method? Perhaps
> open(MAILPIPE, "|telnet mailhost 25");

I use sendmail directly and I finish mail messages with a "." before
closing the file too:

open(MAILPIPE, "|/usr/lib/mail) || die "blah $!\n";
print MAILPIPE "Subject: \"Overdue Notification\" $_[0]\n";
print MAILPIPE "Test Body\n";
print MAILPIPE "Bye\n";
print MAILPIPE ".";
close (MAILPIPE);

The "Subject: .." line is necessary because sendmail doesn't take a -s
command line option.

Alastair.


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

Date: 9 May 1997 03:50:38 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: split problem
Message-Id: <5ku6ue$o2$2@dartvax.dartmouth.edu>

In article <3370B395.690A@russiamail.com>
Slava V Bereza <vvbereza@russiamail.com> writes:

> Does anybody knows how to split lines if I have a number of
> delimiters in row? If I have two or more whitespaces, I get
> whitespaces in my array after splitting. I do not what it.
> Also how is it possible to give different delimiters in one split?

split(/\s+|alternate|alternate2/)

\s+ is one or more whitespace characters.

Chipmunk


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

Date: 9 May 1997 03:08:22 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Win32 Perl
Message-Id: <5ku4f6$qeq@fridge-nf0.shore.net>

Jon Brule (jon_brule@nt.com) wrote:

: Does anyone know if it is possible to execute a Win32 PERL script using
: a DLL call instead of using the convential method of running "perl
: scriptname"?

I've seen NT users run a Perl script named (for example) foo.prl from 
the command-line without executing perl.exe.  I think the answer to your
question is yes, and is probably documented in your distribution or on
www.activeware.com.

--
Nathan V. Patwardhan
nvp@shore.net



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

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

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