[6838] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 463 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 13 01:07:19 1997

Date: Mon, 12 May 97 22:00:26 -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           Mon, 12 May 1997     Volume: 8 Number: 463

Today's topics:
     Re: clever coding required (Chipmunk)
     Re: Drawing a graph? <vladimir@cs.ualberta.ca>
     Re: File Copy <good.luck@getting.spam.to.zenin.at.best.com>
     Re: Finding a pattern in a file (Tad McClellan)
     Re: FTP using LWP (Clay Irving)
     GD.PM on NT (Jared Evans)
     Re: Have a question? Post it here at the CGI Discussion (TOTO)
     Re: how do I get a binary representation of a number in <Lu@Beer.com>
     How do I use a graphic image as a SUBMIT button? (R)
     Re: How do I use a graphic image as a SUBMIT button? (Abigail)
     Re: How to safely and properly update an ASCII text dat (Michael A. Gronlund, Jr.)
     Re: htpasswd & PERL <merlyn@stonehenge.com>
     Re: Information on PERL 5 (Chipmunk)
     Re: Installing Perl 5.003 (Brooks Davis)
     Re: Mime types for .cgi, .pl ?? <djohnson@uu.net>
     Re: Need help on initializing a perl array (MAY DAY) !! <merlyn@stonehenge.com>
     Newbie flock() question <dannyman@arh0135.urh.uiuc.edu>
     Re: Pattern Matching Help Needed!! (Tad McClellan)
     Re: Perl CORBA IIOP module? (Bart Schuller)
     Re: perl/cgi help - need current date function (Andrew M. Langmead)
     Re: perl/cgi help - need current date function (Adam Schneider)
     Re: Perl/HTML/Win 3.1 Newbie question... <mc@marketing1.com>
     Re: Randal Schwartz <merlyn@stonehenge.com>
     readdir -t ? <earl@bell.us>
     Re: REQ: Perl obfuscator <sjn@pvv.ntnu.no>
     Re: STRAW POLL: RFD: comp.lang.perl reorg (Dominic Dunlop)
     Re: url detection in a string (Chipmunk)
     Re: Using variable to name an array???? (David Alan Black)
     wierd error with Shell.pm <debuigny@dallas.net>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 10 May 1997 16:04:03 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: clever coding required
Message-Id: <5l269j$tdd$1@dartvax.dartmouth.edu>

In article <5ksums$ab1@news.service.uci.edu>
"Eric D. Friedman" <friedman@uci.edu> writes:

> In article <5ksrr6$pkb$1@dartvax.dartmouth.edu>,
> Chipmunk <Ronald.J.Kimball@dartmouth.edu> wrote:
> 
> >s/ *\| */\|/g;
> >or
> >split(/ *\| */);
> 
> Not unless you're sure that tabs never get mixed in with those spaces.
> Better, I think, to use \s* instead of ` *`, my furry little friend.

The poster asked for code that would split on multiple *spaces*, so
that's what I gave him.  If he ends up with tabs in there, he can
figure out how to change my regex to match tabs as well.

Chipmunk


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

Date: 12 May 1997 11:23:28 -0600
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
To: uzs90z@uni-bonn.de (Michael Schuerig)
Subject: Re: Drawing a graph?
Message-Id: <omg1vsob8w.fsf@tees.cs.ualberta.ca>

There are several free graph layout programs on the net. Most of them are for
research purposes though. Perhaps the best one is graphviz (dot/neato) from
AT&T. It can generate ps/gif/ismap output. For undirected graphs use neato,
for directed graphs use dot (I see that it's described in tcl-faq/part5 as
tcldot/tkdot).

The site http://www.research.att.com/sw/tools/graphviz doesn't currently work,
but don't despair. It may be because of the recent reorganization of AT&T's
research division. Right, the new link is
http://portal.research.bell-labs.com/orgs/ssr/book/reuse/license/packages/95/graphviz_1_0.html

Also see http://www.cs.sunysb.edu/~algorith/files/drawing-graphs.shtml


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

Date: 13 May 1997 01:10:42 GMT
From: Zenin <good.luck@getting.spam.to.zenin.at.best.com>
Subject: Re: File Copy
Message-Id: <5l8f2i$8ln$1@nntp2.ba.best.com>

Becky Schonfeld <rebecc60@pobox.upenn.edu> wrote:

: Can anyone send me or recommend a very simple script to copy file1 to
: file2 except for one line from file1?  Any help is much appreciated.

	Which one line?

-Zenin
 Zenin @ Best . com


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

Date: Mon, 12 May 1997 07:24:33 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Finding a pattern in a file
Message-Id: <1627l5.9k.ln@localhost>

* (JD@anon.com) wrote:
: Hello - you seemed comfortable with Perl so I was wondering if you could
          ^^^

who?


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


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

Date: 10 May 1997 10:54:54 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: FTP using LWP
Message-Id: <5l227u$q34@panix.com>

