[29867] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1110 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 13 03:09:43 2007

Date: Thu, 13 Dec 2007 00:09:09 -0800 (PST)
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, 13 Dec 2007     Volume: 11 Number: 1110

Today's topics:
    Re: (1)[0] ok but not 1[0] <tadmc@seesig.invalid>
    Re: (1)[0] ok but not 1[0] <sensorflo@gmail.com>
    Re: (1)[0] ok but not 1[0] <sensorflo@gmail.com>
    Re: Get values from hash "in order" <tadmc@seesig.invalid>
        new CPAN modules on Thu Dec 13 2007 (Randal Schwartz)
        Next Page gets downloaded in Perl <visitprakashindia@gmail.com>
    Re: Regular expression for matching words containing un <tadmc@seesig.invalid>
    Re: Regular expression for matching words containing un <rspai9@gmail.com>
    Re: split is not convinient <tadmc@seesig.invalid>
    Re: split is not convinient <xueweizhong@gmail.com>
    Re: split is not convinient <xueweizhong@gmail.com>
    Re: split is not convinient <krahnj@telus.net>
    Re: split is not convinient <jurgenex@hotmail.com>
    Re: split is not convinient <xueweizhong@gmail.com>
    Re: Stupid Mistakes <josef.moellers@fujitsu-siemens.com>
        Testing File Existence - best way? <wheeledBobNOSPAM@yahoo.com>
    Re: Testing File Existence - best way? <jurgenex@hotmail.com>
    Re: When do I need to define a function with "use POSIX <tadmc@seesig.invalid>
    Re: Why isn't void context a 'real' context <tadmc@seesig.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 12 Dec 2007 21:50:27 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: (1)[0] ok but not 1[0]
Message-Id: <slrnfm1b03.on0.tadmc@tadmc30.sbcglobal.net>

Florian Kaufmann <sensorflo@gmail.com> wrote:
> Perldoc says that "List values are denoted by separating individual
> values by commas (and enclosing the list in parentheses where
> precedence requires it):". To repeat the point, parentheses are not
> required to create/specify lists.
>
> The following two are equivalent
> print 1,2,3;
> print (1,2,3);


This is an application of "parenthesis around a function's argument 
list are optional" rule.


> Thus the following two should be equivalent too in my view
> $x = 3[0];
> $x = (3)[0];


Where is the function whose parens are being omitted/included?

There is no "equivalence" between the 1st two and the 2nd two.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Wed, 12 Dec 2007 23:53:48 -0800 (PST)
From: Florian Kaufmann <sensorflo@gmail.com>
Subject: Re: (1)[0] ok but not 1[0]
Message-Id: <b42abe29-1dea-45e5-a03c-2e4f9c0f5beb@e23g2000prf.googlegroups.com>

> This is an application of "parenthesis around a function's argument
> list are optional" rule.

Are you very sure? I think its an application of the more general rule
"you can always add parentheses around an expression"



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

Date: Thu, 13 Dec 2007 00:01:07 -0800 (PST)
From: Florian Kaufmann <sensorflo@gmail.com>
Subject: Re: (1)[0] ok but not 1[0]
Message-Id: <596d03b1-24f3-4b8f-97da-a5d72855c8f3@i29g2000prf.googlegroups.com>

> What are your plans for this documentation? I'm sure people are
> interested.

I think I'll be writing for some weeks, maybe even months. I also have
a job during the day :-). And since I am learning Perl, learning
LaTeX, fiddling at my syntax notation the progress is not fast. But of
course I'll put it under GFDL or something similar and put it on the
net. Provided I am allowed to - the basics of my work are mainly
"Programming Perl" and http://perldoc.perl.org/. I sometimes copied
whole sentences. I fear I would break their copyright when I put my
document under GFDL.

Flo


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

Date: Wed, 12 Dec 2007 22:02:02 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Get values from hash "in order"
Message-Id: <slrnfm1blq.on0.tadmc@tadmc30.sbcglobal.net>

still just me <wheeledBobNOSPAM@yahoo.com> wrote:


[snip: hashes are unorderd]


> Is there some advantage to Perl in them storing in random order?


This is not about Perl, it is about hashing, whether in Perl or not.

