[6551] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 176 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 25 10:13:09 1997

Date: Tue, 25 Mar 97 07:00:27 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 25 Mar 1997     Volume: 8 Number: 176

Today's topics:
     Re: 1 2 Many (Help!) (Tad McClellan)
     ANNOUNCE: CDB_File 0.6 available (Tim Goodwin)
     Announce: Embperl 0.11-beta - embed perl code in html f <richter@ecos.de>
     ANNOUNCE: Math::Fraction, version 0.4 alpha kevina@clark.net
     ANNOUNCE: ZFilter 2.7 (The Viper)
     Re: cls || ClrScr?? (Dominic Dunlop)
     Directory Listing in Perl <pdenman@ims.ltd.uk>
     Document Contains No Data <atms@zilker.net>
     Re: Getting filedates in perl (Honza Pazdziora)
     Re: How do I delete a line out of a text file <mcampbel@tvmaster.turner.com>
     Re: Is CGI a part of or similiar to Perl? <jrtietsort@micron.com>
     Re: Live Randal Schwartz interview <merlyn@stonehenge.com>
     On-line web page editor:  Changing the directory a file (Zyana)
     Re: On-line web page editor:  Changing the directory a  (Eric Bohlman)
     Re: On-line web page editor:  Changing the directory a  (Zyana)
     Perl book sugestions wanted (Falcon)
     perldoc for windows (Win32) <ea1217@fen.baynet.de>
     Pre-Alpha copy of Convert::BinHex available <eryq@enteract.com>
     Re: Reg. Expressions with Associative Arrays (David Alan Black)
     Rename Comand Programming Project - Will Pay Money annette@wwip.com
     Re: Results from a system call <tchrist@mox.perl.com>
     Re: sendmail and perl question (Tad McClellan)
     Re: term 'regular expressions' considered undesirable (Rahul Dhesi)
     Re: Unix 'Cat' equivelent <mcampbel@tvmaster.turner.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 25 Mar 1997 06:26:24 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: 1 2 Many (Help!)
Message-Id: <g9g8h5.vm.ln@localhost>

Honza Pazdziora (adelton@fi.muni.cz) wrote:
: slacker@dixonillinois.com writes:

: > I've been messing with this for far too long for what seems like it
: > should have a simple answer. All I'm trying to do is read a file in
: > ($file) if it exists and then print the same file back out. It works
: > but I'm getting 2 entries for each line in the first file which I do

: 2 entries. Does it mean you get each line twice? Or you get extra
: empty line after each line?


If and extra empty line, then has $, been set to "\n"?


: > not want. Does it matter that it's a comma seperated varable file?
: > If some one has the answer and the time to explain why the answer
: > works I can use all the help I can get. 
: > 
: > 
: > if (-e $file){
: >      open(ORIGINAL_CSV_FILE, "$file") or die "Can't open $file, $!" ;
: > 
: > 	print <ORIGINAL_CSV_FILE> ;
: > }

: Well, this piece of code works for me after I put $file = 'subjects';
: line in front of it. Are you sure you do not mess up perl's variables
                                               ^^^^^^^^^^^^^^^^^^^^^^^^
: somewhere before this code?




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


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

Date: 25 Mar 1997 14:03:59 GMT
From: tim@pipex.net (Tim Goodwin)
Subject: ANNOUNCE: CDB_File 0.6 available
Message-Id: <5h8m0f$br$1@nadine.teleport.com>

An updated version of the CDB_File module is now available.  It includes
these enhancements:

    o full support for repeated keys;
    o compatibility with the Perl I/O abstraction (but not sfio, sorry);
    o support for building as a static extension;
    o improved performance;
    o better handling of exceptional conditions;
    o expanded documentation.

CDB_File is a Perl interface to Dan Bernstein's cdb package, which
implements Constant DataBases.  The CDB_File distribution includes a
complete and unmodified copy of release 0.55 of cdb.

CDB_File-0.6.tar.gz is available now from CPAN.  It is considered an
alpha release.  Please contact me, Tim Goodwin <tim@uunet.pipex.com>,
with any problems, questions, or suggestions

Tim.
-- 
Tim Goodwin | "I suppose this is another case of those darn IP/TCP guys who
UUNET, UK   | work in practice but not in theory." -- Paul Mockapetris




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

Date: 25 Mar 1997 13:07:22 GMT
From: "G.Richter" <richter@ecos.de>
Subject: Announce: Embperl 0.11-beta - embed perl code in html files
Message-Id: <5h8ima$shc$1@nadine.teleport.com>

HTML::Embperl - Embed perl code in HMTL documents

Embperl allows you to embed perl code in your HTML documents. The code
can be used to compute something (e.g. retrieve data from a database) or to

