[19714] in Perl-Users-Digest
Perl-Users Digest, Issue: 1909 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 11 06:05:53 2001
Date: Thu, 11 Oct 2001 03:05:07 -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: <1002794707-v10-i1909@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 11 Oct 2001 Volume: 10 Number: 1909
Today's topics:
&sub(@array1,@array2) ;-( ?? <angenent@kabelfoon.nl>
Re: &sub(@array1,@array2) ;-( ?? (Martien Verbruggen)
Re: &sub(@array1,@array2) ;-( ?? <JPFauvelle@Colt-Telecom.fr>
2 arrays in sub problems <angenent@kabelfoon.nl>
Re: 2 arrays in sub problems (Martien Verbruggen)
> or gt? <s.warhurst@rl.ac.uk>
Re: CGI.pm :: OO or not? <rob_13@excite.com>
Re: Checking Network Access <MrsKensingtonUK@yahoo.co.uk>
Re: Checking Network Access <MrsKensingtonUK@yahoo.co.uk>
Re: Hashes as class members <ecifreo@austin.rr.com>
Re: Hashes as class members <jeff@vpservices.com>
Re: how to execute a unix program with a cgi script news@roaima.demon.co.uk
Pattern Matching & Saving Value of Original Variable <roym@pdq.net>
Re: Pattern Matching & Saving Value of Original Variabl (Garry Williams)
Re: PATTERN Matching: Substitution problem (Anno Siegel)
Re: predefined @- and @+ or what happens here? (Abigail)
print to STDOUT immediatly <harald.meier@rts.at>
Re: print to STDOUT immediatly (Martien Verbruggen)
Re: Regular Expressions <davidhilseenews@yahoo.com>
Re: Regular Expressions <davidhilseenews@yahoo.com>
Re: sort of array containing strings doesn't work (Abigail)
Re: split into filename and extension (need help before (Ian Boreham)
String::CRC32 gives wrong result for file (Oleksii Krykun)
Re: String::CRC32 gives wrong result for file <krahnj@acm.org>
Translate command rare behaviour? (Fernando Nieto)
Re: who said this? <pumalee2000@hotmail.com>
Re: YOU ARE ALL GAY! <geoffrey@bigpond.net.au>
Re: zipping files? <JPFauvelle@Colt-Telecom.fr>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 10 Oct 2001 23:03:52 +0200
From: "GOGAR" <angenent@kabelfoon.nl>
Subject: &sub(@array1,@array2) ;-( ??
Message-Id: <9q2d1b$ac0$1@news.kabelfoon.nl>
Hi i'm making a few subroutines..
In one of them i intended to pass 2 arrays into the sub with various
values..
inside the sub i did "my(@array1,@array2)=@_;" but all the values end
up in the first array (@array1)
i've been trying a few things like defining it as a 2d array.. but i just
can't get it to work..
i have a feeling it's very simple.. but i just don't know how.. so i
thought i'd ask here
thanks guys ;-)
Chris
------------------------------
Date: Thu, 11 Oct 2001 06:37:18 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: &sub(@array1,@array2) ;-( ??
Message-Id: <slrn9safgs.l88.mgjv@verbruggen.comdyn.com.au>
On Wed, 10 Oct 2001 23:03:52 +0200,
GOGAR <angenent@kabelfoon.nl> wrote:
> Hi i'm making a few subroutines..
> In one of them i intended to pass 2 arrays into the sub with various
> values..
See the Perl FAQ, section 7, question:
How can I pass/return a {Function, FileHandle, Array,
Hash, Method, Regex}?
and the perlsub documentation. Do not read the section "Passing Symbol Table
Entries (typeglobs)", but instead read "Pass by Reference".
Martien
P.S. You can access the documentation with the perldoc command on most
platforms, and Shuck on Macintoshes.
$ perldoc perldoc
for more information
--
Martien Verbruggen |
Interactive Media Division | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd. | password?
NSW, Australia |
------------------------------
Date: Thu, 11 Oct 2001 11:52:10 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: &sub(@array1,@array2) ;-( ??
Message-Id: <ooqastc3o37s5hucq1sdse3qriqr3ooo78@4ax.com>
Le Wed, 10 Oct 2001 23:03:52 +0200, "GOGAR" <angenent@kabelfoon.nl> écrit:
my(@data1) = qw/one two three/;
my(@data2) = qw/1 2 3/;
work(\@data1,\@data2);
sub work {
my($ref1,$ref2) = @_;
my(@list1) = @$ref1;
my(@list2) = @$ref2;
# ...
}
Jean-Philippe Fauvelle
>Hi i'm making a few subroutines..
>In one of them i intended to pass 2 arrays into the sub with various
>values..
>inside the sub i did "my(@array1,@array2)=@_;" but all the values end
>up in the first array (@array1)
>i've been trying a few things like defining it as a 2d array.. but i just
>can't get it to work..
> i have a feeling it's very simple.. but i just don't know how.. so i
>thought i'd ask here
>
>thanks guys ;-)
>
>Chris
>
>
>
------------------------------
Date: Wed, 10 Oct 2001 23:07:58 +0200
From: "GOGAR" <angenent@kabelfoon.nl>
Subject: 2 arrays in sub problems
Message-Id: <9q2d90$b2m$1@news.kabelfoon.nl>
.. i just posted this message but it didn't come up.. so incase this is the
2nd posting sorry lol
Hi i'm making a few subroutines..
In one of them i intended to pass 2 arrays into the sub with various
values..
inside the sub i did "my(@array1,@array2)=@_;" but all the values end
up in the first array (@array1)
i've been trying a few things like defining it as a 2d array.. but i just
can't get it to work..
i have a feeling it's very simple.. but i just don't know how.. so i
thought i'd ask here
thanks guys ;-)
Chris
------------------------------
Date: Thu, 11 Oct 2001 06:38:14 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: 2 arrays in sub problems
Message-Id: <slrn9safil.l88.mgjv@verbruggen.comdyn.com.au>
On Wed, 10 Oct 2001 23:07:58 +0200,
GOGAR <angenent@kabelfoon.nl> wrote:
> .. i just posted this message but it didn't come up.. so incase this is the
> 2nd posting sorry lol
Usenet is not instantaneous. For future reference: Please wait a
while before posting again. See the followup to your original post for
an answer.
Martien
--
Martien Verbruggen |
Interactive Media Division | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: Thu, 11 Oct 2001 10:56:43 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: > or gt?
Message-Id: <9q3qcs$k34@newton.cc.rl.ac.uk>
I'm having trouble with operators atm.
If I have a table of data like this (there are actually more columns, hence
my use of a table array):
@lists = (['list1','1'],
['list2','12'],
['list2','0'],
['list2','0'],
['list2','23'],
['list2','120']);
I then have a bit of code that generates stats based on the values in column
1. Results are output to column 1 of another table array - @results:
for($r = 0;$r <= $#lists;$r++)
{
if($lists[$r][1] = 0){$results[0][1]++;} #
Lists with 0 reviews
elsif($lists[$r][1] >= 1 and $lists[$r][1] <= 10){$results[1][1]++;} #
Lists with 1-10 reviews
elsif($lists[$r][1] >= 11 and $lists[$r][1] <= 100){$results[2][1]++;} #
Lists with 11-100 reviews
elsif($lists[$r][1] > 100){$results[3][1]++;} #
Lists with >100 reviews
if($lists[$r][1] > $results[4][1]){$results[4][1] = $lists[$r][1] ;} #
maximum reviews for list
}
Now the problem is this:
If I print out the results of the above code as follows:
foreach(@results){print "$_->[1]\n";}
I effectively get nothing. However if I change the line
if($lists[$r][1] = 0){$results[0][1]++;}
to:
if($lists[$r][1] eq 0){$results[0][1]++;}
then I get
2
1
2
1
120
which is correct... Now from what I've read on the matter, Perl usually
converts numbers in string form to numerical form to make it easy on the
programmer. What I don't understand is why this does not work for the 0 and
yet is fine for sybsequent lines. Can anyone clarify it please?
Thanks
---------¦
Bigus @ work
¦----------
------------------------------
Date: Thu, 11 Oct 2001 04:21:53 GMT
From: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: CGI.pm :: OO or not?
Message-Id: <Xns913739FB1B0Drock13com@64.8.1.227>
Lou Moran <news:h086st8fjldp7lm0qjtvvf43quhn12d46l@4ax.com>:
> --I just started using CGI.pm and I have noticed that while
> perldoc CGI recomends OO funtionality but I rarely see it in
> use.
> --So if --*YOU*-- were using CGI.pm to accomplish some task
> would you write it utilizing the OO approach or the function
> based approach?
I started using the CGI module with the OO approach so continue to
do so.
For me, a newbie Perl user, it keeps it very clear where I'm using
a function from the CGI and where I'm using my own function.
--
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/
------------------------------
Date: Thu, 11 Oct 2001 10:21:13 +0100
From: "MrsKensingtonUK" <MrsKensingtonUK@yahoo.co.uk>
Subject: Re: Checking Network Access
Message-Id: <1002792065.1169.0.nnrp-08.3e31b93c@news.demon.co.uk>
yeah i saw that and fixed it but it still doesn't work!
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:01f9stgnrio5jahcgsvuafee8634c708lq@4ax.com...
> MrsKensingtonUK wrote:
>
> >Any other ideas why i would be getting Access is Denied??
>
> In case you still haven't seen my other follow-up: it's the "\e".
>
> --
> Bart.
------------------------------
Date: Thu, 11 Oct 2001 10:27:47 +0100
From: "MrsKensingtonUK" <MrsKensingtonUK@yahoo.co.uk>
Subject: Re: Checking Network Access
Message-Id: <1002792460.1324.0.nnrp-08.3e31b93c@news.demon.co.uk>
<nobull@mail.com> wrote in message news:u9669nl994.fsf@wcl-l.bham.ac.uk...
> This now has nothing to do with Perl - if access is denied this is
> independant of the language you happen to use.
OK i'll have a look at this null session share and do a check of all of my
settings
> Jeopardy-quoting is considered bad manners.
oops sorry!
>Good manners on Usenet requires that one quotes just enough
> of the message to which one is responding to put one's responses in
> context and then puts the response _after_ the quote - as I am doing here.
OK wont be doing that any more!
> This of course has nothing whatever to do with Perl - the same
> netiquette applies throughout Usenet but jeopardy-quoting and other
> poor manners are less tolerated in "serious" newsgroups such as
> comp.lang.*
some people take this newsgroup thing far to seriously!! (i'm currently
trying to improve my usenet sense of "humour")
------------------------------
Date: Thu, 11 Oct 2001 01:44:00 GMT
From: "Eric Cifreo" <ecifreo@austin.rr.com>
Subject: Re: Hashes as class members
Message-Id: <AP6x7.62207$pN2.19522460@typhoon.austin.rr.com>
> You don't mean from a class, you mean from a method. And actually the
> fact that it's a method rather than a simple subroutine is not
> relevant. This is probably why you are looking in the wrong place.
Sigh. Yes. A method. Or, a method defined in a class.
> Subroutines in Perl return return either a list or a scalar (or void)
depending
> on if the call to the subroutine appears in a list context or a scalar
> context (or a void contest). A subroutine cannot directly return an array
or
> hash. If you want a subroutine to to return a data structure it must
> return a reference to a structure.
>
> > My problem is this: when I try to get the hash out of the Office
object,
> > it's mangled somehow. If in the external script, I say:
> >
> > my %userHash = $office->users();
>
> Did you read the explaination of the warning that was generated by
> that line? What you didn't get a warning? You climb without ropes
> and then when you fall you cry out for help from the very same people
> who are forever advising novice climbers to use ropes! Excuse us if
> we treat you with some exasparation/sarcasm etc.
Trust me, after reading the posts on this newsgroup, I expected nothing more
than flames and sarcasm. Thank you for not disappointing me. And, of
course, you are excused O mighty one.
And no. I didn't get a warning. I've been doing this on a Win32 system
and didn't think puttting #!/usr/bin/perl -w would accomplish anything. And
'use warnings' didn't provide anything either. Your statement above about
what Perl subroutines perhaps return was the most valuable thing you have
said in your post.
> > my %userHash = $office->users();
> > foreach ($key (keys %userHash)) { # where the keys are the User's names
> > print("Key is $key.\n");
> > }
>
> That code does not compile. Please post real code.
That should have been:
my %userHash = $office->users();
foreach $key (keys (%userHash)) { # where the keys are the Users' names
print("Key is $key.\n");
}
Forgive me. Guilty of typing rather than cut-n-paste.
There. That compiles, but it's still wrong. That simply puts the returned
hash into my new hash. I found the clue in some other newsgroup posting
almost immediately after posting my initial question (of course).
The answer to my question involves figuring out how to dereference the
scalar object ref that gets returned from the method. As Jean-Phillipe's
earlier post pointed out, simply doing a %$userHash would have allowed me to
get the keys out of the hash correctly.
Thank you for your help.
Eric Cifreo
Austin, TX
------------------------------
Date: Wed, 10 Oct 2001 19:03:35 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Hashes as class members
Message-Id: <3BC4FDF7.6DFCB0C3@vpservices.com>
> And no. I didn't get a warning. I've been doing this on a Win32 system
> and didn't think puttting #!/usr/bin/perl -w would accomplish anything.
The switches on the shebang line behave the same on windoze as they do
anywhere else. The path to perl might be ignored (depending on how the
script is invoked) but the switches are still in force.
--
Jeff
------------------------------
Date: 11 Oct 2001 10:55:46 GMT
From: news@roaima.demon.co.uk
Subject: Re: how to execute a unix program with a cgi script
Message-Id: <3bc56ca2@news.netserv.net>
I commented:
> I do hope that $borrowedMovie, $allParams[3], and $dateFormat aren't
> obtained directly from a web form.
JHWB <johan@basberg.comnospam> replied:
> But I think it is; please if you have the time visit the page
> http://www.stud.ifi.uio.no/~johanba/dvd/
Go and read about CGI security. NOW. This snippet of code permits anyone
who knows about it to execute arbitrary commands on your server.
Chris
------------------------------
Date: Wed, 10 Oct 2001 20:19:30 -0500
From: "Roy" <roym@pdq.net>
Subject: Pattern Matching & Saving Value of Original Variable
Message-Id: <F7ADD8638263627B.5CE5390933122FA7.FD40E97C6D0A1F2D@lp.airnews.net>
I'm parsing an ascii file and doing a pattern match like this:
if ($line =~ /MatchSomeText/i)
{ @words = split(' ', $line);
some other instructions..... }
How do I do pattern matching while preserving the original value of $line?
I'm looking for various "headings" in the text file and then jumping to
various subroutines where each section of the file is parsed, but I can't
always count on what the value of $line will be after a pattern match. It
seems like if I do something on $line within the sub where the pattern match
occurred then the original value is still there. But if a go to a
subroutine outside of where the pattern match occurred, then $line is
changed. No, I'm not using local variables, so...
Does anyone know or have a better idea for this?
Thanks!
roy
------------------------------
Date: Thu, 11 Oct 2001 02:36:10 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Pattern Matching & Saving Value of Original Variable
Message-Id: <slrn9sa1cq.gc2.garry@zfw.zvolve.net>
On Wed, 10 Oct 2001 20:19:30 -0500, Roy <roym@pdq.net> wrote:
> I'm parsing an ascii file and doing a pattern match like this:
>
> if ($line =~ /MatchSomeText/i)
> { @words = split(' ', $line);
> some other instructions..... }
>
> How do I do pattern matching while preserving the original value of $line?
I don't understand the question. The match operator does *not* affect
the value of the variable it matches.
$ perl -Mstrict -wle '
my $line = "line 1 matchsometext";
if ($line =~ /MatchSomeText/i) {
my @words = split(" ", $line);
local $, = ":";
print @words;
}
print $line;
$line = "line 2 matchnotext";
if ($line =~ /MatchSomeText/i) {
my @words = split(" ", $line);
local $, = ":";
print @words;
}
print $line;
'
line:1:matchsometext
line 1 matchsometext
line 2 matchnotext
$
> I'm looking for various "headings" in the text file and then jumping to
> various subroutines where each section of the file is parsed, but I can't
> always count on what the value of $line will be after a pattern match.
Then you must be doing something other than merely binding it to a
match operator. I think you need to show us the code. (Minimal case
that exhibits the behavior you think is unexpected.)
> It
> seems like if I do something on $line within the sub where the pattern match
^^^^^^^^^^^^^^^^^^^^^
Does this account for the change you are observing?
> occurred then the original value is still there. But if a go to a
> subroutine outside of where the pattern match occurred, then $line is
> changed. No, I'm not using local variables, so...
>
> Does anyone know or have a better idea for this?
Not without code.
--
Garry Williams
------------------------------
Date: 11 Oct 2001 09:10:16 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: PATTERN Matching: Substitution problem
Message-Id: <9q3nlo$l9t$1@mamenchi.zrz.TU-Berlin.DE>
According to <nobull@mail.com>:
> "Jean-Philippe AVELANGE" <Jean-Philippe.AVELANGE@cgey.com> writes:
>
> > i've been looking for a solution to the ???? below, that would (without
> > having to change $PATTERN variable) replace values according to that
> > PATTERN, by the new $v1 and $v2 in my $_ variable to give the final result
> > displayed at the end. Something like: "Replace the $1 and $2 by $v1 and
> > $v2".
>
> > $PATTERN = "ABCD\d+-\d+-EFGH(\d+)-(\d+)";
> > $_ = "ABCD1-2EFGH3-4";
> > ( $v1, $v2 ) = /$PATTERN/;
> > $v1++;
> > $v2++;
> > ????
> > print;
>
> This can easily be done on 5.6 but not before since you need @+ and
> @-.
>
> Firstly, of course, you must adjust the code so that the pattern
> actually matches the string!
>
> Secondly having variables called $v1 and $v2 is a fairly sure sign you
> should have been using an array.
>
> Thirdly whenever you have a // where your code relies on the
> assumption that it will always match it is a good habit to make this
> assumption explicit by appending 'or die'.
>
> Fourthly you should get into the habit of automatically using
> my().
>
> Fifthly it is conventional in Perl to use lowercase variable
> names except in special cases.
>
> my $pattern = 'ABCD\d+-\d+EFGH(\d+)-(\d+)';
> $_ = "ABCD1-2EFGH3-4";
> my @v = /$pattern/ or die;
> $_++ for @v;
> for my $i (reverse 1 .. @v) {
> substr($_, $-[$i], $+[$i] - $-[$i]) = $v[$i-1];
> }
> print;
As given, the problem can be re-stated as "increment the third and
all following numbers in a string" (i.e., the third and fourth). That
suggests a slightly different approach:
/(\d+)/g;
/(\d+)/g;
substr( $_, pos $_) =~ s/(\d+)/$1 + 1/eg;
Depending on the variability of the data, this may work as is, it
may need refinement or may not be applicable at all.
Anno
------------------------------
Date: 11 Oct 2001 06:39:07 GMT
From: abigail@foad.org (Abigail)
Subject: Re: predefined @- and @+ or what happens here?
Message-Id: <slrn9safjo.tpt.abigail@alexandra.xs4all.nl>
Christoph Bergmann (info@java.seite.net) wrote on MMCMLXII September
MCMXCIII in <URL:news:102b94bd.0110101118.251ec030@posting.google.com>:
-: Hi...
-:
-: Does anybody know why this gives an error:
-:
-: my($put,%put);
-: $put=\%put;
-: $$put{bla}="-";
-: $$put{bla}[0]="whatever";
-:
-: It prints out:
-:
-: Modification of a read-only value attempted at xxxxx.pl line xx.
-:
-: I know the example looks a bit weird, but thats how I found it: Perl
-: uses $put{bla} as a symbolic reference with "-" and so it comes to:
-: $-[0]. It only happens with "-" or "+", so it looks like there are
-: predefined arrays like @- and @+. But I've never heard of them, do
-: they exist ?
What did 'man perlvar' tell you?
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'
------------------------------
Date: Thu, 11 Oct 2001 05:31:38 GMT
From: "Harald Meier" <harald.meier@rts.at>
Subject: print to STDOUT immediatly
Message-Id: <_8ax7.12616$XG6.638756@news.chello.at>
hi all,
---
#!/usr/bin/perl
print "abc";
sleep 3;
---
prints the output after 3 seconds after starting the script.
I am using SuSE Linux 7.1, Perl 5.6.0.
how do I have to modify it to print it immediatly?
(I want to use the print, not syswrite/...)
thanks for help,
Harald
------------------------------
Date: Thu, 11 Oct 2001 05:37:25 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: print to STDOUT immediatly
Message-Id: <slrn9sac0k.l88.mgjv@verbruggen.comdyn.com.au>
On Thu, 11 Oct 2001 05:31:38 GMT,
Harald Meier <harald.meier@rts.at> wrote:
>
> #!/usr/bin/perl
> print "abc";
> sleep 3;
>
> prints the output after 3 seconds after starting the script.
> I am using SuSE Linux 7.1, Perl 5.6.0.
>
> how do I have to modify it to print it immediatly?
End it with a newline, or check the perlvar documentation. Look for
the $| or $OUTPUT_AUTOFLUSH variable.
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | values of Beta will give rise to dom!
NSW, Australia |
------------------------------
Date: Thu, 11 Oct 2001 01:48:08 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: Regular Expressions
Message-Id: <sT6x7.142384$Xz1.20177371@news1.rdc1.md.home.com>
"Ben" <ben@benhaworth.com> wrote in message
news:9q2a0h$4il$1@sparkie.st-andrews.ac.uk...
> Does any one know how to search a string from say four different letters
but
> with them in any order? e.g. I want to look for the letters e,l,t and n
in
> the Unix words file. They all need to be in the word but can be in any
> order.
>
> Thanks,
> Ben.
>
>
perl -ne 'tr/l// && tr/n// && tr/t// && tr/e// && print' words.txt
--
David Hilsee
------------------------------
Date: Thu, 11 Oct 2001 01:50:56 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: Regular Expressions
Message-Id: <4W6x7.142429$Xz1.20182676@news1.rdc1.md.home.com>
"David Hilsee" <davidhilseenews@yahoo.com> wrote in message
news:sT6x7.142384$Xz1.20177371@news1.rdc1.md.home.com...
>
> "Ben" <ben@benhaworth.com> wrote in message
> news:9q2a0h$4il$1@sparkie.st-andrews.ac.uk...
> > Does any one know how to search a string from say four different letters
> but
> > with them in any order? e.g. I want to look for the letters e,l,t and n
> in
> > the Unix words file. They all need to be in the word but can be in any
> > order.
> >
> > Thanks,
> > Ben.
> >
> >
>
> perl -ne 'tr/l// && tr/n// && tr/t// && tr/e// && print' words.txt
>
> --
> David Hilsee
>
>
Of course, you might as well use index at this point. It'd be more verbose,
but it would probably be faster.
--
David Hilsee
------------------------------
Date: 11 Oct 2001 06:36:03 GMT
From: abigail@foad.org (Abigail)
Subject: Re: sort of array containing strings doesn't work
Message-Id: <slrn9safe0.tpt.abigail@alexandra.xs4all.nl>
Daniel Berger (djberg96@hotmail.com) wrote on MMCMLXII September MCMXCIII
in <URL:news:q55x7.8956$CN5.572805@typhoon.mn.mediaone.net>:
-:
-: "Abigail" <abigail@foad.org> wrote in message
-: news:slrn9s91vd.soe.abigail@alexandra.xs4all.nl...
-: > Ralph Jocham (rjocham72@netscape.net) wrote on MMCMLXI September MCMXCIII
-: > in <URL:news:ee8febb5.0110091426.1b3fa8f5@posting.google.com>:
-: > @@ Hello,
-: > @@ I am doing some kind of dependency analyisis for java packages.
-: > @@ As a result I get a list of all imports from all classes. Duplicates
-: > @@ are already removed.
-: > @@ Then I sort the array with : sort @uniq;
-: > @@ But the result is not sorted. Is there a size limite. The array
-: contains
-: > @@ about 2000 lines??
-: >
-: > The only size limit is your system. You can't sort a huge array if
-: > you don't have the RAM for it. But if Perl runs out of memory, it'll
-: > tell you.
-: >
-: > You probably have made a mistake.
-: >
-: >
-: >
-: > Abigail
-:
-: On the other hand, Abigail, I've seen cases where values simply dropped off
-: the stack in very large arrays (actually, I think it was a hash in my case)
-: without any warning from Perl or the OS. It took about 10 times through the
-: debugger before I would believe my own eyes, but in the end I had to accept
-: what was happening. Fortunately, I was able to work around it.
-:
-: This is rare, though I'm not the only one in my office that it's happened
-: to, so I'm pretty sure I'm not going crazy. Well, maybe I am, but it would
-: be for other reasons. :)
Did you use perlbug to report this issue? Can you give us a code example
that exhibits this feature?
Abigail
--
tie $" => A; $, = " "; $\ = "\n"; @a = ("") x 2; print map {"@a"} 1 .. 4;
sub A::TIESCALAR {bless \my $A => A} # Yet Another silly JAPH by Abigail
sub A::FETCH {@q = qw /Just Another Perl Hacker/ unless @q; shift @q}
------------------------------
Date: 11 Oct 2001 02:11:41 -0700
From: ianb@ot.com.au (Ian Boreham)
Subject: Re: split into filename and extension (need help before I go insane)
Message-Id: <f02c4576.0110110111.37d87b40@posting.google.com>
Graham Wood <Graham.T.Wood@oracle.com> wrote in message news:<3BC45EDF.488E7018@oracle.com>...
> ($name,$ext)= $filename =~ /(.+)\.{1}([^.]+)?$/;
Why the "{1}"? "\." will match only a single dot anyway.
And why the "([^.]+)?"? "([^.]*)" is more straightforward.
> This should match
> any characters followed by a dot then any characters other than a dot. It will
> put the first lot of any characters into $name and the non-dot characters
> after the last dot into $ext. The ? stops the pattern from matching more than
> one dot before the end of the filename.
I don't quite understand what you mean by that. Since you've used [^.]
for the trailing characters, and anchored the string at the end, the
preceding "\." can only match the last dot in the name, if at all.
Without the "?", The pattern would not match a zero-length extension
(which would be consistent with the "(.+)" you've used at the start, I
suppose), but it's not going to allow any dots to sneak through.
Regards,
Ian
------------------------------
Date: 11 Oct 2001 01:33:24 -0700
From: okrg@my-deja.com (Oleksii Krykun)
Subject: String::CRC32 gives wrong result for file
Message-Id: <ee115e5d.0110110033.2ba4adf6@posting.google.com>
I use ActivePerl (5.6.1-629) on WindowsNT. To calculate CRC-32 I
installed String-CRC32 module with PPM.
Function works fine for strings only.
If I try to calculate CRC for file which consists of more than one
line I get wrong result. I compare this result with Winzip and FreeBSD
String-CRC32 (last both identical).
I use following code (on NT and FreeBSD):
use String::CRC32;
open (FILE, "filename");
$crc = crc32(*FILE);
close FILE;
Where is my mistake and how to resolve this problem?
------------------------------
Date: Thu, 11 Oct 2001 08:53:42 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: String::CRC32 gives wrong result for file
Message-Id: <3BC55E9D.6BC7A3A2@acm.org>
Oleksii Krykun wrote:
>
> I use ActivePerl (5.6.1-629) on WindowsNT. To calculate CRC-32 I
> installed String-CRC32 module with PPM.
> Function works fine for strings only.
> If I try to calculate CRC for file which consists of more than one
> line I get wrong result. I compare this result with Winzip and FreeBSD
> String-CRC32 (last both identical).
>
> I use following code (on NT and FreeBSD):
>
> use String::CRC32;
>
> open (FILE, "filename");
> $crc = crc32(*FILE);
> close FILE;
>
> Where is my mistake and how to resolve this problem?
perldoc -f binmode
John
--
use Perl;
program
fulfillment
------------------------------
Date: 11 Oct 2001 02:25:31 -0700
From: fnieto@satec.es (Fernando Nieto)
Subject: Translate command rare behaviour?
Message-Id: <ad347199.0110110125.355f9301@posting.google.com>
Hello, I've tried the next simple code with "tr" command:
> $line = 'My/name/is: Fran';
> print "BEF TR: $line\n";
> $line =~ tr/ \/:/_-=/;
> print "AFT TR: $line\n";
BEF TR: My/name/is: Fran
AFT TR: My/name/is: Fran ## doesn't work, no warning nor error ??
> $line = 'My/name/is: Fran';
> print "BEF TR: $line\n";
> $line =~ tr/: \//=_-/;
> print "AFT TR: $line\n";
BEF TR: My/name/is: Fran
AFT TR: My-name-is=_Fran ## works properly
Anybody now if this is a correct behaviour or why does it happens?
Thanks so much in advance,
Fernando
------------------------------
Date: Thu, 11 Oct 2001 00:08:46 -0700
From: "yan" <pumalee2000@hotmail.com>
Subject: Re: who said this?
Message-Id: <9q35r1$dp0$1@watserv3.uwaterloo.ca>
"Doug King" <Doug.King@abh.siemens.com> wrote in message
news:3BC48362.F5772C53@abh.siemens.com...
> Dann Corbit wrote:
> >
> > With a PC, I always felt limited by the software available.
> > On Unix, I am limited only by my knowledge.
> >
> > --Peter J. Schoenster
> > --
> > C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
> > "The C-FAQ Book" ISBN 0-201-84519-9
> > C.A.P. FAQ: ftp://cap.connx.com/pub/Chess%20Analysis%20Project%20FAQ.htm
>
> Practically everyone who has ever seriously tried to use both. :-)
yes, i do...
I was a PC user for long, about 7 years...kinda of good at it...Now i am
trying to go with Linux...
I do have the feeling, limited by my knowledge...
for pc, you don't have to know alot about the fundamental theory&rules of
the whole computer|internet thing, but you still can do everything you
want...coz thousands of softwares out there longing for u....
but linux, you have to do everything youself...
that's the difference...From my view point..
------------------------------
Date: Thu, 11 Oct 2001 09:39:18 GMT
From: Geoffrey Pointer <geoffrey@bigpond.net.au>
Subject: Re: YOU ARE ALL GAY!
Message-Id: <B7EBA769.82EC%geoffrey@bigpond.net.au>
I realise now how saying too little can sometimes be misconstrued.
> It's funny about that isn't it? Go figure.
This was a comment about the psychobabble in the original message and not
its subject. Now I can see I also made a joke about the subject. Either
interpretation is fine by me. I suppose there are others I should now be
paranoid about. Again. Go figure.
--
Cheers - Geoff %^>
------------------------------
Date: Thu, 11 Oct 2001 11:40:16 +0200
From: Jean-Philippe Fauvelle <JPFauvelle@Colt-Telecom.fr>
Subject: Re: zipping files?
Message-Id: <q3qast4e1h9f26lfun1ivof2oqm0al9isj@4ax.com>
Le Wed, 10 Oct 2001 18:25:54 GMT, "Jessica Bull" <jessica.bull@broadwing.com> écrit:
The module Compress::Zlib is made for you !
Moreover, this module is part of the Activeperl distribution, which is probably the
one you use.
Jean-Philippe Fauvelle
>I am on a Win NT system. I have a directory with various files. I would
>like to pull files with a certain extention and put them into a new zip file
>with a specific name. Does anyone know if and how this could be done? I
>know how to pull the files I want, but I don't know how or if Perl can zip
>them up. Any information would be appreciated.
>
>Jess
>
------------------------------
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 1909
***************************************