[10273] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3866 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 1 13:07:13 1998

Date: Thu, 1 Oct 98 10:00:33 -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           Thu, 1 Oct 1998     Volume: 8 Number: 3866

Today's topics:
    Re: ****Can you show me a simple perl script to run the (David Alan Black)
    Re: ****Can you show me a simple perl script to run the <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: ****Can you show me a simple perl script to run the <perlguy@inlink.com>
        Attaching file to sendmail pipe (David Bluestein II)
    Re: Attaching file to sendmail pipe (Sean McAfee)
    Re: Attaching file to sendmail pipe <95ncp@eng.cam.ac.uk>
    Re: Can't generate HTML! Why??? <kchunt@mail.hac.com>
    Re: CGI and file uploading <jdporter@min.net>
    Re: Checking FS (File system) <guenter@arithmos.com>
    Re: Coding Standards? <uri@sysarch.com>
    Re: DEL in PERL <jdf@pobox.com>
    Re: DEL in PERL <perlguy@inlink.com>
    Re: Does die close files (when caught) ? (Mark-Jason Dominus)
    Re: Does die close files (when caught) ? (Mark-Jason Dominus)
    Re: File manipulation <aqumsieh@tigre.matrox.com>
    Re: File manipulation <jeff@vpservices.com>
    Re: Help with system() on NT (Martin Vorlaender)
    Re: How to know if I deal with a file or a directory (Mike Stok)
    Re: How to know if I deal with a file or a directory <jdporter@min.net>
        Ignore multiple input record seperators aonghus.onia@ucg.ie
        JR. Opportunity <ijankovi@teksystems.com>
    Re: KDE v. Gnome Eric-Goforth@csi.com
    Re: Locking files, counter, unique serial number... <jdporter@min.net>
    Re: make script for NT? <perlguy@inlink.com>
        Multicast and sockets <angel.mateo@rediris.es>
    Re: need a regular expressions expert.... (Abigail)
    Re: passing javascript vars to CGI <mhicks@nowis.com>
        perlglob.exe and Win32 dmcclory@msn.com
    Re: Rotating an array. <aqumsieh@tigre.matrox.com>
        scope question <Ian_Lowe@fanniemae.com>
    Re: scope question <jdf@pobox.com>
    Re: Some kind of 'real' user interface? <jdporter@min.net>
    Re: Stock paging, anyone seen this script? <merlyn@stonehenge.com>
    Re: this should work. Why doesn't it? <95ncp@eng.cam.ac.uk>
    Re: this should work. Why doesn't it? <daniel.vesma@thewebtree.com>
    Re: this should work. Why doesn't it? <daniel.vesma@thewebtree.com>
    Re: this should work. Why doesn't it? <jdporter@min.net>
        Trouble building 5.005_02 on HP-UX 10.20 <toml@synnet.com>
    Re: UNIVERSAL doesn't work how I'd expect <jdporter@min.net>
    Re: What is HFB? <eashton@bbnplanet.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 1 Oct 1998 10:59:44 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: ****Can you show me a simple perl script to run the POST method?
Message-Id: <6v05d0$7p7$1@pilot.njin.net>

Hello -

burningboy@hotmail.com (James  Bond  098) writes:

