[16327] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3739 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 21:05:38 2000

Date: Tue, 18 Jul 2000 18:05:12 -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: <963968712-v9-i3739@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 18 Jul 2000     Volume: 9 Number: 3739

Today's topics:
    Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!! (NP)
    Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!! (Randal L. Schwartz)
        calling Java methods / classes <arifsaha@yahoo.com>
    Re: CGI.pl problem with checkbox <makarand_kulkarni@my-deja.com>
    Re: chop vs. chomp (was: Read a file into a hash ?) <sumus@aut.dk>
    Re: chop vs. chomp (was: Read a file into a hash ?) <iltzu@sci.invalid>
    Re: chop vs. chomp (was: Read a file into a hash ?) (Abigail)
    Re: chop vs. chomp (was: Read a file into a hash ?) (Abigail)
    Re: convert string to real data. <makarand_kulkarni@my-deja.com>
        File handling problems!! <anuragmenon@my-deja.com>
    Re: File handling problems!! <wyzelli@yahoo.com>
    Re: File handling problems!! (jason)
    Re: File handling problems!! (Cameron Kennedy)
    Re: File handling problems!! (Matthew Zimmerman)
    Re: HELP: Pattern Match <bwalton@rochester.rr.com>
    Re: HELP: Pattern Match (Abigail)
    Re: How do you pass objects to a subroutine? <sumus@aut.dk>
        How to create a mandatory lock on a file using perl? <csyang@cisco.com>
    Re: Is there a Perl bug list? <nospam.nicedoctor@hotmail.com>
    Re: Modify every file in a directory (Neil Kandalgaonkar)
    Re: Modify every file in a directory (jason)
    Re: Modify every file in a directory (Neil Kandalgaonkar)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 18 Jul 2000 23:38:16 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!
Message-Id: <IT5d5.428525$VR.5453968@news5.giganews.com>

On 18 Jul 2000 14:38:20 -0700, Randal L. Schwartz <merlyn@stonehenge.com> wrote:
: 
: Anyone who says "take place periodically" about that event is clearly
: disconnected from reality, and should be distrusted on at least that
: item, and possibly others.

To clarify, a few Boston Perl Mongers (email) messages (where Randal
was the featured guest or speaker) mentioned that it was "buy Randal a
beer night".  Remember the Buddha beer glass/mug, Randal?  Yup, that
was a treasure of a Boston.pm "buy Randal a beer night".

: Amazing how a story can change to fit the speaker's (usually) hidden
: agenda.

If you're refer[r]ing to me, I have no agenda (in regards to the
earlier statements) whatsoever.  Do you have one in thinking that I
have one?

-- 
Nate II



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

Date: 18 Jul 2000 16:55:50 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!
Message-Id: <m1k8ej56yh.fsf@halfdome.holdit.com>

[ouch - this was stealth-cc'ed, and I already typed an answer in
private, which I'm now having to retype in public.  Thank you for
wasting my time.  <sigh> Please don't do that again.]

>>>>> "NP" == NP  <nvp@spamnothanks.speakeasy.org> writes:

NP> : Amazing how a story can change to fit the speaker's (usually) hidden
NP> : agenda.

NP> If you're refer[r]ing to me, I have no agenda (in regards to the
NP> earlier statements) whatsoever.  Do you have one in thinking that I
NP> have one?

Nope.  I'm referring to statements made by our pseudonyminal troll,
<p3rlc0dr@my-deja.com>, whom I now believe I have a good guess as to
the actual identity, or at least understand the person whom this
person most highly respects.  Cool.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 18 Jul 2000 17:32:57 -0500
From: S P Arif Sahari Wibowo <arifsaha@yahoo.com>
Subject: calling Java methods / classes
Message-Id: <Pine.LNX.4.21.0007181731080.14972-100000@ninitowo.civil.columbia.edu>

Hi!

I am looking to get a perl script using some Java classes and calling
their methods. As far as I know, there is two way to do it: using JPL
modules or Java.pm module.

Using JPL will require me to recompile perl - since its dynamic library
requirement, and that may cause perl run slower. Am I right?