produce output (e.g. display a variable). Also some metacommands are 
available which give you the ability to create "loops" or to conditional 
process your HTML document. As fours feature some HTML tags  are specially
interpreted. This allows dynamic
table/list/menu creation and an easier form processing.
 
Embperl can run offline, as CGI script or as module using mod_perl of the
Apache httpd (which is the fastest approach). A fours method is to let it
run as a separate process, which is at the moment only for debugging 
issues.

What's new?

0.11-beta      March 25 1997
                - Name changed from Embperl to HTML::Embperl!!!!!!!!
                - FORM & ENV debug output now available in all modes
                - Ouput from [+  +] and INPUT fields are escaped
                  (e.g. < is send as &lt; )
                - end of tables are working as it should
	    - two dimensional tables
                - added support for list tags (dir, menu, ol, ul, dl)
                - added support for textarea tag
                - bug whiches causes an endless loop when using a \ fixed
                - fixed escaping special html chars above ascii code 128
                - fixed some errors                                        
   


It can be downloaded from

ftp://ftp.dev.ecos.de/pub/perl/embperl

or from CPAN after it has been mirrored.
 
Gerald
 

-- 
Gerald Richter
ECOS  Electronic Communications Services

E-Mail:     richter@ecos.de
WWW:    http://www.ecos.de
Tel:          06133/925151
Fax:         06133/925152
Faxabruf: 06133/93910100




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

Date: 25 Mar 1997 13:04:16 GMT
From: kevina@clark.net
Subject: ANNOUNCE: Math::Fraction, version 0.4 alpha
Message-Id: <5h8igg$sdc$1@nadine.teleport.com>

                    Math::Fraction, version 0.4 alpha

      Alpha Release, 24 March 1997
      Copyright 1997 by Kevin Atkinson (kevina@cark.net)
      Developed with Perl v 5.003_37 for Win32.
      Has been testing on Perl Ver 5.003 on a solaris machine.

  Description
  -----------

    A Module to manipulate exact fractions.  It is meant to replace
    the bigrat.pl library.  It can do everything it can do and a lot
    more.

  Features
  --------

   .  Being able to add, subtract, multiply, and divide, among other
      things just like you would normal numbers that's to the overload
      module.

   .  Being able to convert a decimal, including repeating ones, into
      a fraction.  For example, 1.142857142857 would become 8/7.

   .  Being able to control how the fraction is displayed.  For
   example
      8/7 verses 1 1/7

   .  Being able to use arbitrary size numbers in the numerator and
   the
      denominator.

   .  Being able to covert between SMALL (using normal
   floats/integers)
      and BIG (using arbitrary size floats/integers) as needed so you
      do not have to worry about it. (New as of ver .4a)

   .  Being able to have multiple default sets so that a function can
      modify the defaults with out effecting other functions
      (New as of ver .4a)

  Archive Location
  ----------------

    .  http://sunsite.unc.edu/kevina/perl

    .  or on CPAN

  Other Info
  ----------

    I need alpha testers!  So far I have gotten zero feedback on my
    module. I have tested it as well as I could my self however I am
    positive there are some bugs in it.

    So, if you do have some time please check it out and let me know
    what you think.  Thanks.




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

Date: 25 Mar 1997 13:05:52 GMT
From: viper@buri.kuentos.guam.net (The Viper)
Subject: ANNOUNCE: ZFilter 2.7
Message-Id: <5h8ijg$sf8$1@nadine.teleport.com>

Take charge of your E-Mail!  ZFilter 2.7, the ULTIMATE in mail filtering
has just been released.  Any other filter program you may have used in the
past is but a pale imitation of this, the latest and greatest ZFilter ever!
If you want any hope of being popular, cool and accepted by the other UNIX
nerds, you MUST have ZFilter 2.7 now.  Even if you have a previous version
of ZFilter, you still have no hope of being cool without THIS one.  Tons of
stuff have been added.  
  ZFilter is a vastly superior e-mail filtering program that can (among
billions of other things) automatically destroy junk mail, chain letters,
mail-bomb attempts and spam from fly-by-night eMail addresses before they
even have a chance to contaminate your in-box.  ZFilter can be used to
direct incoming negative e-mail energy from losers and freaks and turn
it against them.  
  ZFilter lets you create form letters to send personalized replies to 
hordes of unimportant people without wasting more than a few minutes of 
your ever-so-valuable time to set it up.  ZFilter can track and maintain
logs of who writes to you the most, what actions it has taken the most,
and up-to-the-second reports of how much mail has been received during the
current year, month, day, hour, and minute.
  ZFilter can "page" your terminals with a message when you receive mail
from specific people.  Depending on the situation, you can run other 
programs, execute your own perl code, copy the message, forward it to another
user or nearly anything else you want.  
  ZFilter is simple to set up and use.  It is designed around helping new