>Plz show me a simple script to POST method(Don't USE any module)

Do I have to stand on one foot and play the piano at the same time?


David Black
dblack@pilot.njin.net
dblack@saturn.superlink.net (on those occasions when the NNTP server
                             doesn't inexplicably start returning 440
                                         after a



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

Date: 01 Oct 1998 17:46:13 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: ****Can you show me a simple perl script to run the POST method?
Message-Id: <834stoe14q.fsf@vcpc.univie.ac.at>

Re: ****Can you show me a simple perl script to run the POST
method?, James <burningboy@hotmail.com> said:

James> Plz show me a simple script to POST method(Don't USE
James> any module)

Woohoo, ROTFL!  You've got to be kidding, right?

What's the objection to modules?  Avoiding the good
libwww/CGI stuff is just going to make it 1000's of times
more difficult to construct HTTP queries.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Thu, 1 Oct 1998 16:00:39 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: ****Can you show me a simple perl script to run the POST method?
Message-Id: <3613A727.EBD17C2E@inlink.com>

#!/usr/local/bin/perl
require "cgi-lib.pl" || die "I couldn't find cgi-lib.pl! $!";
&ReadParse;

$value=$in{'value'};
print "Content-type: text/html\n\n";
print "$value";


cgi-lib.pl is not a module. :-)

Why don't you want to use a module?  They are designed to make things
easier.  CGI.pm certainly does...

BRent

-- 
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: Thu, 01 Oct 1998 10:26:18 -0500
From: dbii@mudpuddle.com (David Bluestein II)
Subject: Attaching file to sendmail pipe
Message-Id: <dbii-0110981026180001@darwin.mudpuddle.com>

I now need to attach a text file to the email message (to preserve
formatting) and cannot see how to do so.

I've routinely sent email via perl using a pipe to sendmail and printing
to it, or using the SMTP or MAIL modules.  I've looked through
documentation on all three but none mention attaching a file and I'm not
familiar enough with sendmail to find out how it handles attachments.

Can someone help with a point or two? Do I have to encode the file and
print it to the sendmail pipe? If so, what is the format? If not, what
should I do?

TIA-

ii

-- 
David H. Bluestein II                  President & Lead Developer
dbii@mudpuddle.com                     Interactive Internet
                                       http://www.interaction.net/
-        Specializing in Designing Interactive Websites        -
-              and Searchable Internet Databases               -


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

Date: Thu, 01 Oct 1998 15:42:09 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Attaching file to sendmail pipe
Message-Id: <lpNQ1.5646$F7.20835023@news.itd.umich.edu>

In article <dbii-0110981026180001@darwin.mudpuddle.com>,
David Bluestein II <dbii@mudpuddle.com> wrote:
>I now need to attach a text file to the email message (to preserve
>formatting) and cannot see how to do so.

>I've routinely sent email via perl using a pipe to sendmail and printing
>to it, or using the SMTP or MAIL modules.  I've looked through
>documentation on all three but none mention attaching a file and I'm not
>familiar enough with sendmail to find out how it handles attachments.

Sendmail, and every other RFC822 mail agent, is unaware of the existence of
attachments.  E-mail clients know how to interpret the MIME header fields
and internal structure.

>Can someone help with a point or two? Do I have to encode the file and
>print it to the sendmail pipe? If so, what is the format? If not, what
>should I do?

Check out the MIME modules on CPAN; perhaps MIME::Lite will do everything
you need.  If you prefer to roll your own, read RFC1521.  Here's
essentially how it works for the special case of text-only attachments:

o   Add two header fields to the main message:
       MIME-Version: 1.0
       Content-Type: multipart/mixed; boundary="foobar"
    (You may replace "foobar" with any string $s, such that no line in
    any of the attachments matches /^--$s(?:--)?$/)

o   Prefix each attachment with the line "--foobar", followed by a blank
    line.

o   Append the line "--foobar--" after the last attachment.

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: Thu, 1 Oct 1998 16:46:16 +0100
From: Nigel Parker <95ncp@eng.cam.ac.uk>
Subject: Re: Attaching file to sendmail pipe
Message-Id: <Pine.HPP.3.96L.981001163447.12282C-100000@club.eng.cam.ac.uk>

On Thu, 1 Oct 1998, David Bluestein II wrote:

: I now need to attach a text file to the email message (to preserve
: formatting) and cannot see how to do so.
: 
: I've routinely sent email via perl using a pipe to sendmail and printing
: to it, or using the SMTP or MAIL modules.  I've looked through
: documentation on all three but none mention attaching a file and I'm not
: familiar enough with sendmail to find out how it handles attachments.
: -- 
: David H. Bluestein II                  President & Lead Developer
: dbii@mudpuddle.com                     Interactive Internet
:                                        http://www.interaction.net/
: -        Specializing in Designing Interactive Websites        -
: -              and Searchable Internet Databases               -

Interactive Internet, eh?  I'll tell you if you employ me as a
consultant! ;-)

Here's a simply routine which will uucode a message (don't use it
commercially though, it's (c) Nigel Parker - and I can't remember who I
ripped it off from):
   sub uu_encode {
      my ($in) = @_;
      foreach $line ($in =~ /.{1,45}/gs) {
            push @result, pack("u", $line);
      }
      join("", "begin 644 rfp.html\n", @result, "end\n");
   }

So you will have:
   &open_and_select_mail;
   $message = <FileHandle> || "some string to be attached";
   print &mail_header;
   print &uu_encode($message);
   &close_mail;

There's also MIME attachments, but I'm not going to get into that!  There
is loads of info on the www if you look for it.


Nigel
-- 
Girton College, Cambridge, England, CB3 0JG.             Tel: 0411 384803

http://welcome.to/nigels                             nigel.parker@iee.org



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

Date: Thu, 01 Oct 1998 08:13:41 -0700
From: Kenneth Hunt <kchunt@mail.hac.com>
Subject: Re: Can't generate HTML! Why???
Message-Id: <36139C25.AC44A096@mail.hac.com>

> And the bit you didn't show us is almost certainly where the
> error is.  Running as a CGI is utterly different to the
> command-line (pace CGI.pm's wonderful efforts to make it
> look the same :-)
> 
> I expect you're not testing the open() for failure.  Do that
> first and you might find out what's going wrong.

Thanks for the help. Naturally, right after I posted that message I
found the problem. I failed to end a block of straight HTML code with
the "END" statement. It didn't show up when I ran it in UNIX because
UNIX dosn't care about HTML.

Also, the server at my job is set up for Perl4. Although the SysAd says
I can invoke Perl5 at the initial command line: #/usr/local/bin/Perl5.

So, all is well.
-- 