In <336F69F8.167E@dircon.co.uk> Alex Schajer <schajer@dircon.co.uk> writes:

>I read somewhere about net::ftp. Is this worthwhile? The most important
>thing is verification of transfer. And is there good documentation
>available!!

I have some documentation available at:

   http://www.panix.com/~clay/perl/module_desc.cgi?5+Net::FTP

-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!


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

Date: 12 May 1997 09:52:35 -0400
From: jared@node6.frontiernet.net (Jared Evans)
Subject: GD.PM on NT
Message-Id: <5l77b3$1loq@node6.frontiernet.net>

I installed GD.PM for NT.  I followed the installation instructions and inserted
the files in the said directories.  I ran the test.pl and got a message saying:
"Error: Parse Exception"  I tracked it down to the bootstrap call in GD.PM.

What is the workaround to get rid of this message and get everything to click
together?



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

Date: Sat, 10 May 1997 16:36:52 GMT
From: sorry@no.can.do (TOTO)
Subject: Re: Have a question? Post it here at the CGI Discussion Forum.
Message-Id: <3375a415.1123590@news.enterprise.net>

In responce to your pathetic reply to my posting, here are my
comments.

>let's see, besides the JavaScript errors,
What errors (you are the first to mention them and I certainly cannot
see them in either NS3 or IE3)

>annoyingly long loading graphics
I'm working on that one but again, many others do not mind.

>small type (why mess with my choice of font size?),
Because it's my site, not yours.

>and poor use of frames
In what sense? I take it you do not like frames. 

>how is this better than usenet? 
It's not, It is intended as a supplement to avoid idiots like you that
post to usenet with posts like this one and for those that do not like
or use usenet.

> (btw, i find it rather ironic that a "CGI Board" would use one of Matt Wright's 
>scripts...)
What's wrong with that? Why do you think he provides them - for fun?

>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. ;)
>
>[1] <URL:http://homepages.enterprise.net/toto/cgi.html>
>in the "Where do I start" section.  i wonder if enterprise.net
>would like know about such poor security advice to users of
>their system?
This is the official CGI FAQ that Enterprise PLC created back in April
96. 

"CGI scripts can reside in any directory, however, this directory must
be both readable and writeable by everyone and executable. As such,
you will need to create a sub-directory."

How can Enterprise complain when they wrote the FAQ? I will be
advising readers in the next part that full read write and execute
permissions should not be given to these types of directories.

I also noticed that on your site (that I don't really think much of by
the way, very plaid) that you don't even practice what you preach! Why
do you no use a cgi script for your email?

Satisfied? No probably not.

TOTO
shootem@hotmail.com



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

Date: Sat, 10 May 1997 10:06:10 -0700
From: Luis Ontanon <Lu@Beer.com>
Subject: Re: how do I get a binary representation of a number in a string
Message-Id: <3374AB02.58F6@Beer.com>

Thomas Oelke wrote:
> Here's what I want to have,
> 
>   $i = "12";   # or any number 0-15.
>   $tmp = somefunc($i);
>   print "$i in binary is $tmp\n";
> 
> Then get for output:
>   1110
no way you can get just "1110" from that print statement... you may be
able to print just 1110 on some systems (by using backspaces) but I
think the output you actually would get (and most probably you do) is
actually:
12 in binary is 1100

Actually, I think there are as many ways to solve this problem as space
in the universe...

let's try some:

one could be just by brute force
sub somefunc {
	(($_[0] == 0 ) && $retval = "0000") ||
	(($_[0] == 1 ) && $retval = "0001") ||
	(($_[0] == 2 ) && $retval = "0010") ||
	(($_[0] == 3 ) && $retval = "0011") ||
	(($_[0] == 4 ) && $retval = "0100") ||
	(($_[0] == 5 ) && $retval = "0101") ||
	(($_[0] == 6 ) && $retval = "0110") ||
	(($_[0] == 7 ) && $retval = "0111") ||
	(($_[0] == 8 ) && $retval = "1000") ||
	(($_[0] == 9 ) && $retval = "1001") ||
	(($_[0] == 10) && $retval = "1010") ||
	(($_[0] == 11) && $retval = "1011") ||
	(($_[0] == 12) && $retval = "1100") ||
	(($_[0] == 13) && $retval = "1101") ||
	(($_[0] == 14) && $retval = "1110") ||
	(($_[0] == 15) && $retval = "1111") ;
	
	$retval;
}
this first one could be done even using if ... elsif ... elsif ...
but I'm lazy so I prefer logical operators.

just as a reminder... the remainder could help!
sub somefunc {
	$retval = "";
	for ( $j = 2 ; $j < 16 ; $j *= 2 ) {
		$retval = $retval.(($n = $_[0] % $j) ? "0" : "1");
		$_[0] -= $n;
	}
	$retval;
}

