[6366] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 988 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 21 14:38:57 1997

Date: Fri, 21 Feb 97 11:00:23 -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           Fri, 21 Feb 1997     Volume: 7 Number: 988

Today's topics:
     ANNOUNCE: File::Sync - fsync() and sync() <c.evans@clear.net.nz>
     ANNOUNCE: PerlMenu version 4.0 (Steven L. Kunz)
     Re: backreferences in a character class? (Kevin Buhr)
     C-style preprocessing for a newbie... <skapp@kodak.com>
     Re: Checking for redirection (file input) (Brian L. Matthews)
     crypt() in NT Perl <bgraham@bgraham.com>
     Re: finding full path to file name (Lack Mr G M)
     for god sake <C-A-T-S@c-a-t-s.demon.co.uk>
     Re: for god sake (Nathan V. Patwardhan)
     Re: futur de perl et java-script <csc80@amdahl.com>
     Re: How do I parse RFC 822 header lines with Perl? <eryq@enteract.com>
     Re: How do I parse RFC 822 header lines with Perl? (Trevor Jenkins)
     how to "free" a hash (Dupont Christophe)
     how to "free" a hash (Dupont Christophe)
     Re: how to "free" a hash <eryq@enteract.com>
     Re: How to spam - legitimately <Jacqui.Caren@ig.co.uk>
     Including a C library in a Perl script <debayqmk@ibmmail.com>
     Links Related To comp.lang.perl.misc - FREE ACCESS links@m2c.com
     Log analysis for Netscape Ent Server (Bruce McGuire)
     Re: Merge content from several files into one document (Alister)
     Re: Merge content from several files into one document (Jan Schipmolder)
     Re: Most efficient way to do a killfile-like regexp tes (Mike Stok)
     Re: output into a variable <jander@jander.com>
     Perl and MAPI (Windows NT Win32 Messaging API) <JeanPhilippe.Amiel@alcatel.titn.fr>
     PERL for NT & Netscape Enterprise Server <strad@mondenet.com>
     Re: Perl on Windows 95 (Rasilon)
     Re: PSCOPE - an CSCOPE for perl source (Harold Bamford)
     Re: relationship between @INC & PERL5LIB w.r.t. module  (Brian L. Matthews)
     Re: REQ: Getting the amount of files in a certain direc <jander@jander.com>
     Resolving IP <buxx@buxx.com>
     Re: sending email and attaching a .gif file <eryq@enteract.com>
     Strange pack/unpack behavior <craig@lucent.com>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 21 Feb 1997 18:26:47 GMT
From: Carey Evans <c.evans@clear.net.nz>
Subject: ANNOUNCE: File::Sync - fsync() and sync()
Message-Id: <5ekpd7$n0q$1@nadine.teleport.com>

I have uploaded my File::Sync module to CPAN.  Simply put, it
implements the POSIX.1b fsync() function, and the *nix sync()
function.  The version is 0.04, but previous versions were not
released.

In more detail, the following functions are provided:

    fsync FILEHANDLE
        Calls the POSIX.1b fsync(2) function on the given file handle,
        copying all parts of a file still in the OS's buffers to
        disk.

    fsync_fd FD
        Internal function - calls fsync(2) given integer file
        descriptor.

    sync
        Calls the *nix sync(2) function, to flush all filesystem
        buffers to disk.

File::Sync also puts its fsync() subroutine in FileHandle and
IO::Handle, so $fh->fsync() will work if $fh is a FileHandle.

Since uploading the module, it's been pointed out to me that sync()
probably belongs in a Filesys::Sync module, and fsync() in IO::Handle.
I'll see what happens.

-- 
                Carey Evans  <*>  c.evans@clear.net.nz

"Linux and Linux-like systems such as UNIX(R) and FreeBSD..."
    - Yggdrasil Computing, <pgpmoose.199702180607.14425@liw.clinet.fi>




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

Date: 21 Feb 1997 18:26:10 GMT
From: skunz@iastate.edu (Steven L. Kunz)
Subject: ANNOUNCE: PerlMenu version 4.0
Message-Id: <5ekpc2$n0l$1@nadine.teleport.com>

----------------------------------
Announcing PerlMenu Version 4.0
----------------------------------

  This is the official announcement of the release of the latest PerlMenu
  package, version 4.0.  Version 4.0 is a release that incorporates several
  new features and bug-fixes. 

  This package has been tested with both Perl5/Curses and Perl4/curseperl.
  For this first time PerlMenu is distributed as a "perlmenu.pm" module
  (a converter is supplied to generate a Perl4-style "menu.pl" module).

--------
Overview
--------

  The "PerlMenu" package is a Perl5 package (built into your Perl program
  with a "use perlmenu;" command) that automates curses-based full screen
  menus and data entry.  A "menu.pl" module can be generated to function
  under Perl4/curseperl (or existing "menu.pl" Perl5 applications).

  Using three simple calls, any number of items may be selected from a
  single or multiple-page menu by moving an arrow to the desired item (or
  directly entering the selection number displayed on the screen).  In
  addition to simple "single one-shot selection menus", "radio button" style
  menus and "multiple-item-selection" menus are provided.  Paging through
  multiple-page menus is handled automatically.  Menu titles, sub-titles,
  prompts, "single column", and "multiple column" menus are supported.

  Using two simple calls a full-screen data entry template may be loaded
  and a fully-titled data entry input screen may be created.  Defaults,
  maximum field lengths, and numeric-only data are supported.

  The "perlmenu.pm" package uses curses interface routine calls supplied by
  the Curses extension for Perl5 (you should be running AT LEAST Perl
  5.001).  A "menu.pl" package can be created which uses curses interface
  routine calls supplied by the "curseperl" package for Perl4.  All
  functions and features are identical whether you are using Perl4 or Perl5. 

 ------------------------------