------------------------------------------------------
Kenneth Hunt
SC S12 V321 Rm. C233
office:	364-7755	pager:	715-0600
------------------------------------------------------


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

Date: Thu, 01 Oct 1998 11:05:43 -0400
From: John Porter <jdporter@min.net>
Subject: Re: CGI and file uploading
Message-Id: <36139A47.2F8A0F75@min.net>

Timothy Church wrote:
> 
> I have tried to use the example from the CGI book on pg 152, but can't
> seem to get my script to read the file.  Does anyone have an example
> that works?

Lincoln Stein's CGI.pm page explains how:
http://stein.cshl.org/WWW/software/CGI/cgi_docs.html

-- 
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer


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

Date: Thu, 01 Oct 1998 15:24:50 GMT
From: Guenter Steinbach <guenter@arithmos.com>
Subject: Re: Checking FS (File system)
Message-Id: <36139EC1.40AE@arithmos.com>

Patrick wrote:

> Does anyone have a script that will check the FS, and when it's > 80%
> full, write a message or display something on the console or any
> terminal.
I am running xfsm.  It displays bar graphs of all mounted file systems,
and the bars change color as %full crosses two or three different
thresholds.  It can send email, too.  Check
http://hpux.cae.wisc.edu/hppd/hpux/Sysadmin/xfsm-1.95/

-- 
        Guenter Steinbach,  Arithmos Inc.,     guenter@arithmos.com


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

Date: 01 Oct 1998 10:54:18 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Coding Standards?
Message-Id: <x71zosuycl.fsf@sysarch.com>

>>>>> "d" == dave  <dave@mag-sol.com> writes:

  d> In article <slrn714snb.vtq.stesch@parsec.rhein-neckar.de>,
  d> stesch@parsec.rhein-neckar.de (Stefan Scholl) wrote:
  >> On 29 Sep 1998 12:48:40 GMT, Ken Rich <kenr@troi.cc.rochester.edu>
  >> wrote: > In comp.lang.perl.misc, lemull@unx.sas.com writes: > :Can
  >> anyone point me to a set of Coding Standards developed >
  >> :specifically for Perl?  > > Not perl specific, but Steve
  >> McConnell's (?) book __Code Complete__ > from Microsoft Press has
  >> really great recommendations on coding ^^^^^^^^^ > standards, that
  >> bear a striking resemblance to man perlstyle, but > goes further in
  >> the good directions.
  >> 
  >> Yeah, right. :-)

  d> Surprisingly, it *is* a good book. If you think that it's ironic
  d> that it comes from Microsoft, remember that another book in the
  d> same series is called 'Writing Solid Code' - now that *is* a laugh!

that book has some good stuff too. i also have trouble picking them up
because of the publisher's name. but the fact that they publish it
doesn't mean they use it all over redmond. and better coding styles does
not necessarily lead to better quality design. it might lower some
stupid low level bugs but high level stupidity will still come
through. that is a typical reesism, standardize the low level stuff and
the high level stuff is better. 

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 01 Oct 1998 17:57:37 +0200
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: DEL in PERL
Message-Id: <m34stoqnpq.fsf@joshua.panix.com>

"Computer Guru" <computerguru@mailexcite.com> writes:

> I am trying to find all files on the HD which end in *.bak and then delete
> them. I was tring to do this as a DOS batch script but noticed DOS does not
> have this capability...I checked my manuals but could not find out how to do
> this..would I need a grep statement or something? Thanx

> Computer Guru Consulting

Please.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Thu, 1 Oct 1998 16:04:52 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: DEL in PERL
Message-Id: <3613A824.87FE2F88@inlink.com>

Computer Guru wrote:
> 
> Hello
> How would I write the following in Perl for Win95
> I am trying to find all files on the HD which end in *.bak and then delete
> them. I was tring to do this as a DOS batch script but noticed DOS does not
> have this capability...I checked my manuals but could not find out how to do
> this..would I need a grep statement or something? Thanx

Computer Guru huh? ;-)

Take a look at the File::Find module.

- Read the directories in
- Traverse the array and use the "unlink" function to delete them

HTH
Brent 
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: 1 Oct 1998 11:25:19 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Does die close files (when caught) ?
Message-Id: <6v06sv$slb$1@monet.op.net>

In article <3613604F.376C8D26@inlink.com>,
Brent Michalski  <perlguy@inlink.com> wrote:
>when the program "dies", all file handles will be closed before Perl
>exits.  so, you don't need the extra code in your program...

In this case, that is the wrong answer, because he is using `eval' to
catch the `die'.


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

Date: 1 Oct 1998 11:36:14 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Does die close files (when caught) ?
Message-Id: <6v07he$so2$1@monet.op.net>

In article <36137235.66CDB1C9@cnam.fr>,
Paul Preziosi  <preziosi@cnam.fr> wrote:
>------------------------------------------------------------
>sub play_with_file {
>  open F, '<fname' or die "can't open";
>  seek F, $doubtful_offset, O or die "bad offset";
>  # ...
> =A0close F;
>}
>
>eval { play_with_file(); }
>handle( $@ ) if $@;