UNIX users get it set up without hassle and use it, as well as providing
a huge selection of abilities for real UNIX techs to drool over.

ZFilter is available from the following locations:
- My home page:  http://www.guam.net/home/viper/files.html
- CPAN:          http://www.perl.com/CPAN/authors/Steve_Zeck
- E-Mail:        Send a message to  viper@kuentos.guam.net with the words
	         "send zfilter" in the subject for the UUEncoded package.
- Usenet: 	 Source, README and complete package are posted to
		 comp.lang.perl.misc

It is completely free.  Some of the above might possibly be hype.  Support
for non-stupid questions is available from the author at 
   viper@kuentos.guam.net
(or)
   sysop@tntbbs.guam.net

New in version 2.7 (and 2.6): (cut from the README file)
ver. 2.7: Experimental "-U (user)" command.  This will obviously only work
          if you're running as root (short of serious security holes in your
          system).  Added the "ip" variable and resolving the IP address of
          of the sender's hostname.  Added "quote" and "mailresult".
ver. 2.6: More bugfixes, adding or removing from lists shouldn't abort
          the entire program if there's a problem.  Canned should be
          fixed, I accidentally trashed it when I was neatening up from
          2.4.  How embarassing!  ZFilter practices safe file-locking
          via it's own method & flock(2).  Zfilter tries to figure out
          if you can use flock(2) during config mode and warns the user
          if it doesn't look like your system supports it.
          ZFilter has signal handling, (most notably, it tries to save
          the letter in memory to disk before dying).  ZFilter is better
          about failed attempts to lock files or save mail.  If it can't
          save the message to the mail folder, inbox or a "dead letter"
          file in the user's home directory, it sends panic email to
          the appropriate postmasters, the sender and the user (it will
          keep re-queueing the error message until it eventually gets through
          or someone explicity deletes the error message from the sendmail
          incoming mail queue).  Fixed the bug in "unique" that flagged
          messages with no content.  Added the "empty" variable so you can
          delete them explicitly if you want to.
          There is an explicit "Ignore" argument for the command line.
          For what it's worth, you can now use a single "-" to prefix multiple
          arguments to zfilter that don't need any additional information.
          Like, you can now say "zfilter -sr" on the command line because
          neither option "s" nor option "r" need to know anything else.

--
Steven Zeck <viper@kuentos.guam.net> <http://www.guam.net/home/viper>
Jr. Sub-Assistant Acting-Under Peon 
Kuentos.... Where Guam's internet day begins




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

Date: Tue, 25 Mar 1997 14:40:36 +0100
From: domo@tcp.ip.lu (Dominic Dunlop)
Subject: Re: cls || ClrScr??
Message-Id: <199703251440361308608@[194.51.248.84]>

Peter Tapolyai <peter@uhu.com> wrote:

> How do you clear the screen in perl ?

use Term::Cap;
$t = Tgetent Term::Cap {TERM=>undef, OSPEED=>9600};
print $t->Tputs("cl");
-- 
Dominic Dunlop


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

Date: Tue, 25 Mar 1997 12:19:07 +0000
From: "Paul Denman" <pdenman@ims.ltd.uk>
Subject: Directory Listing in Perl
Message-Id: <01bc391a$088b2180$9d02a8c0@192.168.2.1.ims.ltd.uk>

Hello,

I am trying to put together a quick n' dirty Perl listing which will ask
for a directory
and output the files in that directory.

I have come up with:

	print "Enter the directory you want listing:";
	chop($newdir = <STDIN>);
	chdir($newdir) || die "Cannot chdir to $newdir";
	opendir(DOT,".") || die "Cannot opendir .";
	foreach (sort readdir(DOT)) {
	                print "$_ \n";
	}
	closedir(DOT);

I would like to also display the date each file was created - Is this so
simple that I'm missing it?
Kind regards,

Paul Denman
---
Interactive Media Services
pdenman@ims.ltd.uk




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

Date: Tue, 25 Mar 1997 08:01:49 -0600
From: Tim Wilson <atms@zilker.net>
Subject: Document Contains No Data
Message-Id: <3337DACD.52A2@zilker.net>

I'm trying to use a "mailform.cgi" script that I downloaded.
However, I am something of a novice when it comes to CGI, and 
have run across a problem.

When I hit the "Submit" button on the form, I get a "Document
Contains No Data" message returned.  Are there one or several
simple explanations for this, or is it more likely that I have
bungled one of a million different possible things in my HTML?

If anyone has the time/patience to respond, I would appreciate it.

Thanks,

Tim Wilson


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

Date: Tue, 25 Mar 1997 13:49:32 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Getting filedates in perl
Message-Id: <adelton.859297772@aisa.fi.muni.cz>

Oscar Wahlberg <qraoswa@era-lvk.ericsson.se> writes:

