[8464] in Perl-Users-Digest
Perl-Users Digest, Issue: 2081 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 12 09:07:37 1998
Date: Thu, 12 Mar 98 06:01:04 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 12 Mar 1998 Volume: 8 Number: 2081
Today's topics:
Re: A to lower case. (Tom Grydeland)
Re: c.l.p.mod and TPI <boys@aspentech.com>
Re: Can't find "from" and "subject" <qdtcall@esb.ericsson.se>
Re: Can't find "from" and "subject" <ckc@dmi.dk>
Checking user names with regexp ?? myself@technologist.com
Re: Checking user names with regexp ?? <eike.grote@theo.phy.uni-bayreuth.de>
Children, zombies, and REAPERs! (oh my!) <mhazen@franklin.uga.edu>
Examples of REGEXP ? myself@technologist.com
Re: Examples of REGEXP ? <ckc@dmi.dk>
Re: HELP!! Can't get PERL script to work.. <alexs@online.emap.com>
Re: How do I rename a file using perl Frank@but_dont_use_this.address
HTTP_USER_AGENT - any others? <ben@wallroyds.demon.co.uk>
Integration with the Perl I/O system (Stefaan A. Eeckels)
Re: New problem .... <webmaster@disconova.com>
Re: New problem .... (Real)
Perl and passwd <santi@gallet.udg.es>
Re: Possible bug or is it my program? [SEEDOC] <eike.grote@theo.phy.uni-bayreuth.de>
Possible bug or is it my program? <benny@goforit.com.sg>
Re: Possible bug or is it my program? <cnwetzel@linguistik.uni-erlangen.de>
preserving age of file? (jay)
Re: printf / unlink / ?: (Tom Grydeland)
problems with POSIX <vegardha@ifi.uio.no>
Re:PGP / $PGPPASS <Jan.Vajda@somi.sk>
regex problem -some gnarly details (David Waring)
Re: regex problem -some gnarly details (Tom Grydeland)
Re: splice -- useful uses? (Abigail)
Where can I get the PERL for Windows NT and 95? <huskystudio@geocities.com>
Re: Why doesn't ' s/\(/#LPAREN#/gi; ' work? !! <ckc@dmi.dk>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 12 Mar 1998 12:28:01 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: A to lower case.
Message-Id: <slrn6gfl6h.5ep.Tom.Grydeland@mitra.phys.uit.no>
On Tue, 10 Mar 1998 20:54:40 +0100,
Mario Soares <mario_soares@hotmail.com> wrote:
> Hi
> How can I make the conversion of this characters with a simple search
> script?
BTW, this has nothing to do with searching.
> A I M S Z C U J
> to lower case.
> a i m s z c u j
Two solutions:
1) (Proper solution) Find a locale which includes these characters as
letters and use that locale. In perl, you must probably say 'use
locale;' man perllocale for details
2) (quick fix) Use tr after lc or uc:
sub toupper ($) {
my $st = uc shift;
$st =~ tr[aimszcuj][AIMSZCUJ];
$st;
}
sub tolower ($) {
my $st = lc shift;
$st =~ tr[AIMSZCUJ][aimszcuj];
$st;
}
Of course, all letters you intend to use must be included here.
> Thank you for help
You're welcome.
> Mario
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Thu, 12 Mar 1998 10:59:27 +0000
From: Ian Boys <boys@aspentech.com>
Subject: Re: c.l.p.mod and TPI
Message-Id: <3507C00F.7DE1@aspentech.com>
? the platypus {aka David Formosa} wrote (from Australia, I think):
>
> I better anogy would be this. The Govener Genral dose all the duites that
> a head of state would noramly do, however legally he is not the head of
> state HRH the Queen is. However most peaple acnolge that he is the
> defacto head of state.
>
<nitpick>
Actually, her correct title is HM the Queen; HRH is used by princes,
princesses and so on. However, you may be a republican, and so may
not care all that much. :-)
</nitpick>
Ian (posting from the UK)
------------------------------
Date: 12 Mar 1998 10:03:33 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Can't find "from" and "subject"
Message-Id: <is67lkgu1m.fsf@godzilla.kiere.ericsson.se>
Kenneth Vogt <kenvogt@sni.net> writes:
> Can anyone suggest what I might look for?
The Mail::Send module.
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: 12 Mar 1998 14:06:41 +0100
From: Casper Kvan Clausen <ckc@dmi.dk>
Subject: Re: Can't find "from" and "subject"
Message-Id: <wvpafawjbxa.fsf@pratt.ejoper.dmi.min.dk>
Kenneth Vogt <kenvogt@sni.net> writes:
> I have a perl script I am trying to use to send mail to a mailing list.
> When I send mail, sendmail leaves 'subject' blank and it does not use
> the 'from' address I specify. I cut the script down to the following
> bare essentials as a test. This script correctly fills the 'from'
> address and 'subject'. So something else in the script is messing me up.
>
> Can anyone suggest what I might look for?
You're either looking for the Mail series of modules
<URL:http://www.perl.com/CPAN/modules/by-module/Mail>
or you're looking for the fine document available by typing 'man
sendmail'. I'd recommend the modules, though.
Kvan.
--
-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
----------<ckc@dmi.dk>---------- | unattempted is impossible.'
Lokal 544 |
I do not speak for DMI, just me. | - Lord Mhoram, Son of Variol.
------------------------------
Date: Thu, 12 Mar 1998 04:10:45 -0600
From: myself@technologist.com
Subject: Checking user names with regexp ??
Message-Id: <6e8c8g$3q7$1@nnrp1.dejanews.com>
I am trying to check the validity of user names with some regexp and I'm not
getting anywhere.
First I do a: $name = substr (lc($name),0,8) so they're
all lower case, 8 chars max.
Then I do a /^[a-z][_a-z0-9]+/ to make sure:
-
they start with a letter- they contain only alphanumeric afterwards
Problem: it still allows things such as "a@#$5s" to be valid, which I don't
want.
How to tell a regexp to match something exclusive of something else?
Now, where is that aspirin ?
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 12 Mar 1998 12:21:55 +0100
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: Checking user names with regexp ??
Message-Id: <3507C553.446B@theo.phy.uni-bayreuth.de>
Hello, "myself" (whoever you are ...)
myself@technologist.com wrote:
>
> I am trying to check the validity of user names with some regexp and I'm not
> getting anywhere.
>
> First I do a: $name = substr (lc($name),0,8) so they're
> all lower case, 8 chars max.
>
> Then I do a /^[a-z][_a-z0-9]+/ to make sure:
^^
insert a '$' here
> -
> they start with a letter
> - they contain only alphanumeric afterwards
> Problem: it still allows things such as "a@#$5s" to be valid, which I don't
> want.
>
> How to tell a regexp to match something exclusive of something else?
If you add a '$' where indicated above, the regexp will only match a
string which starts with a lowercase letter followed by at least one
[_0-9a-z] and (this is now important) _nothing else_ before the end
of the string.
Bye, Eike
--
=======================================================================
>>--->> Eike Grote <eike.grote@theo.phy.uni-bayreuth.de> <<---<<
-----------------------------------------------------------------------
Home Page, Address, PGP,...: http://www.phy.uni-bayreuth.de/~btpa25/
-----------------------------------------------------------------------
PGP fingerprint: 1F F4 AB CF 1B 5F 4B 1D 75 A1 F9 C5 7B 3F 37 06
=======================================================================
------------------------------
Date: Thu, 12 Mar 1998 08:46:28 -0500
From: Mark Hazen <mhazen@franklin.uga.edu>
Subject: Children, zombies, and REAPERs! (oh my!)
Message-Id: <3507E734.30DA0A3@franklin.uga.edu>
Hi, it's me again, the ever-learning bad hack. :)
I'm trying to set up a program as a server process, of sorts. I've got
everything working, with one minor exception, and was hoping someone
could explain what I'm doing wrong here to me. Currently, this is under
Redhat Linux 5.0 with Perl 5.004.
Here's an overly simplified view of what I'm doing:
# Setup Stuff here
while(1)
{
#do some stuff
\&REAPER;
# spawn a child process
sleep 100;
}
sub REAPER
{
$waitedpid = wait;
$SIG{CHLD} = \&REAPER;
}
...now, my problem is (and some of you may have guessed this already)
the REAPER bit does a wonderful job of getting rid of all of those pesky
zombie processes. Unfortunately, it also seems to invalidate the sleep
command as well... i.e. my program runs fine, but no longer does it
pause between cycles.
I'm guessing that the $SIG{CHLD} = \&REAPER tells all child processes
that when they exit, they need to jump back to the main process into the
REAPER subroutine, at which point they just return and close. I don't
understand this well at all, but am I close? I think the problem is that
sleep also creates a child-process of sorts, which I know is interrupted
by a SIGALRM. Does this REAPER function take over this process as well?
And most importantly, what am I doing wrong, and what's the most
(portable/sane/reliable/sanitary/fun) way to handle what I'm trying to
do?
Thanks in advance,
-mh.
----
. _+m"m+_"+_ Mark Hazen Network Administrator, Dean's Office
d' Jp qh qh The Franklin College of Arts & Sciences
Jp O O O The University of Georgia (706)542-1546
Yb Yb dY dY
O "Y5m2Y" " even the mightiest wave starts out as a ripple.
"Y_ why make waves when it's easier to nurture ripples?
------------------------------
Date: Thu, 12 Mar 1998 03:36:30 -0600
From: myself@technologist.com
Subject: Examples of REGEXP ?
Message-Id: <6e8a8m$2jo$1@nnrp1.dejanews.com>
Seems like regexp *is* rocket science in fact... well, it feels like it when
one get started with it.
Looks also that one could only learn from example
as every book or explanation I've read on the topic was confusing at best.
Any place with many examples of regexp ?
Thanks!
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 12 Mar 1998 14:25:24 +0100
From: Casper Kvan Clausen <ckc@dmi.dk>
Subject: Re: Examples of REGEXP ?
Message-Id: <wvp90qgjb23.fsf@pratt.ejoper.dmi.min.dk>
myself@technologist.com writes:
> Seems like regexp *is* rocket science in fact... well, it feels like it when
> one get started with it.Looks also that one could only learn from example
> as every book or explanation I've read on the topic was confusing at best.
> Any place with many examples of regexp ?Thanks!
Sounds like you need to read 'Mastering Regular Expressions' by
Jeffrey Friedl (published by O'Reilly). That's probably the best
technical book I've ever read, on _any_ subject.
Kvan.
--
-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
----------<ckc@dmi.dk>---------- | unattempted is impossible.'
Lokal 544 |
I do not speak for DMI, just me. | - Lord Mhoram, Son of Variol.
------------------------------
Date: Thu, 12 Mar 1998 11:16:58 +0000
From: Alex Schajer <alexs@online.emap.com>
To: Sanghyun Lee <dragon@soback.kornet.nm.kr>
Subject: Re: HELP!! Can't get PERL script to work..
Message-Id: <3507C42A.B26D68F3@online.emap.com>
Hi,
It could be as simple as not specifying the content type before you start
printing
print "Content-type: text/html\n\n":
or
print "\n\n"; (works as well but doesn't do nice HTML output, use the above)
This is nec. so that the browser knows what to do with the output, ie whether it
is text/html or graphics or bins.
This probably is a common problem when people convert from shell to cgi.
If you have done that then Geert Roovers is worth pursuing.
Good Luck,
Alex
Sanghyun Lee wrote:
> OK, I wrote a simple Perl script. I ran it on my ISP (UNIX) through Telnet.
> It appeared to work. Then I typed in the address of the script through my
> web-browser. It just printed the whole script out instead of running it!!
> What's wrong?
> Also is there anyway to use C to write CGI scripts? I tried C too but it
> just returns a 500 error... Maybe you have to compile the thing under a UNIX
> compiler? Where do I get one of these if they are available??
>
> Please help me to get PERL CGI to work in web browser...
> Or better yet help me get C/C++ CGI to work...
> Or even better help me get both to work...
>
> Note: I am a complete beginner and know next to nothing about UNIX, CGI,
> PERL, etc. etc. etc.
>
> PS. Please E-mail reply also...
> Thanks
------------------------------
Date: 12 Mar 1998 11:45:31 +0100
From: Frank@but_dont_use_this.address
Subject: Re: How do I rename a file using perl
Message-Id: <yo9hg542nn8.fsf@nym.sc.philips.com>
Dave Bushong <spamfree@yahoo.com> writes:
> [biteme!dbushong 376] perldoc -f rename
> Unknown option: f
...
>
> Great tip. Except I didn't even get a dinosaur.
>
>
Hello Dave,
to see dinos you will have either to use a later version of perl
(5.004_04 works) or use grep to search in the docs.
Or even better use tkman, which is a pain to install, but allows
fuzzy fulltext searches in all man pages availiable.
regards
Frank
------------------------------
Date: Thu, 12 Mar 1998 11:38:47 -0000
From: "Ben" <ben@wallroyds.demon.co.uk>
Subject: HTTP_USER_AGENT - any others?
Message-Id: <889701957.20849.0.nnrp-11.c2de5b4a@news.demon.co.uk>
Hiya!
I wonder if any1 know whereabout you can find ... For ALL ones you can have
....
Some of them are ....
HTTP referer - $ENV{'HTTP_REFERER'}
Remote addr - $ENV{'REMOTE_ADDR'}
Remote host - $ENV{'REMOTE_HOST'}
Remote ident - $ENV{'REMOTE_IDENT'}
I wonder if any1 know the one for ... HTTP_REFERER or something? When I run
the program, it didn't show where I came from .... And, what about the one
"TZ" or something? But, can any1 show me where to find, for ALL of them?
A-Z!
Thanks in advance :)
Regards
Ben :)
------------------------------
Date: 12 Mar 1998 13:16:52 GMT
From: Stefaan.Eeckels@ecc.lu (Stefaan A. Eeckels)
Subject: Integration with the Perl I/O system
Message-Id: <6e8n84$kfn$1@justus.ecc.lu>
Hi,
(I posted this in clpm, but got no replies - maybe
better luck here?)
I'm writing a Perl module to encapsulate an existing 'C'
library (called STATEL).
This library offers a secure, bi-directional
data exchange mechanism between two (consenting ;-)
applications. It's OS and transport independent, and uses
the open/read/write/close paradigm in a hierarchical
directory structure (familiar, isn't it).
Hence it's fairly natural to try to integrate it to offer
file handles and directory handles, so that the native
Perl functions (such as 'eof') can be used with it.
I did something similar for Tcl (sorry ;-) so that
you can say:
$ tclsh
statel init "Sears-1"
set sf [statel open Data/stats-1]
set df [open stats-1 "w"]
fcopy $sf $df
close $df
close $sf
statel exit
It's easy to write an XS to offer the individual
primitives in Perl, and to add an OO wrapper in
the IO:: style, but I'd really like to be able to
return a native Perl filehandle, where Perl would
call my routines instead of the OS equivalents.
Tcl's IO structure made this quite easy, but I'm not
enough of a Perl fundi to know if this is possible
at all in Perl.
Has anybody done such an excercise? If so, could you
point me to the relevant documentation / and or
source? Oh yes - it has to be implemented as a loadable
module on both Perl and Perl/Win32, as changing
the Perl code itself is not an option (for the
customer).
Any hints, pointers and help gratefully accepted.
--
Stefaan
--
PGP key available from PGP key servers (http://www.pgp.net/pgpnet/)
___________________________________________________________________
"Don't worry about people stealing your ideas. If your ideas
are any good, you'll have to ram them down people's throats."
-- Howard Aiken
------------------------------
Date: Thu, 12 Mar 1998 10:56:22 -0800
From: Markku Uttula <webmaster@disconova.com>
Subject: Re: New problem ....
Message-Id: <35082FD6.6DA7@disconova.com>
Ben wrote:
> Can't find string terminator "end_of_html" anywhere before EOF at
> print <<"end_of_html";
^ ^
[KLIP]
> end_of_html
^ ^
And where are they now ?
--
Markku Uttula | If I ever though you would read this, I'd
webmaster@disconova.com | have written something useful in here...
http://www.disconova.com/ | - Mickey Mouse
------------------------------
Date: Thu, 12 Mar 1998 10:49:40 +0100
From: real@earthling.net (Real)
Subject: Re: New problem ....
Message-Id: <MPG.f71ce23ff9216e4989695@news.surfnet.nl>
Markku Uttula wrote;
> Ben wrote:
> > Can't find string terminator "end_of_html" anywhere before EOF at
> > print <<"end_of_html";
> ^ ^
> [KLIP]
> > end_of_html
> ^ ^
>
> And where are they now ?
Makes no difference in my Perl ! But you have to make sure there are no
spaces, tabs of other inviseable characters before or after the last
"end_of_html" string.
Cheers,
Real
------------------------------
Date: Thu, 12 Mar 1998 11:36:09 +0100
From: Santi <santi@gallet.udg.es>
Subject: Perl and passwd
Message-Id: <3507BA99.AAD9D2F0@gallet.udg.es>
Hi,
Ther question is on Perl 5.004, Solaris and password change.
I'm root (of course) and want to change user passwords from a file.
I think that the best way was via passwd, to avoid locking trouble and
shadow sync.
I've tried openenig a pipe, but...
Can anyone help me.
Please send me private e-mail at santi@si.udg.es
Thanks
------------------------------
Date: Thu, 12 Mar 1998 12:16:45 +0100
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: Possible bug or is it my program? [SEEDOC]
Message-Id: <3507C41D.2781@theo.phy.uni-bayreuth.de>
Hi,
Benny Chee wrote:
>
> Hi,
>
> Was trying to pass some variables to another subroutine
> and found certain errors but was not sure if it was my
> programming's style falut...
>
> I was trying to pass an array and a variable to another
> subroutine.
>
> However if i pass it like :
> &foo(@array,$var);
> I get a error when i put a -w flag:
> Use of uninitialized valu
>
> But if i pass it lie:
> &foo($var,@array);
> No error.
>
> So what's wrong?
Arrays as arguments are expanded to a list of elements:
(1) &foo($var,@array) --> &foo($var,$array[0],$array[1],...)
(2) &foo(@array,$var) --> &foo($array[0],$array[1],...,$var)
Then reading the arguments inside the sub looks like this:
(1) ($var,@array) -> $var = $var , @array = ($array[0],...)
(2) (@array,$var) -> @array = ($array[0],...,$var) [@array eats up
everything what comes in and doesn't leave
any element for $var to read]
See the 'perlsub' manual page for more information and how to solve
the problem (2).
Bye, Eike
--
=======================================================================
>>--->> Eike Grote <eike.grote@theo.phy.uni-bayreuth.de> <<---<<
-----------------------------------------------------------------------
Home Page, Address, PGP,...: http://www.phy.uni-bayreuth.de/~btpa25/
-----------------------------------------------------------------------
PGP fingerprint: 1F F4 AB CF 1B 5F 4B 1D 75 A1 F9 C5 7B 3F 37 06
=======================================================================
------------------------------
Date: Thu, 12 Mar 1998 17:07:24 +0800
From: Benny Chee <benny@goforit.com.sg>
Subject: Possible bug or is it my program?
Message-Id: <Pine.LNX.3.96.980312165736.13917A-100000@maine.goforit.com.sg>
Hi,
Was trying to pass some variables to another subroutine
and found certain errors but was not sure if it was my
programming's style falut...
I was trying to pass an array and a variable to another
subroutine.
However if i pass it like :
&foo(@array,$var);
I get a error when i put a -w flag:
Use of uninitialized valu
But if i pass it lie:
&foo($var,@array);
No error.
So what's wrong?
Any replies...by email pls...thks
Sample program to test:
#!/usr/bin/perl -w
my @array=('1','2','3');
my $var = '2';
&foo(@array,$var);
#&foo($var,@array); #the corrected pass
sub passiton {
my (@array,$var)=@_;
#my ($var,@array)=@_; #the corrected accept
print "@array\n";
print "$var\n";
}
output : (incorrect) with -w flag
1 2 3 2
Use of uninitialized value at ./bug.pl line 14.
output : without -w flag
1 2 3 2
------
Benny
benny@iris.eee.ntu.edu.sg
------------------------------
Date: Thu, 12 Mar 1998 13:35:12 +0100
From: Christian Wetzel <cnwetzel@linguistik.uni-erlangen.de>
Subject: Re: Possible bug or is it my program?
Message-Id: <3507D680.1FF2@linguistik.uni-erlangen.de>
[Copy to author]
Benny Chee wrote:
> I was trying to pass an array and a variable to another
> subroutine.
>
> However if i pass it like :
> &foo(@array,$var);
> I get a error when i put a -w flag:
> Use of uninitialized valu
>
> But if i pass it lie:
> &foo($var,@array);
> No error.
In the subroutine, the array slurps in all values
of @_, so there is nothing left for $var (which
remains undef). If it tries to read $var first
instead, it takes only the first element of @_,
leaving the rest for @array.
Read the perlsub document. The section "pass by
reference" explains how to leave multiple arrays
or hashes "intact" when passing to or from subroutines.
So a solution for your problem is:
#!/usr/bin/perl -w
my @array=('1','2','3');
my $var = '2';
&foo(\@array,\$var);
sub foo {
my ($r_array,$r_var)=@_;
print "@$r_array\n";
print "$$r_var\n";
}
The Output is:
1 2 3
2
Read perlref for details on referencing/dereferencing.
Christian
------------------------------
Date: Thu, 12 Mar 1998 11:32:48 GMT
From: mocat@spamtrap.best.com (jay)
Subject: preserving age of file?
Message-Id: <3507c622.122398049@nntp.best.com>
I'm currently writing a script to keep track of my load average and
other such stats on my machine.
What it does is reads variables from the $ENV hash, and prints them
into a log. (using :: as a delimeter)
Whenever I want to get this information, I run another program and it
splits all of the fields and returns formatted info.
Here's the problem:
I want to keep the newest entry in the logfile at the top of the
logfile. Here's a rough idea on how I did this:
open(RLOG, "logfile");
@rlog = <RLOG>;
close(RLOG);
open(LOG, ">logfile");
print "$newest_entry\n"."@rlog";
It works fine, it puts the newest at the top, and the oldest on the
bottom.
But I want to keep a "yesterday" log, and in order to do this, the
program has to move the "today" log to the "yesterday" log every 24
hours and start building up a new "today" log.
Whenever the program opens the "today" log for writing, it deletes the
old one and starts a new one. So everytime the file is modified, it
gets a new timestamp.
Is there a way I could work around this?
Thanks for any help..
-j
:mocat@best.com/www.best.com/~mocat:
------------------------------
Date: 12 Mar 1998 12:17:49 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: printf / unlink / ?:
Message-Id: <slrn6gfkjc.5ep.Tom.Grydeland@mitra.phys.uit.no>
On Wed, 11 Mar 1998 17:44:22 GMT,
Hans-Georg Rist <hans-georg.rist@zkrd.de> wrote:
> Hi,
>
> I wanted to use unlink in combination with printf and the conditional
> operator ?: like this:
> if ( -e $file ) {
> printf "%ssuccessfully deleted.\n", unlink $file ? "" : "not ";
> testfile.tmp: 0successfully deleted.
> meaning: not deleted, the file still exists. I can't understand where
> this zero '0' comes from, because unlink expects a list and my list
> should end with $file!?
Correct, but ?: has higher precedence (binds tighter) than list
operators, so your expression is parsed as
printf("%sstring\n", (unlink ($file? "": "not ")));
In other words, if your filename is TRUE (different from the empty
string or "0"), unlink a file with an empty filename (which is probably
not allowed anyway), otherwise, try to unlink a file named "not " (which
you probably don't have) and use the return value from unlink in your
printf call. In your case, the return value was "0" (meaning false,
file not deleted.)
> Ok, fixing the problem is easy, using parentheses:
> printf "%ssuccessfully deleted.\n", (unlink $file) ? "" : "not ";
> or:
> printf "%ssuccessfully deleted.\n", unlink($file) ? "" : "not ";
>
> Any explanation?
man perlop. The precedence table is right at the top.
> | Hans-Georg Rist ZKRD, Zentrales Knochenmarkspender-Register
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: 12 Mar 1998 14:21:46 +0100
From: Vegard Hanssen <vegardha@ifi.uio.no>
Subject: problems with POSIX
Message-Id: <y9x67lkqc2d.fsf@hrotti.ifi.uio.no>
Hi!
I have a loading problem with the POSIX module. When I do:
perl -mPOSIX
it works for all users, including root.
But, I have made a program which uses the POSIX module. When I run it
as a regular user, it works, but when I run it as root perl can't find
the loadable object for POSIX. With strace I get this:
stat("/usr/adm/perllib/auto/POSIX", 0x80b6338) = -1 ENOENT (No such file or directory)
stat("/usr/lib/perl5/i386-linux/5.00403/auto/POSIX", {st_mode=S_IFDIR|0755, st_size=3072, ...}) = 0
stat("/usr/lib/perl5/i386-linux/5.00403/auto/POSIX/POSIX.", 0x80b6338) = -1 ENOENT (No such file or directory)
stat("/usr/lib/perl5/auto/POSIX", 0x80b6338) = -1 ENOENT (No such file or directory)
stat("/usr/lib/perl5/site_perl/i386-linux/auto/POSIX", 0x80b6338) = -1 ENOENT (No such file or directory)
stat("/usr/lib/perl5/site_perl/auto/POSIX", 0x80b6338) = -1 ENOENT (No such file or directory)
stat("./auto/POSIX", 0x80b6338) = -1 ENOENT (No such file or directory)
As you probably see it isn't checking for POSIX.so, but for POSIX. .
Why does this problem only occur when I run the program as root??
--
Vegard
------------------------------
Date: 12 Mar 1998 09:55:41 GMT
From: kozo <Jan.Vajda@somi.sk>
Subject: Re:PGP / $PGPPASS
Message-Id: <6e8bet$eh6@gringo.somi.sk>
:> I am trying to execute pgp using 'system("pgp bla-bla-bla") '. Well, the
:> problem is that I don't know how to setup $PGPPASS variable (within perl
:> script), so pgp can use it!? If i use system("setenv...") it doesn't work.
:> $ENV{'PGPPASS'} doesn't work either. Could someone help me, or "forward" to
:> some doc which contains explanation about this?
try use -z _PASSWORD_ options .. really ..
pgp -z pass_phrase +batchmode +force blabla
K O Z O
----------------------------------------------------
posted by WWWNews gateway v1.12
(c) 1997 Somi Systems Ltd. http://www.somi.sk/
somi.sk is NOT the originators of the articles
and are NOT responsible for their content.
------------------------------
Date: 12 Mar 1998 09:45:36 GMT
From: dwaring@nwsr.com (David Waring)
Subject: regex problem -some gnarly details
Message-Id: <dwaring-1203980147140001@blv-lx102-ip28.nwnexus.net>
I found the following in the FAQ about how to split up a string by a delimiter
without spliting on delimiters found inside quotes. This example is for
comma separated fields. I understand most of it but are some things I dont
understand.
push(@new, $+) while $text =~ m{"([^\"\\]*(?:\\.[^\"\\]*)*)",?|
([^,]+),?| ,}gx;
First What are the all the \\ 's doing? Those inside the [] can be removed
and it still works on my test although I figure there is some case I am
not considering. Or is it really just saying (not a " or a \)?
Second why use the (?: operator? and what are the \\. doing in it.
I can strip it down to:
push(@new, $+) while $text =~ m{"(.*?)",?| ([^,]+),?| ,}gx;
and it seems to work but I am afraid that I am missing something here that
I'm not noticing on my testing.
Any ideas?
David
------------------------------
Date: 12 Mar 1998 11:12:23 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: regex problem -some gnarly details
Message-Id: <slrn6gfgon.5ep.Tom.Grydeland@mitra.phys.uit.no>
On 12 Mar 1998 09:45:36 GMT,
David Waring <dwaring@nwsr.com> wrote:
> I can strip it down to:
> push(@new, $+) while $text =~ m{"(.*?)",?| ([^,]+),?| ,}gx;
> and it seems to work but I am afraid that I am missing something here that
> I'm not noticing on my testing.
You're missing escaped string delimiters:
"\"" or '\''
> David
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: 12 Mar 1998 11:09:39 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: splice -- useful uses?
Message-Id: <6e8fpj$5on$1@client2.news.psi.net>
[Cut & pasted from Dejanews, neither of Michaels articles arrived
at my site. PSI.net continues to show to be by far the worst newsserver
I've ever seen in the 10 years I've been around on Usenet. If you
ever get the chance to use PSI.net as your newsfeed, think twice.]
Michael W Peterson wrote:
++ On 12 Mar 1998 02:12:40 GMT, <tchrist@mox.perl.com> wrote:
++ > [courtesy cc of this posting sent to cited authors via email]
++ >
++ >certainly have a situation where a quadratic algorithm (with low overhead)
++ >can beat a linear one (with high overhead). That's what's going on
++ >here -- in the tiny cases, the more native way wins. But keep doubling
++ >your data size and you'll see what I mean. Hers eventually pulls ahead,
++ >as it inevitably must.
++
++ But, as it appears from my results, not because the linear is faster.
++ The native quadratic algorithm continues be optimized to run faster, at
++ the cost of huge memory usage. The quadratic version slows down as the OS
++ thrashes about more and more trying to satisfy the ever-increasing memory
++ demands.
You are not making any sense at all here.
++ >Using just 10,000 iterations so things can get done in my lifetime,
++ >at $N == 32, here's what happened:
++ >
++ > Benchmark: timing 10000 iterations of c, perl...
++ > c: 55 secs (54.59 usr 0.00 sys = 54.59 cpu)
++ > perl: 70 secs (41.60 usr 2.67 sys = 44.27 cpu)
++ >
++
++ When I ran it on my workstation, I got 'Out of Memory!' errors on the
++ quadratic algorithm at $N == 32. Bells went off at this point, so I threw
++ it on a bigger box where I could watch it easier and got the following:
Eh? Something must be majorly wrong. (0 .. 9) x 32 is only an array
of 320 elements. Knuths algorithm is in situ; only needs constant
memory more, and the splice() variant needs linear extra storage.
I ran the algorithms with 50000 elements, in just over 7 Mb.
++ Memory stays at 68M while 'c' runs again and then grows to 234M while
++ 'perl' runs again.
For 640 elements? *boggle*
Abigail
--
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
print+Just (), another (), Perl (), Hacker ();'
------------------------------
Date: Thu, 12 Mar 1998 18:06:40 +0800
From: "Husky" <huskystudio@geocities.com>
Subject: Where can I get the PERL for Windows NT and 95?
Message-Id: <6e8bta$a0k@news.microsoft.com>
If I want to test my perl scripts in IIS on NT or PWS on Win95.
Where can I get the perl software for these OS?
Thanks...
------------------------------
Date: 12 Mar 1998 13:34:39 +0100
From: Casper Kvan Clausen <ckc@dmi.dk>
Subject: Re: Why doesn't ' s/\(/#LPAREN#/gi; ' work? !!
Message-Id: <wvpd8fsjdeo.fsf@pratt.ejoper.dmi.min.dk>
Uri Guttman <uri@sysarch.com> writes:
> Casper Kvan Clausen <ckc@dmi.dk> writes:
> >
> > #!/usr/local/bin/perl -w
> >
> > $text = "fun()";
> > print "Before:\t$text\n";
> > $text=~s/\(/#LPAREN#/gi;
> why this ^
>
> parens have no case! (they lose in court all the time :-)
Hehe. I don't really know why; the substitution wa copied verbatim
from the original poster.
Kvan.
--
-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
----------<ckc@dmi.dk>---------- | unattempted is impossible.'
Lokal 544 |
I do not speak for DMI, just me. | - Lord Mhoram, Son of Variol.
------------------------------
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 2081
**************************************