`die' in this case is something like `goto'.  It will not close the
file; the only way to do that it to invoke `close' explicitly.

The most ordinary way to write this:

	sub play_with_file {
	  unless (open ...) { 
	    $ERROR = "Can't open: $!";
	    return;
	  }
	
	  unless (seek ...) {
	    $ERROR = "Can't seek: $!";
	    close ...;
	    return;
	  }
	
	  ...
	
	  close ...;
	  return 1;
	}
	
	unless (play_with_file()) {
	  print "play_with_file: $ERROR\n";
	}

Graham Barr has an `Error' module that lets you write this:

	try {
	  open ... or throw Error::Simple("Couldn't open: $!");
	  seek ... or throw Error::Simple("Couldn't seek: $!");
	} finally {
	  close ...;
	}
	 
The `finally' part is supposed to be executed even if the stuff in`
try' throws an exception.





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

Date: 01 Oct 1998 10:51:21 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: File manipulation
Message-Id: <x3ysoh8mj2u.fsf@tigre.matrox.com>


Ben Duncan <ben@isolve.net> writes:

> 
> Hi!
> 
> I finally figured out how to extract an email address which
> is wrapped around ()'s
> 
> if(m/\((.*)\)/ ) {
> $email = $1;
> }
> 
> Seems to do the job fine!
> 

Just try your code on something like:

Some text (someone@email.address.com) (hello)

What does it give you?

-- 
Ala Qumsieh             |  No .. not Just Another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)


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

Date: 1 Oct 1998 14:29:32 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: File manipulation
Message-Id: <36139109.B85B676E@vpservices.com>

Ben Duncan wrote:

> [snip: want to find text enclosed in parens]
> ($email) = /\([^(](.*)[^)]\)/;
> [snip]
> How come the first & last characters are stripped? What the
> heck am I doing wrong?!

Here is what your sample asks Perl to do:

\(    = Find an open parens
[^(]  = Find a single character that is not an open parens
(.*)  = Find any characters and remember them
[^)]  = Find a single character that is not a close parens
\)    = Find a close parens

So you have asked it not to remember the first and last characters
between the parens.

Here is what you probably meant to do:

/\(([^)]*)\)/

Which means:

\(       = Find an open parens
([^)]*)  = Find anything that isn't a close parens and remember it
\)       = Find a close parens


- Jeff


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

Date: Thu, 01 Oct 1998 06:35:17 +0200
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Help with system() on NT
Message-Id: <36130685.524144494f47414741@radiogaga.harz.de>

George Kuetemeyer (george.kuetemeyer@mail.tju.edu) wrote:
: scottw7562@my-dejanews.com wrote:
: > I read the docs and apparently the `backtick` method is not supported under
: > NT ?? otherwise I should be able to capture and supress the output of the
: > command.
:
: The `backtick` method *does* work with NT.

 ...unless you are using Perl for CGI scripting, have IIS, and didn't tell
it to create a new console with each script.

For IIS v2 and v3:

Insert Registry key 
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\
CreateProcessWithNewConsole , contents REG_DWORD 1
and restart IIS.

For IIS v4:

- Make sure that you've got "Windows Scripting Host" installed as
  part of Option Pack 4. You can verify this by looking for the file
  %system32%\cscript.exe. If it isn't there, run setup.exe from
  the Option Pack CD-ROM and install it.
- Using the CLI, go to %system32%\inetsrv\adminsamples.
- Run this:

        adsutil.vbs SET W3SVC/1/CreateCGIWithNewConsole 1

  (the number after "W3SVC/" may vary if you have multiple websites.
   If you have, repeat the procedure for all websites.)
  It'll say that CScript isn't set up to handle this. That's ok.
- Click Ok.
- Click yes, you want to register.
- Run it again.
- Using the ISM, restart all web sites.

cu,
  Martin
--
                        | Martin Vorlaender | VMS & WNT programmer
 VMS is today what      | work: mv@pdv-systeme.de
 Microsoft wants        |       http://www.pdv-systeme.de/users/martinv/
 Windows NT 8.0 to be!  | home: martin@radiogaga.harz.de


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

Date: 1 Oct 1998 14:00:11 GMT
From: mike@mike.stok.co.uk (Mike Stok)
Subject: Re: How to know if I deal with a file or a directory
Message-Id: <6v01tb$o44@news-central.tiac.net>

In article <361374B3.284B13E6@imaginet.fr>,
patrick Scotto  <sertim@imaginet.fr> wrote:
>I want my perl program to explore my disk (full of files and
>directories) and to create a list of all the filenames.
>
>For this, it opens the top most directory and takes the name of all
>files... ignoring whether the name it reads is related to a file or a
>directory.
>
>How can I check that the name I deal with is related to a file or a
>diretory ?
>Is there a function that returns the type of a file ?