> Hi all....
>  
> I've got a slight problem, I have to get the modified
> time from a file at a regular basis...
>  
> I need to do this because I want to run specific code
> if a file is older than ten minutes. 
> It seems to work the first time, but not the second 
> (I run it in a while loop)...
>  
> This is what I've done...
>  
>  while (1) {
>   if ((-M $filename) > 0.00694)         #0.00694 = 10 mins approx ?
>   {                                     #1/(24*6) 
>         ## Exec some code...
>   }
>   sleep($sometime);
>  }
>  
> That's simplifying it a bit, but shows what I am trying to do,
> though it doesnt work at all.
> After the second turn around I end up with a negative value from
> the '-M $filename'.
> I've tried doing a stat ($filename) and -M _, though no luck there
> either ?

What does a man page say about -M? It says:

	-M  Age of file in days when script started.

So I assume that you change the file in the ## Exec some code... Well,
now the file is newer. It's even been modified _after_ the script
started. So the age of the file when the script started is negative.

Got the point?

Hope this helps.

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


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

Date: 25 Mar 1997 08:19:39 -0500
From: Mike Campbell <mcampbel@tvmaster.turner.com>
Subject: Re: How do I delete a line out of a text file
Message-Id: <r5zpvsglck.fsf@tvmaster.turner.com>

"Matthew Enger" <menger@mindless.com> writes:

> I am new to perl and I need to delete aline out of a textfile. I
> have a aray called @lines which I was going to delete a part out of
> that then output the aray to file. Does anyone have a methoud of
> doing this? Or deleteing a line using another method?

If you want to simply delete a line from a file without going through
an array, you can use perl's -i switch.  Note that this _does_ make a
(temporary) copy of the file while it works.

perl -i.bak -ne 'print unless (some condition which id's the line you
                               want to remove);' filename


Say you want to delete any line with the word "foo" in it:

perl -i.bak -ne 'print unless /foo/;' file

Or you want to delete line number 10:

perl -i.bak -ne 'print unless ($. == 10);' file


Hope this helps.  (The -i.bak will create a .bak file before it works,
so you have your original if something goes wrong.  Simply using -i
with no parameter will not create any backup file.)


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

Date: 24 Mar 1997 21:18:19 GMT
From: "JR Tietsort" <jrtietsort@micron.com>
Subject: Re: Is CGI a part of or similiar to Perl?
Message-Id: <01bc3899$13938d00$9b6ac989@jrtietsort>

http://hoohoo.ncsa.uiuc.edu/cgi/primer.html

Read this and you should know the difference.....


ccrox39754@aol.com wrote in article
<19970324010400.UAA00999@ladder01.news.aol.com>...
> I've seen numerous references in this newsgroup to cgi. Is CGI a part of
perl or are we talking about two different things here? I realize this may
be a stupid question, but I hope maybe someone can explain it.
> 
> Thanks,
> 
> Carlos Croxton
> 


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

Date: 25 Mar 1997 07:51:57 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: swain@boojie.rt.csuohio.edu (Steve Wainstead)
Subject: Re: Live Randal Schwartz interview
Message-Id: <8clo7cvxbm.fsf@gadget.cscaper.com>

>>>>> "Steve" == Steve Wainstead <swain@boojie.rt.csuohio.edu> writes:

Steve> Randal Schwartz will be interviewed live Tuesday March 25th at
Steve> 6pm EST on the radio show "31337". You can hear the program
Steve> live via Audioactive.

Steve> For more details visit the WCSB-FM web site at
Steve> http://www.wcsb.org. You can download the Audioactive player
Steve> from www.audioactive.com. It's a helper app that once added to
Steve> your browser allows you to click on the link on the WCSB web
Steve> site to hear the station in real time.

Steve> Unfortunately the interview cannot be archived at this time so
Steve> it will not be available for later listening.

Steve> --

Steve> ---
Steve> The radio show 31337 -- http://wcsb.org/31337/ 		
Steve> finger swain@wcsb.org for PGP key
Steve> When encryption is outlawed, ?o'AZ-,++o+i++##4AoA+-/-C++bI+/.+~

This interview has been cancelled. Sorry for the interruption. We
now return you to your regularly scheduled programming.

-- 
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: 25 Mar 1997 13:23:18 GMT
From: zyanya@ix.netcom.com(Zyana)
Subject: On-line web page editor:  Changing the directory a file is written to?
Message-Id: <5h8jk6$pfm@dfw-ixnews12.ix.netcom.com>

Hi Folks,

    Hoping you can help me out.

    Yes, I've pretty much got written, already, a script that runs from