(try Googling for "hashing")


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Thu, 13 Dec 2007 05:42:15 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Dec 13 2007
Message-Id: <Jsz3uF.1LEr@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Catalyst-Controller-HTML-FormFu-0.02000
http://search.cpan.org/~cfranks/Catalyst-Controller-HTML-FormFu-0.02000/
----
Catalyst-Engine-Embeddable-0.0.1
http://search.cpan.org/~druoso/Catalyst-Engine-Embeddable-0.0.1/
Use a Catalyst application as an object 
----
DBIx-FileSystem-1.6
http://search.cpan.org/~afrika/DBIx-FileSystem-1.6/
Manage tables like a filesystem 
----
DBIx-Perlish-0.33
http://search.cpan.org/~gruber/DBIx-Perlish-0.33/
a perlish interface to SQL databases 
----
Data-Table-1.51
http://search.cpan.org/~ezdb/Data-Table-1.51/
Data type related to database tables, spreadsheets, CSV/TSV files, HTML table displays, etc. 
----
EV-ADNS-1.0
http://search.cpan.org/~mlehmann/EV-ADNS-1.0/
lightweight asynchronous dns queries using EV and libadns 
----
FCGI-Async-0.12
http://search.cpan.org/~pevans/FCGI-Async-0.12/
Module to allow use of FastCGI asynchronously 
----
Graphics-GnuplotIF-1.4
http://search.cpan.org/~mehner/Graphics-GnuplotIF-1.4/
A dynamic Perl interface to gnuplot 
----
HTML-FormFu-0.02000
http://search.cpan.org/~cfranks/HTML-FormFu-0.02000/
HTML Form Creation, Rendering and Validation Framework 
----
HTML-FormFu-0.02001
http://search.cpan.org/~cfranks/HTML-FormFu-0.02001/
HTML Form Creation, Rendering and Validation Framework 
----
HTTP-Cache-Transparent-1.0
http://search.cpan.org/~mattiash/HTTP-Cache-Transparent-1.0/
Cache the result of http get-requests persistently. 
----
IPTables-IPv4-DBTarpit-0.38
http://search.cpan.org/~miker/IPTables-IPv4-DBTarpit-0.38/
----
Konstrukt-0.5-beta10
http://search.cpan.org/~twittek/Konstrukt-0.5-beta10/
Web application/design framework 
----
Konstrukt-0.5-beta11
http://search.cpan.org/~twittek/Konstrukt-0.5-beta11/
Web application/design framework 
----
Konstrukt-0.5-beta9
http://search.cpan.org/~twittek/Konstrukt-0.5-beta9/
Web application/design framework 
----
MOSES-MOBY-0.84
http://search.cpan.org/~ekawas/MOSES-MOBY-0.84/
Perl extension for the automatic generation of BioMOBY web services 
----
Mail-Box-IMAP4-SSL-0.01
http://search.cpan.org/~dagolden/Mail-Box-IMAP4-SSL-0.01/
handle IMAP4 folders with SSL 
----
Mail-SpamCannibal-0.85
http://search.cpan.org/~miker/Mail-SpamCannibal-0.85/
A tool to stop SPAM 
----
Maptastic-1.01
http://search.cpan.org/~samv/Maptastic-1.01/
all map, all the time. Maperiffic baby, yeah! 
----
MooseX-Param-0.02
http://search.cpan.org/~stevan/MooseX-Param-0.02/
Simple role to provide a standard param method 
----
Net-LibIDN-0.10
http://search.cpan.org/~thor/Net-LibIDN-0.10/
Perl bindings for GNU Libidn 
----
Net-XMPP2-0.10
http://search.cpan.org/~elmex/Net-XMPP2-0.10/
An implementation of the XMPP Protocol 
----
POE-XUL-0.0300
http://search.cpan.org/~gwyn/POE-XUL-0.0300/
Framework for remote XUL application in POE 
----
Parse-Marpa-0.001_053
http://search.cpan.org/~jkegl/Parse-Marpa-0.001_053/
(pre-Alpha) Jay Earley's general parsing algorithm, with LR(0) precomputation 
----
Parse-Marpa-0.001_054
http://search.cpan.org/~jkegl/Parse-Marpa-0.001_054/
(pre-Alpha) Jay Earley's general parsing algorithm, with LR(0) precomputation 
----
Perl6-Slurp-Interpret-0.10
http://search.cpan.org/~ctbrown/Perl6-Slurp-Interpret-0.10/
Interpret slurped files 
----
Queue-Beanstalk-0.01
http://search.cpan.org/~lunatic/Queue-Beanstalk-0.01/
Client library for the beanstalkd server 
----
Rose-DBx-Garden-0.09
http://search.cpan.org/~karman/Rose-DBx-Garden-0.09/
bootstrap Rose::DB::Object and Rose::HTML::Form classes 
----
Sphinx-Search-0.09
http://search.cpan.org/~jjschutz/Sphinx-Search-0.09/
Sphinx search engine API Perl client 
----
Spreadsheet-Engine-0.02
http://search.cpan.org/~tmtm/Spreadsheet-Engine-0.02/
Core calculation engine for a spreadsheet 
----
Term-ReadPassword-0.09
http://search.cpan.org/~phoenix/Term-ReadPassword-0.09/
Asking the user for a password 
----
Tie-Amazon-S3-0.01
http://search.cpan.org/~zakame/Tie-Amazon-S3-0.01/
tie Amazon S3 buckets to Perl hashes 
----
VCS-CSync-0.02
http://search.cpan.org/~adamk/VCS-CSync-0.02/
Synchronising to local directories from a repository 
----
ZipTie-Client-0.1
http://search.cpan.org/~lbayer/ZipTie-Client-0.1/
Webservice client for the ZipTie server 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
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: Wed, 12 Dec 2007 22:19:58 -0800 (PST)
From: Praki <visitprakashindia@gmail.com>
Subject: Next Page gets downloaded in Perl
Message-Id: <ec4effe7-d85f-4333-97ec-2e71a8287c50@d21g2000prf.googlegroups.com>