You need to look at the file test functions which are described under -X
in the perlfunc man page:

  -X      A file test, where X is one of the letters listed below.  This
          unary operator takes one argument, either a filename or a
          filehandle, and tests the associated file to see if something is
          true about it.  If the argument is omitted, tests $_, except for
          -t, which tests STDIN.  Unless otherwise documented, it returns 1
          for TRUE and '' for FALSE, or the undefined value if the file
          doesn't exist.  Despite the funny names, precedence is the same as
          any other named unary operator, and the argument may be
          parenthesized like any other unary operator.  The operator may be
          any of:

  [...]

              -f  File is a plain file.
              -d  File is a directory.

for more info check out the perfunc man page.

Hope this helps,

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


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

Date: Thu, 01 Oct 1998 11:36:52 -0400
From: John Porter <jdporter@min.net>
Subject: Re: How to know if I deal with a file or a directory
Message-Id: <3613A194.C80F89E3@min.net>

patrick Scotto wrote:
> 
> I want my perl program to explore my disk (full of files and
> directories) and to create a list of all the filenames.
> 
> For this, it opens the top most directory and takes the name of all
> files... ignoring whether the name it reads is related to a file or a
> directory.

I certainly hope you're not reinventing the wheel which
is very robustly implemented by the File::Find module.


> How can I check that the name I deal with is related to a file or a
> diretory ?
> Is there a function that returns the type of a file ?

Nice to see you can't be bothered to read one page of 
documentation.  Do you know how?  There's a command called 'perldoc'.
Try:
	perldoc perlfunc
There is a section named 'Alphabetical Listing of Perl Functions',
and the ones you're interested in are the VERY first ones listed.


> Thanks for your help.

Please use File::Find.

-- 
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer


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

Date: Thu, 01 Oct 1998 14:43:18 GMT
From: aonghus.onia@ucg.ie
Subject: Ignore multiple input record seperators
Message-Id: <6v04e6$i83$1@nnrp1.dejanews.com>

Is it possible to Ignore multiple input record seperators eg multiple spaces
when reading input. (the no. of spaces is not constant). I know I could test
for repeated spaces but I am reading in from an extremly large file an I want
it to be as efficient as possible.+


eg.

$/=" ";
while(<>){
print;
print "\n"
}

1 2  3

produces:
1
2

3

instead of
1
2
3


-Aonghus O Nia
aonghus.onia@ucg.ie




-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 01 Oct 1998 10:12:31 -0400
From: Igor Jankovich <ijankovi@teksystems.com>
Subject: JR. Opportunity
Message-Id: <36138DCF.C253BA8B@teksystems.com>

We are looking for a junior PERL 5 individual who can thread some small
applications on a HP UNIX platform.  It is in the Toronto, Canada area.
If interested contact:
Igor Jankovich
TEKsystems
1-800-254-0778
ijankovi@teksystems.com



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

Date: 01 Oct 1998 10:06:54 -0400
From: Eric-Goforth@csi.com
Subject: Re: KDE v. Gnome
Message-Id: <wk1zos5qbl.fsf@csi.com>

| I learned basic perl from a freely available 10k tutorial on the web and
| later referred to perlfunc, perlop and perlsyn manpages whenever I
| wanted to learn. 

Any idea where I could find this, or a similar, tutorial?
-- 
To respond via e-mail, please remove what's between Eric and Goforth in
my address in order to get my real e-mail address.


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

Date: Thu, 01 Oct 1998 11:09:22 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Locking files, counter, unique serial number...
Message-Id: <36139B22.4346DB38@min.net>

Mark-Jason Dominus wrote:
> 
> Rewrite it like this:
> 
>    sub get_and_update_rfp_counter {
>       sysopen(FH, "rfp_counter", O_RDWR|O_CREAT, 0644)
>         or die "Couldn't open rfp_counter: $!; aborting";
>       flock(FH, 2);
>         or die "Couldn't lock rfp_counter: $!; aborting";
>       my $count = <FH> || 0;
>       seek(FH, 0, 0);
>       truncate(FH, 0);
>       print FH $count+1, "\n";
>       close FH;
>       $form{'serial_no'} = "E-".substr($count, 0, -1);
>    }

Buggus typographicus: 
	flock(); or die;

Should be
      flock(FH, 2)
        or die "Couldn't lock rfp_counter: $!; aborting";

-- 
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer


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

Date: Thu, 1 Oct 1998 16:16:17 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: make script for NT?
Message-Id: <3613AAD1.ACB2C5BF@inlink.com>

Krzysztof Kunowski wrote:
> 
> I've got program in perl and I don't know haw compile it for Windows NT?

I get the idea that you are new to Perl.  That is ok.

>From your question I can't determine if you are trying to compile Perl
itself OR a Perl script that you wrote so...

If you mean Perl itself:
 - You don't have to compile it yourself.  The nice people at
ActiveState have already done that for us.  Go to:
http://www.activeState.com/ActivePerl/ to get it.  It is free!

