[7653] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1279 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 6 10:13:37 1997

Date: Thu, 6 Nov 97 07:00:25 -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           Thu, 6 Nov 1997     Volume: 8 Number: 1279

Today's topics:
     Re: Bug in 5.004_01 Solaris 2.5.1/SPARC fork() and EOF  (Casper H.S. Dik - Network Security Engineer)
     Re: Calling Perl from Web on VMS? (Peter Samuelson)
     Re: CPAN confusion (Honza Pazdziora)
     Re: do "somefile.pl" for perl 4 & 5, any diff? <rootbeer@teleport.com>
     Exact string matches paul@pkamf.demon.co.uk
     Re: Exact string matches (Mike Stok)
     Re: Exact string matches (Andrew M. Langmead)
     Fork workaround for Win32 <trygvei@pvv.ntnu.no>
     Help: Format > 80 char. w/ multiple variables wraps (Lyn Lewis)
     Re: How to send mail w/in Perl program? (Joseph O'Rourke)
     Re: How to send mail w/in Perl program? <barnett@houston.Geco-Prakla.slb.com>
     Re: open() and pipes <Steve_Kilbane@cegelecproj.co.uk>
     Re: open() and pipes <rootbeer@teleport.com>
     Re: open() redirection failing under NT/CGI. <Steve_Kilbane@cegelecproj.co.uk>
     Re: pattern matching options <rootbeer@teleport.com>
     Re: Perl->Java? Java->Perl? Gaaaaa! <sbekman@iil.intel.com>
     Re: Precedence problem? (Mick Farmer)
     Re: Protecting Perl Source (Peter Samuelson)
     Re: Puzzle: palindromep (Steven W McDougall)
     Re: Regex question (Casper K. Clausen)
     Re: Regex question <markm@nortel.ca>
     Re: SSI Parameters (Peter Samuelson)
     Re: sub-totaling lines in a file?? tobez@plab.ku.dk
     Re: Undefining an associative array element <markm@nortel.ca>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 6 Nov 1997 11:49:39 GMT
From: Casper.Dik@Holland.Sun.Com (Casper H.S. Dik - Network Security Engineer)
Subject: Re: Bug in 5.004_01 Solaris 2.5.1/SPARC fork() and EOF handling?
Message-Id: <casper.878817060@uk-usenet.uk.sun.com>

[[ Reply by email or post, don't do both ]]

David C Niemi <niemi@tux.org> writes:

>I have a script that reads through a configuration file, forking off
>children as it goes based on what it sees.  The children do not muck with
>the file descriptor for the configuration file at all, but do open files of
>their own.

That's what you think !

>while (<userconf>) {

>	unless (fork) { ## START CHILD PROCESS ##

>		exit 0;         ## Exit from child process


You lose.

When you fork() the stdio buffers remain shared;  exitfinishes them up.

In solaris this menas (for input files) that the seek pointer is backed
up to the position just after the point the last data was read.

This will confuse the parent no end.  (You'll probably never
reach EOF).

There doesn't seem to be a "_exit" in perl though.

(Try (kill 9, $$))

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.


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

Date: 6 Nov 1997 07:14:40 -0600
From: psamuels@sampo.creighton.edu (Peter Samuelson)
Subject: Re: Calling Perl from Web on VMS?
Message-Id: <63sfs0$8u1$1@sampo.creighton.edu>

--BOUNDARY
Content-Type: text/plain

[John Emmer <jjustice@cs.bsu.edu>]
>     I have a Perl script that I would like to run on the VMS system
> here as it needs access to some software that we only have installed
> on that system, and not on the Unix servers.  I know how to submit
> information to a cgi script written in Perl and located on the Unix
> system, but I'm unfamiliar with the ways of VMS and am quite clueless
> as to how this script needs to be called.

Not a perl question.  A web server question.  Post it on a web server
newsgroup, or maybe a CGI newsgroup.

>  <FORM ACTION="http://etc" METHOD="POST">
> 405:"The server does not implement the operation you have requested"

Means the web server does not implement the operation you have
requested.  I'm guessing that means the POST method.  Try with GET.
Also make sure the server knows where your CGI program is, that it can
execute it (OS permission checks), that it is willing to execute it
(server permission checks), etc.

-- 
Peter Samuelson
<psamuels at sampo.creighton.edu>

--BOUNDARY
Content-Type: text/html

<BODY>This post is best viewed with a <B><I>real newsreader</I></B>.</BODY>
--BOUNDARY--


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

Date: Thu, 6 Nov 1997 08:51:12 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: CPAN confusion
Message-Id: <adelton.878806272@aisa.fi.muni.cz>

hermit@cats.ucsc.edu (William R. Ward) writes:

[...]

> > It's not really a problem with CPAN since it already has the functionlity
> > you request.  If module authors use README files, or put more helpful
> > information in their README's (such as the SYNOPSIS of the POD), then you
> > would have the information that you want.
> 
> I want to be able to see detailed information, not just the README.
> Why ask authors to duplicate the POD contents in a README file when
> the documentation itself could be made available?

I believe (and try to do it that way in my modules) that the README
should give you the idea, what's going on in the package. You can get
on readme using
	perl -MCPAN -e shell
and then
	readme modulename

> > However, I disagree that detailed information, such as the entire
> > manpage, should be made available on CPAN.  One can simply download
> > the module and run it through pod2man or another pod translator.  
> 
> That's asking an awful lot to find out whether a module does what I
> want.  I think having all the POD online and web-accessible would be a
> very good thing.

README should give you the idea. I do not think it is feasible to
duplicate all the *.pms' pod out of the tar.gz's. It would take you
a lot of space and all people mirroring CPAN -- even if you are
welcome to set up a server that would extract the module's content
and docs on the fly.

Also, many people have more versions of one module in their authors'
directory. Some of them are out of date, some of them are new betas --
which documentation should be displayed?

> I think that CPAN is a good thing in general but I find that it is
> awkward to use through the web (does anyone still use ftp clients
> these days?) and could use some user interface improvements.

	perl -MCPAN -e shell
should do what you need. I am also trying to write XCPAN that would
give you more menus and clickable things, but it won't be ready soon
since I am pretty short time :-(

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Thu, 6 Nov 1997 06:55:19 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Pui Ming WONG <s11976@net2.hkbu.edu.hk>
Subject: Re: do "somefile.pl" for perl 4 & 5, any diff?
Message-Id: <Pine.GSO.3.96.971106065116.29771I-100000@usertest.teleport.com>

On 6 Nov 1997, Pui Ming WONG wrote:

> Are there any changes regarding the use of the 
> do "somefile.pl"
> statement in perl5 from perl4 ?

Any changes should be documented in the perltrap(1) manpage, although
perlfunc(1) may also be helpful. 

Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 06 Nov 1997 21:58:15 GMT
From: paul@pkamf.demon.co.uk
Subject: Exact string matches
Message-Id: <878824699.9108.0.nnrp-01.9e98ada2@news.demon.co.uk>

Hi 

I am looking to match the end of a sting exactly ie I want:

if($string =~ $anotherstring){
     do something;
}

This works but matches any bit of $anotherstring to $string
eg

$string = ".baker"; $ anothersting = ".ba";

and gives a match.  How do I code the test so that the only matches I
get are for other strings that end in .ba alone?

Please email any suggestions to

paul@pkamf.demon.co.uk

TIA

Paul



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

Date: 6 Nov 1997 14:39:45 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Exact string matches
Message-Id: <63skrh$89a@news-central.tiac.net>

In article <878824699.9108.0.nnrp-01.9e98ada2@news.demon.co.uk>,
 <paul@pkamf.demon.co.uk> wrote:
>Hi 
>
>I am looking to match the end of a sting exactly ie I want:
>
>if($string =~ $anotherstring){
>     do something;
>}
>
>This works but matches any bit of $anotherstring to $string
>eg
>
>$string = ".baker"; $ anothersting = ".ba";
>
>and gives a match.  How do I code the test so that the only matches I
>get are for other strings that end in .ba alone?

One thing you could do is say something like

  if ($string =~ /\Q$anotherstring\E$/) {
    ...
  }

which uses the $ character to anchor the match to the end of $string and
used \Q and \E to bracket escaping any metacharacters in $anotherstring -
the . in $anotherstring will match any character (usually except \n, see
the perlre man page or pod documentation to investigate the detail of
perl's regexes)

Alternatively if you're matching exact sequences of characters you might
use rindex and length or substr and length and the eq string equality
operator - this is perl and there's more than one way to do it, but I
think the regex produces simpler code...

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Thu, 6 Nov 1997 14:49:26 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Exact string matches
Message-Id: <EJ8BuE.LCt@world.std.com>

paul@pkamf.demon.co.uk writes:

>I am looking to match the end of a sting exactly ie I want:

>if($string =~ $anotherstring){
>     do something;
>}

What you are looking for is probably the "eq" operator

if($string eq $anotherstring) {}

You can also do almost the same thing by anchoring and quoting a
regular expression with the match operator, but less efficiently:

if($string =~ /^\Q$anotherstring$/) {}

Notice that the right hand side of the "=~" operator is a regular
expression match operator. According to the documentation, the right
hand side of the =~ operator should be a match operator (m//, but
maybe without the m), a substitution operator (the s/// operator), or
a transliteration operator (tr/// or y/// operators).

-- 
Andrew Langmead


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

Date: 6 Nov 1997 14:35:59 GMT
From: Trygve Iversland <trygvei@pvv.ntnu.no>
Subject: Fork workaround for Win32
Message-Id: <63skkf$a2n$1@due.unit.no>

I am writing a small socket server program in perl. I generaly use perl under
unix, and I use fork for multiple connections to the server. I would like to 
run this script under windows NT too. Is there any way I can get multiple 
processes with perl for Win32? (I know fork() doesn't work :-(   )


Trygve




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

Date: 6 Nov 1997 01:29:46 GMT
From: lynl@PROBLEM_WITH_INEWS_GATEWAY_FILE (Lyn Lewis)
Subject: Help: Format > 80 char. w/ multiple variables wraps
Message-Id: <63r6ia$p1a23@hpbs1500.boi.hp.com>

Okay, 
	I'm new at perl but after a quick search of the perl faq, man perlform
I still don't have my answer.  

here is my format statement it is longer then 80 characters.

format NAME =
@<<<<<<<<<<<<<<<<<      @|||||  @|||||  @|||||  @|||||  @|||||  @|||||  @|||||  @|||||
$vname, $vasgn[0], $vasgn[1], $vasgn[2], $vasgn[3], $vasgn[4], $vasgn[5], $vasgn[6], $vasgn[7]
 .

It is deliberately longer then 80 character columns, but even when I resize my
X11 windows the output is still wrapped to 80. 

ie 

NAME                    11/10   11/17   11/24   12/01   12/08   12/15   12/22
12/29

even when I have space for 120 characters across.

Hopefully, someone can help or point me in the appropriate direction.

TIA.

Lyn

--
================================================================================
Lyn Lewis 
Email: lynl@boi.hp.com
================================================================================



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

Date: 6 Nov 97 11:35:38 GMT
From: orourke@grendel.csc.smith.edu (Joseph O'Rourke)
Subject: Re: How to send mail w/in Perl program?
Message-Id: <3461ab8a.0@news.smith.edu>

In article <34612503.0@news.smith.edu>,
Joseph O'Rourke <orourke@grendel.csc.smith.edu> wrote:
>I am using Perl 5.0 on a Unix system, and would like my program
>to send me mail whose body is written from information in
>variables inside the Perl program.  [...]

I got this very useful message from Douglas McNaught <doug@tc.net>.
I don't understand every aspect of it, but I can verify that it works.
(I only had to add backslashes before the @'s in the From/To lines.)
-------------------------------------------------------------------
The general practice on Unix is to open a pipe to Sendmail, and let
that venerable and baroque entitity accomplish your mail delivery.
Here's an (untested) example:

open(SENDMAIL, "|/usr/lib/sendmail -t") or 
    die "Pipe open failed: $!\n";
print SENDMAIL <<EOF;
From: joeblow\@domain1.com
To: jimbob\@domain2.com
Subject: Daily status message

This is a status message.  It contains the values of the variables 
$var1 and $var2.  

Signed,
Your Program
EOF
close(SENDMAIL) or 
    warn "Error on pipe close; mail may not have been sent: $!\n";
warn "Mail delivery may have failed! Sendmail exited with status $?.\n" 
    if $? != 0;


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

Date: Thu, 06 Nov 1997 08:18:28 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: How to send mail w/in Perl program?
Message-Id: <3461D1B4.3769@houston.Geco-Prakla.slb.com>

Joseph O'Rourke wrote:
> 
> I am using Perl 5.0 on a Unix system, and would like my program
> to send me mail whose body is written from information in
> variables inside the Perl program.  I tried
> 
>         system "mail orourke"

TMTOWTDI.

The way I use (and is recommended in one of the Perl books (several of
them??)) is to open a pipe to mail, and then print your data to it.  

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

open(MAIL,"|/usr/bin/mailx -s \"$subject\" $mailID") 
	or die ("Unable to create pipe: $!\n");
   # This opens the filehandle MAIL as a pipe to receive input
   # This uses the solaris2 mailx program (may need adjusted)
   # $subject needs to be quoted in case it contains a space, thus the
\" characters around it
   # $mailID is the e-mail address of the recipient
   # If the pipe cannot be created, the program dies, & $! tells you why
the system was unhappy
select(MAIL);
   # selects MAIL as the default output
$| = 1;
   # sets no buffering (SOP is to buffer output)
print MAIL "$body_of_message\n";
   # writes contents of body_of_message to the mailx program
   # This can be put in a loop to print as many lines as you need ...
(or can be scattered 
   #	throughout your program.  Your call.
close(MAIL)

You will probably want to do a 'man mail' and read through it to
determine how to specify subject line, recipient(s), etc.  The above may
not be the correct syntax for your 'mail' executable

HTH

Regards,
Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

Date: Thu, 06 Nov 1997 12:21:46 GMT
From: Steve Kilbane <Steve_Kilbane@cegelecproj.co.uk>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: open() and pipes
Message-Id: <b67cd$c152e.29e@news.cegelecproj.co.uk>

In article <Pine.GSO.3.96.971103085954.10568Z-100000@usertest.teleport.com>, Tom Phoenix <rootbeer@teleport.com> writes:
> Well, if the open failed, you can pretty much count on getting no data
> through the pipe. :-)  But here's something better.
> 
>     pipe(R,W) or die "Can't make pipe: $!";
>     my $pid = open(PIPE, "-|");

This failed on Perl 5.004_01, on NT4.0 under M$ VC++. It
seems to be trying to execute "-". We copied notepad.exe to
-.exe, and a variant of Tom's script opened notepad. :-)
-- 
<Steve_Kilbane@cegelecproj.co.uk> - All opinions are mine alone.
Kilbane's law of integration: standardise on protocols and file
formats, and the applications take care of themselves.



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

Date: Thu, 6 Nov 1997 06:21:52 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Steve Kilbane <Steve_Kilbane@cegelecproj.co.uk>
Subject: Re: open() and pipes
Message-Id: <Pine.GSO.3.96.971106061926.29771D-100000@usertest.teleport.com>

On Thu, 6 Nov 1997, Steve Kilbane wrote:

> >     pipe(R,W) or die "Can't make pipe: $!";
> >     my $pid = open(PIPE, "-|");
> 
> This failed on Perl 5.004_01, on NT4.0 under M$ VC++. It
> seems to be trying to execute "-". 

Sounds as if your system doesn't understand how to open on a pipe. Maybe
you should install Linux. :-)

Or, if that missing feature is not documented in your perl's release
notes, file a bug report to ask that it be (at least) documented.

Cheers!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 06 Nov 1997 12:18:44 GMT
From: Steve Kilbane <Steve_Kilbane@cegelecproj.co.uk>
To: perlfaq-suggestions@mox.perl.com
Subject: Re: open() redirection failing under NT/CGI.
Message-Id: <b67cd$c122c.1fc@news.cegelecproj.co.uk>

In article <b37cd$f3b7.2ac@news.cegelecproj.co.uk>, Steve Kilbane <Steve_Kilbane@cegelecproj.co.uk> writes:
> System: Windows NT 4.0, Perl 5.004_01, compiled with M$ VC++.
> 
> I'm using the open(F,"cmd|") construct, and while it works fine
> from the command line, it's not working when invoked as a
> CGI script by M$ IIS. "Not working" in this case means that
> the open() seems to work (doesn't invoke the associated "or die"),
> but that the redirection doesn't happen - following loop doesn't
> read any data under the CGI environment.

This is now solved. It's an IIS problem. :-) From Chapter 10 of the
IIS docs:

	CreateProcessWithNewConsole REG_DWORD
	Range: 0,1
	Default: 0, disabled

	By default, CGI scripts are run in a detached process. If you
	want to run CGI scripts in a process with a new console, for
	example when input/output redirection is in the script, change
	this setting to 1 The process will then be created using the
	CREATE_NEW_CONSOLE flag.

	Note: Creating a new console for each CGI script has serious
	performance implications and should not be done unless slower
	performance is acceptable.

This attribute goes under HKEY_LOCAL_MACHINE\SYSTEM\
CurrentControlSet\Services\W3SVC\Parameters.

Given that there's already another thread on this topic, it's
probably a good candidate for the CGI FAQ.

steve
-- 
<Steve_Kilbane@cegelecproj.co.uk> - All opinions are mine alone.
Kilbane's law of integration: standardise on protocols and file
formats, and the applications take care of themselves.



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

Date: Thu, 6 Nov 1997 06:48:46 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Todd Reichert <tr7488@swbell.net>
Subject: Re: pattern matching options
Message-Id: <Pine.GSO.3.96.971106064101.29771H-100000@usertest.teleport.com>

On Tue, 4 Nov 1997, Todd Reichert wrote:

> Does anyone know if you can substitute a variable for a pattern matching
> option?  For example:
> 
> $OPTION = "i";
> $word = "welcome";
> $expr = "com";
> if ( $word =~ /$expr/$OPTION) { print $word; } 

If the option is in qw/i m s x/, you may be able to do what you want by
embedding it. Either put it directly into the $expr, or add it yourself.
That is... 

    my $opts = join '',			# glue together strings
	map "(?$_)",			# of embedded regex options
	split //, $OPTION;		# made from chars of $OPTION

    ...  /$opts$expr/  ...

If the option is something else, you may need to use brian d foy's
method, using eval STRING. 

You should be aware that, if the option (or expression) may be supplied by
a user, it may cause an error. If you're trying to make your own grep-like
utility, that could be important. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!




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

Date: Thu, 06 Nov 1997 13:59:37 +0200
From: Bekman Stanislav <sbekman@iil.intel.com>
To: dg50@chrysler.com
Subject: Re: Perl->Java? Java->Perl? Gaaaaa!
Message-Id: <3461B129.ABD@iil.intel.com>

dg50@chrysler.com wrote:
> 
> I've got a nasty little problem I'd like some advice on.
> 
> I need to create a program that adds/edits/deletes from a little flat-file
> database, and executes a subroutine that then does something with the data
> in the flat file.
> 
> This by itself is a no-brainer. I've done similar programs (using a web
> interface as the API) so many times that I've lost count.
> 
> This time, however, it a little bit different. In this case, I don't have
> the luxury of a web server with Perl running behind it to act as my API
> manager. Instead, the application has to run offline - quite possibly on a
> *gasp* Wintel box. :(
> 
> I also can't count on having perlwin32 on this PC, nor can I count on
> this application staying on any particular machine. Next week, it may
> need to run on a Mac, or on Linux, or whatever.
> 
> So, Java, right? "Write once, run anywhere" right? (I can count on having
> access to a Java-enabled web browser, at least)
> 
> So I sketch out a nifty user interface (based loosly on the Win95 Network
> Control Panel) and call up the AWT specs, and... gaaaa, who designed this
> language? It's like trying to read a cookbook written by George Orwell in
> a 1984-ish mood, shortly after ingesting some alien hallucinagen! People
> actually *use* this and accomplish stuff? Inconceivable!
> 
> I want my nice, comprehensible perl code back!
> 
> So I guess what I want to do is write this app in perl, with some sort of
> ties to a windowing package of some sort, that I can then compile to Java
> bytecode (with all the windowing calls mapped to AWT, of course) that can
> then be wrapped up in a web page that resides on the user's local machine
> to be invoked by a browser bookmark.
> 
> Or do I?
> 
> I don't care if the compilation process results in my java program
> containing the perl interpreter, I don't care if native Java would result
> in a file size 100 times smaller, I just want to get this done without
> having to teach myself Java from scratch to accomplish what would be an
> hour long job in perl.
> 
> (and there's this issue of reading/writing local files too - this may not
> be runnable from a browser window, the machine this runs on may require
> the Java RTE no matter what - in which case I have to install some sort
> of RT package on the machine no matter what, throwing the "univeriallity"
> of Java right out the window...)
> 
> Anyone care to offer any advice?

Hi,

The following url might help you out:
japh - A Perl5 and Java Interface
http://www.hermetica.com/technologia/perl/japh/perlconf.html

______________________________________________________________________
Stas Bekman     mailto:sbekman@iil.intel.com [WebMaster Intel Corp]
Home Page:      http://www.eprotect.com/stas
A must visit: 	http://www.eprotect.com/stas/TULARC (Java,CGI,PC,Linux)
Linux-il Home:  http://www.linux.org.il/


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

Date: Thu, 6 Nov 1997 11:33:32 GMT
From: mick@picus.dcs.bbk.ac.uk (Mick Farmer)
Subject: Re: Precedence problem?
Message-Id: <EJ82rw.FCA@mail2.ccs.bbk.ac.uk>

Dear Wade,

Your problem is that "||" has a higher precedence than
"?:".  I suggest you use "or".

Regards,

Mick


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

Date: 6 Nov 1997 06:59:12 -0600
From: psamuels@sampo.creighton.edu (Peter Samuelson)
Subject: Re: Protecting Perl Source
Message-Id: <63sev0$92u$1@sampo.creighton.edu>

--BOUNDARY
Content-Type: text/plain

[Michael A. Suarez <msuarez@cybernet.com>]
> What is a good way to protect perl source...  I want to give some
> perl programs to a client, but I need to keep them from being
> modified, edited, etc.  I want to distribute them more as binaries,
> but compiling them is not allowed.  Any ideas?

Two possibilities.
(1) chmod a-w *.pl
(2) Write a client/server where code actually gets executed on your
    machine and data is passed back and forth, then don't give the code
    away at all.
(3) Write obfuscated code so the client won't *want* to modify it.

Toward (3), you might write a perl program that transforms code by
stripping out comments, collapsing whitespace, recoding to use implicit
$_ wherever possible and and randomly generating 4-character variable
names.  (That last will require some real tricky handling of references
and evals, of course.)

Peter Samuelson
<psamuels at sampo.creighton.edu>

--BOUNDARY
Content-Type: text/html

<BODY>This post is best viewed with a <B><I>real newsreader</I></B>.</BODY>
--BOUNDARY--


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

Date: Thu, 6 Nov 1997 13:44:30 GMT
From: swmcd@world.std.com (Steven W McDougall)
Subject: Re: Puzzle: palindromep
Message-Id: <EJ88u6.2Lx@world.std.com>

A Man of the 90's <brenner@lbrenner.ne.mediaone.net> writes:

>I was reading the unrolling a loop section of Mastering Regular
>Expressions and started thinking about palindromes. 

In general, recognizing palindromes requires a stack.
Therefore, it can't be done with a regular expression alone.

- SWM


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

Date: 06 Nov 1997 10:13:51 +0100
From: ckc@dmi.min.dk (Casper K. Clausen)
Subject: Re: Regex question
Message-Id: <wvp90v2gzao.fsf@hobbes.dmi.min.dk>

>>>>> "A" == Abigail  <abigail@fnx.com> writes:

[The regex was s/(\w+)\s+(\w+)\s+(\.*)/$3 $1 $2/ ]

A> Really? Judging your regex, I don't think so.
A> I would expect:
A>  Foo Barfoobar@foobar.com

Funny, I'd expect it to yield:

 . Foo Bar

It's obvious that what happens is $3 matches 0 occurences of '\.', but
why does $2 gobble up the rest of the line, even past the space?

A> Don't escape the . and it will be fine:-,
                                           |
A> $ perl -wle                             |
A> $_ = 'Foo Bar foobar@foobar.com';       |
A> s/(\w+)\s+(\w+)\s+(\.*)/$3 $1 $2/;      |
A> print;             ^--------------------'
A> __END__

Do what Abi says, not what she does :) And anchor that regex while
you're at it (for principle, if nothing else):

s/^(\w+)\s+(\w+)\s+(.*)/$3 $1 $2/;

Regards,
Kvan.
-- 
-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
----------<ckc@dmi.dk>---------- |  unattempted is impossible.'
           Lokal  544            |   
I do not speak for DMI, just me. |        - Lord Mhoram, Son of Variol.      


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

Date: 06 Nov 1997 04:57:11 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Regex question
Message-Id: <lq1affiuyyw.fsf@bmerhe83.nortel.ca>

Alan <ahecker@interport.net> writes:

> Well, to cut to the heart of the matter, I'm worse at them than I
> thought. With the regex I'm using, the sample line:
>    Foo Bar foobar@foobar.com
> becomes:
>    foobar Foo Bar
> The regex, as I have it, is as follows:
>    s/(\w+)\s+(\w+)\s+(\.*)/$3 $1 $2/;

Actually i can't get these results. But you shouldn't have the "\." which
means a literal ".".

The regexp you are most likely looking for is:

   s/(\S+)\s+(\S+)\s+(\S+)/$3 $1 $2/;

i.e. three words composed of non-space characters with whitespace in between.

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: 6 Nov 1997 06:40:12 -0600
From: psamuels@sampo.creighton.edu (Peter Samuelson)
Subject: Re: SSI Parameters
Message-Id: <63sdrc$90p$1@sampo.creighton.edu>

--BOUNDARY
Content-Type: text/plain

[Tom Pryor <tpryor@ctron.com>]
> Is this even possible?
> Im trying to pass parameters via a SSI to ISAPI perl.dll.

This newsgroup is about perl, not about server-parsed HTML, not about
CGI, certainly not about IIS.  I suspect you'd have the same
parameter-passing problem with other languages.  Maybe a web server
newsgroup would be of some help, or try Microsoft tech support.  (:

> I would like to use this syntax
>   <!--#exec cgi="/cgi-bin/some_script.pl param"-->
> However it doesnt work.  I suspect IIS doesnt like the space.
> I can get it to work this way
>   <!--#exec cgi="/cgi-bin/some_script.pl?paramName=param"-->

Try <!--#exec cgi="/cgi-bin/some_script.pl?param"-->.  I think that'd
work on some web servers, anyway.  Never used IIS.  (Never wanted to,
even.)

-- 
Peter Samuelson
<psamuels at sampo.creighton.edu>

--BOUNDARY
Content-Type: text/html

This post is best viewed with a <FONT SIZE=+2>real newsreader</FONT>.
--BOUNDARY--




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

Date: Thu, 06 Nov 1997 10:53:55 +0100
From: tobez@plab.ku.dk
Subject: Re: sub-totaling lines in a file??
Message-Id: <346193B3.B53@plab.ku.dk>

Burt Lewis wrote:

> This is what my file looks like:
> 
> cell1.gif - Sat Jul 19 14:42:28 EDT 1997 - 207.180.9.135
> amsoil.gif - Sat Jul 20 14:42:28 EDT 1997 - 207.180.9.135
> freitas.gif - Sat Jul 20 14:43:26 EDT 1997 - 207.180.9.135
> coopbank.gif - Sat Jul 20 14:43:27 EDT 1997 - 207.180.9.135
> morseins.gif - Sat Jul 21 14:50:56 EDT 1997 - 207.180.9.135
> morseins.gif - Sat Jul 21 14:50:57 EDT 1997 - 207.180.9.135
> coopbank.gif - Sat Jul 22 14:52:21 EDT 1997 - 207.180.9.135
> freitas.gif - Sat Jul 22 14:52:22 EDT 1997 - 207.180.9.135
> freitas.gif - Sat Aug 19 14:52:22 EDT 1997 - 207.180.9.135
> 
> The results I'm looking for is something like:
> 
> Jul 19 = 1 line
> Jul 20 = 3 lines
> Jul 21 = 2 lines
> Jul 22 = 2 lines
> Aug 19 = 1 lines
> 
> The result needs to be sorted in this order.

How about this:

#! /usr/bin/perl
my %months = (Jan => 0, Feb => 1, Mar => 2, Apr => 3, May => 4, Jun =>
5,
              Jul => 6, Aug => 7, Sep => 8, Oct => 9, Nov => 10, Dec =>
11);
my %h;

while (<>)
{
   next if /^$/;
   next unless /^.*? - .*? (... \d{1,2}) /;
   $h{$1}++;
}

sub month_date
{
   my ($am, $ad) = split ' ', $a;
   my ($bm, $bd) = split ' ', $b;
   my $c = $months{$am} <=> $months{$bm};
   $c ? $c : ($ad <=> $bd);
}

for (sort month_date keys %h)
{
   print "$_ = $h{$_} line${\($h{$_}>1?'s':'')}\n";
}
__END__

Hope this helps,

Anton.


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

Date: 06 Nov 1997 05:30:49 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Undefining an associative array element
Message-Id: <lq190v2uxeu.fsf@bmerhe83.nortel.ca>

wart@ugcs.caltech.edu (Wart) writes:

> I left my camel book at work, else I'd look it up myself.
> I'm using a dbm to store some info that can be submitted/displayed
> using a cgi-bin.  I want to add an option to delete an entry stored
> in the dbm file.  My attempt at this failed:
> 
> dbmopen(%info, $filename, 0644);
> if ($remove) {
>     undef $info{$key_to_delete};
> }
> dbmclose(%info);
> 
> This only seems to remove the value associated with the key, not the
> key itself.  How can I do this?

Perhaps you could try:

    delete $info{$key_to_delete};

As well as using the new tie interface for DBM access?

hope this helps :-)
mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

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

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