we can use it's perfectly equivalent (?), too:
sub somefunc {
	$retval = "";
	$j = 2; 
	while ($j < 16) {
		$retval = $retval.(($n = $_[0] % $j) ? "0" : "1");
		$_[0] -= $n;
		$j *= 2; 
	}
	$retval;
}

an array? yea it can do it too...
@nibble = ("0000","0001","0010","0011","0100","0101","0110","0111",
           "1000","1001","1010","1011","1100","1101","1110","1111")
[...]
sub somefunct {
	$nibble[$_[0]];
}
I think this is the one that involves the least typing so for me it
comes to be the best.

Now i think that's enough for now. I got better thinks to do on a
weekend... 

I'm gratefull to you for the satisfaction I got by wrinting this reply.
-- 
LEGAL NOTICE:
THE ABOVE INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DAMAGES
WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL,
LOSS OF BUSINESS PROFITS, OR SPECIAL DAMAGES, EVEN IF THE AUTHOR
HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THE AUTHOR
DOES NOT AUTHORIZE TO APPLY THE ABOVE INFORMATION IN STATES WHERE
THIS DISCLAIMER IS NOT APPLICABLE.

As you can see, I'm not just lazy but irresponsible too.
---
Luis Ontanon, an officially certified weirdo. :)
mailto:Lu@Beer.com even drunk!
 .


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

Date: Mon, 12 May 1997 23:04:07 GMT
From: R@r.v (R)
Subject: How do I use a graphic image as a SUBMIT button?
Message-Id: <5laebc$b4$1@newsource.ihug.co.nz>

I would like to use a graphic button as a submit button in a form.

Does anyone know how to apply the ACTION from a submit button to a graphic?

Regards


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

Date: Tue, 13 May 1997 03:58:33 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How do I use a graphic image as a SUBMIT button?
Message-Id: <EA3ppL.Jyq@nonexistent.com>

On Mon, 12 May 1997 23:04:07 GMT, R wrote in comp.lang.perl.misc
URL: news:5laebc$b4$1@newsource.ihug.co.nz:
++ I would like to use a graphic button as a submit button in a form.

Goodie! You tax form?

++ Does anyone know how to apply the ACTION from a submit button to a graphic?

<FORM METHOD = "READ THE FAQ"
      ACTION = "news:comp.infosystems.www.authoring.html">


(Yeah, I know the answer, and I would have given it to you on the
right platform.)



Abigail


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

Date: Tue, 06 May 1997 05:53:03 GMT
From: phoenix@ptw.com (Michael A. Gronlund, Jr.)
Subject: Re: How to safely and properly update an ASCII text database?
Message-Id: <336ec69f.10822251@news.ptw.com>

On 5 May 1997 22:42:01 -0700, Martin Mathis wrote:

>Hi all,
>
>I'm learning PERL with a bunch of books at my hands. However, I can't
>seem to find an answer to the following task:
>
>I have an ASCII text database with e.g. addresses for an example, one
>record per line. Each record contains an "active" flag ("Y" or "N").
>Based on some criteria I want to change some flags from Y to N.
>
> [SNIP]
>
>How is a simple ASCII text database commonly and safely being updated?
>
>TIA and best,
>-Martin
>______________________________________________________________

To My Knowledge Thats The Only Way To Modify/Update A Plan Text Database. Best Recommendation I have For You Is To Look Into Using
perl's dbmopen() functionality.  And Write A Second Utility To Export The Database File To An ASCII Delimited Database File.

Best Regards,
Mike

P.S. If You Do Find A Way PLEASE Let Me Know =)


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

Date: 10 May 1997 10:08:09 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: htpasswd & PERL
Message-Id: <8cd8qz45mu.fsf@gadget.cscaper.com>

>>>>> "Magnus" == Magnus Bodin <Magnus.Bodin@tychonides.se> writes:

Magnus> And here's some source sample:

Magnus> # usage: &append_pass(<filename>,<user>,<pass>);
Magnus> #
Magnus> sub append_pass {
Magnus> 	($file,$user,$pwd)=@_;

Magnus> 	$salt=&saltchar+&saltchar;
Magnus>   $cryptpwd=crypt($pwd,$salt);

Magnus> 	open(FILE,">>$file");
Magnus> 	print FILE "$user:$cryptpwd\n";
Magnus> 	close(FILE);
Magnus> }	

Magnus> # returns a "random" saltchar
Magnus> sub saltchar {
Magnus> 	# salt should consists of [A-Za-z0-9./] 
Magnus>   # saltchar is by the way kinda joke for swedes: 
Magnus>   # salt tumblers is called saltkar..

Magnus> 	$rc=rand(62);
Magnus> 	if ($rc<25) { $rc+=65; }     #  0-24 goes   A-Z
Magnus> 	elsif ($rc<50) { $rc+=72; }  # 25-49 goes   a-z 
Magnus> 	else { $rc-=4; }             # 50-61 goes ./0-9
Magnus> 	$rc;
Magnus> }
	