If you mean a Perl script:
 - You don't have to compile those either.  Thanks to a nice guy named
Larry Wall, that is all handled for you by Perl. If you create a
program, you simply have to call it like so:
perl myprogram.pl 

This assumes that you have Perl installed on your system.  If you don't,
then you need to install it first.  

You can even associate the PL extension so you can eliminate the "perl"
when you call your scripts:
myprogram.pl

Hope this helps,
Brent

-- 
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: Thu, 01 Oct 1998 16:00:25 +0200
From: "Angel L. Mateo Martinez" <angel.mateo@rediris.es>
Subject: Multicast and sockets
Message-Id: <36138AF8.CBCBC6CE@rediris.es>

    I am trying to use a socket with a multicast group, but I can4t do
it. To use a multicast group you have to do the next, in C:

    sockfd = socket(AF_INET, SOCK_DGRAM,0);
    mreq.imr_multiaddr.s_addr = inet_addr(IP_ADDR);
    mreq.imr_interface.s_addr = htonl(INADDR_ANY);
    setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq,
sizeof(mreq));

    So in Perl I do:

    use Socket;
    use Sys::Hostname;

    $iaddr = gethostbyname(hostname());
    $proto = getprotobyname('udp');
    $port = getservbyname('0', 'udp');
    $paddr = sockaddr_in(0, $iaddr);

    socket(SOCKET, AF_INET, SOCK_DGRAM, $proto);

    #$maddr = sockaddr_in (42148, '224.2.253.119');
    #$interface = INADDR_ANY;
    $maddr = "224.2.3.4";
    @nums = split (/\./, $maddr);
    $mvalor = $nums[0]*255*255*255 + $nums[1]*255*255 + $nums[2]*255 +
$nums[3];
    $iaddr = "123.123.123.123";
    @nums = split (/\./, $iaddr);
    $ivalor = $nums[0]*255*255*255 + $nums[1]*255*255 + $nums[2]*255 +
$nums[3];
    $mreq = pack ("LL", $mvalor, $ivalor);

    if (setsockopt (SOCKET, IPPROTO_IP, IP_ADD_MEMBERSHIP, $mreq)) {
            print "setsockopt ok\n";
    }
    else {
            die "Error: ", $!;
    }


    But I get the next error message:

        Error: Invalid argument


    Does anybody know why it doesn4t work?

    Can anybody help me?

-----------------------------------------
Angel L. Mateo Martinez
RedIRIS/CSIC
C/ Serrano, 142
E-28006  Madrid (Spain)
Tlfo: +34-91-5855145
Fax:  +34-91-5855146




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

Date: 1 Oct 1998 14:58:41 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: need a regular expressions expert....
Message-Id: <6v05b1$3hg$1@client3.news.psi.net>

James Park (jhpark@james.amherst.edu) wrote on MDCCCLVII September
MCMXCIII in <URL:news:3612cd73.0@amhnt2.amherst.edu>:
++ Abigail <abigail@fnx.com> wrote:
++ : If you can't be bothered to read the group, the answer to your question
++ : can't be important to you.
++ 
++ Maybe he knows that his news server sometimes loses posts, and would like
++ to avoid scanning DejaNews when it would be just as easy for people to
++ cc him replies...


Maybe. But he can't be bothered to mention the reason, so it can't be
important.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Thu, 01 Oct 1998 11:17:18 -0400
From: Michael Hicks <mhicks@nowis.com>
Subject: Re: passing javascript vars to CGI
Message-Id: <36139CFE.45D3BBA9@nowis.com>

Doesn't the WRAP=PHYSICAL attribute do this for you?
-- 
-Michael Hicks
mhicks@nowis.com


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

Date: Thu, 01 Oct 1998 15:44:50 GMT
From: dmcclory@msn.com
Subject: perlglob.exe and Win32
Message-Id: <6v081h$q93$1@nnrp1.dejanews.com>

I've been searching for information on how perlglob.exe, glob() and the <*>
operator work together within the Win32 environment, and I've come up pretty
empty.	Anybody know where I can find information on these items?  In
particular, I'd like to know what kind of expressions I can use, and what
results they obtain.  I know I can use the wildcard operators (* and ?)
within filenames, but what else can I do?  Are regular expressions supported?
 If you replace perlglob.exe with something else, as I've heard you can do,
what result might that have?

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 01 Oct 1998 10:46:02 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: Rotating an array.
Message-Id: <x3yu31omjbp.fsf@tigre.matrox.com>


bart.mediamind@ping.be (Bart Lateur) writes:

> 
> Casper Kvan Clausen wrote:
> 
> >The problem is this: Given an array A of n elements, how do you most
> >efficiently construct a new array B containing the same elements, but
> >rotated so that B[0] = A[n-m], B[1] = A[n-m+1] ... B[m] = A[n]?

You say containing the *SAME ELEMENTS* .. ie B also has n elements. So
what is the m doing up there??