a web page and creates a new page in the directory assigned to the
client, provided they pass database check on their username, password,
and directory.  (Yes, that last part OK.)

    However...  I just cannot find the command(s) for changing to (for
writing) or just plain writing to, the different directory, from the
script that runs this thing.  One snag that I'm sure is involved is
that this is considered a _public_ access thing, even though they have
to pass flat-file database check first to even be able to use the
editor.  It runs fine when I telnet in to test the script for bugs. 
Then in writes to directories/sub directories fine, but it won't do it
when the script is run from the web page it's tied to.  (Again,
considered a built-in public access thing?  You tell me, because it's
got something to do with the right command(s) to use.)

    Changing the path through the script, by just assigning a new path
to the page doesn't work from the web, (i.e.:
/usr/~~whatever~~/filename.filextention), though it does work when you
telnet in under your password and run it.  Changing
ENV{"VARIABLE_NAME"}?  Huh?  Haven't got that to work, though I don't
think I'm doing it right.

    Anyone know the commands?  Or is this a trade secret?

    FYI for those who are interested:  You cannot make your path to the
document being written an "http://~~~~~~~~" path.  Computers just won't
accept that.  It must be a relative path starting way down in in the
most basic /usr/ directory of your machine.  Must be a security thing
to prevent people from writing to other computers.  


Thanks!

Zyana
    


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

Date: Tue, 25 Mar 1997 13:54:26 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: On-line web page editor:  Changing the directory a file is written to?
Message-Id: <ebohlmanE7LqMr.7yK@netcom.com>

Zyana (zyanya@ix.netcom.com) wrote:
:     FYI for those who are interested:  You cannot make your path to the
: document being written an "http://~~~~~~~~" path.  Computers just won't
: accept that.  It must be a relative path starting way down in in the
: most basic /usr/ directory of your machine.  Must be a security thing
: to prevent people from writing to other computers.  

Nope, that's not why.  The reason is that your operating system (which is
what the file-manipulation operators in Perl (or any other language) are
talking to) has no idea how your HTTP server's URL structure is
configured.  It doesn't even know what a URL is.  URLS ARE NOT FILENAMES,
EVEN THOUGH THEY MAY LOOK LIKE IT!!!  The mapping between URLs and
filenames is done by the server when it receives a URL; when you open a
file in Perl, you're not sending a URL to the server, so there's no way
for it to do the translation.  Thus you have to use actual filenames, not
URLs. 



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

Date: 25 Mar 1997 14:17:53 GMT
From: zyanya@ix.netcom.com(Zyana)
Subject: Re: On-line web page editor:  Changing the directory a file is written to?
Message-Id: <5h8mqh$ooa@dfw-ixnews11.ix.netcom.com>

Hey Folks,

    You Know...  The following feedback is great, but before this
thread gets 
lost on a tangent, let's answer the question: 

    "How do you change the directory a file will be written to, on the
same 
internet computer, though a Perl script web page editor run by a web
page?"

    Reference the original message for details and a clearer
understanding of what I'm talking about.

Zyana

>
>Zyana (zyanya@ix.netcom.com) wrote:
>:     FYI for those who are interested:  You cannot make your path to
the
>: document being written an "http://~~~~~~~~" path.  Computers just
won't
>: accept that.  It must be a relative path starting way down in in the
>: most basic /usr/ directory of your machine.  Must be a security
thing
>: to prevent people from writing to other computers.  
>
>Nope, that's not why.  The reason is that your operating system (which
is
>what the file-manipulation operators in Perl (or any other language)
are
>talking to) has no idea how your HTTP server's URL structure is
>configured.  It doesn't even know what a URL is.  URLS ARE NOT
FILENAMES,
>EVEN THOUGH THEY MAY LOOK LIKE IT!!!  The mapping between URLs and
>filenames is done by the server when it receives a URL; when you open
a
>file in Perl, you're not sending a URL to the server, so there's no
way
>for it to do the translation.  Thus you have to use actual filenames,
not
>URLs. 
>



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

Date: Tue, 25 Mar 1997 14:33:36 GMT
From: draggs@hawkeye.idx.com (Falcon)
Subject: Perl book sugestions wanted
Message-Id: <3337e19d.8740054@news.idx.com>

I need a good perl book.  I learn best by examples.  Also, I'm a
professional programmer so I will use the book mostly as just a
reference.  Does anybody have any recomendations?


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

Date: Tue, 25 Mar 1997 09:05:38 +0100
From: Achim Bursian <ea1217@fen.baynet.de>
Subject: perldoc for windows (Win32)
Message-Id: <33378752.A76@fen.baynet.de>

Hi,

I found references to a tool named 'perldoc' sometimes.

It is not in the activeware port for Win NT. Unfortunately, I'm forced
to work on this (fill in waht you want) system.

Is there perldoc ported to Win NT? What exactly does it?

Thanks for help,
	Achim


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