Java.pm is nowhere in CPAN. Where is it? Did it work at all?

Any suggestion?

TIA!

-- 
                                   S P Arif Sahari Wibowo
  _____  _____  _____  _____ 
 /____  /____/ /____/ /____          arifsaha@yahoo.com
_____/ /      /    / _____/       http://www.arifsaha.com/


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

Date: Tue, 18 Jul 2000 16:14:44 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
To: tbalazs-this-must-go@netcomuk.co.uk
Subject: Re: CGI.pl problem with checkbox
Message-Id: <3974E4E4.92682ED1@my-deja.com>



> i.e. there is an extra "ref" being printed before Ref: 100, I guess

CGI.pm will handle the labeling by itself.

use CGI qw(:standard);
$a=100;
print p(checkbox(-name=>"ref",-checked=>'checked',-value=>'Y',
-label=>'ref'), " : $a");
~
~
~
~
~
~
~


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

Date: 19 Jul 2000 00:56:32 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: chop vs. chomp (was: Read a file into a hash ?)
Message-Id: <vgy3dp3z.fsf@macforce.sumus.dk>

iltzu@sci.invalid.bbs@openbazaar.net (Ilmari Karonen) writes:

> Further, we could argue than any claims about execution speed are next
> to worthless unless backed by benchmarks, and that benchmark results
> can sometimes be quite surprising:
> 
>   #!/usr/bin/perl -w
>   use strict;
>   use Benchmark;
> 
>   timethese 1<<(shift||0),
>     { chop  => '$_ = "\n"x1024; chop  while $_;',
>       chomp => '$_ = "\n"x1024; chomp while $_;',
>     };
> 
>   __END__
> 
>   Benchmark: timing 65536 iterations of chomp, chop...
>        chomp: 44 wallclock secs (43.74 usr +  0.00 sys = 43.74 CPU)
> 	chop: 51 wallclock secs (50.52 usr +  0.00 sys = 50.52 CPU)

Oh, but the benchmark is quite misleading. Did you do that on purpose?

with $_ = "\n"x1024 chop must execute 1024 times before not $_, while
chomp only has to execute once. That's not fair.

The question was which function would be faster at removing what is _known_
to be a _single_ newline at the end of a line of text.

Now I deviced a new (perhaps a bit noisy) benchmark test to check this:

use strict;
use Benchmark;

timethese 1<<16,
{ chop  => 'for (my$i=0;$i<100;$i++) { $_ = "Ugu:bu:ba\n"; chop; }',
  chomp => 'for (my$i=0;$i<100;$i++) { $_ = "Ugu:bu:ba\n"; chomp; }'
};

My results were that chomp is just as fast as chop - perhaps a bit faster:

Benchmark: timing 65536 iterations of chomp, chop...
     chomp: 16 wallclock secs (15.40 usr +  0.00 sys = 15.40 CPU)
      chop: 16 wallclock secs (15.70 usr +  0.00 sys = 15.70 CPU)

So the efficiency argument can be overruled in any case. And so the only reason
to ever use chop in stead of chomp is if you specifically want the chop
semantic and do not want that of chomp.

-- 
Jakob


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

Date: 19 Jul 2000 00:07:33 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: chop vs. chomp (was: Read a file into a hash ?)
Message-Id: <963964744.13633@itz.pp.sci.fi>

In article <vgy3dp3z.fsf@macforce.sumus.dk>, Jakob Schmidt wrote:
>iltzu@sci.invalid.bbs@openbazaar.net (Ilmari Karonen) writes:
                  ^^^^^^^^^^^^^^^^^^^
Not that it matters much in this case, but that's a rather interesting
way to mangle addresses..


>>   Benchmark: timing 65536 iterations of chomp, chop...
>>        chomp: 44 wallclock secs (43.74 usr +  0.00 sys = 43.74 CPU)
>> 	chop: 51 wallclock secs (50.52 usr +  0.00 sys = 50.52 CPU)
>
>Oh, but the benchmark is quite misleading. Did you do that on purpose?
>with $_ = "\n"x1024 chop must execute 1024 times before not $_, while
>chomp only has to execute once. That's not fair.

