[19701] in Perl-Users-Digest
Perl-Users Digest, Issue: 1896 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 9 09:05:32 2001
Date: Tue, 9 Oct 2001 06:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1002632709-v10-i1896@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 9 Oct 2001 Volume: 10 Number: 1896
Today's topics:
Re: binmode with "perl -p" doesn't work <nospam-abuse@ilyaz.org>
Comparing files. (Merina)
Re: Comparing files. (Rafael Garcia-Suarez)
Re: Filename case... (Anno Siegel)
Re: hash problem (Clinton A. Pierce)
Re: How do I get the next line? <markus.cl@gmx.de>
I need help with an add and print function (Randall)
Re: Newbie basic question on splitting strings <info@fruiture.de>
Re: Newbie basic question on splitting strings <Thomas@Baetzler.de>
pid list of childs <jens@irs-net.com>
Re: pid list of childs <andrew@erlenstar.demon.co.uk>
Re: Regular expression whole string matching <info@fruiture.de>
Re: Shouldn't /c preserve pos() when matching in list c <david.bouman@nl.xo.com>
Re: Shouldn't /c preserve pos() when matching in list c <joe+usenet@sunstarsys.com>
SIgnaling <plambe@yahoo.com>
Signaling <plambe@yahoo.com>
Re: SIgnaling <Thomas@Baetzler.de>
Re: Skimming an array for non-undef <krahnj@acm.org>
Re: Stop Transversal of a Directory... the dot dot prob (Anno Siegel)
Stupid question... (Andrea)
Re: Stupid question... (Martien Verbruggen)
Re: Stupid question... nobull@mail.com
Re: Text::CSV with Special Chars? <kharrison@icshq.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 9 Oct 2001 11:56:53 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: binmode with "perl -p" doesn't work
Message-Id: <9puom5$30cg$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Abigail
<abigail@foad.org>], who wrote in article <slrn9s4858.pns.abigail@alexandra.xs4all.nl>:
> '' If we have "-g" option, which is a short hand for
> ''
> '' BEGIN { @ARGV = map {glob} @ARGV }
> ''
> '' then the orginal script can still apply
> ''
> '' perl -ge "print @ARGV" *.pl *.txt *.cpp
> ''
> '' thus, helps the portability of scripts on those non-UNIX platforms.
> '' What do you think about it?
>
> Tell me, how should the user *not* do globbing? How do make a program
> that's portable this way? It looks like some platforms "need" the -g,
> while others don't. That's not very portable.
This is how EMX solves it:
a) there is a way to check whether the given argument (in argv) to
the program was ""-ed by the parent;
b) Perl globs the arguments which were not ""-ed;
c) Shells which glob do-"" with the arguments they pass to the kid;
Thus the command-line globbing works transparently *both* from shells
which glob and from those which do not glob.
Ilya
------------------------------
Date: 9 Oct 2001 04:39:44 -0700
From: merigrace@rediffmail.com (Merina)
Subject: Comparing files.
Message-Id: <b860cf59.0110090339.2c541061@posting.google.com>
Hi,
How to compare files using perl? .Is any command has been there?
Thanks,
Merina.
------------------------------
Date: 9 Oct 2001 11:58:11 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Comparing files.
Message-Id: <slrn9s5pi5.5hj.rgarciasuarez@rafael.kazibao.net>
Merina wrote in comp.lang.perl.misc:
} How to compare files using perl? .Is any command has been there?
Can you be a bit more precise ? binary or text files ? Do you want to
know whether the files are different, or do you want a summary of
changes like the diff(1) program does ? (In this case, try either to use
diff, if you have it, or the Algorithm::Diff module).
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: 9 Oct 2001 12:54:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Filename case...
Message-Id: <9pus2b$lsa$1@mamenchi.zrz.TU-Berlin.DE>
According to novastar <novastar@novastar.dtdns.net>:
[Please don't top-post. I moved your reply to below the quoted text
where it belongs]
> "Brian Racer" <brian@brianracer.com> wrote in message
> news:7now7.87578$ME2.13936841@typhoon.kc.rr.com...
> > What I need to do is in certain directories(unix), change every filename
> > that has any upper-case letters to a filename with only lower-case
> > charactors. I am somewhat new to perl (would perl even be the best tool
> for
> > this?) and I just have no idea how to go about doing this. Any help will
> be
> > greatly appreciated!!!
> >
> > Brian Racer
> > brian@brianracer.com
>
> its all yours Brian !
>
> my $directory="f:/work";
> opendir(dir,$directory) || warn "Oh noooo ... $!\n";
That "warn" should be "die", or you should otherwise bypass the code
that tries to use the useless directory handle.
> foreach ( sort ( grep ( /^[^\.]+/ , readdir(dir) ) ) )
Why sort? It may or may not be a good idea to present the file names
in sequence, the OP doesn't say. Routinely sorting directory contents
is a bad idea.
Also, you exclude files whose names begin with a period. We don't know
if this is intended, but if so, "grep !/^\./, ..." would select the
same files.
> {
> next if -d $_;
How do you know directories are not to be lower-cased? Again, we don't
know about this.
> chomp;
There is no need to chomp what comes out of readdir(), actually it
is an error to do so. If a filename ends with "\n", that is part of
the filename (unusual and misguided as it may be) and mustn't be
chomped.
> if ( ! /[A-Z]/ ) {
This is fine, but below you use tr/// to lowercase the filename, so
why not use it here to count upper-case characters: "unless ( tr/A-Z// )".
It would be marginally faster, though a bit obscure.
> print "file $_ is already in lowercase\n" ; next ; }
> print "lets lowercase the file $_\n";
> rename "$directory/$_" , $directory."/".eval{ tr/[A-Z]/[a-z]/; $_ };
Quite generally, you should check the return value of a system call,
especially if it's so crucial to the whole job: 'rename ... or warn
"Can't rename $directory/$_: $!"'. You should also check for the
existence of the target file before renaming. If it exists and is
an ordinary file, rename would overwrite it, so the user should be
asked if he wants that. If it is a directory (or perhaps some other
non-plain file), rename will fail, and the user ought to know.
The way you produce the lower-cased filename is rather convoluted.
First off, "eval" is overkill in "eval { tr/[A-Z]/[a-z]/; $_ }",
"do { tr/[A-Z]/[a-z]/; $_ }" has the same effect, as does
"( tr/[A-Z]/[a-z]/, $_ )", and these don't mask errors you might
want to know about. But then, there is the handy lc() function
that returns the lower-cased value directly, so there's no need
to resort to multi-statement expressions.
Finally, you should learn how to indent you program text to help
readability. Putting it all together, your program should have
looked somewhat like this (untested):
my $directory = "f:/work";
opendir DIR, $directory or die "Can't open directory $directory: $!";
while ( defined ( $_ = readdir DIR) ) {
warn "$_ is already lower-case, skipping\n", next unless /[A-Z]/;
my $new_name = lc;
warn "Not renaming $_ to $new_name, $new_name exists\n", next if
-e "$directory/$new_name";
rename "$directory/$_", $directory/$new_name" or
warn "Can't rename $_ to $new_name: $!";
}
Anno
------------------------------
Date: Tue, 09 Oct 2001 12:05:05 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: hash problem
Message-Id: <RJBw7.156722$K6.75020297@news2>
In article <3BC274E7.6E191955@earthlink.net>,
Benjamin Goldberg <goldbb2@earthlink.net> writes:
> He'll still have to use IPC stuff for synchronization due to cacheing.
Not at all! With careful use of locks, and tie-untie'ing the hash
at appropriate times it's not necessary to get into IPC at all. I've done
this quite a few times to write routines that were portable between
OS's without a hint of caching problems.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Tue, 9 Oct 2001 12:12:17 +0200
From: "Markus Dehmann" <markus.cl@gmx.de>
Subject: Re: How do I get the next line?
Message-Id: <9puimk$le0dt$1@ID-101658.news.dfncis.de>
"blongk" <khirv@hotmail.com> wrote in message
news:3bc2a930$1_2@news.tm.net.my...
> I have 2 files. File A contains inactive user id's and file B contains all
> the id's (including inactive users) and their email addresses. File A has
> its contents in this form:
>
> id5
> id9
Oh, if you don't need to use perl use rather GREP. It's just a single line:
grep -A1 -f inactive.txt all_ids.txt
where inactive.txt contains your
id5
id9
...
and all_ids.txt all id's with e-mails on separated lines. grep -A1 says it
should write out the found id with the following line of all_ids.txt. The
following line is the e-mail address. And -f tells grep in which file you
have the regular expressions/patterns that it shall find.
------------------------------
Date: 9 Oct 2001 05:40:53 -0700
From: rscripter@hotmail.com (Randall)
Subject: I need help with an add and print function
Message-Id: <eebe201.0110090440.3149d89c@posting.google.com>
I am using the following code it adds and prints fine
It adds values from 2 sets of variables and prints them
The 2 sets are a and b
I need to add the totals for a and b sets and print those also
can someone help me?
Below is the portion of the script I need help with:
# Add the a Responses together
print "Your Score equals \n";
print $FORM{a1}+$FORM{a2}+$FORM{a3}+$FORM{a4}
print "</P>\n";
# Add the b Responses together
print "Your Other Score equals \n";
print $FORM{b1}+$FORM{b2}+$FORM{b3}+$FORM{b4}+$FORM{b5}+$FORM{b6}+$FORM{b7};
print "</P>\n";
How can I add the 2 scores together and print that total also?
------------------------------
Date: Tue, 9 Oct 2001 11:59:49 +0200
From: "fruiture" <info@fruiture.de>
Subject: Re: Newbie basic question on splitting strings
Message-Id: <9puhvt$vo7$06$1@news.t-online.com>
"Richard" <webmaster@ukparents.co.uk> wrote:
> Hi
> I am a VB programmer who has inherited a series of complex Perl code
> pages, and so far I have muddled my way through with everyhting I want
> to do, but I have come unstuck with what I am sure i a really simple
> query. I'd be really grateful if someone could help me with it. I
> have a string which always has the same format: numbers(up to 4 as
> low as 1) followed directly (ie no spaces) by some text of an unknown
> length.
>
> eg: 123Wibble, 2332Wobble, 12Foobars etc
>
> Basically I need to access in a string for use in a PRINT statement
> the numbers, so that I would have for example (as output):
>
> The numbers are: 123, or The Numbers are 2332 etc.
>
> I can't tell what on earth I should be using to do this, I feel its
> likely it should be a split and RegExp but I can't get my head round
> the syntax. Can anyone tell me the answer.
$_ = "123Wibble";
easiest method would be:
$numbers = (/^(\d+)/)[0]
but you have to be sure to have the numbers _before_ the letters.
You can also filter each group of numbers:
@groups = /(\d+)/g;
but to be really sure read:
% perldoc perlre
--
require Time::HiRes;my @m=split(/8/,55.52.56.49.49.55.56.49.49.53);push
@m,map{($_%2)?$_-1:$_+1} map ord($_),split//,'u!`onuids!Qdsm!i`bjds';
unshift @m,43 for(0..@m);for(0..@m){print map chr($_),@m[0..(@m/2-1)];
push @m,shift @m;print "\b"x(@m/2);Time::HiRes::usleep(0246*0xA**3);}
------------------------------
Date: Tue, 09 Oct 2001 12:14:52 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Newbie basic question on splitting strings
Message-Id: <ddj5sto68m2mbuss7ae5am1645i9qorqiq@4ax.com>
On 9 Oct 2001 02:37:26 -0700, webmaster@ukparents.co.uk (Richard) wrote:
[...]
> I
>have a string which always has the same format: numbers(up to 4 as
>low as 1) followed directly (ie no spaces) by some text of an unknown
>length.
if( $string =~ m/^(\d+)/ ){
print "The number is $1\n";
} else {
print "Sorry, no number at start of string\n".
}
HTH,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Tue, 09 Oct 2001 13:16:12 +0200
From: Jens Luedicke <jens@irs-net.com>
Subject: pid list of childs
Message-Id: <9pume4$71p$07$1@news.t-online.com>
hi ...
how can I fetch a list of pids of all fork'd child processes?
I want to hangup all running childs without hanging up the
parent.
kill HUP => -$$;
didn't worked like I wanted...
--
Jens Luedicke
jens@irs-net.com
------------------------------
Date: 09 Oct 2001 12:44:11 +0100
From: Andrew Gierth <andrew@erlenstar.demon.co.uk>
Subject: Re: pid list of childs
Message-Id: <87elodjawk.fsf@erlenstar.demon.co.uk>
>>>>> "Jens" == Jens Luedicke <jens@irs-net.com> writes:
Jens> hi ...
Jens> how can I fetch a list of pids of all fork'd child processes?
you have to create such a list yourself.
--
Andrew.
------------------------------
Date: Tue, 9 Oct 2001 12:06:35 +0200
From: "fruiture" <info@fruiture.de>
Subject: Re: Regular expression whole string matching
Message-Id: <9puick$6en$05$1@news.t-online.com>
"Markus Dehmann" <markus.cl@gmx.de> wrote:
> "JJ" <javatasse@yahoo.com> wrote in message
> news:b2e92ea9.0110090131.4cf46f6f@posting.google.com...
>
> > How do I check if a regular expression matches the whole string, like
> > checking an email address.
> > Thanks
>
> You should use ^ to mark the beginning and $ to mark the end of the string.
> Like this (not tested):
>
> $mail = "me@me.com";
$mail = 'me@me.com'; #to be preferred imho
OR
$mail = "me\@me.com";
> if( $mail =~ m/^[^@]+\@[^\.]+\.[a-z]+$/ ){
> print "vaild";
> }
>
> The string must begin with the not-@ and must end with [a-z]. There is
> nothing allowed to be in front of this or behind this.
but now nasty german users could write:
äüö@whatever.com
which is somehow not noticed but a bad address
m/^[\w\.\-]+\@[\w\-]+\.\w{2,4}$/
but i dont' expect to be right with this...
--
require Time::HiRes;my @m=split(/8/,55.52.56.49.49.55.56.49.49.53);push
@m,map{($_%2)?$_-1:$_+1} map ord($_),split//,'u!`onuids!Qdsm!i`bjds';
unshift @m,43 for(0..@m);for(0..@m){print map chr($_),@m[0..(@m/2-1)];
push @m,shift @m;print "\b"x(@m/2);Time::HiRes::usleep(0246*0xA**3);}
------------------------------
Date: Tue, 09 Oct 2001 14:15:00 +0200
From: David Bouman <david.bouman@nl.xo.com>
Subject: Re: Shouldn't /c preserve pos() when matching in list context? (Was: Re: What good is "\G" ...)
Message-Id: <3BC2EA44.6B1237AE@nl.xo.com>
Joe Schaefer wrote:
> David Bouman <david.bouman@nl.xo.com> writes:
>
>> perl5 -le '$_="12345a"; 1 while m/\d/cg; print pos'
>> outputs 5 as expected, whereas something like:
>> perl5 -le '$_="12345a"; @d = m/\d/cg; print pos'
>> doesn't. In fact pos() is undefined just as if /c was never there..
>>
>> It's same in both perl 5.005_03 & 5.6.0 but it doesn't make sense
>> to me.
>
> Me neither, but AFAICT perlop doesn't discuss the effects of /gc
> outside of scalar context.
I see what you mean: Only while discussing /g in scalar context is
the use of /c explained. Still, that's not the same as stating that /c
has no meaning in list context. And merely reading:
c Do not reset search position on a failed match when /g is in effect
from perlop (as I did), the idea of being able to use pos() after you
did a match in list context made perfect sense to me. And it still does.
> ISTR a related thread appeared recently on p5p. I think it was here:
>
> http://archive.develooper.com/perl5-porters@perl.org/msg63860.html
Skimmed through it, but about the only matter related to /c that I'm
able to distill is that it has no effect on s///. But that's a
somewhat different beast isn't it?
--
D.
------------------------------
Date: 09 Oct 2001 06:11:21 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Shouldn't /c preserve pos() when matching in list context? (Was: Re: What good is "\G" ...)
Message-Id: <m3ofnhf7hy.fsf@mumonkan.sunstarsys.com>
David Bouman <david.bouman@nl.xo.com> writes:
> perl5 -le '$_="12345a"; 1 while m/\d/cg; print pos'
>
> outputs 5 as expected, whereas something like:
>
> perl5 -le '$_="12345a"; @d = m/\d/cg; print pos'
>
> doesn't. In fact pos() is undefined just as if /c was never there..
>
> It's same in both perl 5.005_03 & 5.6.0 but it doesn't make sense
> to me.
Me neither, but AFAICT perlop doesn't discuss the effects of /gc outside
of scalar context.
ISTR a related thread appeared recently on p5p. I think it was here:
http://archive.develooper.com/perl5-porters@perl.org/msg63860.html
--
Joe Schaefer "It is better to be feared than loved, if you cannot be both."
-- Niccolo Machiavelli
------------------------------
Date: Tue, 9 Oct 2001 13:18:30 +0200
From: "plambe" <plambe@yahoo.com>
Subject: SIgnaling
Message-Id: <3bc2dca2$1@epflnews.epfl.ch>
Hi all,
I have the following problem:
I work under WinNT40 and I want to use Signals to glue together a script
using external executables. $
I have an executable (hvite.exe) which I want to run from perl script and
then at given moment to send a signal to it from the perl code.
This executable is configured 5 seconds after running to wait for a given
signal (lets say INT). When it receives the signal it should start recording
live audio then on receiving a second signal should stop recording.
My idea was to open the executable like pipe for writing. Then sleep for 5
secs and signal it. Then another 2 sec and signal it.
My code is:
$|=1;
sub send {
kill INT => $pid;
}
$pid=open(WRI, "|hvite -C config3 -H hmm19/macros -H hmm19/hmmdefs -i
recount.mlf -w wdnet -p 0.0 -s 5.0 dict monophones1") or die "Couldn't fork:
$!\n";
sleep 5;
&send();
sleep 2;
&send();
close(WRI) or die "Couldn't close: $!\n";
I doesn't seem to work properly. What happens is that the child is killed
and that way does not start to record.
I know that I can trigger INT with Ctr+C so I tried another aproach. Again I
opened like a pipe for writing my executable and with print command I sent
Ctr+C (\03) to STDIN as I suppose of hvite.exe. It again does not work. It
seems as it sends this symbol after quitting hvite.exe.
My second code is:
$|=1;
$pid=open(WRI, "|hvite -C config3 -H hmm19/macros -H hmm19/hmmdefs -i
recount.mlf -w wdnet -p 0.0 -s 5.0 dict monophones1") or die "Couldn't fork:
$!\n";
sleep 5;
print WRI "\03";
sleep 2;
print WRI "\03";
close(WRI) or die "Couldn't close: $!\n";
OK. So how can I understand under NT if the signal is delivered properly?
And where did my Ctr+C print on STDIN of hvite.exe disappear in the second
example?
I will be very grateful on any answer or other idea on the problem.
Thanks in advance and excuse my lack of appropriate knowledge, as I started
with perl 1 month ago.
BR
Plambeto
------------------------------
Date: Tue, 9 Oct 2001 13:31:58 +0200
From: "plambe" <plambe@yahoo.com>
Subject: Signaling
Message-Id: <3bc2dfca$1@epflnews.epfl.ch>
Hi all,
I have the following problem:
I work under WinNT40 and I want to use Signals to glue together a script
using external executables. $
I have an executable (hvite.exe) which I want to run from perl script and
then at given moment to send a signal to it from the perl code.
This executable is configured 5 seconds after running to wait for a given
signal (lets say INT). When it receives the signal it should start recording
live audio then on receiving a second signal should stop recording.
My idea was to open the executable like pipe for writing. Then sleep for 5
secs and signal it. Then another 2 sec and signal it.
My code is:
$|=1;
sub send {
kill INT => $pid;
}
$pid=open(WRI, "|hvite -C config3 -H hmm19/macros -H hmm19/hmmdefs -i
recount.mlf -w wdnet -p 0.0 -s 5.0 dict monophones1") or die "Couldn't fork:
$!\n";
sleep 5;
&send();
sleep 2;
&send();
close(WRI) or die "Couldn't close: $!\n";
I doesn't seem to work properly. What happens is that the child is killed
and that way does not start to record.
I know that I can trigger INT with Ctr+C so I tried another aproach. Again I
opened like a pipe for writing my executable and with print command I sent
Ctr+C (\03) to STDIN as I suppose of hvite.exe. It again does not work. It
seems as it sends this symbol after quitting hvite.exe.
My second code is:
$|=1;
$pid=open(WRI, "|hvite -C config3 -H hmm19/macros -H hmm19/hmmdefs -i
recount.mlf -w wdnet -p 0.0 -s 5.0 dict monophones1") or die "Couldn't fork:
$!\n";
sleep 5;
print WRI "\03";
sleep 2;
print WRI "\03";
close(WRI) or die "Couldn't close: $!\n";
OK. So how can I understand under NT if the signal is delivered properly?
And where did my Ctr+C print on STDIN of hvite.exe disappear in the second
example?
I will be very grateful on any answer or other idea on the problem.
Thanks in advance and excuse my lack of appropriate knowledge, as I started
with perl 1 month ago.
BR
Plambeto
------------------------------
Date: Tue, 09 Oct 2001 13:37:46 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: SIgnaling
Message-Id: <gbo5st8nf7kdtfres9etfi3adgjjkkjp4v@4ax.com>
On Tue, 9 Oct 2001, "plambe" <plambe@yahoo.com> wrote:
>I have the following problem:
>I work under WinNT40 and I want to use Signals to glue together a script
>using external executables. $
perldoc perlwin32, "Bugs and Caveats"
HTH,
--
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Tue, 09 Oct 2001 10:57:13 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Skimming an array for non-undef
Message-Id: <3BC2D88E.6014D439@acm.org>
Derek Fountain wrote:
>
> I have a long array which has a number of values in the first n elements,
> and from there on all the values are undef. What would be the most
> efficient way of finding the index of the last element of the array which
> contains a value?
>
> I seem to have come up with any number of really clunky ways to do it.
> What's the "perl solution"?
$ perl
-le'@x=(1,2,3,4,5,undef,undef,undef);$y=(grep{defined}@x)-1;print$y'
4
John
--
use Perl;
program
fulfillment
------------------------------
Date: 9 Oct 2001 11:42:03 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Stop Transversal of a Directory... the dot dot problem
Message-Id: <9punqb$fv7$1@mamenchi.zrz.TU-Berlin.DE>
According to Bill Unruh <unruh@physics.ubc.ca>:
> In <3BC10741.44644D5C@home.com> "What A Man !" <whataman@home.com> writes:
>
> ]How can I stop directory transversal with perl? I want to list all of my
> ]files and directories off of a sub-directory named "wkdir". and delete
> ]any files or directories that begin with ".." or "~" (since the shell
> ]can expand a "~"). The purpose is to stop people from writing in my main
> ]directory or other directories; and only allow them to write in "wkdir".
> ]This is running on a FreeBSD server.
>
>
> I think you are confused. .. is NOT a filename. It is a shorthand for
> the parent of
> the current directory. You canot delete it.
Under Unix, .. most certainly *is* a filename. It is a hard link
to the directory's parent directory, just like . is a hard link to
itself. If you cannot delete them, this is not because they are not
files, but because the rm command, or rather the underlying unlink()
routine knows about these names and refuses to delete them. Under
older Unix systems you could delete them under some circumstances.
Anno
------------------------------
Date: 9 Oct 2001 03:23:48 -0700
From: rubash@navigatenewmedia.com (Andrea)
Subject: Stupid question...
Message-Id: <16986fd1.0110090223.679ed5c6@posting.google.com>
I have my site set up to use the standard form mail from my hosting
company (dellhost). Everything works, because the variable names were
listed in the sample HTML document... (it's not the same formmail as
the one at Matt's Script Archive)
However, I can't access the script.. and the standard redirect = URL
has no effect. So... instead of my nice little thank you page, users
get an ugly white page with black text.
I have no idea how to tell this script that I haven't even seen where
to direct users when they have submitted an e-mail. How do I find out
what variable they are using so I can tell the script to direct my
users there?
Andrea
------------------------------
Date: Tue, 9 Oct 2001 21:13:11 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Stupid question...
Message-Id: <slrn9s5mu6.448.mgjv@martien.heliotrope.home>
On 9 Oct 2001 03:23:48 -0700,
Andrea <rubash@navigatenewmedia.com> wrote:
> I have my site set up to use the standard form mail from my hosting
> company (dellhost). Everything works, because the variable names were
> listed in the sample HTML document... (it's not the same formmail as
> the one at Matt's Script Archive)
>
> However, I can't access the script.. and the standard redirect = URL
> has no effect. So... instead of my nice little thank you page, users
> get an ugly white page with black text.
>
> I have no idea how to tell this script that I haven't even seen where
> to direct users when they have submitted an e-mail. How do I find out
> what variable they are using so I can tell the script to direct my
> users there?
I think you'll have to ask your hosting company.
It is very unlikely that anyone here knows anything about that program,
since the only thing you can tell us about it is that
1) it is 'the standard' from your 'hosting company'.
2) It is not Matt's Script Archive's formmail (thank heavens)
3) You can't 'access' it
4) Users get an ugly white page
That sounds like some 451,234 (on last count) different formmail
programs would fit that description.
The _only_ people who can help you are the people you pay to run this
thing.
Martien
--
Martien Verbruggen |
Interactive Media Division | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd. | crops where there ain't no crops.
NSW, Australia |
------------------------------
Date: 09 Oct 2001 12:24:36 +0100
From: nobull@mail.com
Subject: Re: Stupid question...
Message-Id: <u9bsjhm4y3.fsf@wcl-l.bham.ac.uk>
rubash@navigatenewmedia.com (Andrea) writes:
> Newsgroups: comp.lang.perl.misc
> Subject: Re: Stupid question...
Yep, sure is.
[ snip: How can I tell what input is expected by a program in some
unknown language and the source of which I can't examine? ]
Answer: ask someone who knows something a about the program in question.
Now, did you have a Perl question?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 9 Oct 2001 07:52:28 -0400
From: Keith Harrison <kharrison@icshq.com>
Subject: Re: Text::CSV with Special Chars?
Message-Id: <MPG.162caf027c3e7d1298968e@msunews.cl.msu.edu>
Have you tried Text-CSV_XS?
> It seems that the $csv->combine() method will not work if your array
> has any special characters. For example, my test with a field as
> 'Vitória' will not work.
>
> Is there a reason why this module has to fail for special chars? What
> alternatives are there?
>
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1896
***************************************