Date: 25 Mar 1997 13:03:46 GMT
From: Eryq <eryq@enteract.com>
Subject: Pre-Alpha copy of Convert::BinHex available
Message-Id: <5h8ifi$sd9$1@nadine.teleport.com>

(Pre-Alpha because it's not yet done, that's why.  :-)

Convert::BinHex is a Perl module for extracting the header,
data fork, and resource fork from Macintosh BinHex files.
The module is VERY new, and I'm looking for comments and
wishlists. 

BinHex is a layered encoding [with compression], so decoding is not
quite as simple as a "uudecode", but here's the basic usage:

    my $HQX = Convert::BinHex->open(FH=>\*STDIN) || die "open: $!";
    $HQX->read_header;                  # read header info
    @data = $HQX->read_data;            # read in the data fork
    @rsrc = $HQX->read_resource;        # read in the resource fork

Find out more online:

   DOCUMENTATION:
   http://www.enteract.com/~eryq/CPAN/Convert-BinHex/docs/Convert/BinHex.pm.html

   CODE:
   http://www.enteract.com/~eryq/CPAN/Convert-BinHex/

Distribution comes with a "hexbin" program for Unixers. 
Knock yourselves out.

(Mac experts: I'd like to add the "encode" part of this... done anyone know
if it's legal for a Mac file to have an empty resource fork?  Or where some
detailed BinHex documentation other than RFC1741 exists?  TIA).  
-- 
  ___  _ _ _   _  ___ _   Eryq (eryq@enteract.com)
 / _ \| '_| | | |/ _ ' /  Hughes STX, NASA/Goddard Space Flight Cntr.
|  __/| | | |_| | |_| |   http://www.enteract.com/~eryq
 \___||_|  \__, |\__, |___/\  Visit STREETWISE, Chicago's newspaper by/
           |___/    |______/ of the homeless: http://www.streetwise.org




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

Date: 25 Mar 1997 14:35:33 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: Reg. Expressions with Associative Arrays
Message-Id: <5h8nrl$k2u@pirate.shu.edu>

Hello -

Gabriele R Fariello - 608-576-8660 <gabriele@clotho.com> writes:

>Michael Stearns wrote:
>> 
>> This script is really a small part of a bigger script that converts a
>> Framemaker .mif file to html. This script picks up where I have already
>> parsed out all Frame's table description info and I am left with a bunch
>> of html-formatted tables that all have unique imbedded ids. My problem
>> is that the mif document stores all the table content in one place and
>> has a corresponding unique id tag (Called AFrame) for the tables in
>> another part of the document. With my limited knowledge of PERL, I am
>> trying to use associative arrays to store the ids and then make the
>> proper table replacements for the AFrame placeholder. Can anyone see
>> what I am doing wrong here, or if there is an altogether easier method,
>> I'd be interested in hearing that, too. I have included a very watered
>> down example of what I have in the mif file at the bottom.
>> 
>> Thanks,
>> Michael Stearns


>Most of your problem is in the regex. the .* with the s option set will
>match not only end-of-line chars, but also <table> and </table> until it
>is full and can still make the regex be true. Thus m/(<table>.*</table>/
>using your data set will match from the FIRST <table> to teh LAST
></table> including all <table> and </tables> inbetween. use either the
>class [^(<table>)] so as to not match the <table> tag or simply [^<] if
>there are no other <> tags to contend with. 

The character class [^(<table>)] is equivalent to [^()<>abelt] - which is
to say, it has nothing to do with the order of the characters (except the
caret, of course).  If something like this works, it is purely by 
coincidence.

>$tableTemp =~ s|[^(<table>)]*<table>(.*)</table>.*|<table>$1</table>|s;

This would change:

Z
<table>

to

<table>

by coincidence ('Z' happens not to be any of [()<>abelt]).  But that's about
the most it would do.

If you want to get rid of everything before the first <table>
and after the last </table>, try something like:

$tableTemp =~ s!.*?(<table>.*</table>).*!$1!s;


David Black
dblack@icarus.shu.edu



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

Date: Tue, 25 Mar 1997 08:33:11 -0600
From: annette@wwip.com
Subject: Rename Comand Programming Project - Will Pay Money
Message-Id: <859300010.28940@dejanews.com>

Hi,

I have a small programming project that I'm willing to pay someone to
complete. I have a NT 3.51 web server with Perl installed and I need
someone to write and install a perl script that will use the syntax such
as:

rename.pl lastmonth*.* to jan97*.* /s

The DOS command rename does not support the /s attribute to cause the
rename to continue through all subdirectories. I need this functionality
so that when I run a WebTrends statistical report with the name
lastmonth.htm that all the htm file and the graphics associated with them
(such as lastmonth001.gif) can be quickly changed to the name of the
previous month such as jan97.htm and jan97001.gif.

Please send me your quote and how quickly you can complete the project to
annette@wwip.com. Thank you.

Annette Thompson
Internet Adoption Photolisting
http://adoption.com/precious/

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 25 Mar 1997 13:52:29 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Results from a system call
Message-Id: <5h8lat$ehi$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author et al. via email]

