[19494] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1689 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 4 09:05:27 2001

Date: Tue, 4 Sep 2001 06:05:08 -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: <999608708-v10-i1689@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 4 Sep 2001     Volume: 10 Number: 1689

Today's topics:
    Re: Calling sub funcs with scalar variables? <bart.lateur@skynet.be>
    Re: HASH question <pilsl_@goldfisch.at>
    Re: HASH question <Tassilo.Parseval@post.rwth-aachen.de>
        ignoring lines in file using array of phrases to skip (Mike Solomon)
    Re: ignoring lines in file using array of phrases to sk (Rafael Garcia-Suarez)
    Re: ignoring lines in file using array of phrases to sk nobull@mail.com
    Re: OT: Re: Recommendations for a PERL editor (Jonadab the Unsightly One)
    Re: OT: Re: Recommendations for a PERL editor (Tim Hammerquist)
    Re: perl glob failed (Tim Hammerquist)
    Re: Recommendations for a PERL editor (Jonadab the Unsightly One)
    Re: references, slices, voodoo <jasper@guideguide.com>
    Re: references, slices, voodoo <bart.lateur@skynet.be>
        sending email <aort527@hotmail.com>
    Re: sending email <bart.lateur@skynet.be>
    Re: sending email <andyh@nospam.cogs.susx.ac.uk>
    Re: sending email (Rafael Garcia-Suarez)
    Re: sending email (Jonadab the Unsightly One)
    Re: sending email <philippe.perrin@sxb.bsf.alcatel.fr>
    Re: Strange regex behavious <krahnj@acm.org>
    Re: weird kind of eof (Jonadab the Unsightly One)
    Re: win32 rmdir questions <philippe.perrin@sxb.bsf.alcatel.fr>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 04 Sep 2001 11:13:34 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Calling sub funcs with scalar variables?
Message-Id: <6id9ptg2e6b852b5vli6nb4dpcvbkijqen@4ax.com>

GunneR wrote:

>Basically I want to call a sub function based on a scalar. In essance
>I want the following to execute a sub function:
>
>&"$func"; ## Of course this doesnt work... its just to give you an
>idea.
>
>Ive tried &($func); &{$func} and the like but no go. Im sure theres a
>simple solution...

Eh, I think the version with the braces ought to work.

But, as a sidenote: did you know that even while symbolic references are
considered evil, even for sub names, that strict does allow you to go
ahead by using package names and OO, i.e. class methods?

This DOES work:

	use strict;
	foreach my $class (qw(Foo Bar Bar Foo)) {
	    $class->hi;
	}
	package Foo;
	sub hi {
	    print "This is Foo\n";
	}
	package Bar;
	sub hi {
	    print "This is Bar\n";
	}

-->
	This is Foo
	This is Bar
	This is Bar
	This is Foo

Yet I would think this is every bit just as evil as plain symbolic
references.

-- 
	Bart.


------------------------------

Date: Tue, 4 Sep 2001 13:10:54 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: Re: HASH question
Message-Id: <3b94b6c0@e-post.inode.at>

Ilmari Karonen wrote:

>
> 
> In a way, this is true.  However, you should try to ensure that your
> contribution is more signal than noise.  

:) This is what I think about my postings.

In the rest of your skipped text, you draw a picture of perfect usenet, 
where skilled, sophisticated people discuss the latest remaining questions 
that are not already answered in the depths of internet.

To tell the truth, while I'm also annoyed by people asking the same 
question that was anwsered two threads above, your vision is not the usenet 
I'd like to have.

Usenet should be a place where I can ask really sophisticated questions and 
discuss about heavy things (like unicodeimplementation in perl. 
unfortunately not many people joined the thread then)

On the other hand it always must stay a place, where *new* people can ask 
some questions, even if the answer is written already somewhere else. 

And - the last one -it must also be a place where I can ask urgent 
questions and hopefully get a quick answer with a hint.

> 
> The correct answer is in the Perl documentation.  By all means look into
> the modules and documentation pages recommended in this thread, but do
> not actually believe any advice given in it.  Most of it is wrong.
> 

This is the advice of the real guru: 
"other people dont telling you the truth, they lie at you. I know the 
truth, but I wont tell you, cause you need to learn by finding out on your 
own"


> (And no, of course I'm not going to post an answer, after I've just told
> the OP that nothing in this thread should be trusted.  I will, however,
> point him at the perldsc manual page and the Data::Dumper module.)
> 