Greetings All

I have a Perl file in which i m doing all the operaions in one file
based on the command line arguments.
login.cgi
 .
 .
 .
$query = new CGI;
$sid = $query->cookie('CGISESSID') || $query->param('CGISESSID') ||
undef;
$submit_value=$query->param("submit");

if ($sid ne ""){
print $query->header( -cookie=>$cookie );}
else{
print "Content-type: text/html";}

if ($sid eq "" && $submit_value eq "") {
   &auth_page(" Login Authentication"," Login Authentication");
   print "Session id: ";
   print $sid;
   print "\n Submit value:";
   print $query->param("submit");

   print $FORM{'uid'};
   print $query->header( -cookie=>$cookie );
   &print_trailer();
 exit(0);
}
elsif ($sid eq "" && $submit_valu ne "") {
	&print_header(" Login Authentication"," Login Authentication");
        &print_trailer();
	exit(0);
}
 .
 .
 .
when i open the for the first time it should go to

if ($sid eq "" && $submit_value eq "")  this condition as both will be
empty. and here i m getting the login information and again i m
calling the same file(login.cgi). now as the sumbit value will not be
empty it has to go the next condtion

elsif ($sid eq "" && $submit_valu ne "") .i m validating the
credentials here. but the problem here i face is the page info which
is to be displayed in the browser is automaticaly asks for File
Download. when downloaded that file and check by open in the new
window it displays the ouput. i could not understand the problem so
plz can u help me in clearing this problem...

where i m going wrong..
thanks,
Prakash


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

Date: Wed, 12 Dec 2007 21:19:54 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Regular expression for matching words containing underscore _  character
Message-Id: <slrnfm196q.on0.tadmc@tadmc30.sbcglobal.net>

RedGrittyBrick <RedGrittyBrick@SpamWeary.foo> wrote:
> Raj wrote:
>> I have large text passages containing names of database tables,
>> procedures, packages, variables etc having the underscore character as
>> a part of the name. eg. rsp_names_friends_master. I tried "\b[a-zA-
>> Z0-9_]+\b" but it matches all words in the passage.
>
> Similarly "[ab]+" matches "aaa" and "aa" though neither contain "b".
>
> Try "\b[a-zA-Z0-9]+_[a-zA-Z0-9_]+\b"
>
> Or "\b\w+_\w+\b"


Three (six?) useless uses of word boundary in the quotes above...

Every pattern there will behave identically without any \b's.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Wed, 12 Dec 2007 19:54:16 -0800 (PST)
From: Raj <rspai9@gmail.com>
Subject: Re: Regular expression for matching words containing underscore _  character
Message-Id: <046df008-0b2f-49d6-9047-f1287825d7c9@a35g2000prf.googlegroups.com>