In comp.lang.perl, a dead newsgroup, sgilliar@cmp.com writes:
:I'm looking for an easy way to retrieve the output from a system call. 
:For instance, I want to run a script that calls nslookup and returns the
:information from the call into a variable ex: 
:
:system("nslookup 192.33.40.155")
:
:I'd like to then take the Name: portion of the results and be able to
:have the domain name instead of the ip address.  This process that I
:need reads a file that has ip's in it and later translates them to
:domain names.  Any help is greatly appreciated.

Apparently you have been led to believe that one always uses system() to
call other programs.   I'm wondering why this is such a frequent question
of late.  Perhaps it has something to do with the fact that several
of the newer Perl books I've glanced at lately (e.g. P5 for Dummies)
hide backticks for in the back of the book where no one ever finds them.

Here's what I teach beginners: 

		Common Novice Mistakes

    1.  Not using the -w flag: !/usr/bin/perl -w

    2.  Forgetting various punctuation:
	    a. semicolons at the end of each statement
	    b. dollar signs in front of variables
	    c. commas between function parameters
	    d. quotes on strings

    3. Confusing the purposes of system and backticks:
	    $exit_code = system($EDITOR, $file);
	    $output    = `who`;

    4.  Not using the strict pragma to enforce declarations, quoting, 
	and type-checked references:
	    use strict;
	    my ($x, $y, @list);

Notice point three.  I wonder whether this should go in perltrap or
the FAQ or what?  Sure comes up a lot lately.

There's also an entry from part 8 of the perlfaq (findable at
http://www.perl.com/perl/faq/) that might prove enlightening, although
it does become more complicated than you need for this purpose.

 Q: How can I capture STDERR from an external command?

 A: There are three basic ways of running external commands:

        system $cmd;                # using system()
        $output = `$cmd`;           # using backticks (``)
        open (PIPE, "cmd |");       # using open()

    With system(), both STDOUT and STDERR will go the same place
    as the script's versions of these, unless the command redirects
    them. Backticks and open() read only the STDOUT of your command.

    With any of these, you can change file descriptors before the call:

        open(STDOUT, ">logfile");
        system("ls");

    or you can use Bourne shell file-descriptor redirection:

        $output = `$cmd 2>some_file`;
        open (PIPE, "cmd 2>some_file |");

    You can also use file-descriptor redirection to make STDERR a
    duplicate of STDOUT:

        $output = `$cmd 2>&1`;
        open (PIPE, "cmd 2>&1 |");

    Note that you *cannot* simply open STDERR to be a dup of STDOUT
    in your Perl program and avoid calling the shell to do the
    redirection. This doesn't work:

        open(STDERR, ">&STDOUT");
        $alloutput = `cmd args`;  # stderr still escapes

    This fails because the open() makes STDERR go to where STDOUT was
    going at the time of the open(). The backticks then make STDOUT
    go to a string, but don't change STDERR (which still goes to the
    old STDOUT).

    Note that you *must* use Bourne shell (sh(1)) redirection syntax
    in backticks, not csh(1)!  Details on why Perl's system()
    and backtick and pipe opens all use the Bourne shell are in
    http://www.perl.com/CPAN/doc/FMTEYEWTK/versus/csh.whynot .

    You may also use the IPC::Open3 module (part of the standard perl
    distribution), but be warned that it has a different order of
    arguments from IPC::Open2 (see the IPC::Open3 manpage).

-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    I'm sure that that could be indented more readably, but I'm scared of
    the awk parser.             --Larry Wall in <6849@jpl-devvax.JPL.NASA.GOV>


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

Date: Tue, 25 Mar 1997 06:33:57 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: sendmail and perl question
Message-Id: <lng8h5.fn.ln@localhost>

Robert Hutchinson (robh@spatial.co.nz) wrote:
: Hi,

: If I have a text file that contains mail headers will this bit of code send it
                                                   ^^^^^^^^^             ^^^^
: to the address I want it to go to?
  ^^^^^^^^^^^^^^^^^^^^^


Why don't you just try it and see?


: system("$sendmail $mailto < $output");

: where $sendmail = absolute path to sendmail
: where $mailto = email address
: where $output = absolute path to text file

: After sending the message will the program return to the perl script so it can
: delete the text file?

: unlink($output)

: I've only just started learning perl so any pointers to potential problems
: would be appreciated. I haven't tested this yet because my server is being
: rebuilt.

: Thanks


Please don't post here if you don't have a problem.

You haven't tried it yet (or you haven't said what happened when you did),
so you can't really have a problem yet.