Compatibility and New Features
 ------------------------------

  For the first time, this version is distributed as a Perl5-style
  "perlmenu.pm" module.
  
  A program is provided in the distribution kit to convert "perlmenu.pm" to
  a Perl4-style "menu.pl" module.  For current Perl4 or Perl5 "menu.pl
  version 3.x" users, the resulting "menu.pl" module is call-compatible with
  older versions (you need not modify your existing source unless you want
  to take advantage of the new features).

  For current Perl5 users wishing to convert to use the new "perlmenu.pm"
  module, conversion is usually as simple as replacing your 'require
  "menu.pl";' statements with "use perlmenu;" statements.  You may want
  to modify your source to take advantage of the new features.

  Changes between perlmenu.pm version 4.0 and menu.pl version 3.3:

  - Converted to Perl5-style "perlmenu.pm" module.  A program (create_menu.pl)
    is included to convert this module to the old Perl4-style "menu.pl" module
    for legacy applications and Perl4+curseperl users.  All old PerlMenu
    programs should run without changes using this new "menu.pl" module.
    Conversion to use "perlmenu.pm" under Perl5 should only require changing
    "require" to a "use".
  - Added multiple-column menu support (requested by many people).
    Single call to "menu_prefs" converts all menus to "multiple column"
    selections.  No changes to existing menu construction routines in old
    code required.  Automatically scales and computes proper number of
    columns based on length of longest selection text.
  - Added a "highlighted" selection cursor preference.  Previous versions only
    displayed the selection cursor with a "->" in front of the item.  A new
    preference setting removes the "->" and highlights the selection text
    (in reverse video on most systems).  Single call to "menu_prefs" converts
    all menus to "highlighted" selections.
  - Expanded the main "demo" program to enable switching between single and
    multiple column menus, arrowed or highlighted selection cursor, numbered
    and unnumbered menus.
  - Split out (and rewrote) the installation instructions into a new file
    called "INSTALLATION".  Included a new "install_hints.pl" program (for
    Perl5+Curses users) which tries to figure out what tweeks you may need to
    make it work on your system.
  - Made appropriate changes to all other documentation as appropriate for the
    new features.
  - Added a new "FAQ" document.
  - Fixed a bug in that relates to typing an item selection number that is
    greater than the last item in the menu.  Previously it dropped the
    selection arrow to the last item but crashed when you pressed "return".
    Now it "beeps" (to indicate an invalid selection).  Thanks to Jay Fowler
    (CSU-Fresno, USA) for pointing this out.
  - Fixed bug in demo scripts.  Previous versions were missing some calls to
    "endwin" prior to every "exit", which meant the original terminal
    environment was not restored (leaving the terminal in "raw" mode, etc.).
    Thanks to Warren Jones (Fluke Corporation, Everett, WA, USA) for the
    bug report and patches.
  - Added comment for HP-UX 9.05 terminfo/tput users in perlmenu.pm ("tput kent"
    does not work on these systems, use "tput cr").  Thanks to Stuart Poulin
    (Applied Microsystems Corporation, Redmond, WA, USA) for supplying this
    info. 

------------------------------------
The Official PerlMenu WWW home page:
------------------------------------

  The official PerlMenu WWW home page (maintained by the author) is at:

      http://www.cc.iastate.edu/perlmenu/