Ahem?  Why do you think chomp would only run once?  Did you test that?


>Benchmark: timing 65536 iterations of chomp, chop...
>     chomp: 16 wallclock secs (15.40 usr +  0.00 sys = 15.40 CPU)
>      chop: 16 wallclock secs (15.70 usr +  0.00 sys = 15.70 CPU)
>
>So the efficiency argument can be overruled in any case. And so the only reason
>to ever use chop in stead of chomp is if you specifically want the chop
>semantic and do not want that of chomp.

Agreed.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.





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

Date: 18 Jul 2000 20:21:22 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: chop vs. chomp (was: Read a file into a hash ?)
Message-Id: <slrn8n9u4v.3do.abigail@alexandra.delanet.com>

Jakob Schmidt (sumus@aut.dk) wrote on MMDXIII September MCMXCIII in
<URL:news:vgy3dp3z.fsf@macforce.sumus.dk>:
-- iltzu@sci.invalid.bbs@openbazaar.net (Ilmari Karonen) writes:
--
-- >   #!/usr/bin/perl -w
-- >   use strict;
-- >   use Benchmark;
-- > 
-- >   timethese 1<<(shift||0),
-- >     { chop  => '$_ = "\n"x1024; chop  while $_;',
-- >       chomp => '$_ = "\n"x1024; chomp while $_;',
-- >     };
-- > 
-- >   __END__
-- > 
-- >   Benchmark: timing 65536 iterations of chomp, chop...
-- >        chomp: 44 wallclock secs (43.74 usr +  0.00 sys = 43.74 CPU)
-- > 	chop: 51 wallclock secs (50.52 usr +  0.00 sys = 50.52 CPU)
--
-- Oh, but the benchmark is quite misleading. Did you do that on purpose?
--
-- with $_ = "\n"x1024 chop must execute 1024 times before not $_, while
-- chomp only has to execute once. That's not fair.

Really? Then why does the following print 1024?

    perl -wle '$_ = "\n" x 1024; chomp, $c ++ while $_; print $c'
    1024

Also:

    perl -wle '$_ = "\n" x 1024; chomp; print length'
    1023

--
-- The question was which function would be faster at removing what is _known_
-- to be a _single_ newline at the end of a line of text.
--
-- Now I deviced a new (perhaps a bit noisy) benchmark test to check this:
--
-- use strict;
-- use Benchmark;
--
-- timethese 1<<16,
-- { chop  => 'for (my$i=0;$i<100;$i++) { $_ = "Ugu:bu:ba\n"; chop; }',
--   chomp => 'for (my$i=0;$i<100;$i++) { $_ = "Ugu:bu:ba\n"; chomp; }'
-- };

This is a very silly benchmark. The dominating part of the benchmark is
the building of the $_. On top of that, you add some extra overhead of
a loop. If you want the chop/chomp to be executed 6553600 times, why
not "timethese 6553600 => { ... }" ?

    #!/opt/perl/bin/perl -w

    use strict;

    use Benchmark;

    timethese 1<<16,
    { chop  => 'for (my$i=0;$i<100;$i++) { $_ = "Ugu:bu:ba\n"; chop; }',
      chomp => 'for (my$i=0;$i<100;$i++) { $_ = "Ugu:bu:ba\n"; chomp; }',
      blank => 'for (my$i=0;$i<100;$i++) { $_ = "Ugu:bu:ba\n"; }',
    }
    __END__
    Benchmark: timing 65536 iterations of blank, chomp, chop...
        blank: 21 wallclock secs (20.41 usr +  0.00 sys = 20.41 CPU)
             @ 3210.98/s (n=65536)
        chomp: 34 wallclock secs (25.83 usr +  0.02 sys = 25.85 CPU)
             @ 2535.24/s (n=65536)
         chop: 33 wallclock secs (27.15 usr +  0.00 sys = 27.15 CPU)
             @ 2413.85/s (n=65536)



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: 18 Jul 2000 21:00:58 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: chop vs. chomp (was: Read a file into a hash ?)
Message-Id: <slrn8na0fg.3do.abigail@alexandra.delanet.com>