On Dec 12, 8:47 pm, RedGrittyBrick <RedGrittyBr...@SpamWeary.foo>
wrote:
> Raj wrote:
> > I have large text passages containing names of database tables,
> > procedures, packages, variables etc having the underscore character as
> > a part of the name. eg. rsp_names_friends_master. I tried "\b[a-zA-
> > Z0-9_]+\b" but it matches all words in the passage.
>
> Similarly "[ab]+" matches "aaa" and "aa" though neither contain "b".
>
> Try "\b[a-zA-Z0-9]+_[a-zA-Z0-9_]+\b"
>
> Or "\b\w+_\w+\b"

Thanks. It worked.
Raj


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

Date: Wed, 12 Dec 2007 21:13:58 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: split is not convinient
Message-Id: <slrnfm18rm.on0.tadmc@tadmc30.sbcglobal.net>

Ben Morrow <ben@morrow.me.uk> wrote:
>
> Quoth "Jürgen Exner" <jurgenex@hotmail.com>:
>> 
>> One argument not being mentioned by others so far is that when a Perl 
>> function allows omitting of an argument and thus substituting a default 
>> argument it will be $_. Thisis the typical and expected Perl behaviour.
>> Interpreting a single argument as the text string rather than the search 
>> pattern would be unexpected and contradictory to the typical behaviour of 
>> all other Perl functions.
>
> Uh huh... like shift, or readline, or the return value of split in
> scalar context?


Split has "dual defaults" for its 2 most frequent arguments. It
uses $_ for one of them.

My favorite (anti-favorite?) example of a non-$_ default is chdir().


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Wed, 12 Dec 2007 20:37:56 -0800 (PST)
From: Todd <xueweizhong@gmail.com>
Subject: Re: split is not convinient
Message-Id: <352d17f1-67cb-4d6c-b0ca-e39ddc8fc490@e6g2000prf.googlegroups.com>



Mark Seger wrote:
> Maybe I've just been programming for too many years and looked at too
> much code written by people who like to take shortcuts, but I think your
> cases 1/2 should never be used!  In fact I avoid any syntax that has a
> default such as "while (<>)" which is why I always use "while
> ($var=<>)".  After all, you never know when someone is going to insert a
> line of code that blows away your default with a different one.  In
> other words it's all about supportability!
>
> It's also common for someone to pick up a piece of code in a language
> they're not familiar with and try to figure out what it does with
> minimal effort and having something that is not obvious is a real pain.
>   Are people that lazy that typing a few extra characters to make what
> they're doing more explicit too much of a burden?  How is this any
> different from commenting code?  Or don't people do that any more either?
>
> -mark

Hi Mark:

I doubted your "too" many year programming experience:

  while($var = <>) is not same as while (<>), you'll bitten by it some
day.

So why i need to care about other things you mentioned...

-Todd


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

Date: Wed, 12 Dec 2007 20:59:48 -0800 (PST)
From: Todd <xueweizhong@gmail.com>
Subject: Re: split is not convinient
Message-Id: <3fdcc3ab-5c28-4543-a5c2-405ab8a79f97@i12g2000prf.googlegroups.com>

Hi all,

Seems nobody here mentioned the magic that
      split ' ', expr
is same as
      split /\s+/, expr


So let me google it and present some snipet codes from
http://www.google.com/codesearch?q=lang:perl+split+%27+%27&btnG=Search&hl=en&lr=
:


    www.cpan.org/authors/id/J/JS/JSIRACUSA/Rose-HTML-Objects-0.548.tar.gz
- Perl -
    libwww/config/makedefs.pl - 69 identical

        67:   while(<$INPUT>) {
                  local($name) =  split(" ",$_);
                  &NumberDefs'numberEach($name);
              }


    ftp.mozilla.org/.../mozilla1.7b/src/mozilla-source-1.7b-
source.tar.bz2 - Mozilla - Perl
    FAQ-OMatic-2.717/t-informal/split.pl - 6 identical


        58:   my @words = split(/(\s+)/, $text);
              my $title = join('', splice(@words, 0, 13));


    www.cpan.org/authors/id/T/TT/TTY/kurila-0_02.tar.gz - Artistic -
