[24921] in Perl-Users-Digest
Perl-Users Digest, Issue: 7171 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 23 18:06:39 2004
Date: Thu, 23 Sep 2004 15: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)
Perl-Users Digest Thu, 23 Sep 2004 Volume: 10 Number: 7171
Today's topics:
Re: [OT?] SDBM file HUGE on disk <corff@cis.fu-berlin.de>
Re: Help with my brute force method (Larry Felton Johnson)
Is it possible to embed perl inside a shell script say <david@tvisnospam.co.uk>
Re: Is it possible to embed perl inside a shell script <xx087@freenet.carleton.ca>
Re: Is it possible to embed perl inside a shell script <shawn.corey@sympatico.ca>
Re: Modulus Operator (%) ctcgag@hotmail.com
Re: Mystery message: Undefined subroutine &OS2::Bootdri (Seymour J.)
Re: NDBM module for ActiveState/Winxx? <corff@cis.fu-berlin.de>
Re: new commands written in perl <rob_gamble99@hotmail.com>
Re: order a semicolon-separated data file by a value of <stfhostf@kartos.de>
Re: parse_html_string reports error <ebohlman@omsdev.com>
Re: perl newsgroup question <ebohlman@omsdev.com>
Permagick Fonts <jds@atavailcheck.com>
Re: Regular expression <"mshelor[at]cpan.org">
Re: Regular expression <noreply@gunnar.cc>
Re: Regular expression <matrix_calling@yahoo.dot.com>
Re: Regular expression (John S. Humanski)
Re: Regular expression (Jim Keenan)
Re: What does this do ? !/somestring/ <matrix_calling@yahoo.dot.com>
Re: what module could easiely load all files to a @arra (krakle)
Re: what module could easiely load all files to a @arra (krakle)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Sep 2004 16:13:41 GMT
From: <corff@cis.fu-berlin.de>
Subject: Re: [OT?] SDBM file HUGE on disk
Message-Id: <2rgb1lF19d7moU1@uni-berlin.de>
corff@cis.fu-berlin.de wrote:
: In the meantime I made Tie::File work with my data set, it's a bit slow,
: but it works.
: More details later,
As promised, more details. I use the Tie::File module to open 10 files,
each with approx. 19000 lines, and usually the response speed is quite
acceptable. Only if my first seek targets record no. 17000 or so, then
the time gets slow, approx. one second per file, so in total 10 seconds.
However all following seek operations take place in "real time". Attaching
the utf8 discipline slows down the operation by about 30 percent, so a
seek without utf8 takes 8 seconds, with utf8 discipline takes 12 seconds.
However, the memory footprint is quite small, and the disk file is just
the 600kB (+/-) so for my purpose (line-based editing of pseudo database)
the Tie::File module is exactly what I need, and no remote installation
(which would take place without my supervision) of any additional software
is necessary as AS Perl 5.8.0 is up and running on the target machine.
Thanks again for all comments and ideas,
Oliver.
--
Dr. Oliver Corff e-mail: corff@zedat.fu-berlin.de
------------------------------
Date: 23 Sep 2004 11:37:21 -0700
From: larryj@gsu.edu (Larry Felton Johnson)
Subject: Re: Help with my brute force method
Message-Id: <4ae7bf57.0409231037.7ecf1515@posting.google.com>
krakle@visto.com (krakle) wrote in message
>
> Do you leave your home door wide open when you enter your house?
It depends on the weather, the time of year, whether I plan on being in
the front room for the evening, and a number of other factors :-)
You wanna elaborate, or should I continue with domestic habit flow?
Larry
------------------------------
Date: Thu, 23 Sep 2004 19:15:19 GMT
From: zzapper <david@tvisnospam.co.uk>
Subject: Is it possible to embed perl inside a shell script say bash?
Message-Id: <bl76l05pff9qqmg44sibp8qo511tskp011@4ax.com>
Hi,
Many years ago I used to embed AWK into a shell script, I've tried doing this with Perl with limited
results
A perl oneliner works no problem
eg
#!/bin/bash
fred=$(perl -e 'for $i (1..4) { $j="goat$i"; print " billy$j"; }')
echo $fred
But I really want to write more complex perl programs.
Any ideas?
zzapper (vim, cygwin, wiki & zsh)
--
vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips
------------------------------
Date: 23 Sep 2004 19:33:28 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Is it possible to embed perl inside a shell script say bash?
Message-Id: <slrncl6988.nfj.xx087@smeagol.ncf.ca>
At 2004-09-23 03:15PM, zzapper <david@tvisnospam.co.uk> wrote:
> Hi,
> Many years ago I used to embed AWK into a shell script, I've tried doing this with Perl with limited
> results
>
#!/bin/bash
perlscript='
for $i (1..4) { $j="goat$i"; print " billy$j"; }
# make the script as arbitrarily long as you like,
# taking care to avoid single quotes
my $string = q{a single quoted string};
...
'
fred=$(perl -e $perlscript)
echo $fred
# or just write your perl code "inline"
out=`perl -e '
# perl code here
'`
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Thu, 23 Sep 2004 15:43:41 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Is it possible to embed perl inside a shell script say bash?
Message-Id: <6HF4d.28604$bL1.1113545@news20.bellglobal.com>
zzapper wrote:
8< snipped
> Any ideas?
Yes, skip the shell and use Perl directly. Perl can do anything your
shell can do, only better. It is also portable. And add in all the neat
stuff at CPAN http://www.cpan.org/ it's hard to justify using shell.
--- Shawn
------------------------------
Date: 23 Sep 2004 16:00:22 GMT
From: ctcgag@hotmail.com
Subject: Re: Modulus Operator (%)
Message-Id: <20040923120022.769$G4@newsreader.com>
"Paul Lalli" <mritty@gmail.com> wrote:
> "Mike Flannigan" <mikeflan@earthlink.net> wrote in message
> news:4151CB14.7F04762C@earthlink.net...
> > use strict;
> > use warnings;
> >
> > my $num1 = 10.564;
> > my $num2 = 4;
> > my $num3 = $num1 % $num2;
> >
> > print "\n$num1 - $num2 - $num3\n\n";
> > When I run that I get
> > 10.564 - 4 - 2
> >
> > I expected
> > 10.564 - 4 - 2.564
> >
> > The documentation says:
> > Binary ``%'' computes the modulus of two numbers. Given integer
> operands
> > $a and $b: If $b is positive, then $a % $b is $a minus the largest
> multiple
> > of $b that is not greater than $a.
> >
> >
> > What am I not seeing in all this?
>
> The part that said "given integer operands". That means that the
> operands to % are converted to integers, regardless of what they
> actually are.
That should be described as "operands will be interpreted as integers".
"Given integer operands" suggest that will be other sections of
documentation to cover the other possibilities.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Thu, 23 Sep 2004 13:43:07 -0300
From: "Shmuel (Seymour J.) Metz" <spamtrap@library.lspace.org.invalid>
Subject: Re: Mystery message: Undefined subroutine &OS2::Bootdrive
Message-Id: <41530b2b$4$fuzhry+tra$mr2ice@news.patriot.net>
In <Vgm4d.75406$%S.49494@pd7tw2no>, on 09/22/2004
at 09:37 PM, Darin McBride <dmcbride@naboo.to.org.no.spam.for.me>
said:
>I would actually assume it's the comma ...
Thanks, although that turned out to not be the problem. My Mark II
eyeball failed to note the difference in case between Bootdrive and
BootDrive. I should have looked for something simple before looking
for a subtle explanation :-(
--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>
Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to spamtrap@library.lspace.org
------------------------------
Date: 23 Sep 2004 16:18:29 GMT
From: <corff@cis.fu-berlin.de>
Subject: Re: NDBM module for ActiveState/Winxx?
Message-Id: <2rgbalF19d7moU2@uni-berlin.de>
Bob Walton <see@sig.invalid> wrote:
: I think "plover"'s comments are referring to Unix systems. Recent AS
: installs come with everything needed for DB_File. I'm not sure how
: Tie::File is implemented -- since it deals with an ordinary text file,
: it needs to rewrite the entire file if any given line changed length
: during a modification. For large files (where tied hashes to DBM-type
: files are useful), rewriting the entire file has to be time-consuming.
: I have found tied hashes are very advantageous for typical CGI programs
: which need to open/access/modify/close quickly on very large sets of
: data, but where the complexity of a full-blown external database and its
: connection overhead is not required (and yes, I know about mod_perl to
: avoid that overhead).
I wrote about performance issues in the other thread. Hashes risk to
be memory-intensive. I cannot analyse if the program crashes, because
my colleague is not a computer specialist; I have to program as conservative
as possible.
: >
: > As far as the performance is concerned, I think that for all MY concerns,
: > Tie::File is much more practical than DB_File as it only keeps in memory
: > the line/record I am working on, so things should actually speed up at
: > start and end of program runs.
: Also note that Tie::File (in its docs) states that by default the
: *entire file* following that record is written every time a record is
: changed. Deferred writing can be turned on, but even then the entire
: file following the first modified record is written when the connection
: is shut down. So if record 0 of a 1000000 record file is changed, the
: entire file is rewritten.
Not 100% exactly, it rewrites everything _after_ the record in question.
However, even seek operations over 10 files, each with 19000 records,
may take up to 12 seconds on a reasonable machine (1000MHz, 256MB).
: Yet another alternative is to use fixed-length records in a file. Then
: the offset into the file is computable, and one may use seek() and
: tell() to hop around as one pleases. And one need not even waste space
: on record separator characters. Of course, that only works if the
: length of the biggest record to be stored has a reasonable upper bound
: which isn't much bigger than the typical record length.
Not in my case, there is a ratio of 1 to 50 between shortest and longest
record.
Thanks again for the discussion,
Oliver.
--
Dr. Oliver Corff e-mail: corff@zedat.fu-berlin.de
------------------------------
Date: Thu, 23 Sep 2004 15:28:15 -0400
From: Robert Gamble <rob_gamble99@hotmail.com>
Subject: Re: new commands written in perl
Message-Id: <pan.2004.09.23.19.28.14.883667@hotmail.com>
On Thu, 23 Sep 2004 10:26:15 -0400, Ted Zlatanov wrote:
> On Wed, 22 Sep 2004, rob_gamble99@hotmail.com wrote:
>
>> On Wed, 22 Sep 2004 10:27:52 -0400, Ted Zlatanov wrote:
>
>>> No, it's NOT the same thing. His program doesn't use the shell. It
>>> may be trivial, but it's not useless.
>>
>> Of course his program uses the shell, what do you think is calling the
>> program and passing it the parameters?
>
> Any other program can do it - the shell is a common choice, but not
> the only one.
You are the second person so far to selectively quote what I said about
the shell running the program to misrepresent my statements. Why don't
you try reading the sentence immediately following the one you quoted
where I address the same thing you comment on?
>> It may not be totally useless but the point is that this functionality
>> already exists with trivial shell operations which addresses the
>> question the OP asked.
>
> Sometimes the shell is not a good choice for trivial operations (e.g.
> `cat' is a pretty redundant program when you use a shell).
>
> Hell, we don't need 90% of Unix commands because Perl can emulate them
> according to your argument.
Don't see how you come up with this at all...
>>> In addition, note the default behavior is to append to ~/.into when no
>>> file name is given.
>>
>> Maybe there should be a complementing utility called "outof" that will
>> read from ~/.into by default to justify using it over cat...
>
> I like the way you glossed over this big difference from the `cat'
> approach with a quick "if this goes on..." response. Good work.
I was being sarcastic although I do not quite understand what you are
trying to say here either.
> Ted
------------------------------
Date: Thu, 23 Sep 2004 17:33:32 GMT
From: Stefan H. <stfhostf@kartos.de>
Subject: Re: order a semicolon-separated data file by a value of a column
Message-Id: <it16l0dq06nthfsqs9eql19aikji52i7ck@4ax.com>
On Wed, 22 Sep 2004 18:13:47 -0400, Paul Lalli <mritty@gmail.com> wrote:
Hi Paul, thank you very much for the suggestions.
I removed declarations and open file checking to have a lighter code to
post here.
Mi idea was:
- create a list containing each row
- apply to that list the sort function
- the sort function need to split each row and compare the fifth element
now I know that I don't know how sort function works :-)
Your code works very well, thanks. I'm learning perl since last week, I
need it for my work and I'm still a beginner. I didn't know perl had
references, I read the lama book and it does't mention references. I've
just ordered the second volume by swartz (perl objects...) I think I
need it.
Thanks again you and others answered my question.
For Graham: you script is very interesting. I'm learning unix shell
scripting just now. Great.
Bye
Stefan
>My suggestion would be to read each element, store each line in an array
>reference, store each reference in a larger array, sort the array by the
>fifth element of each 'inner' array, and then print the results to a new
>file:
>
>#!/usr/bin/perl
>use strict;
>use warnings;
>open my $DATAFILE, 'data.csv' or die "Cannot open file: $!";
>
>my @lines; #holds all the lines of the file.
>
>while (<$DATAFILE>) {
> push @lines, [split /;/]; #add this line's elements to the array
>}
>
>open my $DATA_OUT, '>', 'ordered_data.csv'
> or die "Cannot open file for writing: $!";
>
>sub by_fifth {
> $a->[4] <=> $b->[4];
>}
>
>foreach (sort by_fifth @lines){
> print $DATA_OUT join (';', @{$_});
>}
>__END__
>
>Paul Lalli
------------------------------
Date: 23 Sep 2004 21:21:04 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: parse_html_string reports error
Message-Id: <Xns956DA73FEC467ebohlmanomsdevcom@130.133.1.4>
Ben Morrow <usenet@morrow.me.uk> wrote in
news:g7sa22-cc5.ln1@osiris.mauzo.dyndns.org:
> BTW, are you aware that ordinary HTML (as opposed to strict XHTML) is
> *not* valid XML? You may be better off with an HTML parser.
libxml, upon which XML::LibXML is based, includes a dedicated HTML parser,
and that's what the OP was using.
------------------------------
Date: 23 Sep 2004 21:17:58 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: perl newsgroup question
Message-Id: <Xns956DA6B8AEF81ebohlmanomsdevcom@130.133.1.4>
"daniel kaplan" <nospam@nospam.com> wrote in
news:1095875098.163702@nntp.acecape.com:
> oh man ... so it is out there....funny how i dont see it....oh well,
> let the spamming begin :-(
If the only place your email address could be found was in your signature,
then most spam harvesters won't pick it up. They normally look only at
newsgroup headers. It would take them too long to fetch the body of each
article and "mine" it. Remember that the people who harvest addresses from
newsgroups aren't usually spammers themselves; rather they're scammers who
sell address lists to spammers. Their marketing point is simply the number
of unique addresses in their lists, not the "quality" of those addresses
(remember that they're selling the lists to people who are naive enough to
think they can actually make money spamming; in reality, the only people in
the "spam trade" who make any money are those who sell address lists and
spamming tools).
------------------------------
Date: Thu, 23 Sep 2004 19:18:38 GMT
From: "Julia De Silva" <jds@atavailcheck.com>
Subject: Permagick Fonts
Message-Id: <ikF4d.70321$U04.49926@fe1.news.blueyonder.co.uk>
Hi there all.
Has anyone any experience of putting text on top of images using Perlmagick,
in fact can anyone give us a few clues on using fonts with this module.
I've tried the shadow_text.cgi example in CGI Programming with Perl
(O'Reilly) but where are the fonts on a UNIX box, and how do I find them?
TIA.
J
------------------------------
Date: Thu, 23 Sep 2004 08:25:21 -0700
From: "mshelor[at]cpan.org" <"mshelor[at]cpan.org">
Subject: Re: Regular expression
Message-Id: <dcidnZJaTpp-d8_cRVn-og@comcast.com>
a246456 wrote:
> Hello,
> I am processing a list from a file which contains different paths to be
> processed. for example:
> /apps/oracle/a.htm
> /apps/user/bin/a.gif
> /apps/export/images/sdsd.gif
> /apps/images/client/list/wqerew.gif
> I want to split the filename and the path. Then i can use the path as input
> to fetch the file from a remote machine through ftp.. I am able to get the
> filename, but i am not able to get the full path with the slashes in it..
> Thanks for your help...
use File::Basename;
------------------------------
Date: Thu, 23 Sep 2004 17:31:13 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regular expression
Message-Id: <2rg8g9F189dhcU1@uni-berlin.de>
a246456 wrote:
> I am processing a list from a file which contains different paths
> to be processed. for example:
> /apps/oracle/a.htm
> /apps/user/bin/a.gif
> /apps/export/images/sdsd.gif
> /apps/images/client/list/wqerew.gif
> I want to split the filename and the path. Then i can use the path
> as input to fetch the file from a remote machine through ftp.. I am
> able to get the filename, but i am not able to get the full path
> with the slashes in it..
use File::Basename;
open LST, "content.txt" or die "File content.txt not found. $!";
while ( my $cont = <LST> ) {
chomp $cont;
my ($file, $path) = fileparse $cont;
print "File Name is $file\n", "Path is $path\n";
}
close LST;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 23 Sep 2004 21:01:09 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: Re: Regular expression
Message-Id: <N9C4d.44$6E4.97@news.oracle.com>
a246456 wrote:
> Hello,
> I am processing a list from a file which contains different paths to be
> processed. for example:
> /apps/oracle/a.htm
> /apps/user/bin/a.gif
> /apps/export/images/sdsd.gif
> /apps/images/client/list/wqerew.gif
> I want to split the filename and the path. Then i can use the path as input
> to fetch the file from a remote machine through ftp.. I am able to get the
> filename, but i am not able to get the full path with the slashes in it..
> Thanks for your help...
you can use the fileparse routine :
perldoc File::Basename
HTH
Abhinav
------------------------------
Date: 23 Sep 2004 13:05:24 -0700
From: jhumanski@yahoo.com (John S. Humanski)
Subject: Re: Regular expression
Message-Id: <3812e041.0409231205.3c53801a@posting.google.com>
"a246456" <a246456@fmr.com> wrote in message news:<mnB4d.43$Nq3.36@news-srv1.fmr.com>...
> Hello,
> I am processing a list from a file which contains different paths to be
> processed. for example:
> /apps/oracle/a.htm
> /apps/user/bin/a.gif
> /apps/export/images/sdsd.gif
> /apps/images/client/list/wqerew.gif
> I want to split the filename and the path. Then i can use the path as input
> to fetch the file from a remote machine through ftp.. I am able to get the
> filename, but i am not able to get the full path with the slashes in it..
> Thanks for your help...
> ----------------------------------------------------------------------------
> --------------
> open(LST, "content.txt") || die "File content.txt not found. $!\n";
> open(FAIL, ">fail.txt");
> $cont=<LST>;
> chomp($cont);
> while($cont ne "")
> {
> @line=split('/', $cont);
> $file=pop(@line);
> print "File Name is $file\n";
> $cont=<LST>;
> }
> close LST;
Look at the File::Basename module.
------------------------------
Date: 23 Sep 2004 13:44:38 -0700
From: jkeen_via_google@yahoo.com (Jim Keenan)
Subject: Re: Regular expression
Message-Id: <196cb7af.0409231244.393296ea@posting.google.com>
"a246456" <a246456@fmr.com> wrote in message news:<mnB4d.43$Nq3.36@news-srv1.fmr.com>...
> Hello,
> I am processing a list from a file which contains different paths to be
> processed. for example:
> /apps/oracle/a.htm
> /apps/user/bin/a.gif
> /apps/export/images/sdsd.gif
> /apps/images/client/list/wqerew.gif
> I want to split the filename and the path. Then i can use the path as input
> to fetch the file from a remote machine through ftp.. I am able to get the
> filename, but i am not able to get the full path with the slashes in it..
> Thanks for your help...
> ----------------------------------------------------------------------------
> --------------
> open(LST, "content.txt") || die "File content.txt not found. $!\n";
> open(FAIL, ">fail.txt");
> $cont=<LST>;
> chomp($cont);
> while($cont ne "")
> {
> @line=split('/', $cont);
> $file=pop(@line);
> print "File Name is $file\n";
> $cont=<LST>;
> }
> close LST;
1. Subject is misleading. You don't use a regular expression in code
above; you're only using a pattern as the first argument to 'split'.
2. But using a Perl module is a better approach:
use File::Basename;
use Data::Dumper;
my @results;
push(@results, [ dirname($_), basename($_) ]) while (<DATA>);
print Dumper(\@results);
__DATA__
/apps/oracle/a.htm
/apps/user/bin/a.gif
/apps/export/images/sdsd.gif
/apps/images/client/list/wqerew.gif
For reference:
perldoc File::Basename
HTH!
Jim Keenan
------------------------------
Date: Thu, 23 Sep 2004 22:07:42 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: Re: What does this do ? !/somestring/
Message-Id: <b8D4d.51$6E4.51@news.oracle.com>
J. Romano wrote:
> Abhinav <matrix_calling@yahoo.dot.com> wrote in message news:<6hP3d.58$AE3.95@news.oracle.com>...
>
>>Hmm ..
>>Reading this inside out, this would
>>
>>1. check if $_ !~ /asd/
>>2. The return value from this check is taken an expression,
>>which is on the right side of $str
>>
>>Hence, $str =~ expr # This is evaluated as $str =~ /expr/
>>
>>This is what I could ascertain from "Programming Perl",
>>page 90, "Binding Operators". I hope I am correct ?
>
>
>
> It looks like you are correct, Abhinav. According to the "Binding
> Operators" section of "perldoc perlop", "if the right argument is an
> expression rather than a search pattern [(or a substitution or
> transliteration)] it is interpreted as a search pattern at run time."
> So the code:
>
> $str =~ "asd";
>
> is just a sloppy way of saying:
>
> $str =~ m/asd/;
>
> It gets weirder, however. According to "perldoc perlop" in the
> section "m/PATTERN/cgimosx", "if the PATTERN evaluates to the empty
> string, the last
> *successfully* matched regular expression is used instead."
>
> Usually this isn't a major concern, but it is if the pattern
> contains a variable that is set to the empty string. So how does that
> affect you?
>
> Well, by tinkering around with Perl's regular expression matching,
> it seems that m/PATTERN/ either returns a 1 if the match was
> successful, or "" (the empty string -- which evaluates to false) if
> the match was unsuccessful. Putting a "!" in front of either will
> return the other (in other words, ((!1) eq "") and ((!"") eq 1).
>
> Therefore, the original line of code you posted:
>
> $str =~ !/asd/;
>
> is equivalent to:
>
> $str =~ ! ($_ =~ m/asd/);
>
> If $_ is either undefined or does not contain the string "asd",
> then the line is also equivalent to:
>
> $str =~ ! ("");
>
> which is equivalent to:
>
> $str =~ 1;
>
> which is equivalent to:
>
> $str =~ m/1/;
>
> which will return true only if $str contains a "1".
>
> On the other hand, if $_ is defined and contains the string "asd",
> then the line:
>
> $str =~ !/asd/;
>
> which, as I already said, is equivalent to:
>
> $str =~ ! ($_ =~ m/asd/);
>
> is now equivalent to:
>
> $str =~ ! (1);
>
> which is equivalent to:
>
> $str =~ "";
>
> which is equivalent to:
>
> $str =~ m//;
>
> which, according to the perldoc, will not try to match an empty
> string, but will use the last *successfully* matched regular
> expression instead.
>
> Therefore, if you see had lines of code:
>
> "Wizard of Wor" =~ m/Wor/; # successful match
> "All your base are belong to us" =~ m/bases/;
> $_ = "wasderful";
> $str = "Hello, World!";
> $str =~ !/asd/; # original line
>
> the line:
>
> $str =~ !/asd/; # original line
>
> will be equivalent to:
>
> $str =~ m/Wor/;
>
> because the m/Wor/ match was the last successful pattern match. It
> will therefore evaluate to true, even though $str does not contain the
> string "asd".
>
> Strange, isn't it?
>
> Maybe this bizzare side-effect helps explain why, as you said in
> your first post, that the code worked in some cases. The original
> line of code was meant to check for the non-existence of "asd", but
> instead checked for the existence of "Wor". Either way, it's still
> possible to evaluate to true in some cases (like the one I just showed
> you).
>
> I hope this explains things more than it confused you. To tell you
> the truth, Abhinav, your question made me search through the Perl
> documentation for a good while before I figured out what was
> happening. In other words, a lot more was happening "behind the
> scenes" with your code than I first realized!
>
Thank you for your detailed investigation and lucid analysis..they were a
great help.
As I had mentioned earlier, this does not affect my code...someone had been
using the !// construct incorrectly, and getting by with it for no apparent
reason. Even Perl did not complain much.. :)
Your post explains it to a point of being crystal clear :)
Thanks,
Abhinav
[Not removing the text below so that the archive has a complete explanation..]
------------------------------
Date: 23 Sep 2004 10:05:46 -0700
From: krakle@visto.com (krakle)
Subject: Re: what module could easiely load all files to a @array from a specified folder(and subfolders)?
Message-Id: <237aaff8.0409230905.620f5362@posting.google.com>
Alont <end@dream.life> wrote in message news:<4151a17b.15044562@130.133.1.4>...
> just tell me the name of module,
> my english too poor to can't understand all module help files, forgive
> me....
Here's a better question... If your english is too poor to understand
a plain english help file how is your english going to be sufficient
enough to understand a plain english reply? :)
------------------------------
Date: 23 Sep 2004 10:07:40 -0700
From: krakle@visto.com (krakle)
Subject: Re: what module could easiely load all files to a @array from a specified folder(and subfolders)?
Message-Id: <237aaff8.0409230907.54d0666c@posting.google.com>
"Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net> wrote in message news:<Xns956D661FBBE0Delhber1lidotechnet@62.89.127.66>...
> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote:
>
> > Alont <end@dream.life> wrote in
> > news:4151a17b.15044562@130.133.1.4:
> >
> >> just tell me the name of module,
> >
> > Don't order people around.
>
>
> Which is what you just did.
Touche.
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7171
***************************************