[8964] in Perl-Users-Digest
Perl-Users Digest, Issue: 2582 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 13 14:10:29 1998
Date: Wed, 13 May 98 11:00:36 -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 Wed, 13 May 1998 Volume: 8 Number: 2582
Today's topics:
Re: [Q]CGI script to simulate a form submition? <rootbeer@teleport.com>
Re: `back ticks` ? (Mark Maurer)
Re: `back ticks` ? scott@softbase.com
Re: a header for `Mail me copies' or `Do not mail me co <Russell_Schulz@locutus.ofB.ORG>
collapse string <kimron@amigar.co.il>
Re: Compile RE pat only when I change pat? <rootbeer@teleport.com>
Re: Compiling perl with static libc (Tom Hukins)
Cross-Platform 4-box Perl "Sharing" (Jack Siler)
Re: Does Perl have a IDE?I don't like command line. (Greg Bacon)
Re: Does Perl have a IDE?I don't like command line. <birgitt@order.booktraders.com>
Re: Does Perl have a IDE?I don't like command line. (Greg Bacon)
Re: Does Perl have a IDE?I don't like command line. (Sitaram Chamarty)
Re: eval doesn't catch exit in custom die <rootbeer@teleport.com>
Re: How can you break out of a 'while... ' loop in a fu <rootbeer@teleport.com>
Re: How can you break out of a 'while... ' loop in a fu <rootbeer@teleport.com>
Re: How can you break out of a 'while... ' loop in a fu (brian d foy)
Looking underneath the black box dbryson@tclock.com
Re: Looking underneath the black box <jdf@pobox.com>
Re: Matching period with regular expression (Tad McClellan)
multi-byte parsing darrenross@my-dejanews.com
Re: New IDE for Perl (Stuart McDow)
newbie question: handling errors (Scott Stark)
Re: newbie question: handling errors <brianm@kodak.com>
Re: newbie question: handling errors <angst@scrye.com>
Re: password <brianm@kodak.com>
Re: Perl compiler: does it work <rootbeer@teleport.com>
Re: Perl compiler: does it work <rjk@fprsdev3.fmr.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 13 May 1998 16:39:17 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Gong Wei <ccegongw@leonis.nus.sg>
Subject: Re: [Q]CGI script to simulate a form submition?
Message-Id: <Pine.GSO.3.96.980513093353.21974l-100000@user2.teleport.com>
On 13 May 1998, Gong Wei wrote:
> is there any way to run the script.cgi just as if it were started by the
> "submit" request sent from a browser client?
Sure there is. All you need to do is implement the server's side of the
CGI protocol. Of course, that's not terribly trivial to do. It's more
common to call the script over the web, which you can do from Perl with
the LWP module. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 13 May 1998 12:55:53 -0400
From: mwmaurer@mtu.edu (Mark Maurer)
Subject: Re: `back ticks` ?
Message-Id: <6jcjap$gge$1@pace1.cts.mtu.edu>
*/chebs (chebs@elfin.org) wrote:
: Hi all
: I'm trying to set a files permission from a perl script using
:
: `chmod 0777 $file`;
:
: It works when script created the file [upload] or from the shell but
: not if I call the script via a browser
:
: I have studied several 'works from the command line not as cgi' posts
: But haven't found an answer yet.
:
: I have tried system() and qx/ but I didn't think 'chmod' returned anything.
:
: Any help would be a great help.
Well, for starters, does $file have the path to the file along with it, a la
"/usr/local/web/servers/blah.txt" or is it just the file name?
Second, if it is being called from a CGI, unless the webserver is not running
as nobody, you can't do anything to files, because the webserver is running
as user nobody (unless the directory is world writeable, but that is a big
no-no...)
Try the perl chmod function...: perldoc -f chmod
--
Mark Maurer markm@dct.com mwmaurer@mtu.edu
Programmer, Digital Magic Interactive http://www.dminteractive.com
Senior, Michigan Technological University Houghton, MI
-- Views do not represent those of my employer or school
------------------------------
Date: 13 May 1998 15:01:55 GMT
From: scott@softbase.com
Subject: Re: `back ticks` ?
Message-Id: <6jccl3$m62$2@mainsrv.main.nc.us>
*/chebs (chebs@elfin.org) wrote:
>
> `chmod 0777 $file`;
> It works when script created the file [upload] or from the shell but
> not if I call the script via a browser
You can't "call the script via a browser". You're running a
CGI script on a Web server.
A CGI program runs as user "nobody", which intentionally doesn't
have permissions to do much of anything. It likely is unable to
change permissions because it doesn't own the files.
Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more.
------------------------------
Date: Wed, 13 May 1998 12:37:22 +0100
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: a header for `Mail me copies' or `Do not mail me copies'
Message-Id: <19980513.123722.9L1.rnr.w164w@locutus.ofB.ORG>
stanley@skyking.OCE.ORST.EDU (John Stanley) writes:
>> (not to mention the Posted-And-Mailed: header proposal I grabbed
>> off of the internic.net internet-drafts directory recently which
>> makes this line of argument even more pointless...)
>
> Oh, you mean proposal that Jamie Zawinski extracted from the more
> complete proposal I wrote that dealt with the entire issue of mail-news
> integration? But then I assume you know that and are just being dense.
no, I hadn't particularly noticed your name in the acknowledgements,
but it is there.
where is your fuller proposal?
>>> Please provide an RFC reference that defines this header for news.
>>
>> I can't.
I put that on a line by itself so that I could tempt you into quoting
it out of context.
thanks for obliging!
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: Wed, 06 May 1998 11:24:28 +0300
From: Kimron Yossi <kimron@amigar.co.il>
Subject: collapse string
Message-Id: <35501E3B.B1A19135@amigar.co.il>
Please , How can i collapse strings in perl .
example :
my string is 'c:\temp\my_file '
and i need to get it like this 'c:\temp\my_file'
Thanks ...
--
Yossi Kimron,
Amigar Information Systems (1993) Ltd.
Phone: (972)6-6321272/557
Fax: (972)6-6321574
Mobile:(972)50-494269
email: kimron@amigar.co.il
------------------------------
Date: Wed, 13 May 1998 16:55:34 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Peng Li <teilipe@tss.tei.ericsson.se>
Subject: Re: Compile RE pat only when I change pat?
Message-Id: <Pine.GSO.3.96.980513094053.21974n-100000@user2.teleport.com>
On Wed, 13 May 1998, Peng Li wrote:
> As I understand in PERL, if you use variable in regular
> expression, you have only two choices:
> 1) compile only once for the script life time by adding o flag
> 2) compile every time when you use the RE
Just to make this clear: Perl will normally compile a pattern just once.
But if it may vary (since there's a variable within it), Perl will have to
re-compile each time. Using /o forces it to compile just once.
> sub match {
> $pat = shift;
>
> while (<FH>) {
> if ( /$pat/o ) {...}
> }
> }
>
> What I mean is, in the while loop, can PERL just compile one time in the
> reg exp /$pat/, and recompile it again when I recall the function match.
Sure, but you'll need to be tricky. :-)
sub match {
my $pat = shift;
my $match = eval q{ # Yes, just one q!
sub {
$_[0] =~ /$pat/o; # Compile each one just once
}
};
die $@ if $@;
while (<FH>) {
if ($match->($_)) { ... }
}
}
Note that this won't set the match variables ($2 and such), although it's
not hard to get those values, if you need them. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 13 May 1998 17:16:54 GMT
From: tom@NOSPAMeborcom.com (Tom Hukins)
Subject: Re: Compiling perl with static libc
Message-Id: <3559cece.3120330@nntp.netcom.net.uk>
Keywords: compiling perl static libc
On Sun, 19 Apr 1998 21:45:20 GMT, I wrote:
>This is probably a really simple question, but I've had no luck
>finding the answer anywhere: How do I build Perl to use a static
>libc rather than a dynamic libc?
[Details snipped]
I've been trying to do this again, without success. I thought I'd
share my experiences in case anyone else is having similar
problems.
I gave up on compiling just libc statically as I wasn't getting
anywhere with this. "ldd ./perl" always reported that libc was
linked dynamically. I tried to compile Perl to only use static
libraries, as this is covered in the documentation (in the
INSTALL file).
I've tried several variations of config.sh, compiled with "make
realclean", "Configure -S", "make depend", then "make". Every
time "ldd ./perl" shows that I have created a dynamic executable,
with libm, libc and libcrypt linked. "./perl -V:usedl" sometimes
suggests shared libraries are enabled, but sometimes not. In
fact, "./perl -V" can sometimes be quite different to my
config.sh. I have deleted and re-installed the Perl source, but
this still happens. Is it possible Perl is taking variables from
elsewhere?
I have tried using "-static" in CFLAGS and CPPFLAGS and
"-Bstatic" in ldflags.
I'm far from an expert at compiling Unix software, but I can't
see what I'm doing wrong.
Thanks in advance,
Tom
If you want to e-mail me remove 'NOSPAM' from my address
--
Learn how to create amazing web sites
Visit eBORcOM's Web Development Resources
http://www.eborcom.com/webmaker/
------------------------------
Date: 13 May 1998 17:08:31 GMT
From: siler@compstat.wharton.upenn.edu (Jack Siler)
Subject: Cross-Platform 4-box Perl "Sharing"
Message-Id: <6jck2f$url$1@netnews.upenn.edu>
c:\> perl \\AN611921\perlprogs\bigdirs.pl m:/ 100000 | more
"bigdirs.pl" in the preceding command line is being invoked from an NT
machine, the script itself (a file-walker a la R.Schwartz) resides on
a second NT box, the perl binaries and libraries (GS version) are on a
Novell server (and in the path of the first NT box), and the directory
being walked is on a Linux box running Samba.
In retrospect this all seems straightforward to the point of
triviality but I hadn't seen it in the newsgroup. Such flexibility
and utility could be mentioned to perl-phobic/ignorant management in
shops that are having trouble with NT administration. The machine
being analyzed can be any box which is shared to the first; the
binaries can be on an NT box shared via either domain or peer-to-peer.
Jack
siler@wharton.upenn.edu
------------------------------
Date: 13 May 1998 16:57:52 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jcjeg$71o$2@info.uah.edu>
In article <6jadad$65k@mozo.cc.purdue.edu>,
gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
: I never claimed the language should
: change, or be dumbed-down, in any way.
The very act of exposing Perl's pristine beauty to the unappreciative,
unthinking, and, hence, unworthy clueless droves of lose32 users is
dumbing down the language. I'm not denying that there are win32 users
of clue, but their helpless comrades far outnumber them. When people
are presented with install docs that read ``once things are installed,
you can get documentation in these ways'' and they're still lost, they
should immediately uninstall perl because they lack the fundamental
clues necessary to use such a sharp tool. Perhaps they should try
visual basic.
: Programming languages are not an everyday thing, but help systems
: should be. Perldoc is an oddity for non-unix programmers. They can
: understand it, but it clashes, and will continue to be ignored
: forever.
If I had a software product whose reference port was half an^W^WOS/2, I
wouldn't bitch and moan because the docs were in OS/2 book format
(*especially* if it provided tools to convert books to manpages and a
book viewer for my platform). This is the reality of having seven
thousand platforms.
I'll say it again: there's nothing in the world stopping the subunix
users from writing their own IDE complete with a really spiffy help
system and floating yellow boxes and colored syntax and whatever other
bloat they want to throw in. If having such software is so vital and
necessary, please go implement it; the world will thank you.
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Wed, 13 May 1998 12:59:21 -0400
From: Birgitt Funk <birgitt@order.booktraders.com>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <3559D169.66F5E089@order.booktraders.com>
I R A Aggie wrote:
[snip]
>
> Further, perl will quite cheerfully hand you more than enough rope to
> hang yourself, your program, and possibly your system.
>
> + > Well, sure it is. And so is C, sh, awk, sed, BASIC, FORTRAN, Lisp,
> + > etc.
>
> + O.K., so what language is then left to the new incoming generation
> + of programming students ?
>
> Pascal? It enforces the top-down, bottom-up programming strategy. Write
> enough programs that way, and it becomes second nature. Once you know that,
> then learning any particular languge is just syntax, details and culture.
>
> + Why can't Perl be a first language ?
>
> It could be, but its _not the optimal_ first language. There's lots of twists
> and turns and gory details. The demands for self-discipline become much
> greater, because the interpreter won't force you.
>
> My advice: learn to program first, then picking perl up will be a snap.
Thank you very much for the answer. It is the second advice I get
regarding picking PASCAL to learn programming with.
If thank you notes should *always* go private mail, this will be
my last public one.
Birgitt Funk
------------------------------
Date: 13 May 1998 17:06:12 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jcju4$71o$3@info.uah.edu>
In article <3558eb24.38542625@news.nask.org.pl>,
cicho@polbox.com (Marek Jedlinski) writes:
: I'm not sure what you call "standard", and I'll happily allow that the
: ActiveState win95 port is not, but it so happens that the ActiveState
: distribution does *not* include perldoc.
Then the ActiveState ``ports'' are both nonstandard and broken. If
you're so cursed as to be forced to use a win32 platform, I highly
recommend Sarathy's binary distribution (if you can't build the standard
distribution yourself).
: Now,
: seeing as most of the reviled, recurrent FAQs come from win95 users...
: ahem.
Perhaps we the readers of clpmisc should send a big whopping bill to
ActiveState.
: >All ports have
: >the capability to generate HTML versions of the docs. It's the
: >responsibility of whoever installs perl to make sure that the docs are
: >available.
:
: But it's a vicious circle for a newbie, don't you see? You're saying a
: newbie who just downloaded his first distribution is responsible for
: installing the docs? The newbie, at this point, doesn't even know the
: perlish *convention* for docs! (pods et al) Of course, if you're talking
: about a sysadmin, then we agree just fine.
Sarathy's bindist generates an HTML version of the docs which it
installs in a user-specified place. Someone who cannot handle this has
no business using software like perl.
: (Pet peeve: modules, of course. Hint: telling a win95 user to use
: Html::Parser for HTML jobs is potentially worse than no response at all,
: unless you add "and before you use it, install perl on Linux". [In my case,
: perl refuses to compile entities.pm; plus I find the documentation
: somewhat, well, obscure.)
You should submit bug reports and/or patches to the author. Be willing
and prepared to assist the author in debugging the problem.
: Similarly, any module that depends on external C
: libraries is useless for the ActiveState port, unless the module was
: specifically made/ported for that OS (such as it is).
If that is the case, then I would write the ActiveState port off as
useless as well.
: Yes, I do re-invent
: the wheels daily; it's either that or no wheels at all *much of the time*.)
Perl5 seeks to keep you out of that trap. Don't fight it by using
pretenders to the throne.
: >Programming languages aren't and should never be everyday things.
:
: One could say that nuclear power plants aren't, either, yet I bet they
: color-code control switches there, too :)
Such a comparison between programming languages and operator panels is
invalid.
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: 13 May 98 14:58:28 GMT
From: sitaram@diac.com (Sitaram Chamarty)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <slrn6ljgn9.vs.sitaram@ltusitaram.diac.com>
On 12 May 1998 16:32:36 GMT, Greg Bacon <gbacon@cs.uah.edu> wrote:
>It's all a matter of what you're used to. Perl was fathered by a Unix
>hacker, after all. Had Larry been a Microsoft weenie, Perl would
>probably be full of wizards and menus and general protection faults.
With all due respect - I doubt that Perl would have existed at all
if Larry Wall had been a Microsoft weenie. At least not in
anywhere near the form it is in now, I'm sure. The mindset is
totally different, as you are probably well aware.
------------------------------
Date: Wed, 13 May 1998 17:01:53 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Bart Lateur <bart.mediamind@tornado.be>
Subject: Re: eval doesn't catch exit in custom die
Message-Id: <Pine.GSO.3.96.980513095951.21974q-100000@user2.teleport.com>
On Wed, 13 May 1998, Bart Lateur wrote:
> Subject: eval doesn't catch exit in custom die
eval isn't documented to catch exit. :-)
> is there another way to terminate a __DIE__ sub, that is NOT
> fatal in eval?
There shouldn't be. If I write code that will die(), I intend for it to
die! Another way to think of this is, "die should never return". If I want
it to return, I'd use warn. (Of course, your __WARN__ handler could
prevent that from returning, if it chose.)
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 13 May 1998 16:00:36 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Stuart Wright <stu-w@usa.net.remove.everything.after.net>
Subject: Re: How can you break out of a 'while... ' loop in a function?
Message-Id: <Pine.GSO.3.96.980513085148.21974i-100000@user2.teleport.com>
On Wed, 13 May 1998, Stuart Wright wrote:
> On Mon, 11 May 1998 15:59:09 GMT, Tom Phoenix <rootbeer@teleport.com>
> wrote:
>
> >On Mon, 11 May 1998, Stuart Wright wrote:
> >
> >> A simple question, but all the pearl FAQs are useless.
> >
> >Please justify that sweeping generalization.
>
> I read them and I found *no* useful information for the 'novice' Perl
> programmer.
Perhaps you define some of those words differently than I do. Of course,
even if there were nothing in the FAQs for the novice Perl programmer,
that doesn't justify your claim that "all the pearl FAQs are useless."
> >You couldn't have looked very hard at the FAQ if you didn't find pointers
> >to documentation on all parts of Perl. And those docs also lead you to
> >references on CGI scripting, too, at no extra charge.
>
> I read the FAQ and I couldn't find a reference.
perlfaq3 has a question entitled, "Where can I learn about CGI or Web
programming in Perl?" The answer includes several references. Didn't you
find those?
> I'm too busy and definately too ignorant, mate.
I can't argue with that! :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 13 May 1998 16:02:10 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Stuart Wright <stu-w@usa.net.remove.everything.after.net>
Subject: Re: How can you break out of a 'while... ' loop in a function?
Message-Id: <Pine.GSO.3.96.980513090126.21974j-100000@user2.teleport.com>
On Wed, 13 May 1998, Stuart Wright wrote:
> Why *should* I have the Perl documentation on my system ?! Does it
> come bundled with Windows 95 or something ?!
It comes bundled with recent versions of perl. If perl is properly
installed, you should have the docs and FAQs as well. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 13 May 1998 13:17:30 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: How can you break out of a 'while... ' loop in a function?
Message-Id: <comdog-ya02408000R1305981317300001@news.panix.com>
Keywords: from just another new york perl hacker
In article <35596f2b.3205549@news.demon.co.uk>, stu-w@usa.net.remove.everything.after.net (Stuart Wright) posted:
>>> All I want is a basic perl/cgi reference - all the commands, functions
>>> etc.
>>
>>You couldn't have looked very hard at the FAQ if you didn't find pointers
>>to documentation on all parts of Perl. And those docs also lead you to
>>references on CGI scripting, too, at no extra charge.
>
>I read the FAQ and I couldn't find a reference.
everything you want is in the sig.
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
------------------------------
Date: Wed, 13 May 1998 16:30:10 GMT
From: dbryson@tclock.com
Subject: Looking underneath the black box
Message-Id: <6jchqk$gm7$1@nnrp1.dejanews.com>
I was wondering if anyone has had any experience with changing coding
practices, doing trick programming, etc. by reviewing the source code of the
interpreter. Many times when you look too closely underneath the covers of a
language, library, operating system, etc. and code based on what you see then
your program breaks with the next release.
Some programmers believe that programming undocumented features (in the case
of Perl this would be information gleamed from the source code instead of the
man pages, books by Wall and others) is full of problems and shouldn't be
done. Others believe that the added efficiency is worth the risk and actually
is the dividing line between an OK programmer and a true hacker.
Personally, while I've hacked hardware/OS/langauges/etc before, I try not to
do it anymore -- as a matter of practice. Does anyone have thoughts or
experiences on the subject? I would be very interested in hearing them.
Don Bryson
President and CEO
Quality Software Solutions, Inc.
http://www.tclock.com
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 13 May 1998 13:54:06 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: dbryson@tclock.com
Subject: Re: Looking underneath the black box
Message-Id: <n2cmrohd.fsf@mailhost.panix.com>
dbryson@tclock.com writes:
> I was wondering if anyone has had any experience with changing
> coding practices, doing trick programming, etc. by reviewing the
> source code of the interpreter.
My opinion: One should code for human legibility, maintainability,
and efficiency. Many good practices for efficiency in Perl are laid
out in the docs. If raw speed is *that* important to the task at
hand, then Perl is the wrong tool for the job. Then again, thanks to
perl's extensibility, certain kinds of tasks (like mathematical
manipulation of large matrices, bit-vector twiddling, et al.) are
reasonably done in Perl given the right modules.
Ultimately (I'm sure the recently-returned Abigail will back me up on
this) your choice of data structure and algorithm are far more
important to your runtime than any tricks that depend on arcane
knowledge.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: Wed, 13 May 1998 12:12:28 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Matching period with regular expression
Message-Id: <s9kcj6.i24.ln@localhost>
Jason Murray (jmurray@mfg.sgi.com) wrote:
: I am using the following as part of a program to find large files on my
: hard drive. The problem I am having is how to match a period at the
: begging of the line with a regular expression. I am using the following
: but it dosen't seem to work. Any suggestions.
: #!/usr/bin/perl5
You are missing the -w switch there:
#!/usr/bin/perl5 -w
: open(FILES, "ls -lRA /|");
^
^ filenames are at the _end_ of the line
How do you get a dot for that permission bit?
What does a dot mean there?
Do you really want to match a dot "at the beginning of a line", or
at the beginning of the filename field?
: while (<FILES>){
: chomp $_;
: if (/^\./){
: print "$'\n";
I would replace those last two lines with:
print if s/^\.//;
Using $' anywhere in your script slows down every single pattern match.
I have never needed to use them...
: }
You are missing a check to see if the 'ls' command ran OK:
die "problem running 'ls'" unless close(FILES);
: Thanks in advance,
You're welcome.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 13 May 1998 17:01:54 GMT
From: darrenross@my-dejanews.com
Subject: multi-byte parsing
Message-Id: <6jcjm2$jjv$1@nnrp1.dejanews.com>
I am involved in a project that requires me to parse multi-byte database
export files. I have no experience doing this, and would be grateful for any
suggestions and pointers to reference materials.
Thank you,
Darren
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 13 May 1998 16:04:35 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: New IDE for Perl
Message-Id: <6jcgaj$1fn$1@ns1.arlut.utexas.edu>
Samuel King <samk@was.net> writes:
> This is the place to try the first IDE for perl, well that I know of
> anyway..
The *first* IDE? What, then, is emacs?
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"Look for beauty in roughness, unpolishedness"
------------------------------
Date: 13 May 1998 16:00:09 GMT
From: sstark@informix.com (Scott Stark)
Subject: newbie question: handling errors
Message-Id: <6jcg29$7or1@webint.na.informix.com>
Can anyone tell me a good source for learning how to handle errors in a perl
script? That is, if a routine fails, do this or that, etc. (other than just
"die"). I looked in the FAQ but the only mention of errors is "Error checking
is left as an exercise for the reader." Whew!
------------------------------
Date: Wed, 13 May 1998 13:10:12 -0400
From: Brian Mathis <brianm@kodak.com>
To: Scott Stark <sstark@informix.com>
Subject: Re: newbie question: handling errors
Message-Id: <3559D3F4.49C6D606@kodak.com>
[posted and emailed]
Scott Stark wrote:
>
> Can anyone tell me a good source for learning how to handle errors in a perl
> script? That is, if a routine fails, do this or that, etc. (other than just
> "die"). I looked in the FAQ but the only mention of errors is "Error checking
> is left as an exercise for the reader." Whew!
There is a very nice construct you can use to catch errors, using the
eval/die method. If you enclose your code inside and eval { }, any die
that you issue will be caught by the eval, and stored in $@. You can
then look at $@ to see what went wrong.
Example:
eval {
open(FILE, "foo.txt") or die('File Open');
}
if( $@ ) {
$_ = $@; # just to make it a little more readable
/File Open/ && do { print "Had an error while trying to open the
file";
exit 1;
};
}
Hope that helps.
Brian Mathis
------------------------------
Date: 13 May 1998 17:27:37 GMT
From: angst <angst@scrye.com>
Subject: Re: newbie question: handling errors
Message-Id: <6jcl69$st4$1@jelerak.scrye.com>
Scott Stark <sstark@informix.com> wrote:
: Can anyone tell me a good source for learning how to handle errors in a perl
: script? That is, if a routine fails, do this or that, etc. (other than just
: "die"). I looked in the FAQ but the only mention of errors is "Error checking
: is left as an exercise for the reader." Whew!
However you want. In a "do something or die" type of routine, just replace
die with however you want to handle it...print a message, call a subroutine,
whatever you want. Other than errors due to buggy code, "errors" in your
script are really only there if you define a certain thing returning a certain
other thing as an error. If you feel like it, you could make your script
behave as if *failing* to open a file was actually what should happen, and
a successful open would be an "error". Why you would actually want to
do this is beyond me.
Things that call die are just like any other thing. You could say something
like
print "hello world" and die("i didn't really want to print that");
and perl would find that just fine. Your average user might think you'd
gone insane, but the point is perl doesn't really care.
so you could replace something like
open(FOO,"/restricted/file") or die("failed to open: $!");
with something like
open(FOO,"/restricted/file") or print "i didn't really want to open that file anyway.\n";
or even
open(FOO,"/restricted/file") or my_subroutine($args);
where my_subroutine is an ordinary subroutine doing whatever you want, including
maybe exiting the program. die is just an internal function that happens
to exit the script with an appropriate exit code as part of its function.
It can be replaced with any other construct you want.
--
Erik Nielsen <eln@rmci.net>
mail to above (rather than header address) is answered significantly faster.
this post != views of anyone at all, really
"You are like...unix GOD" -- local tech support
------------------------------
Date: Wed, 13 May 1998 11:58:33 -0400
From: Brian Mathis <brianm@kodak.com>
Subject: Re: password
Message-Id: <3559C329.75022EB0@kodak.com>
Martien Verbruggen wrote:
> In article <6j8eib$7ot$1@netnews.upenn.edu>,
> miuwong@blue.seas.upenn.edu (Miu Alex Wong) writes:
> > hi,
> > I need to have users type in their telnet account login name and passwd
> > on the web and check them against the master password file see whether they
> > have typed in the correct one, is there any way to do that.
>
> Hmm. You do realise that unless you use the right dort of connection,
> which uses some sort of encryption, that this is unsafe, right? But
> that is a discussion for one of the comp.infosystems.www.* groups, and
> maybe some of the security groups.
I'm really getting sick of these kinds of paranoid answers. It's really
rediculous to contsantly bring issue like this up, especially to people
who really don't know what the whole story is. It only serves to
further instill unfounded paranoia and public contempt for new
technology.
All people hear about is that something is insecure, and they think that
is a bad thing, so they probably don't want to do that. The fact is,
that *everything* on the net is fundamentally insecure. Bringing up the
issue only serves to instill doubt in someone's mind. *EVERY* network
session is insecure, whether you send the password over the web, or via
telnet (just because you don't *see* the password echoed back to you
doesn't mean it's not going over the net in plain text). (Yes, I know
kerberos is different, but it's not very widespread).
I'm just getting fed up with the amount of misleading information that
is constantly being brought up, especially to newbies, with the sole
intent of trying to make them paranoid.
Brian Mathis
> Once again: I urge you strongly to have a look into how insecure this
> all is.
>
> Martien
> --
> Martien Verbruggen |
------------------------------
Date: Wed, 13 May 1998 16:58:45 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Rick Meldrum <rjk@fprsdev3.fmr.com>
Subject: Re: Perl compiler: does it work
Message-Id: <Pine.GSO.3.96.980513095622.21974o-100000@user2.teleport.com>
On Wed, 13 May 1998, Rick Meldrum wrote:
> I have an app that would work a lot better with compiled code, but
> I'm a little hesitant to use a perl compiler.
Perhaps you haven't seen what the FAQ says about compiling Perl. Then
again, if you're hesitant, perhaps you have. :-)
Compiling Perl confers few of the "traditional advantages of compiling".
You probably needn't bother. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 13 May 1998 13:14:52 -0400
From: Rick Meldrum <rjk@fprsdev3.fmr.com>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Perl compiler: does it work
Message-Id: <3559D50C.2B0B@fprsdev3.fmr.com>
Tom Phoenix wrote:
>
> On Wed, 13 May 1998, Rick Meldrum wrote:
>
> > I have an app that would work a lot better with compiled code, but
> > I'm a little hesitant to use a perl compiler.
> Compiling Perl confers few of the "traditional advantages of compiling".
> You probably needn't bother. Hope this helps!
Thanks Tom;
I am familiar with the pros and cons of the "compiled Perl approach." I
agree
with you entirely!
We have a perl script that we execute at login that
takes about 2 seconds to run. I was hoping to:
a) reduce the time this script takes to run, and
b) provide a slightly more secure "entry point" into our systems.
So I am still curious if the compiler will help, or if it is better left
as a toy (like the FAQ says)???
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 2582
**************************************