I recommended the Dumper-module to the OP ages ago and I recommended 
reading the perldoc and I posted a small codeexample for him.
So whats your problem about it ??

Was it wrong that I answered to the OP or was it wrong the way I answered.

In fact, I think my posting was more help to the OP than yours ;) 

best,
peter



-- 
mag. peter pilsl
pilsl_@goldfisch.at
http://www.goldfisch.at



------------------------------

Date: Tue, 04 Sep 2001 13:39:09 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: HASH question
Message-Id: <3B94BD5D.4070602@post.rwth-aachen.de>

peter pilsl wrote:

> Usenet should be a place where I can ask really sophisticated questions and 
> discuss about heavy things (like unicodeimplementation in perl. 
> unfortunately not many people joined the thread then)
> 
> On the other hand it always must stay a place, where *new* people can ask 
> some questions, even if the answer is written already somewhere else. 

Yes, they can do this....but only once. But asking a FAQ-question is 
pardonable only the first time since people are quickly told what they 
should do before posting to this group. If they don't follow this 
adivice, chances are high to annoy people here. Two many obvious 
questions account for a lot of traffic each day.

> And - the last one -it must also be a place where I can ask urgent 
> questions and hopefully get a quick answer with a hint.

This is usenet, not a 24/7 support-center. Ask your question but don't 
state that you need an urgent reply. This will almost certainly result 
in a few biting comments.

>>The correct answer is in the Perl documentation.  By all means look into
>>the modules and documentation pages recommended in this thread, but do
>>not actually believe any advice given in it.  Most of it is wrong.
>>
>>
> 
> This is the advice of the real guru: 
> "other people dont telling you the truth, they lie at you. I know the 
> truth, but I wont tell you, cause you need to learn by finding out on your 
> own"

It is, for one very good reason: self-protection.
In this group a few of the most acclaimed Perl-experts can be found. You 
know, people who master Perl even while they're happily asleep. 
Impossible to imagine one could pass with a not 100% correct answer. 
Sooner than you expect they detect a little mistake in your reply and, 
well, they will let you know...and not just you but the whole group. 
Once you have been folded into small pieces by, say, Abigail, Uri 
Guttman, Ted McClellan and others, you know what I am talking about. ;-)

These are very nice and helpful people, but they wont allow you to pass 
with dubious information. It is because due these very people that clpm 
is known as a never-ending source of Perl-competence to anyone seriously 
seeking help.

So, rather refer to already existing documentation than taking the risk 
of saying something wrong....or partly right. You'd bitterly regret it 
soon enough.

>>(And no, of course I'm not going to post an answer, after I've just told
>>the OP that nothing in this thread should be trusted.  I will, however,
>>point him at the perldsc manual page and the Data::Dumper module.)
>>
>>
> 
> I recommended the Dumper-module to the OP ages ago and I recommended 
> reading the perldoc and I posted a small codeexample for him.
> So whats your problem about it ??

You see now? Your information wasn't as precise as it could have been 
provoking possible follow-up questions on a matter where one clear reply 
could have already done.

> Was it wrong that I answered to the OP or was it wrong the way I answered.

It is not wrong to answer, it is just wrong to answer in the wrong way. :-)

Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



------------------------------

Date: 4 Sep 2001 04:35:03 -0700
From: mike_solomon@lineone.net (Mike Solomon)
Subject: ignoring lines in file using array of phrases to skip
Message-Id: <56568be5.0109040335.670d5ad9@posting.google.com>

I am writing a script to filter lines out of a file

I have put the items I want to ignore into an array

What I can't work out how to do is put end of line character ($) into
the array and make it work


The line I am having problems filtering is

"Mar  5 23:20:19 dmgww-bls1 /kernel: "

I need to use something like /kernel:\s$/ but I cant make this work
from the array

Any help would be welcome

example code folows

#--------------------------------------------------------------------

use strict;

my @ignore = ( 
				"kernel: timecounter",
		"kernel: support",
		"kernel: cpu",
		"kernel: origin",
		"kernel: features",
		"kernel: preloaded",
		"kernel: K6",
		"kernel: vesa",
		"kernel: npx0",
		"kernel: pci",
		"kernel: is",
		"kernel: at",
		"kernel: xl",
            "kernel:\s\$"                    #this line does not work
);