Ilmari Karonen (iltzu@sci.invalid) wrote on MMDXIV September MCMXCIII in
<URL:news:963964744.13633@itz.pp.sci.fi>:
-: In article <vgy3dp3z.fsf@macforce.sumus.dk>, Jakob Schmidt wrote:
-: >iltzu@sci.invalid.bbs@openbazaar.net (Ilmari Karonen) writes:
-:                   ^^^^^^^^^^^^^^^^^^^
-: Not that it matters much in this case, but that's a rather interesting
-: way to mangle addresses..

I'm sure that Ilmari didn't mangle his own address. It looks like a site
in Taiwan has been spewing. My filters killed about 500 postings from
"bbs@openbazaar.net" in this group this morning....



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: Tue, 18 Jul 2000 16:02:09 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
To: Edward C Morgan <ecmorgan@lucent.com>
Subject: Re: convert string to real data.
Message-Id: <3974E1F1.E6C649B4@my-deja.com>

> 
> %map=();
> $fh=IO::File->new("> foo");
> $map{$fh}=1;
you are using references as keys.
If you want to really do that then
use Tie::RefHash module

--


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

Date: Tue, 18 Jul 2000 22:58:01 GMT
From: Vinod K. Menon <anuragmenon@my-deja.com>
Subject: File handling problems!!
Message-Id: <8l2ndg$gmo$1@nnrp1.deja.com>

Hello all...

I have a file handling question. I am trying to sandwich two strings
that are created elsewhere in the code between two files and make that
into a new file. the two files are named "firstpart" and "secondpart"
and each of them are regular text files with about a 1000 lines each.
the following section of code does the manipulation. What is happening
is that when the newfile is generated, all that is there in the newfile
are the two strings ($keyString and $KeyValString2 - they are generated
elsewhere). Moreover, the other two files "firstpart" and "lastpart" are
also empty..the lines are deleted in those two!!! Then I replaced the
two files(firstpart and lastpart ) again with the 1000 lines (i had
copies thank god!) and opened them before I ran the script to see if
they had the text and they did. THen I ran the script (its part of a CGI
script) and the same thing happened. Only the two new strings in the
newfile and the other source files empty!!! The following is the section
of code that performs these operations.

I am going nuts trying to figure it out..can anyone help with
suggestions?
Vinod
------------------------------------------------------------


open(GENFILE, "> newfile")|| die "cannot create the file:$!";

open (FIRSTPART, "> firstpart")||die "cannot open file firstpart:$!";

while(<FIRSTPART>){
print GENFILE $-;
}

close(FIRSTPART);

print GENFILE "$KeyString \n ";
print GENFILE "$KeyValString2 \n";

open(SECONDPART, "> lastpart")||die "cannot open file secondpart:$!";

while (<SECONDPART>){
print GENFILE $_;
}

close(SECONDPART);
close (GENFILE);

rename ("newfile", "world.wrl");



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 19 Jul 2000 09:20:26 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: File handling problems!!
Message-Id: <I16d5.6$261.2121@vic.nntp.telstra.net>

Vinod K. Menon <anuragmenon@my-deja.com> wrote in message
news:8l2ndg$gmo$1@nnrp1.deja.com...
> Hello all...
>
> I have a file handling question. I am trying to sandwich two strings
> that are created elsewhere in the code between two files and make that
> into a new file. the two files are named "firstpart" and "secondpart"
> and each of them are regular text files with about a 1000 lines each.
> the following section of code does the manipulation. What is happening
> is that when the newfile is generated, all that is there in the
newfile
> are the two strings ($keyString and $KeyValString2 - they are
generated
> elsewhere). Moreover, the other two files "firstpart" and "lastpart"
are
> also empty..the lines are deleted in those two!!! Then I replaced the
> two files(firstpart and lastpart ) again with the 1000 lines (i had
> copies thank god!) and opened them before I ran the script to see if
> they had the text and they did. THen I ran the script (its part of a
CGI
> script) and the same thing happened. Only the two new strings in the
> newfile and the other source files empty!!! The following is the
section
> of code that performs these operations.
>
> I am going nuts trying to figure it out..can anyone help with
> suggestions?
> Vinod
> ------------------------------------------------------------
>
>
> open(GENFILE, "> newfile")|| die "cannot create the file:$!";