Perl - More from kurila-0_02.tar.gz >>
    perl5.00402-bindist04-bc/distfiles/perl5.004_02/t/op/split.t - 30
identical

        33: $_ = join(':', 'foo', split(/ /,'a b  c'), 'bar');
            if ($_ eq "foo:a:b::c:bar") {print "ok 7\n";} else {print
"not ok 7 $_\n";}

    purl.oclc.org/.../OPENSRC/downloads/webutils/tars/HTML-
MetaExtor-1.08.tar - Perl - Perl
    perl/lib/pod/Text.pm - 10 identical

       207:   # $needspace = 0;               # Assume this.
              # s/\n/ /g;
              ($Cmd, $_) = split(' ', $_, 2);
              # clear_noremap(1);


-Todd


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

Date: Thu, 13 Dec 2007 05:09:33 GMT
From: "John W. Krahn" <krahnj@telus.net>
Subject: Re: split is not convinient
Message-Id: <4760BE8D.8EFDC107@telus.net>

Todd wrote:
> 
> Seems nobody here mentioned the magic that
>       split ' ', expr
> is same as
>       split /\s+/, expr

No it is not:

$ perl
-le'                                                                                     
$_ = q[ a b c
];                                                                    
print q[split " "];                                                
print ">$_<" for split " ";                              
print q[split /\s+/];        
print ">$_<" for split /\s+/;
'
split " "
>a<
>b<
>c<
split /\s+/
><
>a<
>b<
>c<



John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 13 Dec 2007 05:11:07 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: split is not convinient
Message-Id: <L938j.18419$R4.373@trndny05>

Mark Seger wrote:
> Maybe I've just been programming for too many years and looked at too
> much code written by people who like to take shortcuts, but I think
> your cases 1/2 should never be used!  In fact I avoid any syntax that
> has a default such as "while (<>)" which is why I always use "while
> ($var=<>)".  After all, you never know when someone is going to
> insert a line of code that blows away your default with a different
> one.  In other words it's all about supportability!
>
> It's also common for someone to pick up a piece of code in a language
> they're not familiar with and try to figure out what it does with
> minimal effort and having something that is not obvious is a real
>  pain. Are people that lazy that typing a few extra characters to
> make what they're doing more explicit too much of a burden?

I am somewhat torn. You certainly have a very valid point and taking 
shortcuts that lead to unreadable code is definitely not a good idea.

On the other hand a lot of the elegance of Perl comes from its default "work 
space". It is so ingrained in the Perl world that I would almost call it a 
prerequisit for programming in Perl. If you don't know how to take advantage 
of $_ and @_ then maybe you shouldn't program in Perl or maintain Perl code.

> How is
> this any different from commenting code?  Or don't people do that any
> more either?

Now that is actually comparing apples and oranges. I think you would agree 
that a comment like
    $index++ #increments $index by 1
is nonsense. Correct, but still nonsense. Comments should describe _what_ is 
being done, not _how_ it is done. So the comment above should be something 
like "examine next personal file" or whatever action this increment 
indicates.

Now, if you were using
    shift @_;
instead of relying on the default as in
    shift;
then you would just re-state information that is already there anyway, just 
like with the stupid comment above. If this shift moves on to the next 
personal file, then by all means comment it as such. But replacing shift; 
with shift @_; doesn't add any new information for the code maintainance 
person as long as he has at least a basic understanding of the language.

jue 




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

Date: Wed, 12 Dec 2007 22:55:12 -0800 (PST)
From: Todd <xueweizhong@gmail.com>
Subject: Re: split is not convinient
Message-Id: <c0f72983-17e0-41e0-96c7-ee93df08666f@d21g2000prf.googlegroups.com>



John W. Krahn wrote:
> Todd wrote:
> > Seems nobody here mentioned the magic that
> >       split ' ', expr
> > is same as
> >       split /\s+/, expr
>
> No it is not:
>
> $ perl

    #! /bin/perl -l

    $_ = q[ a b c];

    $,=q/,/;
    print split ' ';
    print split /\s+/;

    __END__

    a,b,c
    ,a,b,c

Thanks John for pointing out this, so split ' ' is more natural than
split /\s+/.

-Todd


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

Date: Thu, 13 Dec 2007 08:46:29 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Stupid Mistakes
Message-Id: <fjqo0o$9r7$1@nntp.fujitsu-siemens.com>