my $ignore = join "|", @ignore;

open FILE, "myfile.txt" or die "cant open file";

while (<FILE>) {
      chomp;
      $line = $_;

      print if $line !~ /$ignore/i;
}

#-----------------------------------------------------------------

Regards


Mike Solomon


------------------------------

Date: 4 Sep 2001 11:54:11 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: ignoring lines in file using array of phrases to skip
Message-Id: <slrn9p9g7a.3ii.rgarciasuarez@rafael.kazibao.net>

Mike Solomon wrote in comp.lang.perl.misc:
} I need to use something like /kernel:\s$/ but I cant make this work
} from the array
[...]
}             "kernel:\s\$"                    #this line does not work

Have you checked what's actually in this string ?

$ perl -le 'print "kernel:\s\$"'
kernel:s$

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


------------------------------

Date: 04 Sep 2001 13:03:06 +0100
From: nobull@mail.com
Subject: Re: ignoring lines in file using array of phrases to skip
Message-Id: <u966azrwn9.fsf@wcl-l.bham.ac.uk>

mike_solomon@lineone.net (Mike Solomon) writes:

> I have put the items I want to ignore into an array
> 
> What I can't work out how to do is put end of line character ($) into
> the array and make it work

General approach to solving problems, try reducing your problem to a
simpler one.  (This applies not just to Perl progrmming but to all
aspects of life).

Try removing the array and see if the problem persists - it is does
then the problem is not related to the fact that you use an array.

In fact you should always reduce your problem to the smallest subset
of your original code that reproduces the problem.

For example you can simplfy your problem to:

$_= 'Mar  5 23:20:19 dmgww-bls1 /kernel: ';
my $ignore = "kernel:\s\$";
print if ! /$ignore/i;

Now, if you've not yet spotted the cause of your problem then run the
above under debug and check the value of $ignore.  If you don't
understand what you see then read up on the double-quote operator in
perlop.

BTW: Why did you use '\s' in the first place rather than just a space?

Oh, and antoher thing...

> my $ignore = join "|", @ignore;

The FAQ "How do I efficiently match many regular expressions at once?"
does not recommend this approach.  ISTR it can actually be less
efficient than matching each pattern separately.  Not that this stops
me using your approach myself as I do think it's more natural.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Tue, 04 Sep 2001 12:31:20 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: OT: Re: Recommendations for a PERL editor
Message-Id: <3b94c787.212476@news.bright.net>

tim@vegeta.ath.cx (Tim Hammerquist) wrote:

>   - Win32 stability is compromised proportional to the number of
>     programs open at any given time.
>   - Win32 stability is further compromised proportional to the number of
>     Microsoft(C) applications open at any given time.
>   - Win(95/98) stability is compromised proportional to the length of
>     time since installation of the OS (w/o good housekeeping).
>   - Win32 stability is compromised proportional to the number of
>     Microsoft Office applications _installed_ at any given time.

Win9x stability is also compromised by 
    - every running internet application after the first
    - each _installed_ instant messaging app
    - uptime greater than a few hours (so reboot now and then)
    - running low on free memory

Linux stability is compromised by (what I've discovered so far):
    - running out of swap space
    - deliberately executing forkbombs to see what will happen
    - running out of swap space (don't, trust me)
    - running out of swap space (really, you can't have too much)

- jonadab


------------------------------

Date: Tue, 04 Sep 2001 12:40:42 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: OT: Re: Recommendations for a PERL editor
Message-Id: <slrn9p9jl8.497.tim@vegeta.ath.cx>

Me parece que Jonadab the Unsightly One <jonadab@bright.net> dijo:
[ snip ]
> Win9x stability is also compromised by 
>     - every running internet application after the first

I usually have no more running than MSIE, Netscape, WS_FTP, (PWS ||
Apache), AIM, and.... well, you see why I had to switch. ;)

>     - each _installed_ instant messaging app

Just AIM for me, and not anymore anyway. ICQ was crap. MSN Msgr was,
well, Microsoft.

>     - uptime greater than a few hours (so reboot now and then)

Agreed. =)

>     - running low on free memory

Agreed (2) =)