Magnus> example:

Magnus> &append_pass('.htaccess','reinar','xyzzy');

Magnus> or whatever..

Or even:

	use HTTPD::UserAdmin;
	HTTPD::UserAdmin
		->new(Path => '/Path/to/directory')
		->add('reinar','xyzzy');

which even handles the locking and everything all behind the scenes.
HTTPD::UserAdmin is in the CPAN (of course).

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 478 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 10 May 1997 16:35:10 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Information on PERL 5
Message-Id: <5l283u$v8c$1@dartvax.dartmouth.edu>

In article <5ktm8u$6du@samba.rahul.net>
"Jennie Van Heuit" <peapod@rahul.net> writes:

> On Sat, 26 Apr 1997 08:19:56 GMT, "Mark Allison"
> <mark@markallison.demon.co.uk> wrote:
> > My current contract requires me to learn PERL 5. After first glances at
> > this language, I was absolutely horrified. Expressions like /([^ )*&
> > $b)]{(~=} are normal! 
> 
> Of course, anyone who has to *maintain* code like this will
> want to kill you. It isn't that hard to write easy-to-read
> perl code.

But it's much more fun to write hard-to-read Perl code!  Hehe!

Chipmunk

Good programmers don't write comments - if it was hard to code, it
should be hard to understand.


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

Date: 12 May 1997 23:04:36 GMT
From: brdavis@orion.ac.hmc.edu (Brooks Davis)
Subject: Re: Installing Perl 5.003
Message-Id: <5l87m4$l2r$1@cinenews.claremont.edu>

Terry Robison (trobison@erols.com) wrote:
: First, let me say that I am not a systems person, I am a programmer working
: with the systems shop to get 5.003 installed. With that said let me explain
: the problem.  We have Perl 5.001 installed on our server.  I want to
: install 5.003 on the server, but systems can't upgrade the current version
: because of config mgt. Would like to install in another directory.  Systems
: has tar'd to a new directory. We can't find installation instructions or
: readme in the directory. Are we missing something. Can someone point us to
: installation/compiling guidance?

The fourth question in the Configure script is:

Installation prefix to use? (~name ok) [/usr/local]

If you set it to something other then where perl-5.001 is installed then
everything should be fine.  The system I administer has perl installed
in /usr/local/pkg/perl-5.003.

-- Brooks


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

Date: Mon, 12 May 1997 15:47:02 -0500
From: Dale Johnson <djohnson@uu.net>
Subject: Re: Mime types for .cgi, .pl ??
Message-Id: <337781C6.2781E494@uu.net>

Zonycat wrote:
> 
> I am having no luck trying to locall display my cgi scripts.  I have
> installed PWS and it works for finding my htm file.  When it tries to
> execute the cgi file, a window flashes and it appears to say something
> about not finding something in the Temporary Internet directory.  Why on
> earth it is trying to go there I have no idea.  I did get the "source "
> of the cgi script to display if I associated the .cgi with a mime type
> of 'text/htm'.  I know that is not right.

> Any ideas would be greatly appreciated from people trying to use a local
> server to test cgi programs such as the Personal Web Server (PWS)
> 
> Thanks,
> 
> Dennis

Dennis,

The MIME Type for cgi stuff is this:

Content-type: application/x-httpd-cgi

Then set the extentions to be .cgi and .pl.

Make sense?

Good luck.

Dale

--


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

Date: 10 May 1997 10:03:00 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: masroor <masroor@bga.com>
Subject: Re: Need help on initializing a perl array (MAY DAY) !!!!!
Message-Id: <8cg1vv45vf.fsf@gadget.cscaper.com>

>>>>> "masroor" == masroor  <masroor@bga.com> writes:

masroor> Question ==> Now how can I make this array contain 

masroor> "1" and "2" and "3". That is if I print the array , it should print
masroor> the numbers with the qoutes. In other words How can I make the array print
masroor> "1" "2" and "3", instead of 1 2 3 without the qoutes.

Map is your friend.  Use map.

	@quoted_array = map qq/"$_"/, @original_array;

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 478 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 13 May 1997 04:40:54 GMT
From: Dannyman <dannyman@arh0135.urh.uiuc.edu>
Subject: Newbie flock() question
Message-Id: <5l8rcm$e6m@vixen.cso.uiuc.edu>

	Uhmmm, I've taken knowledge of flock(0 based on pages 153 and 154 of
O'Reilly's CGI book, and from reading the man page on my FreeBSD system.

	One locks files, yet flock is called on file descriptor. The
methodology used on page 154 of Gundavaram involves locking the file, reading
it in, unlocking it, then re-opening the file, locking it, and writing it
again.

	Is this entirely reliable? Is there a better way? my guess is that
one could, in the space of releasing the lock between switching from a read
filehandle to a write filehandle, another process could intervene and change
the file, but that that change would be overwriten by the first process that
has read the file data in to it's memory, and must release it's lock before
it can write out its changes to the file.

	Obviously, any enlightenment would be much appreciated. Can a
textfile be safely opened in read/write mode somehow? (File newbie here too
 ..) How then, does that work? Is the locking state somehow maintained by perl
between the releases on the filehandle? Does close() actually release the
file lock? If it doesn't, is it then cool to leave the flock() in cloce while
closing,reopening the filehandle? Could flock() then be called to unlock the
new file descriptor?

	TIA.

-- 
  //Dan  -=-     This message brought to you by djhoward@uiuc.edu    -=-
\\/yori  -=-     HOME PAGE! http://www.uiuc.edu/ph/www/djhoward/     -=-
                          The Choice for Me: SPAM FREE!


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

Date: Mon, 12 May 1997 07:39:56 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Pattern Matching Help Needed!!
Message-Id: <s237l5.go.ln@localhost>

Frank Fisher (frank@primemail.com) wrote:
: I have a string I'm trying to match on:

: $filter = "this is a test string 1234****";
: $str = "1234****";


1)
$str = "1234\*\*\*\*";  # escape metacharacters yourself