You are creating a new file here with the > operator

>
> open (FIRSTPART, "> firstpart")||die "cannot open file firstpart:$!";

Same here..

I think you want read mode which is either nothing (the default mode) or
the < operator.

Wyzelli





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

Date: Tue, 18 Jul 2000 23:49:45 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: File handling problems!!
Message-Id: <MPG.13df8a6cb86d6cbd9896ec@news>

Vinod K. Menon wrote ..
>Hello all...
>
>I have a file handling question. I am trying to sandwich two strings
>that are created elsewhere in the code between two files and make that
>into a new file. the two files are named "firstpart" and "secondpart"
>and each of them are regular text files with about a 1000 lines each.
>the following section of code does the manipulation. What is happening
>is that when the newfile is generated, all that is there in the newfile
>are the two strings ($keyString and $KeyValString2 - they are generated
>elsewhere). Moreover, the other two files "firstpart" and "lastpart" are
>also empty..the lines are deleted in those two!!! Then I replaced the
>two files(firstpart and lastpart ) again with the 1000 lines (i had
>copies thank god!) and opened them before I ran the script to see if
>they had the text and they did. THen I ran the script (its part of a CGI
>script) and the same thing happened. Only the two new strings in the
>newfile and the other source files empty!!! The following is the section
>of code that performs these operations.
>
>I am going nuts trying to figure it out..can anyone help with
>suggestions?
>Vinod
>------------------------------------------------------------
>
>
>open(GENFILE, "> newfile")|| die "cannot create the file:$!";
>
>open (FIRSTPART, "> firstpart")||die "cannot open file firstpart:$!";
>
>while(<FIRSTPART>){
>print GENFILE $-;
>}
>
>close(FIRSTPART);
>
>print GENFILE "$KeyString \n ";
>print GENFILE "$KeyValString2 \n";
>
>open(SECONDPART, "> lastpart")||die "cannot open file secondpart:$!";
>
>while (<SECONDPART>){
>print GENFILE $_;
>}
>
>close(SECONDPART);
>close (GENFILE);
>
>rename ("newfile", "world.wrl");

look at the documentation for open

  perldoc -f open

you're using it incorrectly for firstpart and lastpart

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Tue, 18 Jul 2000 16:49:05 -0800
From: kenned57@NoSpam.edu (Cameron Kennedy)
Subject: Re: File handling problems!!
Message-Id: <kenned57-1807001649050001@alexthinkpad.salk.edu>

In article <8l2ndg$gmo$1@nnrp1.deja.com>, Vinod K. Menon
<anuragmenon@my-deja.com> wrote:

> Hello all...
> 
> I have a file handling question. 
> ------------------------------------------------------------

> open (FIRSTPART, "> firstpart")||die "cannot open file firstpart:$!";

opening for writing will erase your file content. do you want reading or
appending?
i would guess reading for this
open(FIRST,"<first") or die;


> open(SECONDPART, "> lastpart")||die "cannot open file secondpart:$!";

Same as above.

--
Cameron


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

Date: 18 Jul 2000 23:44:50 GMT
From: mdz4c@node1.unix.Virginia.EDU (Matthew Zimmerman)
Subject: Re: File handling problems!!
Message-Id: <8l2q5i$rtl$1@murdoch.acc.Virginia.EDU>

In article <8l2ndg$gmo$1@nnrp1.deja.com>,
Vinod K. Menon  <anuragmenon@my-deja.com> wrote:
>
>open(GENFILE, "> newfile")|| die "cannot create the file:$!";
>
>open (FIRSTPART, "> firstpart")||die "cannot open file firstpart:$!";
                   ^
                   ^
         should be <  (you're opening it for input)

>
>while(<FIRSTPART>){
>print GENFILE $-;
               ^^
               ^^
     should be $_

>}
>
>close(FIRSTPART);
>
>print GENFILE "$KeyString \n ";
                          ^  ^
                          ^  ^

>print GENFILE "$KeyValString2 \n";
                              ^
                              ^
                     Why the superfluous spaces?

>
>open(SECONDPART, "> lastpart")||die "cannot open file secondpart:$!";
                   ^
                   ^
         should be < (see above)


>
>while (<SECONDPART>){
>print GENFILE $_;
>}
>
>close(SECONDPART);
>close (GENFILE);
>
>rename ("newfile", "world.wrl");

Other than that, the code you have should work. Perhaps the bug is
somewhere else in your code? 

By the way, indentation is your friend. :)