> 
> I'm not sure I quite understand the specification, but this is my first
> thought:
> 
> 	@b = (@a,@a)[$m .. $m+$#a];
> 
> 	Bart.

how about 

@B = reverse @A; 

Hope this helps,
-- 
Ala Qumsieh             |  No .. not Just Another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)


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

Date: Thu, 01 Oct 1998 10:26:01 -0400
From: Ian Lowe <Ian_Lowe@fanniemae.com>
Subject: scope question
Message-Id: <361390F9.11760E26@fanniemae.com>

Are variables in Perl, by default local to a loop?  The following piece
of code that I have been working on has been confusing me to no end!


open(DF,"/usr/ucb/df -Fufs | grep -v Filesystem |");
    while (<DF>) {
       chop;
       ($size,$capacity) = (split(/\s+/))[1,4];
        $size = "$size" / 1000;
        %FSSIZE = ("$size","$capacity");
}

foreach $key (keys (%FSSIZE)) {
    print "at $key we have $FSSIZE{$key}\n";
}



This will NOT print out the hash keys and value correctly.  However, if
I nest the foreach loop within the while loop, it does.  Why is this? 
Do I need to predeclare the variables as globals somehow?  If so, how?

Thanks for the help.

Ian


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

Date: 01 Oct 1998 18:05:29 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: Ian Lowe <Ian_Lowe@fanniemae.com>
Subject: Re: scope question
Message-Id: <m33e98qncm.fsf@joshua.panix.com>

Ian Lowe <Ian_Lowe@fanniemae.com> writes:

> Are variables in Perl, by default local to a loop?

No. The scope of the $_ variable varies, but that's not the problem
here.

>         $size = "$size" / 1000;

Why are you using those doublequotes? (Also, 1000 is not a meaningful
number in this context; you probably want 1024.)

>         %FSSIZE = ("$size","$capacity");

You are re-initializing the FSSIZE hash each time through the loop. I
don't think that's what you mean to do.

  $FSSIZE{$size} = $capacity;

You'd benefit from a thorough reading of the book _Learning Perl_.
-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Thu, 01 Oct 1998 10:50:05 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Some kind of 'real' user interface?
Message-Id: <3613969D.F5ADFD16@min.net>

Michal Rutka wrote:
> 
> You can try tcl/tk. It works cool under Windows.

Even better, try Perl/Tk.

-- 
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer


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

Date: Thu, 01 Oct 1998 16:17:35 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Stock paging, anyone seen this script?
Message-Id: <8cyar08der.fsf@gadget.cscaper.com>

>>>>> "Michal" == Michal Rutka <erhmiru@erh.ericsson.se> writes:

Michal> perl -ne 's/<.*?>//g;print;'

Or

	perl -pe 's/<.*>//'

unless you feel like typing a lot. :)

-- 
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@teleport.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: Thu, 1 Oct 1998 16:31:52 +0100
From: Nigel Parker <95ncp@eng.cam.ac.uk>
To: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: this should work. Why doesn't it?
Message-Id: <Pine.HPP.3.96L.981001162752.12282A-100000@club.eng.cam.ac.uk>

On 1 Oct 1998, Jonathan Feinberg wrote:

: "Daniel Vesma" <daniel.vesma@thewebtree.com> writes:
: 
: > From what I know of Perl, this should work fine. Why the hell
: > doesn't it????  It gets through my ISP's script checker (-c I
: > believe), but it only seams to get as far as the #THIS IS WHERE IT
: > BREAKS LINE
: 
: Stop yelling. "-c" is not your ISP's script checker; it's an argument
: to the perl program, as documented in perlrun. What do you mean by "it 
: only seems to get as far as" a given line? What happens next? Does
: your browser explode?
: 
: > $SearchMode = param("SearchMode");
: 
: I'd guess that there is no param called "SearchMode", and that,
: therefore, $SearchMode is undefined. Are you sure about the
: capitalization of the field name on the form?

I've not used CGI.pm before...

But I thought you need to do something like:
  $query = new CGI;
  $SearchMode = $query->param("SearchMode");

Otherwise, it must be something to do with capitalization, as Daniel
suggested.

Cheers.


Nigel
-- 
Girton College, Cambridge, England, CB3 0JG.             Tel: 0411 384803

http://welcome.to/nigels                             nigel.parker@iee.org



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

Date: Thu, 1 Oct 1998 16:56:07 +0100
From: "Daniel Vesma" <daniel.vesma@thewebtree.com>
Subject: Re: this should work. Why doesn't it?
Message-Id: <3613a5e8.0@news.thefree.net>

Yep, that hit the spot. Cheers. All works now :-)

Daniel Vesma






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

Date: Thu, 1 Oct 1998 16:43:51 +0100
From: "Daniel Vesma" <daniel.vesma@thewebtree.com>
Subject: Re: this should work. Why doesn't it?
Message-Id: <3613a30b.0@news.thefree.net>