----------------------------
Official Distribution Points
----------------------------

  The PerlMenu package is distributed via "CPAN" (the "Comprehensive Perl 
  Archive Network").  Pick a CPAN site near you with a WWW browser pointed
  at "http://www.perl.com/perl/CPAN/CPAN.html" and go into the
  "authors/Steven_L_Kunz" folder.  You should find "perlmenu.v4.0.tar.Z" in
  there.

  The author's official distribution is also available via anonymous FTP
  from: 

      ftp://ftp.iastate.edu/pub/perl/perlmenu.v4.0.tar.Z

  New releases are announced in the Usenet newsgroups
  "comp.lang.perl.announce" and "comp.lang.perl.modules".  

----------------------
Distribution Contents
----------------------

This is "perlmenu.pm" - a set of perl routines that will perform full screen
menu functions using Perl5+Curses.  What you should have after unpacking
this package is the following:  

  ARTISTIC          Artistic License

  COPYING           Library GNU Public License

  FAQ               Frequently Asked Questions

  INSTALLATION      Guide to installing PerlMenus

  MENU_DOC          A user's guide to the perlmenu.pm routines.

  MENU_DOC          A user's guide to the menuutil.pl routines.

  README            (this file)

  RELEASE_NOTES     Differences between this version and previous versions.

  TO_DO             List of things on my "to do" sheet.

  create_menu.pl    Create a Perl4-style "menu.pl" module from the
                    Perl5-style "perlmenu.pm" module.  Used for legacy
                    applications under Perl4 or Perl5. 

  demo              A simple menu demo showing all several types of menu
                    selection capabilities (simple single-page, simple
                    multiple-page, radio-button, and multiple-selection). 

  demo_getstr       A simple menu demo using the "menu_getstr" routine.

  demo_template     A demo using the "menu_load_template" and
                    "menu_display_template" routines.

  demo_top          A simple menu demo with "top" menus.

  demo_util         A simple demo of the routines in "menuutil.pl".

  ezpasswd          A more involved demo showing how menu_getstr, menuutil.pl,
                    and templates can be used to display full-screen formatted
                    entries from a BSD-style /etc/password file.

  ezreg             A more involved demo showing how menu template routines 
                    can be used in a full-screen user registration panel
                    that a multiple required fields. 

  ezview            A more involved demo showing how menus can be used to call
                    routines, select files, etc.

  install_hints.pl  A small Perl5 program that helps you decide how to tweek
                    "perlmenu.pm" for use on your system (with your flavor
                    of termcap or terminfo).

  perlmenu.pm       The PerlMenu subroutines in a Perl5-style package (usually 
                    placed somewhere like /usr/local/lib/perl/perlmenu.pm). 
                    See also "create_menu.pl". 

  menuutil.pl       Some curses subroutines useful in constructing curseperl
                    transactions which use "perlmenu.pm".  These are purely
                    optional and are not needed for using PerlMenus
                    ("perlmenu.pm").  Shows some examples of "curses" 
                    programming techniques. 

  paint_text        A sample file used by "demo" to display bottom-titles
                    loaded from a file.

  template_data     A sample full-screen input template used by "demo_template"
                    to input name/address/phone data records.

  template_ezp      The display template used by ezpasswd.

  template_reg      The display template used by ezreg.

-------
License
-------

PerlMenu - Perl library module for curses-based menus & data-entry templates
Copyright (C) 1992-97  Iowa State University Computation Center                        Ames, Iowa  (USA)

   This Perl library module is free software; you can redistribute it
   and/or modify it under the terms of the GNU Library General Public
   License (as published by the Free Software Foundation) or the
   Artistic License.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; if not, write to the Free
   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

---
Steven L. Kunz
Networked Applications
Iowa State University Computation Center, Iowa State University, Ames  IA
Email: skunz@iastate.edu
-- 
Steven L. Kunz
Networked Applications  --  Project Manager, Microcomputer Networked Services
Iowa State University Computation Center, Iowa State University, Ames, Iowa
E-mail: skunz@iastate.edu




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

Date: 21 Feb 1997 11:53:45 -0600
From: buhr@stat.wisc.edu (Kevin Buhr)
Subject: Re: backreferences in a character class?
Message-Id: <vbaeneakpue.fsf@mozart.stat.wisc.edu>

tadmc@flash.net (Tad McClellan) writes:
> 
> : Bzzzt!^H^H^H^H^H^H    ;-) 
> 
> --------------
> #! /usr/bin/perl -w
> 
> $_ = q/ "Hi, 'Fred', or whoever you are." /;
> 
> /(["'])([^\1]*)\1/ and $string = $2;
> print "$string\n";

It's not doing what you think, as this example illustrates:

#! /usr/bin/perl -w
$_ = q/ "Hi, 'Fred', or whoever you are."  I replied, "I'm Bill." /;
/(["'])([^\1]*)\1/ and $string = $2;
print "$string\n";

As I mentioned in some other post, "\1" in a character class is
interpreted in the same way as "\001", so the character class [^\1]
matches any character except ^A.

Kevin <buhr@stat.wisc.edu>


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

Date: Fri, 21 Feb 1997 09:19:35 -0500
From: Steven Kapp <skapp@kodak.com>
Subject: C-style preprocessing for a newbie...
Message-Id: <330DAEF7.55A0@kodak.com>

Hi,

	I would like to use Perl to expand a C-style macro "IFDEBUG(x)" to
"x".  I have looked in the FAQ and CPAN but have not found anything that
does just this.  Also, as I am relatively new to Perl, I am not sure if
I have found some regexp code which does this but I did not recognize
it.

							Steve
							skapp@kodak.com


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

Date: 21 Feb 1997 09:31:59 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: Checking for redirection (file input)
Message-Id: <5ekm6f$c09$1@halcyon.com>

In article <5eil33$gj2@nntp1.u.washington.edu>,
J. Mello <kingjamm@u.washington.edu> wrote:
|   foo.perl < testfile
|I've tried searching for a "<" in @ARGV, but for some reason,
|arguments to your shell don't include pipes or redirections.

That's because the shell handles it all for you.

Anyway, the -t file test returns 1 if a filehandle (STDIN by default)
is attached to a tty, otherwise ''. So:

if (-t)
{
	# script was run without file redirection
}
else
{
	# script was run with file redirection
}

Brian
-- 
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: Fri, 21 Feb 1997 06:06:09 -0800
From: Bo Graham <bgraham@bgraham.com>
Subject: crypt() in NT Perl
Message-Id: <330DABD1.7305@bgraham.com>

Hello,

The crypt function is documented *not* to be supported in NT Perl.  I am
searching for the equivalent..... or failing that... an NT port of Matt
Wright's wwwadmin.pl

Thank you,
Bo Graham
bgraham@bgraham.com
http://bgraham.com


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

Date: 21 Feb 1997 14:52:36 GMT
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: Re: finding full path to file name
Message-Id: <5ekcrk$k4q@ukwsv3.ggr.co.uk>

In article <3303377F.6A60@net.com>, Todd Lowpensky <toddl@net.com> writes:
|> I'm being passed a file name to work on, and I need to
|> figure out the entire path of the file.  The string passed
|> to me may be "../../../motive/file", so it would require
|> a fair amount of work to reconstruct it from the current
|> directory.
|> 
|> I'm using PERL 5 in Solaris.  Any ideas?
|> thanks

   The  following  should  work  (ie.   it has always worked for me...).
NOTE that it actually splits the result as $dir and $ent, so if you just
want  the  complete path you will need to change the last few lines (but
*do* read the comments preceding them first). 

   This  is  just  a  cut from a program I have.  The comment about $dir
having to be absolute refers to its  usgae  later  in  the  rest  of  my
program. 

   The "/usr/central/bin/pwd" is something which can handle pathnames
under /tmp_mnt - since you are using Solaris (and hence autofs rather
than automount) you won't need it.  Replace the $here assignement with
something like:

use Cwd;
$here = getwcd();

   Finally, here is the code...
 

# split the name - we need to know what the final part is so that we can
# follow links to their logical conclusion...
# regexp allows for bare name and (multiple) trailing / (stripped off).
# The ? in (.*?) is to stop it grabbing everything except the last character
# if $ent is not defined then something has gone wrong...
# Currently, $dir *must* be absolute!! (We cd around before using it).
# So, if it isn't, we us pwd (autmount-aware version) to make it so.

   $rt = $target;                # Copy for editing
# The following is to get to an absolute pathname...
   if (substr($rt, 0, 1) ne '/') {
      chomp($here = qx( /usr/central/bin/pwd ));
      $rt = $here . '/' . $rt;
   }
   $rt =~ tr|/||s;   # Remove multiple /'s

# ...now remove . and .. entries.
   1 while ($rt =~ s{/\.(/|$)}{$1});
   1 while ($rt =~ s{/[^/]+/\.\.(?:/|$)}{/});
# Now remove any leading /.. entries... (must do this last as they can
# appear as a result of removing the .. entries.
   1 while ($rt =~ s{^/\.\.}{});
# Now have 2 special cases.  '/' and '' (the later results from removing
# leading '/..' entries. Since we have removed all . and .. entries it is 
# now "safe" to put one back in.
   if ($rt eq '/' or $rt eq '') {
      $dir = '/';
      $ent = '.';
   } elsif ($rt =~ m|^(.*?)(?:/?)([^/]+)/*$|) { 
      $dir = ($1 eq '') ? '/' : $1;
      $ent = $2;
   }
   die "$target makes no sense - sorry\n" unless defined $ent;



-- 
----------- Gordon Lack ----------------- gml4410@ggr.co.uk  ------------
The contents of this message *may* reflect my personal opinion.  They are
*not* intended to reflect those of my employer, or anyone else.


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

Date: Fri, 21 Feb 1997 12:48:18 +0000
From: Tony Facey <C-A-T-S@c-a-t-s.demon.co.uk>
Subject: for god sake
Message-Id: <uHfgcCASmZDzEw5M@c-a-t-s.demon.co.uk>


I have twice tried to download latest.tar.gz, While decompressing the
file it freezes at aux_sh.
I am using windows 95 and winzip to decompress the file..


Am i doing somthing wrong?
should i be downloading a diffrent file for windows 95?

help???
tony@c-a-t-s.demon.co.uk


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

Date: 21 Feb 1997 15:20:51 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: for god sake
Message-Id: <5ekegj$351@fridge-nf0.shore.net>

Tony Facey (C-A-T-S@c-a-t-s.demon.co.uk) wrote:

: Am i doing somthing wrong?

Totally.  :-)  You should be looking at http://www.activeware.com for
the Perl 5.003_07 NTPerl port (both in Intel binaries and source).

--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
	--Jamie Zawinski


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

Date: Fri, 21 Feb 1997 17:00:43 GMT
From: "Carol C. Kankelborg" <csc80@amdahl.com>
To: Dominique BAGOT <Dominique.BAGOT@cetp.ipsl.fr>
Subject: Re: futur de perl et java-script
Message-Id: <330DD4BB.41C67EA6@amdahl.com>

Dominique BAGOT wrote:
> 
> Bonjour a tous,
> 
>         A votre avis, Perl est-il condamne ?
>         Je veux dire : Java script ne le remplacera-t-il pas ?
> 
> Dom
> Dominique.BAGOT@cetp.ipsl.fr

Ah, c'est une topique un peu religieuse dans ce groupe.
Je ne connais point ni JavaScript ni Java, donc je ne peux que
raconter ce que j'ai lu ici.  Si vous connaissez anglais, il
valait rechercher dans les archives avec DejaNews pour ces fils.

Ma conclusion de ces fils c'est que cettes deux langues ont leurs
forts et leurs faiblesses.  On peut faire certaines choses 
meilleurement avec l'une, et des autres choses aved l'autre.

Mais, il y a des autres considerations qui controllent l'avenir d'une
langue logicielle (comment dit-on "computer language" en francais?).
Quelle langue vient avec une ordinateur?  Quelle langue est ensignee
dans l'universite?  Quelles companies favorisent quelles langues?

--------------------
Ah, this is a bit of a religious topic for this group.  I know neither
JavaScript nor Java, so I can only recount what I have read here.  If 
you know English, it would be worthwhile to search DejaNews for such
threads.

My conclusion of these threads is that these two languages each have
their own strengths and weaknesses.  There are certain tasks more
suited to one or the other.

But, there are other factors controlling the future of a language.
What language comes with your computer?  What language are you taught
in college?  What companies favor which languages?

-- 
**********************************************************************
*** Carol C. Kankelborg                 csc80@amdahl.com           ***
*** Amdahl Corporation       The above opinions are uniquely mine. ***
**********************************************************************


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

Date: Fri, 21 Feb 1997 09:50:27 -0600
From: Eryq <eryq@enteract.com>
To: Trevor Jenkins <tfj@apusapus.demon.co.uk>
Subject: Re: How do I parse RFC 822 header lines with Perl?
Message-Id: <330DC443.47F1351E@enteract.com>

Trevor Jenkins wrote:
> 
> I'm trying to write a Perl script to analyze email meassages, specifically
> the header information. I can easily extract the information that I want
> from single lines but continuation lines are causing me grief.

Get Graham Barr's excellent MailTools kit.  Mail::Header does what you want.

> "Real Men don't Read Instruction Manuals"
>   Tim Allen, Home Improvement

Sadly, wrong... Real Men know about the Perl5 Module List.  ;-)

-- 
  ___  _ _ _   _  ___ _   Eryq (eryq@enteract.com)
 / _ \| '_| | | |/ _ ' /  Hughes STX, NASA/Goddard Space Flight Cntr.
|  __/| | | |_| | |_| |   http://www.mcs.net/~eryq
 \___||_|  \__, |\__, |__ 
           |___/    |___/ UNIX-FM: more talk ; less yacc yacc yacc


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

Date: Fri, 21 Feb 1997 18:07:14 GMT
From: tfj@apusapus.demon.co.uk (Trevor Jenkins)
Subject: Re: How do I parse RFC 822 header lines with Perl?
Message-Id: <330de3df.5809746@news.demon.co.uk>

Eryq <eryq@enteract.com> wrote:

> Trevor Jenkins wrote:
> > 
> > I'm trying to write a Perl script to analyze email meassages, specifically
> > the header information. I can easily extract the information that I want
> > from single lines but continuation lines are causing me grief.
> 
> Get Graham Barr's excellent MailTools kit.  Mail::Header does what you want.

Wonderful, someone's done it for me. :-))

> > "Real Men don't Read Instruction Manuals"
> Sadly, wrong... Real Men know about the Perl5 Module List.  ;-)

The first on-topic comment I've ever had about .sig.  :-) But in mitigation
I plead that my local copy doesn't mention MailTools.

Regards, Trevor.

--

"Real Men don't Read Instruction Manuals"
   Tim Allen, Home Improvement


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

Date: 21 Feb 1997 17:22:26 GMT
From: dupont@galois.unice.fr (Dupont Christophe)
Subject: how to "free" a hash
Message-Id: <5eklki$997$1@malibu.unice.fr>

Hi,

I am trying to store a large amount of data in perl hashes.
I would like to "free" the memory used by these hashes when I finish with  
them (I'd like to see a decrease of VSIZE and RSIZE)

but I don't know how to do

%MyHash=() does not work
undef %MyHash does not work
while(1)
{ ($key, undef)=each %MyHash; delete $MyHash{$key}; } 
does not work

so What to do ?
Maybe nothing similar to "free" is implemented in PERL ?

thanks for any help.

Christophe.
dupont@doublon.unice.fr


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

Date: 21 Feb 1997 17:22:15 GMT
From: dupont@galois.unice.fr (Dupont Christophe)
Subject: how to "free" a hash
Message-Id: <5eklk7$aai$1@malibu.unice.fr>

Hi,

I am trying to store a large amount of data in perl hashes.
I would like to "free" the memory used by these hashes when I finish with  
them (I'd like to see a decrease of VSIZE and RSIZE)

but I don't know how to do

%MyHash=() does not work
undef %MyHash does not work
while(1)
{ ($key, undef)=each %MyHash; delete $MyHash{$key}; } 
does not work

so What to do ?
Maybe nothing similar to "free" is implemented in PERL ?

thanks for any help.

Christophe.
dupont@doublon.unice.fr


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

Date: Fri, 21 Feb 1997 12:03:26 -0600
From: Eryq <eryq@enteract.com>
To: Dupont Christophe <dupont@galois.unice.fr>
Subject: Re: how to "free" a hash
Message-Id: <330DE36E.537B9FAD@enteract.com>

Dupont Christophe wrote:
> 
> Hi,
> 
> I am trying to store a large amount of data in perl hashes.
> I would like to "free" the memory used by these hashes when I finish with
> them (I'd like to see a decrease of VSIZE and RSIZE)
> 
> but I don't know how to do
> 
> %MyHash=() does not work
> undef %MyHash does not work
> while(1)
> { ($key, undef)=each %MyHash; delete $MyHash{$key}; }
> does not work
> 
> so What to do ?
> Maybe nothing similar to "free" is implemented in PERL ?
> 
> thanks for any help.

Perl, like Java and Lisp, is a garbage-collecting language.
You don't need to free stuff; Perl will do it automatically 
when that stuff is no longer referenced by anybody (for example,
if you declare a variable "local" or "my" to a subroutine, and
that subroutine exits.  

The most strightforward way I can think of to force the issue is... 

	undef %MyHash; 
	
Keep in mind that even when you free() memory in a C program,
that memory will possibly *not* be returned to the operating system
(depending on your OS, and on the implementation of free()). 
However, the freed memory *is* made available to the next caller
of malloc().   

(Aside: does anyone know whether we plan to have mark-and-sweep
implemented in Perl's GC anytime soon?  I long for circular data
structures without cleanup hackery.)    
-- 
  ___  _ _ _   _  ___ _   Eryq (eryq@enteract.com)
 / _ \| '_| | | |/ _ ' /  Hughes STX, NASA/Goddard Space Flight Cntr.
|  __/| | | |_| | |_| |   http://www.mcs.net/~eryq
 \___||_|  \__, |\__, |__ 
           |___/    |___/ UNIX-FM: more talk ; less yacc yacc yacc


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

Date: Fri, 21 Feb 1997 17:33:45 GMT
From: Jacqui Caren <Jacqui.Caren@ig.co.uk>
Subject: Re: How to spam - legitimately
Message-Id: <E5yrG9.6MB@ig.co.uk>

In article <7vohdf3vnx.fsf@speedy.speakeasy.org>,
Brett McCormick  <brett@speedy.speakeasy.org> wrote:
>
>You can invoke sendmail in SMTP mode and feed those commands to it
>(probably better than making a net connection)
>
>Valdis Kletnieks <valdis.kletnieks@vt.edu> writes:
>> 


my $from = "whatever";
my @recips =qw(aaa@bbb.com ccc@ddd.com);

use Net::SMTP;
my $session = Net::SMTP::new("mailhost");
$session->from($from);
foreach $to (@recips) {
	$session->to($to);
}

$session->data_start();
$session->data(<<"END");
From: $from
To: mailing-list@xxx.com
Subject: xxxxxxxxx
Date: xxxxxxxxxx


END
$session->data("content goes here\n");
$session->data_end();
$session->quit();

or something very similar... :-)

-- 
Jacqui Caren, Software Systems, Paul Ingram Group Ltd. J.Caren@ig.co.uk
AD: Need flexible, high quality reporting? - www.perl.co.uk/ig/dp.html



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

Date: 21 Feb 1997 05:30:41 -0800
From: Dirk Eschmoeller <debayqmk@ibmmail.com>
Subject: Including a C library in a Perl script
Message-Id: <5ek821$e5t@lex.zippo.com>

Hello,

does somebody know how you can include a C library into a Perl
script and how you can get the full access to the functions (with paramaters)?
We have Perl 4.0 on AIX.

I hope somebody could help me,

thank you
      Dirk


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

Date: Fri, 21 Feb 97 15:12:03 GMT
From: links@m2c.com
Subject: Links Related To comp.lang.perl.misc - FREE ACCESS
Message-Id: <5ekdm9$q41@colombia.earthlink.net>

For Free Access To Links Related To comp.lang.perl.misc Set Your Web Browser 
To:

http://www.m2c.com/links/compute.htm

Courtesy Of Surfing Links By M2C

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

Sponsored by Robo Surfer - Your Own Personal Internet Robot

Download Your Free Demo Today!
http://www.robosurfer.com


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

Date: 21 Feb 1997 18:00:44 GMT
From: bmcguire@business.uvic.ca (Bruce McGuire)
Subject: Log analysis for Netscape Ent Server
Message-Id: <5eknsc$1ekq@uvaix3e1.comp.UVic.CA>

Hello.

Has anyone written a log analysis tool for Netscapes Enterprise Server?
I have done some minimal customization of the log, including referrer and
browser, and would like to automate the analysis of the log.

I hope to find out just what browsers are being used in certain parts of
the world to view our site.

Your help would be greatly appreciated.

Thanks,

Bruce.
--



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

Date: Fri, 21 Feb 1997 18:38:00 GMT
From: alister@theoffice.net (Alister)
Subject: Re: Merge content from several files into one document
Message-Id: <330ec452.2051082@news.demon.co.uk>

sajaa@sn.no (Jarle Aasland) wrote:

>I have made a script for generating individual text-files (based on
>user input through html/forms), named dd-mm-y-hrs-min-sec.txt.
>The next thing - this is where I'm stuck - is to retrieve the content
>from the 25 NEWEST (how can I get it sorted??) 

Easiest way to store (& sort) dates - yyyymmddhhmmss   
{year, month, day, hour, mins, secs}.  Add a sequence number as
required if you want  Sorting is almost automatic.  

psuedo code:

opendir
while ( $directory{$fname} = getdir ())
{	}

Then sort the assoc array by key (to get newest date first), and write
out to the file as required.

Alister


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

Date: 21 Feb 1997 18:12:01 GMT
From: schip@lmsc.lockheed.com (Jan Schipmolder)
Subject: Re: Merge content from several files into one document
Message-Id: <5ekohh$5cd@butch.lmsc.lockheed.com>

Jarle Aasland (sajaa@sn.no) wrote:
: This is what I am trying to do:
: 
: I have made a script for generating individual text-files (based on
: user input through html/forms), named dd-mm-y-hrs-min-sec.txt.
: 
: The next thing - this is where I'm stuck - is to retrieve the content
: from the 25 NEWEST (how can I get it sorted??) files and put it all

Use the built-in named "stat()" on your files, get the mtime, sort
on mtime, take the top 25 items from your sorted list.

--
jan.b.schipmolder@lmco.com


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

Date: 21 Feb 1997 15:04:28 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Most efficient way to do a killfile-like regexp test?
Message-Id: <5ekdhs$kal@news-central.tiac.net>

In article <5ei2ln$apf@senator-bedfellow.MIT.EDU>,
Christopher Russo <crusso@mit.edu> wrote:

>inefficient.  Right now, I'm doing something like:
>
>	foreach $line (@lines) {
>		foreach (user-definable-regexp) {
>			if ($line =~ eval-ed regexp) {
>				do whatever...
>			}
>		}
>	}
>
>Anybody know a faster way to do this, or am I just being greedy?  :)

You might want to do something like this pseudo code:

  $code = 'foreach $line (@lines) { ; ... ';
  foreach $regex (@listOfRegexes) {
    $code .= 'if ($line =~ /', $regex, ') { ... } ';
  }
  $code .= '}'; 

because I don't quite see what you mean by 'eval-ed regexp'.  This would
build the loop and eval it once so each regex only gets compiled once.  

There's a link on http://www.perl.com/perl/everything_to_know/index.html
under the text "What Makes Perl's Regular Expressions Dynamite" which has
a match_any routine at the bottom which you may find useful.

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@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 21 Feb 1997 10:06:28 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: output into a variable
Message-Id: <wws2qjuz.fsf@jander.com>

Edjair de Souza Mota <mota@ftsu00.ee.TU-Berlin.DE> writes:

> 
> Hallo, Perl gurus
> 
> I'm coming to the perl world and testing how it works as a simulation
> controller.
> 
> I need to run a same C-simulation model many times, each time I've got
> the results at my monitor. In order to analyse these results I need to
> read them and the way I've found 'till today is sending the output to a
> temporary file ( "tempaq"), read the results, make some calculations and
> depending on the accuracy of the results I ask for another run of the
> program. I'm afraid making a hole at the memory 'cause the simulation
> runs a hundred of thousends of time :-)
> 
> Is there any way to get the output direct to a Perl array ?

The quick-n-dirty approach would be something like this:

@results = `/my/simulation/pgm arg1 arg2`;

A more robust method would be more like this:

    my $pipe = "/my/path/to/pgm";
    open PIPE, "$path |"
      or die ("fork (open) failed for '$path' : $!$NL");
    local $SIG{PIPE} = sub { die ("'$path' pipe broke: $!$NL") };
    @results = <PIPE>;
    close PIPE;


-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: Fri, 21 Feb 1997 19:31:57 +0100
From: jean-philippe amiel <JeanPhilippe.Amiel@alcatel.titn.fr>
Subject: Perl and MAPI (Windows NT Win32 Messaging API)
Message-Id: <330DEA1C.167EB0E7@alcatel.titn.fr>

Could someone tell me please if it exits a Perl "package" for MAPI,
(Microsoft Messaging API ) for Win32 Windows NT ????

I would like to know also the references for the latests:
        - PERL         FAQ
        - PERL source code for SUN
        - PERL source code for Windows NT


Thank you very much.


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

Date: Fri, 21 Feb 1997 10:46:03 -0600
From: Anthony John Doyle <strad@mondenet.com>
Subject: PERL for NT & Netscape Enterprise Server
Message-Id: <330DD14B.234C@mondenet.com>

Have been working the last few weeks with the Netscape Communications
Server 1.12 and have been doing some PERL scripts which would get
executed as:
  
  http://host/cgi-bin/perl.exe?myscript.pl
  
where the perl.exe had to be in the cgi-bin directory - which was
not great security wise - but the scripts worked
  
now we have upgraded to the Netscape Enterprise Server 3.0beta2
and that methodology does not work anymore.

i have tried to follow the various instructions for PERL and
for Enterprise Server 3.0beta2 and am now trying the following:
  
  http://host/cgi-bin/myscript.pl
  
with the /cgi-bin/ being defined as a shell cgi directory from the
netscape administration server - what i get back on the web page
calling the script is an error message saying:
  
  This server has encountered an internal error which prevents it from
  fulfilling your request. The most likely cause is a misconfiguration.
  Please ask the administrator to look for messages in the server's
error
  log.
  
checking the server's error log i get:
  
  [21/Feb/1997:10:25:54] failure: for host 142.125.108.152 trying to
  POST /cgi-bin/myscript.pl,
  cgi-parse-output reports: the CGI program C:\\Perl\\bin\\Perl.exe
  did not produce a valid header (program terminated without a valid
  CGI header (check for core dump or other abnormal termination)
  
and checking with the netscape web pages i get the following advice:
  
  If your CGI script written in Perl is causing this error to appear in
  your server's error log whenever you try to run the script:
  
    cgi-parse-output reports: the CGI program /path/foo.cgi did not
produce
    a valid header (program terminated without a valid CGI header; check 
    for core dump or other abnormal termination)
  
  then add the line
  
    $|=1;
  
well - i did add that line to myscript.pl and still i get the same
problems
occuring.....

HELP!  anyone have this problem and a fix for it?

Thanks!

strad@mondenet.com


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

Date: Fri, 21 Feb 1997 18:16:43 GMT
From: Rasilon (Rasilon)
Subject: Re: Perl on Windows 95
Message-Id: <330de618.20116530@news.mnsinc.com>

On Mon, 17 Feb 1997 15:51:00 -0700, Mark Perry
<mdperry@cougar.netutah.net> wrote:

>I am setting up a website and I want to use some scripts.  I want to
>test them to make sure they work befor sending them to the ISP.  I
>downloaded Perl for Windows 95/NT.  I can see if a script compiles and
>what its output is in a dos box by typing C:\>perl myscript.pl.  
>
>I would like to also see how it works by loading the page into Netscape
>locally and then running the script (like it would on a server).  Is
>this possible.  When I tried clicking on the button that calls the
>script nothing happened.  
>
>Any suggestions?
>
>Thanks.

I do exactly the same stuff. I downloaded/instaled Microsoft's
Personal Web server and voila.... Now my partable acts just like the
comercial web server that I am designing for.
Whats more... this is free.


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

Date: 21 Feb 1997 16:32:39 GMT
From: bamford@marconi.ih.lucent.com (Harold Bamford)
Subject: Re: PSCOPE - an CSCOPE for perl source
Message-Id: <5ekin7$6rs@ssbunews.ih.lucent.com>

In article <856378708.26721@dejanews.com>,  <mlehmann@prismnet.com> wrote:

>  CSCOPE is a code scoping database.  It is probably a descendant of grep.
>It creates a database of qualities of the code.  Specifically it provides
>the
>following features:
>
>  Find a symbol in all of the source files
>  Finding a definition of a variable, function
>  Finding functions called by a certain function
>  Finding functions calling a certain function
>  Finding assignments to a variable
>  Global changing a regular expression throughout the code
>  Finding a regular expression throughout the code
>  Finding a particular file
>  Finding files #including a certain file

Pretty good summary.  Clearly, mlehmann@prismnet.com has a copy of
cscope on his machine.

I think a little history is appropriate here.  Cscope was invented by
Joe Steffen of Bell Laboratories (formerly of AT&T and now part of
Lucent Technologies).  It is NOT descended from grep.  It consists of a
very forgiving parser that identifies variables, functions, file
inclusions, assignments (including passing an argument to a variable),
etc and a single file database.  More recent versions of cscope have
trigraph compression in the database and inverted indices for symbols.

There are browsers available that also do these things but the vast
majority of them use the object symbol table to get this information.
Which requires that the program be compilable.  Which is worthless when
trying to get NEW code analyzed.  Also not much use when trying to port
code from one platform to another.

Joe Steffen (and two others) continue to maintain cscope on a large
number of platforms.

And now for my own 2 cents worth on PSCOPE:  This is a GREAT idea!  But
be sure that the parser is sufficiently forgiving that the first syntax
error won't stop it dead.  The whole idea is to use this to FIX or
ENHANCE a perl program.  Egrep is great, but *scope fills a void in the
developer's toolchest.

-- Harold Bamford


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

Date: 21 Feb 1997 09:38:48 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: relationship between @INC & PERL5LIB w.r.t. module loading?
Message-Id: <5ekmj8$c5o$1@halcyon.com>

In article <5eiuvh$g8g@ptdcs5.ra.intel.com>,
Silvio Picano <spicano@ptdcs2.intel.com> wrote:
|Now I though that adding paths into @INC was enough to find these
|modules, but I cannot get them to load thru @INC:
|    push @INC, '/usr/guest/spicano/lib/perl5/site_perl/rs_aix325';
|    push @INC, '/usr/guest/spicano/lib/perl5/site_perl';
|    use Data::Dumper;

use happens at compile time, so it's being executed *before* the
modification of @INC. Instead of modifying @INC directly, look at
lib.pm. It even handles the site specific stuff for you:

use lib '/usr/guest/spicano/lib/perl5/site_perl';
use Data::Dumper;

|I really do not want to use PERL5LIB.

Why not? If you use PERL5LIB, you only have to modify the path(s) you
add in one place (your .profile/.kshrc/.login/.wombat/.whatever) if you
move, but if you hardcode the paths in each of your scripts, you have to
modify them all in every single script you write.

Brian
-- 
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: 21 Feb 1997 10:13:22 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: REQ: Getting the amount of files in a certain directory.
Message-Id: <sp2qqjjh.fsf@jander.com>

pcolosi@freenet.hut.fi (pino colosi) writes:

> 
> Nathan V. Patwardhan wrote:
> > 
> > Nathan D Richards (nathanr@k2.ashpool.com) wrote:
> > : I need to know how many *.D files there are in a certain directory.
> > : Is there anyway to do this in a CGI script?
> > 
> > Even better (I could kick myself for the last, two assinine suggestions):
> > 
> > $dir '/path/dir';
> > $entry = '' unless $entry;
> > 
> > opendir(DIR, "$dir");
> > @entries = grep(/\.D$/, sort(readdir(DIR)));
> > closedir(DIR);
> > 
> > foreach $entry (@entries) {
> >     $i++ if $entry;
> > }
> > 
> > print("There were $i entries with a .D extension.\n");
> > 
> > --
> > Nathan V. Patwardhan
> > nvp@shore.net
> > "Lane, this is pure snow!
> > Do you have any idea what
> > the street value of this mountain is?"
> >         --Charles Demar from _Better Off Dead_
> 
> Hi, I'm new to perl.
> I have modified the script:
> 
> print "Content-type: text/html\n\n";
> print "<HTML>";
> print "<head>";
> print "</HEAD>";
> print "<BODY bgcolor=3D'#C0F0D3'>";
> print "<center>";
> print "<table border=0 cellpadding=3D'4' cellspacing=3D'4'>";

[...]

> This script shows the files of a directory.
> In every html document, I have put a file's description inside
> <title></title>, my question is :
> is it possible to show this information along with the file name?

The pathname of the executing script is in $0;

BTW, you could make this code a lot "cleaner" by changing the way
you're doing the print. For example,

=========================================================
print <<EOD;
Content-type: text/html

<HTML>
<head>
</HEAD>";
<BODY bgcolor=3D'#C0F0D3'>
<center>
<table border=0 cellpadding=3D'4' cellspacing=3D'4'>
EOD
=========================================================














-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: Fri, 21 Feb 1997 09:30:09 -0600
From: Steve Vandiver <buxx@buxx.com>
Subject: Resolving IP
Message-Id: <330DBF81.4400@buxx.com>

Need to resolve my currnet IP address

Any help ??


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

Date: Fri, 21 Feb 1997 09:54:47 -0600
From: Eryq <eryq@enteract.com>
To: penta@knoware.nl
Subject: Re: sending email and attaching a .gif file
Message-Id: <330DC547.615262B9@enteract.com>

penta@knoware.nl wrote:
> 
> I am working on a program to automaticaly send  E-mail messages to my
> members. Sending a message is easy. I already fixed that part. But,
> now I want to attach a graph of statistics to this mail. This is
> difficult. I looked at a page which handled about MIME, but I did not
> understand how to use this.

Get and install the latest release of MIME-tools 3.x from the
CPAN (authors directory Eryq).  Then do something like this:

    use MIME::Entity;	

    # Create the top-level, and set up the mail headers:
    $top = build MIME::Entity Type     => "multipart/mixed",
                              -From    => 'me@myhost.com',
                              -To      => 'you@yourhost.com',
                              -Subject => "Hello, nurse!";
    
    # Attachment #1: a simple text document: 
    attach $top  Path=>"./testin/short.txt";
    
    # Attachment #2: a GIF file:
    attach $top  Path        => "./docs/mime-sm.gif",
                 Type        => "image/gif",
                 Encoding    => "base64";
     
    # Attachment #3: text we'll create with text we have on-hand:
    attach $top Data=>$contents;
    
    # Output!
    $top->print(\*STDOUT);

MIME-Lite available REAL SOON NOW, I mean it!

-- 
  ___  _ _ _   _  ___ _   Eryq (eryq@enteract.com)
 / _ \| '_| | | |/ _ ' /  Hughes STX, NASA/Goddard Space Flight Cntr.
|  __/| | | |_| | |_| |   http://www.mcs.net/~eryq
 \___||_|  \__, |\__, |__ 
           |___/    |___/ UNIX-FM: more talk ; less yacc yacc yacc


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

Date: Fri, 21 Feb 1997 11:02:38 -0600
From: Craig Votava <craig@lucent.com>
Subject: Strange pack/unpack behavior
Message-Id: <330DD52E.41C6@lucent.com>

Folks-

When I use the following command, to change a bit pattern into a hex
value, I get an incorrect value:

perl -e 'print "ret=", unpack("H1",pack("B2","10")), "\n";'

The returned value is 8, the correct value is 2. To get this to return
the correct value, change ("B2", "10") to ("B4", "0010").

I guess I don't understand why this is. Please explain!

Thanks!


	()_()	Craig Votava
	 (_)	Lucent Technologies
		craig@lucent.com


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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 V7 Issue 988
*************************************

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