[16081] in Perl-Users-Digest
Perl-Users Digest, Issue: 3493 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 27 18:05:58 2000
Date: Tue, 27 Jun 2000 15:05:41 -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: <962143540-v9-i3493@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 27 Jun 2000 Volume: 9 Number: 3493
Today's topics:
Re: # of occurrances in a list (M.J.T. Guy)
$/ behaviour awkster@my-deja.com
Re: $/ behaviour (Tim)
\ and single quote <-newbie_member@newsguy.com>
Re: \ and single quote <care227@attglobal.net>
Re: \ and single quote <-newbie_member@newsguy.com>
Re: binary and regular expressions (Tad McClellan)
Re: binary and regular expressions (Abigail)
Re: binary and regular expressions (Tad McClellan)
Re: Changing case in a file! <flavell@mail.cern.ch>
Re: Changing case in a file! (Jerome O'Neil)
Re: Changing case in a file! <flavell@mail.cern.ch>
Do you have an email script??? <landim2NOlaSPAM@brhs.com.br.invalid>
Re: Embedding images into Perl script (Abigail)
Re: hash and translation (Abigail)
Re: hash and translation <uri@sysarch.com>
Help With Reg Exp. <skpurcell@hotmail.com>
How to maniputlate windows' filenames with perl? (Steve A. Taylor)
Re: i'm stuck! help? <trevor@trevorsky.com>
Re: Image size change by Perl (Abigail)
Insecure dependency when trying to unlink files? <blavender@spk.usace.army.mil>
Re: Insecure dependency when trying to unlink files? <care227@attglobal.net>
Re: Insecure dependency when trying to unlink files? (Tad McClellan)
Re: Matching an octal <news@webneeds.com>
Re: Matching an octal (Abigail)
Need P/T MWF 8-5 Perl, mSQL, ASP, Cold Fusion Programme cheena88@my-deja.com
Re: Need P/T MWF 8-5 Perl, mSQL, ASP, Cold Fusion Progr cheena88@my-deja.com
Re: Need P/T MWF 8-5 Perl, mSQL, ASP, Cold Fusion Progr (Tad McClellan)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Jun 2000 19:31:14 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: # of occurrances in a list
Message-Id: <8jave2$h4v$1@pegasus.csx.cam.ac.uk>
Colby Hansen <cghansen@micron.com> wrote:
>I'm using the following to find the number of unique items in a list:
>
>my %unique = ();
>@unique{@list} = (undef) x scalar @list;
That 'scalar' is unnecessary - the RH operand of 'x' is already in
context. In fact, the whole RHS isn't needed - the usual paradigm is
@unique{@list} = ();
which does the same as your code.
>my $uniquecount = scalar keys %unique;
>
>This works great! Now I'm looking for a slick way to determine how many
>occurrances of one particular item there are. Thanks!
I'd answer your real question as well, but others have beaten me to it.
:-)
Mike Guy
------------------------------
Date: Tue, 27 Jun 2000 19:51:01 GMT
From: awkster@my-deja.com
Subject: $/ behaviour
Message-Id: <8jb0is$rf4$1@nnrp1.deja.com>
I am getting inconsistent behaviour from $/.
My code (shown below) parses a file and creates a temp file
and an array both of which hold the same data. The date is a
group of records seperated periodically by a blank line ("").
LIKE THIS:
N6964 S1VC
-95.00 245.00
-105.00 245.00
-110.00 255.00
-105.00 255.00
-40.00 255.00
-57.50 235.00
-77.50 237.50
-77.50 240.00
-67.50 235.00
-67.50 240.00
-57.50 240.00
-52.50 240.00
-52.50 255.00
-65.00 255.00
N6969 ------
-40.00 247.50
-50.00 247.50
-57.50 227.50
-77.50 227.50
-77.50 225.00
-67.50 227.50
-67.50 225.00
-57.50 225.00
-50.00 225.00
-50.00 222.50
When I set $/ = ""; and open a file handle, it sees everything
between blank lines as a single record (which is what I want)
but when I do a foreach on my array it doesn't seem to honor
the $/ statement.
Can someone point me in the right direction? (please not out the door)
Any help is appreciated.
Thank You and regards
George
open (POINTS, "points") || die "couldnt open points file for reading: $!
\n";
open (TEMP, ">temp") || die "couldnt open temp file for writing: $!\n";
while(<POINTS>){
if($_ =~ /Net Name:/){
s/ +/ /g; s/\$//g;
@net_toks = split(/ /, $_);
$nets = "$net_toks[1] $net_toks[4]";
push(@arr, "");
push(@arr, $nets);
}elsif($_ =~ /V\$/ && $_ =~ /\,/){
s/ +/ /g; s/\,/ /g; s/\)//g; s/\(//g;
@vec_toks = split(/ /, $_);
$vecs = "$vec_toks[2] $vec_toks[3]";
push(@arr, $vecs);
print TEMP "$vecs\n";
}
}
close(POINTS);
close(TEMP);
open (TEMP, "temp") || die "couldnt open temp file for reading: $!\n";
$/="";
$cnt = 0;
### The following works fine ######
while(<TEMP>){
++$cnt;
$len = length($_);
print "$cnt $len $_\n";
}
close(TEMP);
### The following ignores $/ ######
$cnt = 0;
foreach $arr(@arr){
++$cnt;
$len = length($arr);
print "$cnt $len $arr\n";
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 27 Jun 2000 21:52:01 GMT
From: SPAM+indigo@dimensional.com (Tim)
Subject: Re: $/ behaviour
Message-Id: <8F60A42F8indigodimcom@166.93.207.145>
awkster@my-deja.com wrote in <8jb0is$rf4$1@nnrp1.deja.com>:
>When I set $/ = ""; and open a file handle, it sees everything
>between blank lines as a single record (which is what I want)
>but when I do a foreach on my array it doesn't seem to honor
>the $/ statement.
>
>Can someone point me in the right direction? (please not out the door)
>Any help is appreciated.
$/ only applies to file handles. for (@array) will always step through
an array one element at a time.
You code will have to be a little more careful how it is constructing
your array. In your first while loop, each push statement adds a
new element to your array. You would be better off building a single
string with all the information you want in each element, then pushing
once at the end.
-T
------------------------------
Date: 27 Jun 2000 10:44:42 -0700
From: -newbie <-newbie_member@newsguy.com>
Subject: \ and single quote
Message-Id: <8jap6a$2okq@drn.newsguy.com>
Hi gurus:
I have trouble to understand this one:
'three \\\'s: "\\\\\"';
I understood the first part: the first \ escapes the second \; the third \
escapes the single ' right before the letter "s"; but I am trying to confirm the
second part: the first \ right after " escapes the second \; the third \ escapes
the forth \ and last \ right before " stay it is because of the single quote; am
I right?
TIA
-gl
------------------------------
Date: Tue, 27 Jun 2000 15:04:00 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: \ and single quote
Message-Id: <3958FAA0.A6EC0B3F@attglobal.net>
-newbie wrote:
>
> Hi gurus:
>
> I have trouble to understand this one:
>
> 'three \\\'s: "\\\\\"';
>
> I understood the first part: the first \ escapes the second \; the third \
> escapes the single ' right before the letter "s"; but I am trying to confirm the
> second part: the first \ right after " escapes the second \; the third \ escapes
> the forth \ and last \ right before " stay it is because of the single quote; am
> I right?
It is good manners not to start a new thread to discuss the same matter
that you were previously discussing in a prior thread.
Please keep that in mind.
------------------------------
Date: 27 Jun 2000 13:42:00 -0700
From: -newbie <-newbie_member@newsguy.com>
Subject: Re: \ and single quote
Message-Id: <8jb3io$e1d@drn.newsguy.com>
Sorry if this upsets you, but it was the first message ever I sent to this
group. Did anyone discussed this before?
TIA
-gl
In article <3958FAA0.A6EC0B3F@attglobal.net>, Drew says...
>
>-newbie wrote:
>>
>> Hi gurus:
>>
>> I have trouble to understand this one:
>>
>> 'three \\\'s: "\\\\\"';
>>
>> I understood the first part: the first \ escapes the second \; the third \
>>escapes the single ' right before the letter "s"; but I am trying to confirm the
>>second part: the first \ right after " escapes the second \; the third \ escapes
>>the forth \ and last \ right before " stay it is because of the single quote; am
>> I right?
>
>It is good manners not to start a new thread to discuss the same matter
>that you were previously discussing in a prior thread.
>
>Please keep that in mind.
------------------------------
Date: Tue, 27 Jun 2000 13:08:47 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: binary and regular expressions
Message-Id: <slrn8lhnsv.aav.tadmc@magna.metronet.com>
On Tue, 27 Jun 2000 16:07:49 GMT, doglovers@rocketmail.com <doglovers@rocketmail.com> wrote:
>Been thinking about this for days, but can't find the answer anywhere
>
>if 109 eq ord("m") is true, and
^^
eq compares *strings*, not numbers.
use == to compare numbers.
>if "m" = chr(109) is true, then
You cannot assign to a constant.
= is assignment
== tests for numeric equality
>then why do all of the following evaluate to false?
>"m" =~ / chr(109) /
match if:
a space character, followed by
a 'c' character, followed by
a 'h' character, followed by
a 'r' character, followed by
a '1' character, followed by
a '0' character, followed by
a '9' character, followed by
a space character.
i.e. that pattern matches 8 literal characters.
>"m" =~ /"chr(109) /
still 8 characters, but the first character is different
>"m" =~ /(chr(109))/
six characters, leaves off the first and last one
>"m" =~/{chr(109)}/
back to 8 characters, now first and last must be curly brace characters.
The PATTERN is a double-quotish *string*, not Perl code.
You can put the result of an EXPR into a scalar, and then
interpolate the scalar into the double-quotish pattern:
my $ch = chr(109);
print "matched\n" if /$ch/;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 27 Jun 2000 14:43:50 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: binary and regular expressions
Message-Id: <slrn8lhuh1.ka1.abigail@alexandra.delanet.com>
doglovers@rocketmail.com (doglovers@rocketmail.com) wrote on MMCDXCII
September MCMXCIII in <URL:news:3958cfdd.53660066@news.erols.com>:
@@ Been thinking about this for days, but can't find the answer anywhere
@@
@@ if 109 eq ord("m") is true, and
Use == to compare numbers, eq for strings.
@@ if "m" = chr(109) is true, then
That isn't true, that's a syntax error. Perhaps you mean:
109 == ord "m";
"m" eq chr 109;
@@ then why do all of the following evaluate to false?
@@ "m" =~ / chr(109) /
Because "m" does not start with a space.
@@ "m" =~ /"chr(109) /
Because "m" does not start with a double quote.
@@ "m" =~ /(chr(109))/
Because "m" does not start with a left parenthesis.
@@ "m" =~/{chr(109)}/
Because "m" does not start with a left brace.
@@ I am trying to do pattern matching on a binary string. I have searched
@@ deja, and the perl docs, and don't seem to have the answer. Anyone
@@ know where to look for complete information on how to manipuate,
@@ search through, and match against binary strings?
Perl doesn't know the difference between "binary string"s and
non-"binary string"s. I'm not sure I do. A string is a string, and
nothing more than a string. Just a sequence of characters.
For your specific problem, it looks like you want to do:
"m" =~ /\x6D/;
Abigail
--
BEGIN {require overload; overload::constant (q => sub {print $_[1]});}
"Just "; "another "; "Perl "; "Hacker\n";
------------------------------
Date: Tue, 27 Jun 2000 14:23:42 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: binary and regular expressions
Message-Id: <slrn8lhs9e.aha.tadmc@magna.metronet.com>
On 27 Jun 2000 14:43:50 EDT, Abigail <abigail@delanet.com> wrote:
[ snip "why don't these match?" ]
>@@ "m" =~ /(chr(109))/
>
>Because "m" does not start with a left parenthesis.
Errr, better make that:
Because "m" does not start with a 'c'.
:-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 27 Jun 2000 20:47:54 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Changing case in a file!
Message-Id: <Pine.GHP.4.21.0006272027190.26942-100000@hpplus03.cern.ch>
Sorry about all this, but I couldn't leave it uncommented.
On Tue, 27 Jun 2000, Jerome O'Neil wrote:
> > Folks who want the whole story should read the RFCs.
>
> Right again. But nothing in the RFCs says URLs are case sensitive.
Upper and lower case letters are different characters, after all.
_Where_ they are to be understood as equivalent to each other, the
RFCs say so explicitly.
For example, RFC2396 section 6 makes the point explicitly that host
names are "actually case insensitive", the implication surely being
that other parts of a URL would be case-sensitive unless otherwise
stated. We know that some servers do in fact deliver different
resources when URLpaths differ only in regard to their case. Thus, a
client which treated such URLs as equivalent would prevent access to
some resources. Since the client cannot know whether a server is
going to return the same or a different resource, it must treat the
two URLs as distinct.
> In fact, most of the literature says the exact opposite.
But it states that opposite in the exceptional cases. This "proves
the rule", i.e that URLs are case-sensitive except where stated
otherwise.
btw, to be totally pedantic, the scheme part is specified to be
lower-case. Clients are encouraged "for resilience" (I take that to
mean "error fixup") to treat upper-case scheme as equivalent.
But as I already said, it's the URLpath that I'm bleating on about.
Now I'll copy Tom Phoenix's example and set f'ups, OK? Email is
also feasible, if anyone feels strongly enough.
------------------------------
Date: Tue, 27 Jun 2000 21:58:01 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Changing case in a file!
Message-Id: <Jr965.255$J4.160019@news.uswest.net>
"Alan J. Flavell" <flavell@mail.cern.ch> elucidates:
>
> Sorry about all this, but I couldn't leave it uncommented.
>
> On Tue, 27 Jun 2000, Jerome O'Neil wrote:
>
>> > Folks who want the whole story should read the RFCs.
>>
> For example, RFC2396 section 6 makes the point explicitly that host
> names are "actually case insensitive", the implication surely being
> that other parts of a URL would be case-sensitive unless otherwise
> stated. We know that some servers do in fact deliver different
> resources when URLpaths differ only in regard to their case.
The only thing that can be implied by the RFC's exclusion is that
a path may be case sensitive.
Servers have the option of delivering a 300 response of a URL
maps to more than one resource.
The path section is case sensitive if the resource
is a file, and the file system is case sensitive. Even then
a server may do what it wishes with a particular URL, and how
it resolves it to a resource. Apache's mod_speling, for example.
> Thus, a client which treated such URLs as equivalent would prevent
> access to some resources.
A client shouldn't be preventing access to any resources. The server
might, though. Case sensitivity should be used bt a client to
compare two URLs for equality, with the exceptions of the scheme
and host parts. Note that's not a MUST.
>> In fact, most of the literature says the exact opposite.
>
> But it states that opposite in the exceptional cases. This "proves
> the rule", i.e that URLs are case-sensitive except where stated
> otherwise.
Those aren't the exceptional cases, as the default case is *never*
specified as case sensitive.
> btw, to be totally pedantic,
I love pedantry. :)
> Now I'll copy Tom Phoenix's example and set f'ups, OK?
OK, but I don't know if it's on topic anymore in c.l.p.moderated than it is
here.
------------------------------
Date: Tue, 27 Jun 2000 22:48:05 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Changing case in a file!
Message-Id: <Pine.GHP.4.21.0006272231591.26942-100000@hpplus03.cern.ch>
On Tue, 27 Jun 2000, Jerome O'Neil wrote:
> The path section is case sensitive if the resource
> is a file, and the file system is case sensitive.
Nononono, this is a defined client-server interface. The client is
_not_ supposed to know anything about the internals of the server: as
far as the client is concerned, all URLpaths are case sensitive.
> Even then
> a server may do what it wishes with a particular URL, and how
> it resolves it to a resource. Apache's mod_speling, for example.
100% agreed. What the server does internally is its own affair. The
client only gets to know about it by means of protocol-defined
transactions, and those have nothing to do with the internals of the
server. There is no protocol for a server to say "I'm a
case-insensitive server". Thus, clients must assume that all servers
are case-sensitive, otherwise there would be loss of functionality:
> > Thus, a client which treated such URLs as equivalent would prevent
> > access to some resources.
>
> A client shouldn't be preventing access to any resources.
Exactly my point. As far as the client is concerned, as far as the
network transaction is concerned, the URLpath _is_ case sensitive.
> > the rule", i.e that URLs are case-sensitive except where stated
> > otherwise.
>
> Those aren't the exceptional cases, as the default case is *never*
> specified as case sensitive.
Upper and lower case letters are different characters. If the RFCs
wanted to make them equivalent, they would say so. They don't say so.
For me that's Q.E.D.
> > Now I'll copy Tom Phoenix's example and set f'ups, OK?
>
> OK, but I don't know if it's on topic anymore in c.l.p.moderated than it is
> here.
I'm sure that was precisely the point that Tom was making!!!
But now we've gone and undone his good work again.
See you over at the c.i.w.* hierarchy, or I'm done now. (f'ups to
poster this time).
Oh, there is one specific exception. If a server sends a status-301
(i.e permanent) redirection, to a new URL that differs only in its
case from the one that was requested, then clearly the client then
knows what's what, about this one URL. But that does not allow any
deductions to be made about other URLs on that server.
all the best
------------------------------
Date: Tue, 27 Jun 2000 14:21:28 -0700
From: Landim <landim2NOlaSPAM@brhs.com.br.invalid>
Subject: Do you have an email script???
Message-Id: <06c9b2b6.2331f1f6@usw-ex0109-068.remarq.com>
Hi...
I need a CGI script that receives a form and send an email,
like yahoo mail...
If you have one that works (i've tried others), please send
it to
landim2@brhs.com.br
Thanks
* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful
------------------------------
Date: 27 Jun 2000 14:53:44 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Embedding images into Perl script
Message-Id: <slrn8lhv3k.ka1.abigail@alexandra.delanet.com>
Vladimir Rybintsev (vlad@soft-tronik.ru) wrote on MMCDXCII September
MCMXCIII in <URL:news:8ja4om$22d5$1@storm.comstar.ru>:
%% I find some Perl script, which generates HTML page with some
%% images.
%% Something like:
%% $fG=<<'fC';
%% M1TE&.#=A$@`/`+,``/_2+N.[*<>D)*J,'XYU&G)>%55&$#DO"QT8!@```/__
%% M_____________________R'Y!`$```D`+``````2``\```1F,,E)C3DT4T0"
%% M$(B6'0)@`H6$I*-WHE+!4NZ+D>&$E)]1$@D$P)`A``*%4`>!&`1RDD/@B2`2
%% MF*594"`P-(D(Z:<(P`@"!XX'O1'<7B<B118<P,L9CJIF`HYR.R=L&E`)!29N
%% %(@D1`#L`
%%
%% fC
%% ...
%% ...
%%
%% <img src=$fG>
%% ...
%% So in variable $fG is encoded image. But what kind of encoding is used?
%% Does'nt seems like uuencode or Base64.
%% I never meet before with such methods.
%% May be, sombody knows?
And your Perl question is?
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: 27 Jun 2000 14:09:50 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: hash and translation
Message-Id: <slrn8lhsha.ka1.abigail@alexandra.delanet.com>
Clinton A. Pierce (clintp@geeksalad.org) wrote on MMCDXCII September
MCMXCIII in <URL:news:wf265.11598$fR2.143422@news1.rdc1.mi.home.com>:
<>
<> Or a bit more compact, and concise as well:
<>
<> $text=~s/\b(\W+)\b/exists($tr{$1})?$tr{$1}:$1/ge;
<> print $text;
As was pointed out before, the \W has to be \w. But what are those \b's
doing there? Afraid + isn't greedy enough in your version of Perl? ;-)
Also, since the exercise replaces words with words, and therefore it's
likely that one way assume words are never replaced with "", 0, or undef:
$text=~s/\w+/$tr{$&}||$&/ge; # Only works if all replacements are true.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
------------------------------
Date: Tue, 27 Jun 2000 20:24:39 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: hash and translation
Message-Id: <x7k8faub21.fsf@home.sysarch.com>
>>>>> "AQ" == Ala Qumsieh <aqumsieh@hyperchip.com> writes:
AQ> my $y = undef;
AQ> $x{$y} = 'YES';
AQ> print $x{$y} if exists $x{$y};
AQ> Use of uninitialized value at - line 3.
AQ> Use of uninitialized value at - line 3.
AQ> Use of uninitialized value at - line 4.
AQ> You are wrong. Both key and value can be undefined. Whether or not that
AQ> is useful is a totally different subject.
the key cannot be undefined as a hash provides a string context for the
key (implied quotes) so undef is converted to '' before being used as a
key. in your example all 3 times $y is used it generates a warning
during the conversion.
try that again and look at keys %x. it will have a '' key but not an
undef key. the hash algorithm needs a string for a key and undef is not
a string.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 27 Jun 2000 16:52:16 -0500
From: "spurcell" <skpurcell@hotmail.com>
Subject: Help With Reg Exp.
Message-Id: <3959225e$0$6021@wodc7nh1.news.uu.net>
Hello,
Could someone step me through this please. I understand all the components,
but when they are all placed together, I am getting lost. This comes from
Tom C.s class. I really need help understanding what the regular expression
is doing and how the line is getting pushed to the array.
Thanks
Scott
sub lines_here {
my $string = shift;
my @lines = $string =~ /\S.*\S/gm; # \s space, tab or newline
return @lines;
}
@thickness = lines_here <<EOF;
thin and crispy
thick and doughy
regular
EOF
------------------------------
Date: Tue, 27 Jun 2000 20:05:59 GMT
From: an400@freenet.carleton.ca (Steve A. Taylor)
Subject: How to maniputlate windows' filenames with perl?
Message-Id: <3959054a.10323883@news.ncf.carleton.ca>
If I've missed the Perldocs that explain, let me know
Question: How can I, without using
dos commands, convert
short filenames to long filenames
Example, from short to long
c:\html-p~2 gz
c:\HTML-Parser-3_08_tar.gz
Discovering that quoted input is accepted
helps and allows parsing -- but only after the shell's
"dir/s/b %1" is used (these four lines are one
wrapped line):
dir/s/b "%1"|perl -MFile::Basename
-ne "chomp;s/_/./g;
($n,$p,$s)=fileparse( $_,'.gz' );
print \"$n $p $s\n\";"
This turns c:\html-p~2 gz into
HTML-Parser-3.08.tar c:\ .gz
But can perl do it without dir/s/b?
------------------------------
Date: Tue, 27 Jun 2000 13:42:20 -0700
From: "Trevor Sky Garside" <trevor@trevorsky.com>
Subject: Re: i'm stuck! help?
Message-Id: <mi865.386$Hk1.78466@nntp3.onemain.com>
<nobody@nowhere.com> wrote in message news:39589141.85273001@nowhere.com...
| I hava a program that fills a numer of arrays (all going well); then I
| want to use every element of that array in a regular expression to match
| it to a word; but, immediately after the if that matches the 2 words,
| the array is completely empty...! I can't figure out why. Here's the
| piece of code:
|
| #searh for context-sensitive names
| for($i=0; $i<@c_roles_entry; $i++) {
| $c_role = $c_roles_entry[$i];
| if(($samples[$word_nr -1] =~ /($c_role)/) ||
| ($samples[$word_nr + 1] =~ /($c_role)/)) {
| &mark_name($word_nr, $word_nr +
| &is_uc_series($word_nr) - 1, $c_roles_type[$i]);
| $found = 1;
| }
| }
|
| $c_role is the i-th element of the array, and thats the one in the
| regexp; a word from the array @samples is matched against it...
First off, please put the nature of your problem in the subject - you're
more likely to get a response that way.
Second, I think we need to Perlize your code a bit - your complex for loop
has a very simple construct in Perl - foreach:
foreach $c_role (@c_roles_entry) {
Ok, now for the if clause. Since I have no idea what @samples is, or what
$word_nr is, I'm just going to throw in placeholders for those elements.
I'm also curious why you are using parens in your RegEx:
if (SOMETHING =~ /$c_role/ or SOMETHHING_ELSE =~ /$c_role/) {
The next bit is a bit confusing - you're calling some sub you have -
mark_name - with parameters, so the & is not necessary:
mark_name(PARAMETERS);
Ok, here's the whole thing:
foreach $c_role (@c_roles_entry) {
if (SOMETHING =~ /$c_role/ or SOMETHHING_ELSE =~ /$c_role/) {
mark_name(PARAMETERS);
$found = 1;
}
}
As far as your original question is concerned, I don't see anything that
could be removing array items. Perhaps it is located somewhere in your
subroutine.
I hope that cleaning up the code a bit helps you to find the error. Good
luck!
--Trevor
------------------------------
Date: 27 Jun 2000 14:55:49 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Image size change by Perl
Message-Id: <slrn8lhv7i.ka1.abigail@alexandra.delanet.com>
Lucas Tsoi (lucas@cplhk.com) wrote on MMCDXCII September MCMXCIII in
<URL:news:8ja3pf$fsr1@imsp212.netvigator.com>:
// Hi
// I am to ask that could I change the image size by Perl,
// i.e. from high pixel values to low pixel values?
In the same way as you would do in C, Java or Python.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: Tue, 27 Jun 2000 18:05:55 GMT
From: Brian Lavender <blavender@spk.usace.army.mil>
Subject: Insecure dependency when trying to unlink files?
Message-Id: <8jaqdk$m3r$1@nnrp1.deja.com>
I have a script (happens to run within a CGI) where I want to remove
temp files which hold session information which have not been accessed
within the last five minutes. I am running under -T flag. When I run the
following script, I get the following error. What can I do to fix this?
brian
[Tue Jun 27 09:34:54 2000] correspond.pl: Insecure dependency in unlink
while running with -T switch
at /home/www/cgi-bin/correspond.pl line 804.
#!/usr/local/bin/perl -Tw
use strict;
opendir TMPDIR, "/tmp" or die "Serious dainbrammage: $!";
my @alltmpfiles = grep /\.cor\.db$/, readdir TMPDIR;
close TMPDIR;
foreach (@alltmpfiles) {
$_ = "/tmp/" . $_;
my ($atime, $mtime, $ctime) = (stat $_)[8,9,10];
# $atime - Last access time
# $mtime - Last modify time
# $ctime - Inode change time
my $amins = (time - $atime ) / 60;
if ($amins > 5) {
# Session has been unmodified longer than five minutes
# remove it
print "Remove: ",$_,"\n";
unlink($_) or die "Couldn't unlink $_ : $!";
}
}
--
Brian E. Lavender
US Army Corps of Engineers -- Programmer / Systems Analyst
Sacramento, CA (916) 557-6623
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 27 Jun 2000 14:45:31 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Insecure dependency when trying to unlink files?
Message-Id: <3958F64B.583BDD66@attglobal.net>
Brian Lavender wrote:
>
>
> opendir TMPDIR, "/tmp" or die "Serious dainbrammage: $!";
> my @alltmpfiles = grep /\.cor\.db$/, readdir TMPDIR;
> close TMPDIR;
> foreach (@alltmpfiles) {
> $_ = "/tmp/" . $_;
> my ($atime, $mtime, $ctime) = (stat $_)[8,9,10];
> # $atime - Last access time
> # $mtime - Last modify time
> # $ctime - Inode change time
> my $amins = (time - $atime ) / 60;
> if ($amins > 5) {
> # Session has been unmodified longer than five minutes
> # remove it
> print "Remove: ",$_,"\n";
> unlink($_) or die "Couldn't unlink $_ : $!";
> }
> }
>
From the perlsec documentation:
"You may not use data derived from outside your program to affect
something else outside your program--at least, not by accident.
All command line arguments, environment variables, locale information
(see the perllocale manpage), results of certain system calls
(readdir, readlink, the gecos field of getpw* calls), and all file
input are marked as ``tainted''. Tainted data may not be used directly
or indirectly in any command that invokes a sub-shell, nor in any
command that modifies files, directories, or processes. "
------------------------------
Date: Tue, 27 Jun 2000 14:32:19 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Insecure dependency when trying to unlink files?
Message-Id: <slrn8lhspj.aha.tadmc@magna.metronet.com>
On Tue, 27 Jun 2000 18:05:55 GMT, Brian Lavender <blavender@spk.usace.army.mil> wrote:
>I have a script (happens to run within a CGI) where I want to remove
>temp files which hold session information which have not been accessed
>within the last five minutes. I am running under -T flag. When I run the
>following script, I get the following error. What can I do to fix this?
Untaint the data before using it with unlink().
($_ comes from outside (from the filesystem) of your program,
it is tainted.
)
>[Tue Jun 27 09:34:54 2000] correspond.pl: Insecure dependency in unlink
>while running with -T switch
>at /home/www/cgi-bin/correspond.pl line 804.
>
> my @alltmpfiles = grep /\.cor\.db$/, readdir TMPDIR;
[snip]
> foreach (@alltmpfiles) {
[snip]
> unlink($_) or die "Couldn't unlink $_ : $!";
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 27 Jun 2000 12:39:37 -0600
From: "Dan Manion" <news@webneeds.com>
Subject: Re: Matching an octal
Message-Id: <qC665.51$%%5.1469@news.uswest.net>
Or this will work:
if ("m" =~ chr(109) ) {
print "passed\n";
}
see perldoc -f chr
<doglovers@rocketmail.com> wrote in message
news:3958afeb.45481516@news.erols.com...
> I have been working on this for days, it's embarrassing.
>
> The letter m is ascii 109. Why does this keep evaluating to false?
>
> "m" =~ /\0109/;
>
> Thanks
------------------------------
Date: 27 Jun 2000 14:58:33 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Matching an octal
Message-Id: <slrn8lhvcn.ka1.abigail@alexandra.delanet.com>
doglovers@rocketmail.com (doglovers@rocketmail.com) wrote on MMCDXCII
September MCMXCIII in <URL:news:3958afeb.45481516@news.erols.com>:
## I have been working on this for days, it's embarrassing.
##
## The letter m is ascii 109. Why does this keep evaluating to false?
##
## "m" =~ /\0109/;
Because "m" doesn't contain a 9. Or "\010" for that matter.
Hint: 9 > 8.
Abigail
--
BEGIN {require overload; overload::constant (q => sub {print $_[1]});}
"Just "; "another "; "Perl "; "Hacker\n";
------------------------------
Date: Tue, 27 Jun 2000 18:06:16 GMT
From: cheena88@my-deja.com
Subject: Need P/T MWF 8-5 Perl, mSQL, ASP, Cold Fusion Programmer
Message-Id: <8jaqe9$m46$1@nnrp1.deja.com>
Our company is in need of a backend web programmer to create custom
applications for our client sites that we design and maintain. We work
with both Unix and NT environments. Only serious individuals need
reply. The right individual would start immediately.
Please fax resume to the following:
(714) 674-1645
Attention: Interactive Services Dept.
Thanks.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 27 Jun 2000 18:09:19 GMT
From: cheena88@my-deja.com
Subject: Re: Need P/T MWF 8-5 Perl, mSQL, ASP, Cold Fusion Programmer
Message-Id: <8jaqjv$md4$1@nnrp1.deja.com>
Company location is North Orange County area of California.
In article <8jaqe9$m46$1@nnrp1.deja.com>,
cheena88@my-deja.com wrote:
> Our company is in need of a backend web programmer to create custom
> applications for our client sites that we design and maintain. We
work
> with both Unix and NT environments. Only serious individuals need
> reply. The right individual would start immediately.
>
> Please fax resume to the following:
>
> (714) 674-1645
> Attention: Interactive Services Dept.
>
> Thanks.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 27 Jun 2000 14:27:58 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Need P/T MWF 8-5 Perl, mSQL, ASP, Cold Fusion Programmer
Message-Id: <slrn8lhshe.aha.tadmc@magna.metronet.com>
On Tue, 27 Jun 2000 18:06:16 GMT, cheena88@my-deja.com <cheena88@my-deja.com> wrote:
>Our company is in need of a backend
Looks like your company already has a backend.
This newsgroup is for the discussion of the Perl programming language.
Newsgroups where job ads are welcome have "jobs" in their name.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3493
**************************************