Why so complicated? You don't need another call to findswfile(): just=20
set $File::Find:prune =3D 1 at the place where you decide that you don't =

need to go further.

A. Bax wrote:

>     our $f =3D "";
>     find(\&findswfile, $topdir);
>     ...
>=20
>     sub findswfile
>     {
#        if (our $f) {
#            # do not look further if we found our target
#            $File::Find:prune =3D 1;
#            return;
#        }
>=20
[...]
>         if (/$swfile/ && /\.SLDPRT/i) {
>             #if part and (caliptal or lower) match
>             our $f =3D $File::Find::name;        #directory and file
> name
>             print "     Found: $f\n\n";
>             system("copy \"$f\" \"$destination\" >nul"); #copy file to
> destination
		$File::Find:prune =3D 1;
>         }
>     }

--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize (T.  Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html



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

Date: Thu, 13 Dec 2007 04:36:08 GMT
From: still just me <wheeledBobNOSPAM@yahoo.com>
Subject: Testing File Existence - best way?
Message-Id: <uhd1m3155lbs3tieo5lb2mjeb5h2dtoebv@4ax.com>

I need to test if a file exists. Is there a better technique than
"attempt open and watch for an error"? The program will be a cgi
running in a windows or linux environment. 

Thanks, 


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

Date: Thu, 13 Dec 2007 04:40:36 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Testing File Existence - best way?
Message-Id: <8J28j.22428$Bg7.7073@trndny07>

still just me wrote:
> I need to test if a file exists. Is there a better technique than
> "attempt open and watch for an error"? The program will be a cgi
> running in a windows or linux environment.

Why not use the "file exists" operator? See

    perldoc -f -e

jue 




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

Date: Wed, 12 Dec 2007 21:06:50 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: When do I need to define a function with "use POSIX qw(.....)" and when not ?
Message-Id: <slrnfm18ea.on0.tadmc@tadmc30.sbcglobal.net>

Ted Zlatanov <tzz@lifelogs.com> wrote:
> On Wed, 12 Dec 2007 12:04:47 GMT Tad J McClellan <tadmc@seesig.invalid> wrote: 
>
> TJM> Thomas Blabb <t.blabb@gmail.com> wrote:
>>> use POSIX qw(strftime);


This declares that strftime() is being imported into the program.


>>> use POSIX;


This "smuggles" strftime() (and bunch of others) into the program.


> TJM> The first is better Software Engineering, the second is more convenient.
>
> (This is similar to "import package.class" vs. "import package.*" in
> Java, which is also a matter of taste...)
>
> I wonder if the first really is better.  I can think of two problems
> with a full import:
>
> 1) memory usage
> 2) name conflicts


I had name conflicts in mind when I posted my followup.


> The latter seems bad until you realize none of your code should be
> overriding POSIX functions anyhow.  


My comment was not (meant to be) specific to the POSIX module.

Explicit imports are better than implicit imports.

And the potential for name conflicts is not even the biggest reason
IMNSHO. The biggest reason is so that I don't have to go searching
for where some function is defined, I can just look at the "use" 
lines to figure out where it came from.

Determining origin is easier when "declared" rather than "smuggled".


(No, I am not a Customs Agent, I don't even play one on TV)


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Wed, 12 Dec 2007 22:24:14 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Why isn't void context a 'real' context
Message-Id: <slrnfm1cve.on0.tadmc@tadmc30.sbcglobal.net>

Pinocchio wrote:
> On Dec 11, 5:01 pm, mer...@stonehenge.com (Randal L. Schwartz) wrote:
>
>>
>> print "Just another Perl hacker," ; # the original
>
> NO, you asshole. Larry Wall is the original Perl hacker.


As with most comments in code, it refers to the code, not to the coder.

The quoted code _is_ the original JAPH.


> You are

   [ snip ]

And who are you?

An anonymous coward.

Everybody here knows how much weight that carries.


> Charlton Wilbur
> John Bokma
> Paul Lalli
> Jürgen Exner
> Tad McClellan
> A. Sinan Unur a.k.a. A.Sinine
> Michele Dondi
> Uri Guttman a.k.a. Urine Buttman
> Sherman Pendley


All of those people have the balls to post under their names.

Are you an eunuch, or do you just want to become a real boy?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V11 Issue 1110
***************************************


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