>Stop yelling. "-c" is not your ISP's script checker; it's an argument
>to the perl program, as documented in perlrun. What do you mean by "it
>only seems to get as far as" a given line? What happens next? Does
>your browser explode?


No, you can try it for yourself at
www.thewebtree.com/temp/noList/gloucestershire/search.html

It doesn't get to the bottom of the script.

>> $SearchMode = param("SearchMode");
>
>I'd guess that there is no param called "SearchMode", and that,
>therefore, $SearchMode is undefined. Are you sure about the
>capitalization of the field name on the form?


Here is the form at calls it

<FORM ACTION="http://www.thewebtree.com/cgi-bin/glossearch.pl"
METHOD="POST">
<P><INPUT TYPE="RADIO" NAME="SearchMode"
VALUE="attraction">Attraction<P><INPUT TYPE="RADIO" NAME="SearchMode"
VALUE="pub">Pub
<P><INPUT TYPE="TEXT SIZE="20" NAME="SearchString"><INPUT TYPE="submit"
VALUE="OK">
</FORM>


Hope you can help me further.

Daniel Vesma




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

Date: Thu, 01 Oct 1998 11:47:14 -0400
From: John Porter <jdporter@min.net>
Subject: Re: this should work. Why doesn't it?
Message-Id: <3613A402.CF568472@min.net>

Daniel Vesma wrote:

> use CGI qw(param);

Try
	use CGI qw(:standard);
instead.


> print "Content-type: text/html\n\n";

try
	print header();
instead.



> sub pub();

YIKES!

There should be no semicolon there!

("From what I know of Perl", heh.)



> open(INDB, $URLstring);

Always, ALWAYS, *ALWAYS* check the result of open()!



> sub attraction();
> {
> open(INDB, $URLstring);

Ditto here, of course.



You would probably do very well to use the handy
functions provided by CGI.pm to generate HTML.

-- 
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer


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

Date: Thu, 01 Oct 1998 09:59:51 -0400
From: Tom Lynch <toml@synnet.com>
Subject: Trouble building 5.005_02 on HP-UX 10.20
Message-Id: <36138AD7.C85DE4D3@synnet.com>

Greetings:

	I have been trying to build version 5.005_02 on a HP-UX
	10.20 machine but can't get two of the tests to work. I'm
	using cygnus gcc version 2.7-97r2. Here's the errors:

pragma/locale.......assertion botched (chunk's tail overwrite?): *((char
*)((caddr_t)ovp + nbytes - sizeof (unsigned int) + i)) == 0x55
sh: 20367 Abort
dubious
        Test returned status 134 (wstat 34304, 0x8600)
DIED. FAILED tests 99-102
        Failed 4/102 tests, 96.08% okay

	and......

lib/posix...........assertion botched (chunk's tail overwrite?): *((char
*)((caddr_t)ovp + nbytes - sizeof (unsigned int) + i)) == 0x55
dubious
        Test returned status 0 (wstat 6, 0x6)
DIED. FAILED tests 15-18
        Failed 4/18 tests, 77.78% okay

	Does anyone know what I'm missing here? Thanks for any 
	help in advance.

	-Tom

-- 
#--------------------------------------------------------------+
# Tom Lynch                 |  Email: toml@synnet.com          |
# Switching Division        |  Phone: (978)-264-1443           |
# 3COM Corporation          |  Fax  : (978)-264-1418           |
# 80 Central Street         |  MS   : MA#35                    |
# Boxborough, Massachusetts |  Zip  : 01719                    |
#--------------------------------------------------------------+


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

Date: Thu, 01 Oct 1998 11:03:56 -0400
From: John Porter <jdporter@min.net>
Subject: Re: UNIVERSAL doesn't work how I'd expect
Message-Id: <361399DC.5989DD17@min.net>

William R. Ward wrote:
> 
> I want to create a global filehandle that behaves the way STDOUT et al
> do, in otherwords it is a global in all packages.  I though that
> opening it as UNIVERSAL::NEWFH would do the trick, but it doesn't
> work.  Is there another way?  Am I misunderstanding the meaning of
> UNIVERSAL?

Well, that's not what UNIVERSAL is for.

But, if you really want to, you can create symbols in that
namespace.  This worked for me:

  open( UNIVERSAL::F, "> ufoo") or die $!;
  print UNIVERSAL::F "ufoo!\n";
  close UNIVERSAL::F;

I notice that I had to use parens for the open() call;
leaving them out gave a strange error.

-- 
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer


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

Date: Thu, 01 Oct 1998 16:43:29 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: What is HFB?
Message-Id: <3613AEBE.C00A080B@bbnplanet.com>

Jeffrey R. Drumm wrote:

> Whew. Thank God. All along I was thinking it was simply some thinly-veiled
> sexual innuendo thing.

Well, I used to be nicknamed Miss Emma Peel. The leather cat suit just
never really worked for me though. *mwaahaahaa* (/me wonders how HFB was
misconstrued as sexual)

> And, of course, that you were bragging . . . ;-)

Moi? Brag? I don't need to :)

e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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