> 
> Linux stability is compromised by (what I've discovered so far):
>     - running out of swap space

Never experienced this. What distro? Mine's Linux-Mandrake 7.1.

>     - deliberately executing forkbombs to see what will happen

Um, isn't that what you get?  ;)

>     - running out of swap space (don't, trust me)
>     - running out of swap space (really, you can't have too much)

Ok, I think I see a pattern. My biggest problem with linux lately has
been that logrotate (run from cron.daily) quickly chomps up 80% CPU time
and doesn't *ever* give it back! Even after 5-6 hours, and I _know_ it
can't take that long on my home box (1 usr, occasionally httpd requests,
some compiling, and an X-server).  I have to explicitly kill it, it's
parent process, and slocate, in order to get my CPU time back!

> - jonadab

Tim
-- 
I would feel infinitely more comfortable in your presence if you would agree
to treat Gravity as a Law, rather than one of a number suggested options.
    -- Barnabas, The Sandman


------------------------------

Date: Tue, 04 Sep 2001 12:26:42 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: perl glob failed
Message-Id: <slrn9p9ir0.497.tim@vegeta.ath.cx>

Me parece que Chi-Yin Hsu <chsu@cooperneff.com> dijo:
> What causes perl glob to succeed in some cases but fail in other cases
> with the same regular expression but different input directory? The
> perl error message is below:
> 
> glob failed (child exited with status 1) 
> 
> To clarify the statement of the problem, the script does not fail
> always.
> It fails only when the results of the pattern having more than 1300
> files names. What can application do to make it to work regardless of
> the size of the result?

It might help to know what version of perl you're running (not to
mention your platform).

IAC, in earlier version (< 5.6.0) globbing on non-DOS/WIN platforms was
done using an external csh process which IIRC placed a limit on the
number of files returnable.

Later versions of perl (my 5.6.1, eg) uses an internal and portable
globbing routine that returns predictable results, even on DOS/Win
systems.

Check `perldoc -f glob` for any mention of this. If it doesn't mention
the implementation change, just use the standard File::Glob module thus:

use File::Glob qw/ :globally /;

According to the pod, this should override the core glob() function
(along with the <*> operator), even on pre-5.6.0 versions.

If this doesn't solve your problem, post back with more info (`perl -v`,
OS, code example, etc.).

HTH
-- 
Anyway, comdemning her to an eternity in Hell, just because
she turned you down... That's a really shitty thing to do.
    -- Death, The Sandman


------------------------------

Date: Tue, 04 Sep 2001 11:23:25 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: Recommendations for a PERL editor
Message-Id: <3b94b915.67615110@news.bright.net>

"sabin" <sabin@cornhusker.net> wrote:

> It only seems to happen when I am running internet explorer 

What version?  Versions of IE prior to version 5 are unstable
and problematic, but version 5 is much better.  Also, either 
major browser (IE or Navigator) can be unstable unless you 
turn off the client-side dynamic content (Java, Javascript, 
and in the case of IE, ActiveX).  

If you're using, say, IE3, that could definitely be your problem.

- jonadab


------------------------------

Date: Tue, 04 Sep 2001 11:37:07 +0100
From: Jasper McCrea <jasper@guideguide.com>
Subject: Re: references, slices, voodoo
Message-Id: <3B94AED2.698A3CF@guideguide.com>

Walter Hafner wrote:
> 
> What I don't understand:
> 
> abigail writes:
> 
> > Note that the stupid 'unless $i == $j' no longer appears in modern
> > editions of the FAQ.
> 
> why "stupid"?
> 
> -Walter

I suppose because the test isn't much faster than the swap. Quick
benchmark showed that a swap was only 1/5 as fast as the test, so if the
array has more than twice as many elements that are different than are
the same (likely), it's a waste of time to do the test every time, when
you may as well swap.

A nice XOR swap benchmarked 1/2 as fast as a (==) test, but I suppose
it's harder to see what's going on there, so more confusion would arise.

Jasper
-- 
      split//,'019617511192'.
      '17011111610114101114'.
      '21011141011840799901'.
            '17101174';
            foreach(0..         # my
            $#_){$_[$_          # signature is too
            ++]^=$_[$_          # bignature
            --]^=$_[$_
]^=$_[++    $_]if!($_%
2)}$g.=$_  ,chr($g)=~
 /(\w)/&&($o.=$1and
   $g='')foreach@_;
      print"$o\n"


------------------------------

Date: Tue, 04 Sep 2001 10:57:57 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: references, slices, voodoo
Message-Id: <0nc9pt8lddgrcf7hlvh24nvtko43778jqb@4ax.com>

