[19722] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1917 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 12 06:06:33 2001

Date: Fri, 12 Oct 2001 03:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1002881107-v10-i1917@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 12 Oct 2001     Volume: 10 Number: 1917

Today's topics:
        ANNOUNCE: Date::Calc 5.0 <sb@engelschall.com>
        Emacs modules for Perl programming (Jari Aalto+mail.perl)
        extracting strings from variable length lines <hugo@fractalgraphics.com.au>
    Re: extracting strings from variable length lines <Thomas@Baetzler.de>
    Re: extracting strings from variable length lines <Thomas@Baetzler.de>
    Re: extracting strings from variable length lines (Rafael Garcia-Suarez)
    Re: extracting strings from variable length lines (Anno Siegel)
    Re: extracting strings from variable length lines (Anno Siegel)
    Re: File test operators can't tell a file from a direct <pne-news-20011012@newton.digitalspace.net>
    Re: File test operators can't tell a file from a direct <andrew@erlenstar.demon.co.uk>
    Re: FTP mirror script <Thomas@Baetzler.de>
        How to stop File Upload (CGI) <petar.markovic@uniserv.de>
    Re: open file for appending (David Efflandt)
        OT: This is a useless thread. (was: YOU ARE ALL GAY!) <myohe+USENET@redhat.com>
    Re: OT: This is a useless thread. (was: YOU ARE ALL GAY <tmoero@yahoo.invalid>
    Re: OT: This is a useless thread. (was: YOU ARE ALL GAY <geoffrey@bigpond.net.au>
    Re: Perl Power Limits? <JPFauvelle@Colt-Telecom.fr>
    Re: Signal SEGV with overload (Ari Jolma)
    Re: Stop Transversal of a Directory with Tar and Unzip (Randal L. Schwartz)
    Re: YOU ARE ALL GAY! <geoffrey@bigpond.net.au>
    Re: YOU ARE ALL GAY! <tmoero@yahoo.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 12 Oct 2001 08:21:12 +0200
From: Steffen Beyer <sb@engelschall.com>
Subject: ANNOUNCE: Date::Calc 5.0
Message-Id: <tsd6draqt8vf3f@corp.supernews.com>

Dear Perl fan! :-)

At last, after over 18 months of (intermittent) development,
the new version 5.0 of my module "Date::Calc" (for gregorian
calendar date calculations) is officially released!

The module is available for download either from my web site at

                  http://www.engelschall.com/u/sb/download/

or from any CPAN (= "Comprehensive Perl Archive Network") mirror server:

               http://www.perl.com/CPAN/authors/id/S/ST/STBEY/


Abstract:
---------

This package consists of a C library (intended to make life easier for C
developers) and a Perl module to access this library from Perl.

The library provides all sorts of date calculations based on the Gregorian
calendar (the one used in all western countries today), thereby complying
with all relevant norms and standards: ISO/R 2015-1971, DIN 1355 and, to
some extent, ISO 8601 (where applicable).

The package is designed as an efficient (and fast) toolbox, not a bulky
ready-made application. It provides extensive documentation and examples
of use, multi-language support and special functions for business needs.

The C library is specifically designed so that it can be used stand-alone,
without Perl.

Moreover, version 5.0 features date objects (in addition to the functional
interface) with overloaded operators, and a set of modules for calculations
which take local holidays into account (both additions in Perl only, however).


New features in version 5.0:
----------------------------

 *  Many new functions in Date::Calc
    (but the module continues to be small, fast and simple)

 *  Optionally, Date::Calc objects with overloaded operators
    for more ease of use (when speed is not so critical)

 *  An optional module for performing date calculations which
    take holidays into account, e.g., today plus 60 workdays,
    what date gives that?  Or how many workdays are there
    between two dates?

 *  A library containing profiles for a large number of countries
    with all their legal holidays (i.e., you get a day off) and
    many commemorative days (you don't)

 *  The possibility to create your own profiles for any special
    needs you may have, for instance for schools, banks, stock
    market, birthdays of relatives and friends, ...

 *  It is easy to generate calendars for any of these profiles
    and any year you like - there is a script to do so on the
    command line, and a CGI script for doing so on the web

 *  A couple of new example scripts to illustrate the use of
    the various modules

 *  Modularized, tailor-made components to assist you in particular
    tasks, instead of one bulky application larger than your own
    costing lots of overhead for features you do not need or want


Legal issues:
-------------

This package with all its parts is

Copyright (c) 1995 - 2001 by Steffen Beyer.
All rights reserved.

This package is free software; you can use, modify and redistribute
it under the same terms as Perl itself, i.e., under the terms of
the "Artistic License" or the "GNU General Public License".

The C library at the core of this Perl module can additionally
be used, modified and redistributed under the terms of the
"GNU Library General Public License".

Please refer to the files "Artistic.txt", "GNU_GPL.txt" and
"GNU_LGPL.txt" in this distribution, respectively, for details!


Prerequisites:
--------------

Perl version 5.000 or higher, and an ANSI C compiler. (!)
                                     ^^^^^^
If you plan to use the modules "Date::Calendar" or
"Date::Calendar::Year" from this package, you will
also need the module "Bit::Vector" version 5.7 or
newer (which also needs an ANSI C compiler!).

Otherwise you may safely ignore the warning message
"Warning: prerequisite Bit::Vector 5.7 not found at ..."
when running "perl Makefile.PL".

You can install "Bit::Vector" at any time later if you
change your mind.

If you compile under Windows, note that you will need
exactly the same compiler your Perl itself was compiled
with! (This is also true for Unix, but rarely a problem.)

Moreover, you usually cannot build any modules under
Windows 95/98, the Win 95/98 command shell doesn't
grok the "&&" operator. You will need the Windows NT
command shell ("cmd.exe") or the "4DOS" shell.

Note that ActiveState provides precompiled binaries of
both modules (Date::Calc and Bit::Vector) for their
Win32 port of Perl ("ActivePerl") on their web site,
which you should be able to install simply by typing
"ppm install Bit-Vector" and "ppm install Date-Calc"
in your MS-DOS command shell (but note the "-" instead
of "::" in the package name!). This also works under
Windows 95/98.

If your firewall prevents "ppm" from downloading these
packages, you can also download them manually from
http://www.activestate.com/ppmpackages/5.005/zips/ or
http://www.activestate.com/ppmpackages/5.6/zips/.
Follow the installation instructions included in
the "zip" archives.

Note also that a "plain Perl" version of Date::Calc 4.3
called "Date::Pcalc" exists (written by J. David Eisenberg);
you should be able to download it from the same place where
you found this package, or from David's web site at
http://catcode.com/date/pcalc.html.


Note to CPAN Testers:
---------------------

Version 5.0 of this module has already been tested successfully
during development with the following configurations:

  Perl 5.003     -  Solaris 2.6 (SunOS 5.6)
  Perl 5.003_07  -  Solaris 2.6 (SunOS 5.6)
  Perl 5.004_04  -  Solaris 2.6 (SunOS 5.6)
  Perl 5.004_05  -  Solaris 2.6 (SunOS 5.6)
  Perl 5.005_03  -  FreeBSD 4.1.1-RELEASE (with "dlopen() relative paths" patch)
  Perl 5.005_03  -  Windows NT 4.0 & MS VC++ 6.0 (native Perl build)
  Perl 5.6.0     -  FreeBSD 4.1.1-RELEASE
  Perl 5.6.1     -  FreeBSD 4.1.1-RELEASE
  Perl 5.6.1     -  Windows NT 4.0 & ActivePerl 5.6.1.626 (multi-thread)
  Perl 5.7.0     -  FreeBSD 4.1.1-RELEASE
  Perl 5.7.1     -  FreeBSD 4.1.1-RELEASE
  Perl 5.7.2     -  FreeBSD 4.1.1-RELEASE

Note: You can safely ignore the failing tests in module Bit::Vector 6.0
(Bit::Vector::Overload, to be precise) in file "t/30_overloaded.t" under
Perl 5.7.1 and Perl 5.7.2. The same applies to older versions of
Bit::Vector.

The failing tests are due to a change in Perl's core module "overload.pm"
which attempts to modify a read-only value when an exception is thrown
in the handler of an overloaded operator. This just causes a different
error message to be printed than the intended one.


Author's note:
--------------

If you have any questions, suggestions or need any assistance, please
let me know!

Please do send feedback, this is essential for improving this module
according to your needs!

I hope you will find this module useful. Enjoy!

Yours sincerely,
-- 
    Steffen Beyer <sb@engelschall.com>
    http://www.engelschall.com/u/sb/whoami/ (Who am I)
    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)




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

Date: 12 Oct 2001 09:41:37 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1002879646@rtfm.mit.edu>

Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto <jari.aalto@poboxes.com>

Announcement: "What Emacs lisp modules can help with programming Perl"

    Preface

        Emacs is your friend if you have to do anything comcerning software
        development: It offers plug-in modules, written in Emacs lisp
        (elisp) language, that makes all your programmings wishes come
        true. Please introduce yourself to Emacs and your programming era
        will get a new light.

    Where to find Emacs/XEmacs

        o   Unix:
            http://www.gnu.org/software/emacs/emacs.html
            http://www.xemacs.org/

        o   Windows
            http://www.gnu.org/software/emacs/windows/ntemacs.html
	    ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe

	o   More Emacs resources at 
	    http://tiny-tools.sourceforge.net/emacs-elisp.html


Emacs Perl Modules

    Cperl -- Perl programming mode

        .ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
        .<olson@mcs.anl.gov>           Bob Olson (started 1991)
        .<ilya@math.ohio-state.edu>    Ilya Zakharevich

        Major mode for editing perl files. Forget the default
        `perl-mode' that comes with Emacs, this is much better. Comes
        standard in newest Emacs.

    TinyPerl -- Perl related utilities

	.http://tiny-tools.sourceforge.net/

        If you ever wonder how to deal with Perl POD pages or how to find
        documentation from all perl manpages, this package is for you.
        Couple of keystrokes and all the documentaion is in your hands.

        o   Instant function help: See documentation of `shift', `pop'...
        o   Show Perl manual pages in *pod* buffer
        o   Load source code into Emacs, like Devel::DProf.pm
        o   Grep through all Perl manpages (.pod)
        o   Follow POD manpage references to next pod page with TinyUrl
        o   Coloured pod pages with `font-lock'
        o   Separate `tiperl-pod-view-mode' for jumping topics and pages
            forward and backward in *pod* buffer.
        o   TinyUrl is used to jump to URLs (other pod pages, man pages etc)
            mentioned in POD pages. (It's a general URL minor mode)

    TinyIgrep -- Perl Code browsing and easy grepping

        [TinyIgrep is included in the Kit]

        To grep from all installed Perl modules, define database to
        TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
        how to set up datatbases for Perl5, Perl4 whatever you have
        installed

        TinyIgrep calls Igrep.el to run the find for you, You can adjust
        recursive grep options, ignored case, add user grep options.

        You can get `igrep.el' module from <kevinr@ihs.com>. Ask for copy.
	Check also ftp://ftp.ihs.com/pub/kevinr/

    TinyCompile -- Browsing grep results in Emacs *compile* buffer

        TinyCompile is minor mode for *compile* buffer from where
        you can collapse unwanted lines, shorten the file URLs

            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT

            -->
            cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
            file1:NNN: MATCHED TEXT
            file1:NNN: MATCHED TEXT

End



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

Date: Fri, 12 Oct 2001 16:35:55 +0800
From: hugo <hugo@fractalgraphics.com.au>
Subject: extracting strings from variable length lines
Message-Id: <3BC6AB6B.AE71BCBA@fractalgraphics.com.au>

Hi 

I would like to extract individual strings (words) from lines in a file,
the moment several lines have the same length (i.e. contain the same
number of words, delimited by whitespace). How do I do this? 

I can get the lines themselves: 

@s =();
@c =();
$count =0;

while (defined ($input =<>)) {
   chomp ($input);
   $s[$count] = $input; 
   $c[$count] = split(" ", $input);
   ...and here I look for lines of equal length.
   if ($c[$count] == $c[$count -1] && $c[$count -2]) {
   ...here I can keep the lines of equal length (same number of separate
strings)
   }
  $count++;
}

But how do I store the separate strings in an array, if beforehand I do
not know how long the line will be i.e how many words it will contain? 

Any help will be greatly appreciated. 

Thanks

Hugo 

-- 
Dr Hugo Bouckaert
R&D Support Engineer, Fractal Graphics 
57 Havelock Street, West Perth 6005
Western Australia 6009
Tel: +618 9211 6000
Email:hugo@fractalgraphics.com.au
Web: http://www.fractalgraphics.com.au


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

Date: Fri, 12 Oct 2001 10:55:49 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: extracting strings from variable length lines
Message-Id: <mjbdst84sb98cr48g3cuj5ifmn9glf3ert@4ax.com>

On Fri, 12 Oct 2001, hugo <hugo@fractalgraphics.com.au> wrote:
>I would like to extract individual strings (words) from lines in a file,
>the moment several lines have the same length (i.e. contain the same
>number of words, delimited by whitespace). How do I do this? 

First, you start with a clear specification of your problem :-)

Is the selection criteria that the lines have the same length, or is the
criteria that they have the same number of words? Maybe both?

>   $c[$count] = split(" ", $input);

You'd better use split /\s+/, $input. 

>   ...and here I look for lines of equal length.
>   if ($c[$count] == $c[$count -1] && $c[$count -2]) {

Really? Yuu compare  $c[$count] against the bigger of the two values or
0 if one of the two is 0 or undef.

>Any help will be greatly appreciated. 

Please restate the problem and give some examples.

TIA,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: Fri, 12 Oct 2001 10:58:32 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: extracting strings from variable length lines
Message-Id: <43cdstk3c1tloem07jfdmhusu6sof5taaj@4ax.com>

On Fri, 12 Oct 2001, Thomas Bätzler <Thomas@Baetzler.de> wrote:

>>   if ($c[$count] == $c[$count -1] && $c[$count -2]) {
>
>Really? Yuu compare  $c[$count] against the bigger of the two values or
>0 if one of the two is 0 or undef.

Oops, got my precedences mixed up again. This compares $c[$count] to
$c[$count -1] and evaluates to true if $c[ $count - 2] is true. My bad.

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: 12 Oct 2001 09:04:34 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: extracting strings from variable length lines
Message-Id: <slrn9sdcgu.hsk.rgarciasuarez@rafael.kazibao.net>

Thomas Bätzler wrote in comp.lang.perl.misc:
} 
} >   $c[$count] = split(" ", $input);
} 
} You'd better use split /\s+/, $input. 

Remember that " " is special in split.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
Removing old functionality is not unlike wearing a copper armour and
climbing to the top of tree in a lightning storm. -- Jarkko Hietaniemi


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

Date: 12 Oct 2001 09:32:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: extracting strings from variable length lines
Message-Id: <9q6das$bqv$1@mamenchi.zrz.TU-Berlin.DE>

According to hugo  <hugo@fractalgraphics.com.au>:
> Hi 
> 
> I would like to extract individual strings (words) from lines in a file,
> the moment several lines have the same length (i.e. contain the same
> number of words, delimited by whitespace). How do I do this? 

Your description doesn't make very clear what you want to do.  Extract
which words?  When which lines have the same length?
 
> I can get the lines themselves: 
> 
> @s =();
> @c =();
> $count =0;
> 
> while (defined ($input =<>)) {
>    chomp ($input);
>    $s[$count] = $input; 
>    $c[$count] = split(" ", $input);
>    ...and here I look for lines of equal length.
>    if ($c[$count] == $c[$count -1] && $c[$count -2]) {

Ugh.  What to you think the last statement does?  It doesn't do that...

>    ...here I can keep the lines of equal length (same number of separate
> strings)
>    }
>   $count++;
> }
> 
> But how do I store the separate strings in an array, if beforehand I do
> not know how long the line will be i.e how many words it will contain? 

If you want to bring together all sentences of equal length, you
can do it this way:

    # collect lines
    my @coll;
    {   no warnings 'deprecated';
        push @{ $coll[ split]}, $_ while <>;
    }
    $_ ||= [] for @coll; # fill in an empty list if a length didn't occur

    # see stats:
    print "There are ", scalar @{ $coll[ $_]}, " sentences of length $_\n" for
        0 .. @coll - 1;

The action is in the line "push @{ $coll[ split]}, $_ while <>;".
Using split with no argument splits $_ on whitespace.  Using it as
an array subscript puts it in scalar context, so the number of words
in $_ is the subscript we use.  Thus every line is pushed on the list
of lines of the same length.

Using split without assigning the result also gives an ugly warning
about "implicit split to @_", that's why the "no warnings..." pragma
has been invoked.

The result is that all lines with $i words are collected in @coll[ $i],
as the last statement demonstrates.

Anno


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

Date: 12 Oct 2001 09:34:32 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: extracting strings from variable length lines
Message-Id: <9q6df8$bqv$2@mamenchi.zrz.TU-Berlin.DE>

According to Rafael Garcia-Suarez <rgarciasuarez@free.fr>:
> Thomas Bätzler wrote in comp.lang.perl.misc:
> } 
> } >   $c[$count] = split(" ", $input);
> } 
> } You'd better use split /\s+/, $input. 
> 
> Remember that " " is special in split.

Is there anything that isn't special in split?

Anno


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

Date: Fri, 12 Oct 2001 09:29:53 +0200
From: Philip Newton <pne-news-20011012@newton.digitalspace.net>
Subject: Re: File test operators can't tell a file from a directory
Message-Id: <m74dstgkfsu4og4enj1d2f1injjfp4jem2@4ax.com>

On 11 Oct 2001 09:44:17 -0700, eamonn.gormley@eecad.com (Eamonn) wrote:

> Once I get down into the second level of sub-directories, the file
> test operators don't seem to be able to tell the difference between a
> file and a directory.  The scrip begins to treat sub-sub-directories
> as files.

Do they return true for -f? Or do they simply not return true for -d?

Two points:

* You are probably getting names like 'foobar' from the readdir, and -d
'foobar' will return false since './foobar' doesn't exist (it's actually
'dir/subdir/foobar'). Solution: either chdir into the directory or add
the correct path before testing (e.g. 'if(-d "dir/subdir/$entry")'.

* But you probably really want to use File::Find here, as Uri suggested.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: 12 Oct 2001 09:35:10 +0100
From: Andrew Gierth <andrew@erlenstar.demon.co.uk>
Subject: Re: File test operators can't tell a file from a directory
Message-Id: <87lmihfe81.fsf@erlenstar.demon.co.uk>

>>>>> "Eamonn" == Eamonn  <eamonn.gormley@eecad.com> writes:

 Eamonn>   opendir (L2DIR, "$entry/$subdirentry") || die "could not open";
 Eamonn>   @thissubsubdir = grep { $_ ne '.' and $_ ne '..' and $_ ne 'CVS' }
 Eamonn>      readdir L2DIR;

This gives you a list of names that are _relative_ to
$entry/$subdirentry, and therefore those names can't be passed
directly to the file test operators without prepending
$entry/$subdirentry first.

-- 
Andrew.


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

Date: Fri, 12 Oct 2001 10:30:45 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: FTP mirror script
Message-Id: <q88dst43t7kcgfjbgvc0jgvvg5f5k3tao1@4ax.com>

On Thu, 11 Oct 2001, "ANDERS FLODERUS" <anders.floderus@swipnet.se>
wrote:

>Now I have made a mirror script but before I try it, I wonder
>if somebody can check to see if it ought to work, I am afraid
>to do something that will anger my ISP.

You'll probably only end up doing something that'll anger yourself :-)

>( I found a mirror.pl script on the web but it was 91 KB.
>I think that is to much.)

Do you still have to live off a single floppy? Or is  the download with
your 300 bps modem a problem? :-)

mirror.pl is quite certainly that big because it does a bit more than
what your code does - and because it does it well. If you need a
reliable mirroring solution and can't use rsync, then you could do worse
than picking mirror.pl.

>  use strict;
>  use Net::FTP;
>  my $ftp;

No need to define that here. People usually put the my on the same line
where you instantiate the object - i.e. my $ftp = new ...

>  $ftp = Net::FTP->new( $host ) or
>    die "Can not connect: $@\n";
>  $ftp->login( $user, $passw ) or
>    die 'Can not login: ', $ftp->message;
>  $ftp->cwd( $rdir ); # set working directory

You really should check all return values - not only those from the new
and login. Things can break later on, too.

>  &update( 'a', '.htm' );
>  &update( 'b', '.jpg' );
>  &update( 'b', '.gif' );

Strike the leading dots from the extension - this won't work.

>  $ftp->quit;
>  exit 0;

exit 0? Nothng ever goes wrong?

>sub update( ) {

Where you put subs is probably a matter of taste. I prefer mine right at
the start - probably an old instinct left over from my C coding days.
That way, you didn't need to write prototypes for local functions. I
guess in Perl that practise is still good to avoid unintentionally using
globals.

>  if( $_[0] eq 'a' ) { $ftp->ascii; }
>  else               { $ftp->binary; }

Another matter of taste - why anybody would want the FTP server to
mangle their files is beyond me. But if you feel that you do have files
that could benefit from the ASCII treatment, you could replace the
clunky $_[0] with a simple shift. Or you could write:
my( $mode, $extension ) = @_;

>  my $dev, my $ino, my $mode, my $nlink, my $uid;
>  my $gid, my $rdev, my $size, my $atime, my $ltime;
>  my $ctime, my $blksize, my $blocks;
>  my $file, my @lfiles, my $lfile, my $rtime;

You should define lexicals when they are needed. There's no need to
predeclare them.

>  opendir( DIRHANDLE, $ldir );
>  @lfiles = readdir( DIRHANDLE );

I.e. add a "my" here.

>  closedir( DIRHANDLE );
>
>  foreach $file ( @lfiles ) {

Same here.

>    if( $file !~ m/$_[1]/ ) { next; }

The Perlish idiom would be to say
next if $file !~ m/\.$extension$/i;

Please note the pattern anchor $ - this makes sure that the match occurs
at the end of a string. Please also note the leading \. - this will
match a single dot. Using your code and your arguments, '.htm' would
have easily matched stuff like 'anyhtm.zip'.

In any case it doesn't make much sense to do three scans of the
directory - you should rather do one scan and use a match against all
three extensions, i.e. like "\.(htm|jpg|gif)$". If you still wanted to
have the capability to switch ACSII/binary transfers, you could for
example pass in a hash with the extensions as the keys, and the modes as
the value, i.e. ( 'htm' => 'a', 'jpg'=>'b', 'gif' => 'b' );

>    $lfile = $ldir . '\\' . $file;

To quote Jospeph N. Hall: "author has read the stat manpage".

>    ( $dev, $ino, $mode, $nlink, $uid,
>      $gid, $rdev, $size, $atime, $ltime,
>      $ctime, $blksize, $blocks ) = stat( $lfile );

my( $ltime ) = (stat( $lfile ))[9];

>    my $rtime = $ftp->mdtm( $file ); # remote modification time

May need to be adjusted for skew against local time, time zone, etc.

>    if( $rtime ) {
>      if( $ltime <= $rtime ) { next; }

Better written as:

if( (my $rtime = $ftp->mdtm( $file )) && ($ltime > $rtime) ){

>      $ftp->delete( $file );

You should check a result here...

>    $ftp->put( $lfile, $file );

And most definitely here. It is also advisable to stat the remote file
to see if it's got the right size - Net::FTP on Win32 has this uncanny
bug that will upload incomplete files at time without telling you about
it.

Well, everything IMHO, my $0.02, etc.

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: Fri, 12 Oct 2001 11:13:11 +0200
From: Petar Markovic <petar.markovic@uniserv.de>
Subject: How to stop File Upload (CGI)
Message-Id: <57c6q9.ti2.ln@news.uniserv.de>

Hi,

I an making CGI scripts for uploading files.
It is designed for business clients and some of them need to upload
large files.

If a client pushes the Stop button on the browser I want the upload to
stop and delete the part of file already copied to Server.

my $error;
while ($bytes_count = read($file_query,$buff,1024))
{
        $size += $bytes_count;
        $bytes_loaded = $size;
        $buff =~ s/\r//g;
        print FILE $buff;
        $error = $query->cgi_error();
        if($error) {
                close(FILE);
                unlink("$upload_dir/$file_name");
                &Error("Upload interrupted, error: $error", 1);
        }
}

When Stop button is pressed $query->cgi_error() function does not detect
that signal.

I don't know what to do in order to Cancel uploading in progress. It
cannot be allowed because a file can be very large and should be
deleted. 

Anybody has an idea how to fix this?


Regards,
Petar Markovic


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

Date: Fri, 12 Oct 2001 09:00:27 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: open file for appending
Message-Id: <slrn9sdc9b.cp6.efflandt@typhoon.xnet.com>

On Thu, 11 Oct 2001 21:23:13 -0400, Zimmen Gnauh <yah00204052@yahoo.com> wrote:
>   I need to open a file for writing if that file does not exist, or open
> the file for appending if that file alreadys exist. What's the simplest
> statement to do that. It looks neither
>    open(FILE, ">$file")
> nor
>    open(FILE, ">>$file")
> does  the job.

I seem to remember having a similar problem somewhere too.  Or maybe it
was when I tried to open a file for read/write (+<), so if that failed, I
would open it write only (since there was nothing to read anyway).

But you should always test your open statements and print out why it
failed so you know why.  See:  perldoc -f open

-- 
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Fri, 12 Oct 2001 03:29:13 -0500
From: Michael Lee Yohe <myohe+USENET@redhat.com>
Subject: OT: This is a useless thread. (was: YOU ARE ALL GAY!)
Message-Id: <3BC6A9D9.2030608@redhat.com>

Please quit cross-posting this big piece of excrement.

-- 

Michael Lee Yohe (myohe+USENET@redhat.com)
Software Developer, Engineering Services
Red Hat, Inc.

QUIPd 0.12:
-> It is better to deserve honors and not have them than to have them
-> and not deserve them.
-> - Mark Twain (1835-1910)



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

Date: Fri, 12 Oct 2001 17:36:24 +0900
From: tm <tmoero@yahoo.invalid>
Subject: Re: OT: This is a useless thread. (was: YOU ARE ALL GAY!)
Message-Id: <tmoero-AFABB5.17362412102001@newsflood.tokyo.att.ne.jp>

Michael Lee Yohe wrote:

> Please quit cross-posting this big piece of excrement.

Okay.


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

Date: Fri, 12 Oct 2001 09:46:11 GMT
From: Geoffrey Pointer <geoffrey@bigpond.net.au>
Subject: Re: OT: This is a useless thread. (was: YOU ARE ALL GAY!)
Message-Id: <B7ECFA88.83CD%geoffrey@bigpond.net.au>

On: Fri, 12 Oct 2001 03:29:13 -0500
Michael Lee Yohe <myohe+USENET@redhat.com> said:

> Please quit cross-posting this big piece of excrement.

Excuse me!! Whether or not you agree with what tm and I are saying and
whether or not we agree with each other, this often happens in threads.
Sometimes the issue of _how_ to use the usenet comes up. How do you expect
these ideas to disseminate other wise? I'm glad tm was bothered to comment
whatever I might think about his approach. You on the other hand are just
totally blinkered.

The cross-posting thing happened in the original message. I'm sorry if that
was contributed to by me but as in this case also, you yourself have replied
by cross-posting so who knows where from and not only that, you've changed
the thread subject. You've personally contributed to the multiplication of
the excrement you apparently detest. Need I say more? This is certainly my
last message in this/that thread.

--

    Cheers - Geoff %^>




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

Date: Fri, 12 Oct 2001 11:26:03 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: Perl Power Limits?
Message-Id: <qeddst88k910ffc58fvvadtq9bfb8kcf26@4ax.com>

Le Thu, 11 Oct 2001 22:14:02 -0400, Sean O'Dwyer <notspam@spamfree.dud> écrit:


>I'm working on a site at the moment that gets approximately 900k hits 
>and 32k unique visits per month.
>
>There are some aspects of the site that should be databased and I'm 
>wondering what the real world outside limit for Perl might be: 1,000 SSI 
>calls per hour, 10,000?
>
>In other words, is this a job for C++ or can Perl handle it with room to 
>spare? Does my question even make sense?

Without details, it is hard to anwser.

1) You can write your own modules in full Perl, test it, and then
rewrite a part of it in C or C++, later, if you need more speed.

2) Start by making CGI. If the speed is not enough, then just
translate them to fastcgi, which is an easy task, and offers
a good stability with high performance.

3) Use tools like HTML::Embperl

All this is just my point of view.

Jean-Philippe Fauvelle




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

Date: Fri, 12 Oct 2001 07:20:31 +0000 (UTC)
From: ajolma@water.hut.fi (Ari Jolma)
Subject: Re: Signal SEGV with overload
Message-Id: <9q65jv$h1t$1@water.hut.fi>

More info:

this produces the same bug:

$a = init();
$b = $a;
$a += 1;

sub init {
    my $a = new Object;
    return $a;
}

package Object;

use overload ('fallback' => 1,
	      '+=' => 'add');

sub new {
    my $class = shift;
    my $self = {};
    bless($self, $class);
    return $self;
}

sub add {
    my $self = shift;
}

but if one uses references, then not:

$b = \$a;

The problem is also in 5.6.1.

perl -Do gives eventually:

(test.pl:3)     Overloaded operator `+=':
        method for left argument found in package Object
(test.pl:3)     Operation `=': no method found, argument in overloaded package ObjectSegmentation fault (core dumped)

The segfault is in 

0x08065508 in Perl_amagic_call (left=0x8151adc, right=0x8151a94, method=54, 
    flags=0) at gv.c:1316

So is Perl trying to reassign $a to $b after the "+=" and failing there?

Ari
--
Ari.Jolma@hut.fi


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

Date: 12 Oct 2001 00:40:09 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Stop Transversal of a Directory with Tar and Unzip
Message-Id: <m1ofndz4py.fsf@halfdome.holdit.com>

>>>>> "Benjamin" == Benjamin Goldberg <goldbb2@earthlink.net> writes:

Benjamin> The correct way to do this from within perl would be:
Benjamin> unless( fork ) {
Benjamin>     open(STDERR, "<&STDOUT") or die "Couldn't dup STDOUT: $!";

{ahem} "correct" being used loosely?

        open STDERR, ">&STDOUT" ...

:-)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Fri, 12 Oct 2001 09:24:19 GMT
From: Geoffrey Pointer <geoffrey@bigpond.net.au>
Subject: Re: YOU ARE ALL GAY!
Message-Id: <B7ECF567.83BB%geoffrey@bigpond.net.au>

On: Fri, 12 Oct 2001 14:48:34 +0900
Subject: Re: YOU ARE ALL GAY!
tm <tmoero@yahoo.invalid> said:

> Much better geof, you left the attributes this time. Shows you are
> capable of learning. You could use some help with snipping, but keep up
> the good work.

Read the whole message that you are commenting on here. My original comment
was a one off, off hand comment, meant to be just light hearted in the
spirit of the original message. Just like at least two of the other replies
which I read in context with the original post. The only reason I clipped
the entire original message (something I normally NEVER do) is because Nigel
said he hadn't seen the original message.

They say you can lead a horse to water but you can't make it drink. Well,
this little black horse has been to the water of his own volition has drunk
the water heartily and moved on. You on the other hand it seems would have
me drown.

> Say, would you like to learn how to make a proper sig delimiter?

Proper?? There is obviously no accounting for taste, its only text for
crying out loud.

--

    Cheers - Geoff %^>



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

Date: Fri, 12 Oct 2001 18:53:27 +0900
From: tm <tmoero@yahoo.invalid>
Subject: Re: YOU ARE ALL GAY!
Message-Id: <tmoero-3C54DD.18532712102001@newsflood.tokyo.att.ne.jp>

Geoffrey Pointer wrote:
> tm said:
> 
> > Much better geof, you left the attributes this time. Shows you are
> > capable of learning. You could use some help with snipping, but keep up
> > the good work.
> 
> Read the whole message that you are commenting on here. 

Which one? The one where you fucked up the attributes, or the one where 
you strung a bunch of messages together?

> My original comment
> was a one off, off hand comment, meant to be just light hearted in the
> spirit of the original message. 

Oh, the one where you fucked up the attributes and didn't snip pages of 
useless shit. Thanks for the clarification.

> Just like at least two of the other replies
> which I read in context with the original post. The only reason I clipped
> the entire original message (something I normally NEVER do) is because Nigel
> said he hadn't seen the original message.

Ah, so 'nigel' was the attribute you snipped?
 
> They say you can lead a horse to water but you can't make it drink. Well,
> this little black horse has been to the water of his own volition has drunk
> the water heartily and moved on. You on the other hand it seems would have
> me drown.

heh. Whatever. 

> > Say, would you like to learn how to make a proper sig delimiter?
> 
> Proper?? There is obviously no accounting for taste, its only text for
> crying out loud.
> 
> --
> 
>     Cheers - Geoff %^>
> 

Good try. Still not right. You need a space after the dashes.
HTH,
TM


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

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

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 V10 Issue 1917
***************************************


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