HTH!
Matt

-- 
-- 
|Matthew Zimmerman            http://www.people.virginia.edu/~mdz4c  |
|Interdisciplinary Biophysics Program |"I AM serious.                |
|University of Virginia               | And stop calling me Shirley."|


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

Date: Tue, 18 Jul 2000 22:11:23 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: HELP: Pattern Match
Message-Id: <3974D645.1E527FF6@rochester.rr.com>

Nigel Heinsius wrote:
> 
> I need to make sure customers are not abbreviating Street, Avenue, etc.
> 
> Why doesn't this pattern match work:
> 
> $address =~ s/\bst\.?\b|\bstr\.?\b/Street/ig;
> 
> It keeps giving me "Street." with the period on the end. Why can't I match
> the period?
> 
> Nigel

That is because the first thing the regular expression engine tries to
match is the string 'st' followed by zero periods.  That match will
succeed regard of whether the string being matched is 'st', 'st.',
'str', 'str.', or 'street'.  Then the \b tries to match, which will
succeed if a period or a space (or any other non-word character or the
end of the string or a newline) is next.  Thus, it succeeds for 'st.',
matching just the 'st' piece.  That then gets substituted with Street,
which leaves the period.  The same logic applies for 'str.'.
-- 
Bob Walton


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

Date: 18 Jul 2000 18:26:02 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: HELP: Pattern Match
Message-Id: <slrn8n9nd1.3do.abigail@alexandra.delanet.com>

Nigel Heinsius (heinsius@u.washington.edu) wrote on MMDXIII September
MCMXCIII in <URL:news:B59A0A29.13C0%heinsius@u.washington.edu>:
\\ I need to make sure customers are not abbreviating Street, Avenue, etc.
\\ 
\\ Why doesn't this pattern match work:
\\ 
\\ $address =~ s/\bst\.?\b|\bstr\.?\b/Street/ig;
\\ 
\\ It keeps giving me "Street." with the period on the end. Why can't I match
\\ the period?


Because you instruct Perl to only match the period if needed.
Perl doesn't have to use the period to match the regex, so,
it does as instructed and leaves the period alone.

Now, tell us, why do you use the ?'s in the regex?


Abigail
-- 
BEGIN {$^H {q} = sub {$_ [1] =~ y/S-ZA-IK-O/q-tc-fe-m/d; $_ [1]}; $^H = 0x28100}
print "Just another PYTHON hacker\n";


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

Date: 19 Jul 2000 01:01:07 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: How do you pass objects to a subroutine?
Message-Id: <u2dndowc.fsf@macforce.sumus.dk>

Frederic <j_f9NOj_SPAM@yahoo.com.invalid> writes:

> I created a new Net::FTP object ($ftp = Net::FTP->new
> ("some.host.name");) and I want to pass a reference to it to a
> subroutine where it's going to be dereferenced.  How do I do
> that?

Just do it. The reference is in $ftp, so:

mySub( $ftp );

does the tricky trick.

In the sub retrieve the reference as any other scalar and do with it what
you do with object references.

-- 
Jakob


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

Date: Tue, 18 Jul 2000 18:00:27 -0700
From: Chien Yang <csyang@cisco.com>
Subject: How to create a mandatory lock on a file using perl?
Message-Id: <3974FDAB.13B6DC00@cisco.com>

Hello,

I want to create a mandatory lock on a file using perl, so other process
can not modify the file when the script is run.  How can I do that?
Thanks.


Chien



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