2)
$str = quotemeta("1234****"); # escapes all metacharacters for you


: I get the following perl error:

: /*/: ?+* follows nothing in regexp at test.pl line 58

: this is line 58:

: if ($str =~ /$filter$/)
      ^^^^^^^^^^^^^^^^^

You have those backwards.  $filter =~ /$str$/;

3)
if ($filter =~ /\Q$str\E$/)  # escapes all metacharacters for you


: Is there anyway to turn off perl trying to see the * char as a special
: character?  I need to look at the last part of the string which is
: 1234****


There's three, all easily found by word searching for "metacharacter"
in the Perl man pages.


: Thanks...


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


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

Date: 10 May 1997 13:12:31 GMT
From: schuller+news@lunatech.com (Bart Schuller)
Subject: Re: Perl CORBA IIOP module?
Message-Id: <5l1s7v$er4$1@aladdin.rotterdam.luna.net>

[comp.lang.perl is long dead, Newsgroups trimmed]

In article <5kqng8$rqo$1@inet16.us.oracle.com>,
Oracle News 2 <rpang@us.oracle.com> wrote:
>
>A related question.  Is there any CORBA-Perl mapping definition underway
>right now?  I understand that Perl does not have the notion of datatypes
>which makes such a mapping difficult.  Has anyone thought about how to
>overcome this difficulty?

I've set up a mailinglist to discuss these issues, as well as my own
implementation of CORBA in Perl. The list is at cope-request@lunatech.com
Details on htpp://www.lunatech.com/cope/

For your question: A CORBA mapping is not hard. Perl does have plenty of
datatypes, it's just that they are not strongly typed.

For example, a short and a string will both map to the same perl datatype
(a scalar). But a stub method knows that for example the CORBA object
expects a short and so interprets the parameter as a short. You could
hand this method a string and it will probably be interpreted as 0. That's
a case of "Don't do that, then". After all, the IDL for the method told you
it expects a number.

The same goes for other datatypes. I represent structs as associative-
arrays. What happens if you put more keys in them? That's undefined.

The bottom line is: as long as you remember that you're talking to a
strongly typed system and play by the rules of that system, all will
be fine.

-- 
Bart Schuller                  schuller+sig@lunatech.com At Lunalabs, where the
Lunatech Research              http://www.lunatech.com/  future is made today..
Partner of The Perl Institute  http://www.perl.org/    Linux http://www.li.org/


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

Date: Sat, 10 May 1997 13:19:33 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: perl/cgi help - need current date function
Message-Id: <E9yvoL.59A@world.std.com>

peter.wood@axom.com (Peter Wood) writes:

>I'm trying to put a function in a cgi perl script that will print out the
>current date into an html form field.  What I have now is:

>sub getTheDate {
>  $thedate = system("date +%D);
>}

>and when I am in the subroutine where I want to call it, I just:

>&getTheDate;

system() does not do what you think it does. It runs the program and
the output of the program is sent to the same place as the parent
programs output. (If you where running the script from a terminal,
when you call system, it outputs to the terminal too.

I think you want the backticks operator `date +%D`.

This is coverted in the FAQ.


-- 
Andrew Langmead


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

Date: Sat, 10 May 1997 10:39:35 -0600
From: acs@bitstream.net (Adam Schneider)
Subject: Re: perl/cgi help - need current date function
Message-Id: <acs-1005971039350001@port109.bitstream.net>

peter.wood@axom.com (Peter Wood) said:
> I'm trying to put a function in a cgi perl script that will print out the
> current date into an html form field.

Here's the ugly little subroutine that I wrote for my CGI stuff:

sub CurrentTime
{
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  $mon += 1;
  if ($hour < 12) { $ampm = "AM"; }  else { $ampm = "PM"; }
  if ($hour > 12) { $hour -= 12; }
  if ($hour == 0) { $hour = 12; }
  if ($min < 10) { $min = "0$min"; }
  $datetime = "$mon/$mday/$year, $hour:$min $ampm";
}

The important part is the "localtime" function that takes the long number
that is "time" and turns it into a readable array.

If you don't mind 24-hour time, you can take out ALL the "if" statements
and remove "$ampm" from the last statement.

If you only need the date, take out all the if's and pare the last
statement down to just "$mon/$mday/$year".  You do need $mon += 1, though,
because Perl thinks January is 0, May is 4, etc.


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Adam Schneider * schneider@pobox.com * http://pobox.com/~schneider/adam.html
Co-author of "The Web Server Handbook": http://www.prenhall.com/~palmer/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


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

Date: Fri, 09 May 1997 06:48:41 -0700
From: Mike Christopher <mc@marketing1.com>
Subject: Re: Perl/HTML/Win 3.1 Newbie question...
Message-Id: <33732B38.7325@marketing1.com>

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

<snip>

> a Delphi .EXE which executes "PERL.EXE PerlScript.pl" which works fine
> from my FileManager, but again doesn't work right from inside my
> browser's HTML page.  It tries to "download" the .EXE instead of running
> it.  Can anyone help me here???
>

Here's a possible solution. There are probably better ways, but this
will
work on your machine ...

In your browser, associate all .exe's to run PERL.EXE
-- 
=========================================================================
Michael Christopher                                Internet Solutions 
WWW Marketing Solutions               		      for Business
Portland, Oregon 97220-3819
(503) 253-3782                                  HTML - JavaScript - Perl
http://www.marketing1.com
=========================================================================
  "The first rule of intelligent tinkering is to save all the pieces."
						       - Aldo Leopold


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

Date: 12 May 1997 19:15:29 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Randal Schwartz
Message-Id: <8cwwp4rubi.fsf@gadget.cscaper.com>

>>>>> "Tung-chiang" == Tung-chiang Yang <tcyang@netcom.com> writes:

Tungchiang> He/she wants to catch everyone's attention by using
Tungchiang> Randal's name in the subject :)

Well, at least he-she spelled my name right.  You wouldn't believe the
number of incorrect ways to spell either Randal or Schwartz, and
therefore the number of permutations of both.

Of course, some would argue that my first name is spelled wrong
anyway. :-)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 476 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Fri, 09 May 1997 09:15:51 -0700
From: Chris Andrew <earl@bell.us>
Subject: readdir -t ?
Message-Id: <33734DB7.7ADC@bell.us>

How can I read the files of a directory *time-sorted* kind of the
Unix *ls -t* command. I want to do it in an easy way when doing

@files = readdir(DIR);

Is there a switch to 'readdir'?


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

Date: 13 May 1997 01:05:50 GMT
From: Salve J Nilsen <sjn@pvv.ntnu.no>
Subject: Re: REQ: Perl obfuscator
Message-Id: <5l8epe$hll@due.unit.no>

And then, Chipmunk suddenly uttered...
> In article <5kqat4$3un@due.unit.no>
> Salve J Nilsen <sjn@pvv.ntnu.no> writes:

> > ==================================< arghify.pl >==
[deletia codum]

> 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.

Right, here comes my latest version of arghify.pl, :)

==================================< badarghify.pl >==
#!/store/bin/perl -w
require 5.003;use strict;use diagnostics;my $c = 0;my $d = 0;$/ = undef;$_ = <> || "";my %e = {};my %f = {};my %g = {};my $h = "";study $_;s/^(\#\!.*?[\n\r])/\n/s;$h = $1 || "";my $i = "a";warn "Pass 1... Variables\n" unless $d;s/([\$\@\%]|\$\#)([a-zA-Z]\w*|_\w+)/$1.&r($2,\%e,0)/gem;my $j = "a";warn "Pass 2... Subroutines\n" unless $d;s/(:?sub\s+)([a-zA-Z]\w*)/"sub ".&r($2,\%f,0)/gem;s/\&([a-zA-Z]\w*)/"&".&r($1,\%f,1)/ge;my $k = "A";warn "Pass 3... Filehandles\n" unless $d;s/^\s*open(\s+|\s*\(\s*)([A-Z]\w*
)/"open$1".&r($2,\%g,0)/gem;s/([A-Z]\w*)/&r($1,\%g,1)/ge;warn "Pass 4... Whitespace and comments\n" unless $d;s/((?:\\\\)*(?!\\)?([\"\'])[^\1]*(?:\\\\)*[^\\]\1|([\"\'])\2|(?:\\\\)*\\\#.*?$|\$\#.*?$)|\#.*?$|\s{2,}|[\r\n]|\#.*?$/$1/gmx;warn "Printing.\n" unless $d;print "$h$_";warn "\nDone!\n" unless $d;sub r {my($n, $m, $o) = @_;$$m{$n} = $i++ unless ($o || $$m{$n});warn "SWAP($m) -> $n:$$m{$n}\n" if ($c && !$o);return $$m{$n}?$$m{$n}:$n;}
==================================< badarghify.pl >==

Just kidding! :D

Here's the real code... 

==================================< arghify.pl >==
#!/store/bin/perl -w
#@(#)RELEASE VERSION 'arghify.pl' V0.06 Perl obfuscator
# STORE is a system for installing and maintaining third party
# software on UNIX computers. For more info, take a look at 
# URL:http://www.pvv.unit.no/~arnej/store/storedoc_toc.html

#
# This program was made by Salve J. Nilsen <sjn@pvv.org> with
# good advice from <Ronald.J.Kimball@dartmouth.edu>
#

require 5.003;
use strict;
use diagnostics;

my $DEBUG = 0;
my $QUIET = 0;

# It's quite important to unset the input record seperator here :)
$/ = undef;
$_ = <> || "";

my %vars = {};
my %subs = {};
my %filehandles = {};
my $head = "";

study $_;

# single out the first line - if it begins with #!
s/^(\#\!.*?[\n\r])/\n/s;
$head = $1 || "";

# ##############################
# 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:
#
my $msv = "a";
# (note that the variables will look like "_$msv" in the end :)
warn "Pass 1... Variables\n" unless $QUIET;
s/([\$\@\%]|\$\#)([a-zA-Z]\w*|_\w+)/$1.&swap($2,\%vars,0)/gem;

# Bugs:
# Doesn't understand the ${name} construct
# ##############################


# ##############################
# ... Then we'd we'd like to garble up the subroutine names....
# Our MetaSyntactical Subroutinename of Choice Today is:
#
my $mss = "a";
warn "Pass 2... Subroutines\n" unless $QUIET;
s/(:?sub\s+)([a-zA-Z]\w*)/"sub ".&swap($2,\%subs,0)/gem;
s/\&([a-zA-Z]\w*)/"&".&swap($1,\%subs,1)/ge;

# Bugs:
# Doesn't check if the sub is inside a textstring :\
# ##############################


# ##############################
# ... And finally like to garble up the filehandles! :)
# Our MetaSyntactical Filehandle of Choice Today is:
#
my $msf = "A";
warn "Pass 3... Filehandles\n" unless $QUIET;
s/^\s*open(\s+|\s*\(\s*)([A-Z]\w*)/"open$1".&swap($2,\%filehandles,0)/gem;
s/([A-Z]\w*)/&swap($1,\%filehandles,1)/ge;

# Bugs:
# Works only with filehandles declared with open()
# Doesn't check if the filehandle is inside a textstring :P
# ##############################


# ##############################
# Remove text from q|#| to end of line, exept when q|\#|, q|'#'|
# or q|"#"|.
# Look out for \\# and similar cases (q|\\\\#| etc).
# Remove excess (two or more) whitespaces plus newlines/returns.
#
warn "Pass 4... Whitespace and comments\n" unless $QUIET;
s/(
   (?:\\\\)*(?!\\)?([\"\'])[^\1]*(?:\\\\)*[^\\]\1|
   # We don't want to touch strings
   ([\"\'])\2|
   # - not even empty ones!
   (?:\\\\)*\\\#.*?$|
   # and we're aware of escaped hashes
   \$\#.*?$)|
   # and the length-of-array index ($#foo)
   \#.*?$|
   # ... so let's keep this stuff!
   \s{2,}|
   # We want to remove all excess whitespace (but leave one though)
   [\r\n]|
   # and the newlines
   \#.*?$/$1/gmx;
   # and the comments!

# Bugs:
# Can't remove comments from inside regular expressions
#  with the /x modifier, unless they are on a seperate line.
# Can't remove comments from inside RE of the (?#comment) type.
# Doesn't recognize "print << EOT;" constructs.
# The \\\\\# comment construct is not tested (yet)
# A tab whitespace ("\t") won't be substituted with a space (' ')
# ##############################

warn "Printing.\n" unless $QUIET;
print "$head$_";
warn "\nDone!\n" unless $QUIET;


# ##############################
# swap() builds a hash (%$hashref) of the $name strings swap()
# gets each call. If $safe is set, the hash will not be updated,
# and if $$hasref{$name} does not exist, $name is retuned.
#
sub swap {
    my($name, $hashref, $safe) = @_;
    $$hashref{$name} = $msv++ unless ($safe || $$hashref{$name});
    warn "SWAP($hashref) -> $name:$$hashref{$name}\n" if ($DEBUG && !$safe);
    return $$hashref{$name}?$$hashref{$name}:$name; 
}

# Bugs:
# Dunno any yet!
# ##############################
==================================< arghify.pl >==

Well, my program works! But it is still uncomplete, and if anyone ahs
any thoughts, It'd love to hear them! :)

-- Salve J. Nilsen

#!/store/bin/perl
#@(#)RELEASE VERSION .sig V1.02 by Salve J. Nilsen - Hacker, Student, Magician
($_='$ZNVYGB+$FWA?$CII:$BET;')?y:;ZA-Y\:?+${':\nm-za-l.@\:\0:?print:'}.':'.$';


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

Date: Sat, 10 May 1997 17:00:01 +0200
From: domo@tcp.ip.lu (Dominic Dunlop)
Subject: Re: STRAW POLL: RFD: comp.lang.perl reorg
Message-Id: <19970510170001135379@dialup16.ip.lu>

A. Deckers <I-hate-cyber-promo@man.ac.uk> wrote:

> Date: 9 May 1997 18:31:03 GMT
>...
> The ballot will close on Saturday, 10th of May sometime in the morning
> (as soon as I'm awake enough to logon).

Sorry, Alain, this straw poll idea won't fly.  You can't post something
like this after close of business in England on a Friday and expect to
have useful, representative feedback the next morning.  Even if news
propagates fast (as it tends to, these days) most people just won't read
news in the short window you allow.  Either allow a longer time for
responses -- including, I'd say, at the very least one working day
throughout the world, or just don't bother.

>[NB: followup to poster]

Apologies for posting my response, but, ummm, this isn't a responsive
reply.
-- 
Dominic Dunlop


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

Date: 10 May 1997 16:49:51 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: url detection in a string
Message-Id: <5l28vf$u7p$1@dartvax.dartmouth.edu>

In article <3372F546.4BFB@unl.ac.uk>
Alastair Aitken <a.aitken@unl.ac.uk> writes:

> Sascha Kerschhofer wrote:
> 
> > $test = "look at http://info.com/mor.html for further information";
> > &findurl($test);
> > 
> > $test should now be: "look at <A
> > HREF="http://info.com/more.html">http://info.com/more.html</A> for further
> > information"
> > 
> > i tried with the following:
> > 
> > sub findurl {
> >   $_ =~ s/(.*)(\shttp://.*\s)(.*)/$1 <A HREF="$2">$2</A> $3/g
> > }
> > but this doesnt work.
> 
> This does:

 ...

> sub findurl {
>     $test = s#"|\\##g;
>     $test =~ s#(.*)\s(http://.*?)\s(.*)#$1 <A HREF="$2">$2</A> $3#g;
> }
> 
> The first substitution (using the '#' character to separate the elements
> of the 's' function) removes all escape characters and double quote -
> you could take this as far as you need.  The second line makes an href
> out of the http://... in $test.  the '?' in the regexp is for non-greedy
> matching (ie: stop matching asap).  I tried this with a simple query
> type url of the form above and it coped ok.


Did you test that with multiple URLs in the same line?  It looks to me
like it would only change the first URL, because the second (.*) would
match the rest of the line.  What's the point in matching (.*) anyway?

Try this instead:
s#(\s)(http://\S*)#$1<A HREF="$2">$2</A>#g;

(This one also preserves the exact whitespace character before the URL,
instead of changing it to a space.)

Chipmunk


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

Date: 12 May 1997 23:08:06 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: Using variable to name an array????
Message-Id: <5l87sm$eo6@pirate.shu.edu>

Hello -

Steve Fling <sfling@pcisys.net> writes:

>If it is possible, what is the syntax to use a variable to name an
>array?  For example, this is what I am inclined to do: @"$name"
>but this does not seem to work.

You want to learn about symbolic references.  Example:

$a = "abc";
@{$a} = (1,2,3);
print @abc;
^D
123

Have a look at the perlref man page.

David Black
dblack@icarus.shu.edu


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

Date: Fri, 09 May 1997 14:46:52 -0700
From: "Art C. DeBuigny" <debuigny@dallas.net>
Subject: wierd error with Shell.pm
Message-Id: <33739B4C.72E4@dallas.net>

Greetings.  I am running perl 5.003 on an AIX 3.2.5 system.  I have a
script that uses Shell.pm to access a shell within the perl script.  As
a test, I did this.

use Shell qw(lsps);

print lsps("-a");

This code runs fine from a command prompt.  When it is called from a web
browser, though, it doesn't do anything but display the hourglass.  They
leave background processes running that must be killed.  If I comment
out those two lines, the rest of the script runs fine and returns
information to the browser.

My question is has anyone experienced this problem, or does it sound
familiar?  It must be something simple, but I cannot imagine what that
may be.  

Thanks!

-- 
--------------------------
| Art C. DeBuigny        |
| debuigny@dallas.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 463
*************************************

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