We are not a SW testing service you know.

The above is not dangerous or anything ($mailto=robh@spatial.co.nz, for
example).

Just give it a try. If it doesn't work, _then_ you'll have a problem.

Once you have a problem, follow the suggestions in the perl autoFAQ,
and likely get the solution in a couple of minutes.

If that doesn't fix the problem, _then_ post a question, and wait 
hours/days/forever to get the answer...



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


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

Date: 25 Mar 1997 13:00:40 GMT
From: c.c.eiftj@33.usenet.us.com (Rahul Dhesi)
Subject: Re: term 'regular expressions' considered undesirable
Message-Id: <5h8i9o$fhc@samba.rahul.net>

Here is a composite response to many claims that have been made in
this subject thread.

CLAIM: /^a.*b.*c/ (greedy) and /^a.*?b.*?c/ (nongreedy) both match the
same strings.

RESPONSE: Any string that in its entirety is matched by /^a.*b.*c/ is
also matched by /^a.*?b.*c/ .  But what if the input stream is not
entirely matched by either?  Then, in normal perl code operation, we may
end up matching different substrings of the input stream by the two
patterns.  Thus it's incorrect to say that both match the same strings
unless you carefully define just what you mean by 'match' and 'the same
strings'.

COMMENT: Perl and similar pattern matching has one of two goals:
(a) either deciding whether an entire input string is matched by a given
pattern, or (b) searching the input string for some substring that is
matched by a given pattern.  Language parsers, on the other hand, care
not much about whether or not we can find a substring that can be parsed
using the rules of the language -- we generally want to parse the entire
input stream.  If we find a portion that does not fit our grammar we
declare a parse error.

Therefore blindly extending the concepts of language grammars to pattern
matching will lead to much confusion.

CLAIM:  /^a.*?b.*?c/ requires backtracking.
RESPONSE:  See finite state machine in another posting.

CLAIM:  In /^a.*?b.*?c/ the ``lookahead'' for the first .*? is /b.*?c/,
not simply one character.
RESPONSE:  See finite state machine in another posting.

CLAIM:  /^a.*?b.*?c/ (nongreedy) and /^a.*b.*c/ (greedy) can be
implemented with exactly the same finite state machine.

RESPONSE:  The greedy /^a.*b.*c/ cannot be implemented with a finite
state machine.  The first time that we see a 'b' we cannot know if this
is the 'b' we want.  Want want the longest possible match for the .*
preceding the 'b'.  So we must keep scanning for more occurrences of 'b'
But if we do and find none, then we have lost all the input symbols so
far and cannot make any more decisions based on them.  A finite state
machine has no memory of the symbols it has already seen.

CLAIM:  /^a.*?b.*?c/ requires backtracking but /^a[^b]*?b[^c]*?c/ does not.
RESPONSE:  There is no difference -- the simplest finite state machines
that implement both are identical.

CLAIM: Anything that is generated by a regular language is a regular
expression.
RESPONSE:  Only if you remain within the spirit of regular languages and
ask only this question:  Whether or not the entire input stream is a
string that belongs to the regular language.  As soon as you start
looking for any *substring* in the input stream that is in the regular
language, you are misusing the terminology.

CLAIMS: "How a matcher is implemented (backtracking etc) has no bearing
on the language it recognizes" and "Backtracking is an implementation
feature of the perl pattern matcher (ok, of any reasonable pattern
matcher) that has nothing to do with regularity."

RESPONSE:  Certain pattern matches can be implemented without
backtracking and certain others cannot.  You can always be sloppy and do
backtracking where it's not needed.  But if something absolutely
requires backtracking, then you can't do it without backtracking.

NOW WE CAN SAY IT:

A regular expression is a pattern one for which we can declare a match
or no match, while scanning an input string, without having to rescan
the input string.  If we must ever rescan the input string, then the
pattern we are trying to match is not a regular expression.

Almost no perl patterns are regular expressions.
-- 
Rahul Dhesi <dhesi@spams.r.us.com>
a2i communications, a quality ISP with sophisticated anti-junkmail features
** message body scan immune to fake headers ***   see http://www.rahul.net/
>>> "please ignore Dhesi" -- Mark Crispin <mrc@CAC.Washington.EDU> <<<


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

Date: 25 Mar 1997 08:14:30 -0500
From: Mike Campbell <mcampbel@tvmaster.turner.com>
Subject: Re: Unix 'Cat' equivelent
Message-Id: <r52094i05l.fsf@tvmaster.turner.com>

bill@sover.net.no.junkmail (Bill) writes:

>    Here's a quick and easy cat clone:
> 
> #!/usr/bin/perl -w
> 
>   while (<>) {
>       print;
>   }

perl -e 'print while (<>);'







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

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

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