Walter Hafner wrote:

>> Note that the stupid 'unless $i == $j' no longer appears in modern
>> editions of the FAQ.
>
>why "stupid"?

Why indeed.

I think that at one time,

	@array[2, 2] = @array[2, 2];

did fail, or at least, generated a warning.

5.6.1 does neither. So the test is not (or: no longer) necessary.

-- 
	Bart.


------------------------------

Date: Tue, 04 Sep 2001 05:53:41 -0500
From: alex <aort527@hotmail.com>
Subject: sending email
Message-Id: <3B94B2B5.E367770F@hotmail.com>

how can I do this with my Perl script?



------------------------------

Date: Tue, 04 Sep 2001 11:26:47 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: sending email
Message-Id: <95e9pto8pj2flapg44bv2dlfeb7ct7u4n1@4ax.com>

alex wrote:

>how can I do this with my Perl script?

Sending email that is? (Please don't put your question only ion your
subject line. That's not what it's for.)

Various methods. There a several modules available on CPAN, most are
even plain and simple perl code (not really needing an actual
installation). Let's see: Net::SMTP, Mail::Sendmail, Mail::Sender,
Mail::Mailer, MailTool, ...

Virtually all have a different idea on the API. Pick one you like.

-- 
	Bart.


------------------------------

Date: Tue, 04 Sep 2001 12:36:33 +0100
From: Andy Holyer <andyh@nospam.cogs.susx.ac.uk>
Subject: Re: sending email
Message-Id: <040920011236330964%andyh@nospam.cogs.susx.ac.uk>

In article <3B94B2B5.E367770F@hotmail.com>, alex <aort527@hotmail.com>
wrote:

> how can I do this with my Perl script?

The Simplest way on a *nix system is to do

open MAIL, "| my_mailer $recipient -s $subject" || die ...

print MAIL $body_of_mail;

close MAIL;

A more general approach, which also allows attachments should use one
of the Mail:: modules. Mail::Mailer or Mail::Send are pretty good.


------------------------------

Date: 4 Sep 2001 11:51:46 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: sending email
Message-Id: <slrn9p9g2o.3ii.rgarciasuarez@rafael.kazibao.net>

Andy Holyer wrote in comp.lang.perl.misc:
} 
} The Simplest way on a *nix system is to do
} 
} open MAIL, "| my_mailer $recipient -s $subject" || die ...

The above line is equivalent to
  open MAIL, ("| my_mailer $recipient -s $subject" || die ...)

You should use 'or' instead of ||.

} print MAIL $body_of_mail;
} 
} close MAIL;

You should check the return status of close when writing to a pipe.

} A more general approach, which also allows attachments should use one
} of the Mail:: modules. Mail::Mailer or Mail::Send are pretty good.

And with modules, you don't have to reinvent the wheel ;-)
Check also the FAQ, when the Question looks like it's Frequently Asked.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


------------------------------

Date: Tue, 04 Sep 2001 12:06:01 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: sending email
Message-Id: <3b94c248.69970327@news.bright.net>

alex <aort527@hotmail.com> wrote:

> how can I do this with my Perl script?

Unless your script is running on a system with a mail 
transport agent, you'll have to send it through an
outgoing mail server where you have an account.  You 
can use Net::SMTP to do this.  

- jonadab


------------------------------

Date: Tue, 04 Sep 2001 14:39:05 +0200
From: Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr>
Subject: Re: sending email
Message-Id: <3B94CB69.D3AF630D@sxb.bsf.alcatel.fr>

alex wrote:
> 
> how can I do this with my Perl script?

If you want to do it on Windows platforms, I suggest you use MIME::Lite.
You can get an example of such a script at
http://www.enseirb.fr/~perrin/progsperl/mail101.zip

-- 
PhP

($r1,$r2,$r3,$r4)=("19|20","0|1","28|29","5|24");($r5,$r6)=("9|10|15|16|$r1|$r2","9|10|$r3");%h=("1|",$r6,"1=","[1-5]|2[0-4]","1/","0|19","1\\","6|25","2|","0|6|19|25|$r6","2/","1|20","2\\",$r4,"3|","$r2|6|$r1|25|$r6","3/",$r4,"4|","$r2|$r1|$r6","4=","2|3|4|11|12|13|14|21|22|23","4/",$r4,"4\\",15,"5|","$r2|9|15|$r1|20|$r3","5/",10,"6|",$r5,"7|",$r5,"7/",$r3);for($l=1;$l<8;$l++){b:for($i=0;$i<30;$i++){c:foreach(keys
%h){next c if(!(/^$l(.*)$/));$a=$1;if($i=~/^($h{$_})$/){print $a;next
b;}}print " ";}print "\n";}