Date: Tue, 18 Jul 2000 23:04:54 GMT
From: "Mark Lewis" <nospam.nicedoctor@hotmail.com>
Subject: Re: Is there a Perl bug list?
Message-Id: <qo5d5.1166$GQ1.40807@newsread2.prod.itd.earthlink.net>


Jonathan Stowe wrote in message <3bRGl4$UmO@openbazaar.net>...
>On Mon, 17 Jul 2000 03:15:41 GMT, Mark Lewis Wrote:
>>
>> Jonathan Stowe wrote in message
<8ksbpn$av5$1@orpheus.gellyfish.com>...
>>>On Sun, 16 Jul 2000 03:18:58 GMT Mark Lewis wrote:
>>>> Hello,
>>>>
>>>> Where can a comprehensive list of confirmed Perl bugs be found? The
>> only
>>>> thing I have be able to find is an outdated list at perl.com.
>>>>
>>>
>>><http://bugs.perl.org> at a guess ...
>>>
>>
>>
>> This seems to be what I'm looking for. I went to this website and
tried
>> the database form with no luck. No matter what I enter in the form,
>> submitting the form results in a blank database form being returned.
The
>> help info at the site doesn't help.
>>
>> Can anyone instruct me as to how to use the database search form at
>> bugs.perl.org?
>>
>
>But an asterisk in the subject field and press query ....


Tried this but still nothing, just get a blank database form after
selecting query.





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

Date: Tue, 18 Jul 2000 23:17:01 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: Modify every file in a directory
Message-Id: <8l2o4g$1kg$1@localhost.localdomain>

In article <8l2eq6$a26$1@nnrp1.deja.com>,  <tony121076@my-deja.com> wrote:
>I have 30 to 50 text files in a directory. They are all formated the
>same (a simple database). I need to change the 6th column of every entry
>in every file of the directory. How should I go about this? Thank you
>for your time and attention.

Assuming your files are whitespace delimited, and that you want to change
every occurence of "foo" in the 6th column to "bar", this one-liner
will suffice:

$ perl -pli.bak -e '@F=split; $F[5] =~ s/foo/bar/; $_ = join "\t", @F' *

See man perlrun for an explanation of the switches.

-- 
Neil Kandalgaonkar <neil@brevity.org>


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

Date: Tue, 18 Jul 2000 23:54:25 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Modify every file in a directory
Message-Id: <MPG.13df8b8710f82a759896ed@news>

Neil Kandalgaonkar wrote ..
>In article <8l2eq6$a26$1@nnrp1.deja.com>,  <tony121076@my-deja.com> wrote:
>>I have 30 to 50 text files in a directory. They are all formated the
>>same (a simple database). I need to change the 6th column of every entry
>>in every file of the directory. How should I go about this? Thank you
>>for your time and attention.
>
>Assuming your files are whitespace delimited, and that you want to change
>every occurence of "foo" in the 6th column to "bar", this one-liner
>will suffice:
>
>$ perl -pli.bak -e '@F=split; $F[5] =~ s/foo/bar/; $_ = join "\t", @F' *
>
>See man perlrun for an explanation of the switches.

also assuming that you have a non-whitespace value in all of the first 6 
fields

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Wed, 19 Jul 2000 00:11:56 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: Modify every file in a directory
Message-Id: <8l2rbe$1qe$1@localhost.localdomain>

In article <MPG.13df8b8710f82a759896ed@news>,
jason <elephant@squirrelgroup.com> wrote:
>>Assuming your files are whitespace delimited, and that you want to change
>>every occurence of "foo" in the 6th column to "bar", this one-liner
>>will suffice:
>>
>>$ perl -pli.bak -e '@F=split; $F[5] =~ s/foo/bar/; $_ = join "\t", @F' *
>>
>>See man perlrun for an explanation of the switches.
>
>also assuming that you have a non-whitespace value in all of the first 6 
>fields

It wouldn't be whitespace delimited then, would it?

Assuming another delimiter, say '|';

perl -F'\|' -pali.bak -e '$F[5] =~ s/this/that/; $_ = join "|", @F' *


-- 
Neil Kandalgaonkar <neil@brevity.org>


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

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


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