------------------------------

Date: Tue, 04 Sep 2001 10:39:31 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Strange regex behavious
Message-Id: <3B94AFDA.8F01B15E@acm.org>

Ian Oversby wrote:
> 
> Can anyone explain why the resultant strings after each of these calls
> are different please?
> 
> $str = 'VISHASHAL';
> $str =~ s/(?<=[AEIOU])SH(?:[AEIOU])/Z/g;
> print "$str\n";

The two matches (ISHA and ASHA) are found by the regex and then
replaced.

> $str = 'VISHASHAL';
> $str =~ s/(?<=[AEIOU])SH(?:[AEIOU])/Z/;
> $str =~ s/(?<=[AEIOU])SH(?:[AEIOU])/Z/;
> print "$str\n";

The first match is found and replaced, there is no other match for the
second regex.

Use the re module to see what is going on.

perl -Mre=debug
-le'$_="VISHASHAL";s/(?<=[AEIOU])SH(?:[AEIOU])/Z/g;print'

perl -Mre=debug
-le'$_="VISHASHAL";s/(?<=[AEIOU])SH(?:[AEIOU])/Z/;s/(?<=[AEIOU])SH(?:[AEIOU])/Z/;print'



John
-- 
use Perl;
program
fulfillment


------------------------------

Date: Tue, 04 Sep 2001 11:52:13 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: weird kind of eof
Message-Id: <3b94bb40.68169557@news.bright.net>

"Bart Van der Donck" <bart@nijlen.com> wrote:

> My string contains an eof that I cannot detect.
> The purpose is to delete the eof from my string.

Open the file in a hex editor, and determine exactly
what character it is that you need to remove.  Perl
will let you specify characters by their decimal or
hex value.  Another posted gave an example for how
to remove decimal 015 and 012, but you could just as
well remove 026, or 010 and 013, or whatever; a hex 
editor will show you the value of the thing so you
know what to remove.

> In notepad the string appears as a little square. 

That only means the font Notepad is using doesn't
have an entry for the character.  It doesn't tell us
anything about which character it might be.  

> On a unix prompt it has
> the same effect as pressing the "Return"-key.

That doesn't sound like an EOF character to me, although
I'm not a unix guru per se.  

> The question is:
> Is there a line that erases all kinds of eofs (DOS, 
> Unix) from my string ?

s/[^\w ]//g;  

Well, maybe that's a little overzealous...  probably it's
best to determine exactly what you want to remove, and 
remove that.  

- jonadab


------------------------------

Date: Tue, 04 Sep 2001 13:45:02 +0200
From: Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr>
Subject: Re: win32 rmdir questions
Message-Id: <3B94BEBE.34BE7C51@sxb.bsf.alcatel.fr>

"John W. Krahn" wrote:
> system "deltree /y $yourDir";

deltree doesn't exist on all Windows-OS (not on W2000 for instance).

-- 
PhP

($r1,$r2,$r3,$r4)=("19|20","0|1","28|29","5|24");($r5,$r6)=("9|10|15|16|$r1|$r2","9|10|$r3");%h=("1|",$r6,"1=","[1-5]|2[0-4]","1/","0|19","1\\","6|25","2|","0|6|19|25|$r6","2/","1|20","2\\",$r4,"3|","$r2|6|$r1|25|$r6","3/",$r4,"4|","$r2|$r1|$r6","4=","2|3|4|11|12|13|14|21|22|23","4/",$r4,"4\\",15,"5|","$r2|9|15|$r1|20|$r3","5/",10,"6|",$r5,"7|",$r5,"7/",$r3);for($l=1;$l<8;$l++){b:for($i=0;$i<30;$i++){c:foreach(keys
%h){next c if(!(/^$l(.*)$/));$a=$1;if($i=~/^($h{$_})$/){print $a;next
b;}}print " ";}print "\n";}


------------------------------

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 1689
***************************************


home help back first fref pref prev next nref lref last post