[29401] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 645 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 12 00:09:54 2007

Date: Wed, 11 Jul 2007 21:09:03 -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           Wed, 11 Jul 2007     Volume: 11 Number: 645

Today's topics:
    Re: Capturing a Repeated Group <xicheng@gmail.com>
    Re: Capturing a Repeated Group <noreply@gunnar.cc>
    Re: Capturing a Repeated Group <xicheng@gmail.com>
    Re: Capturing a Repeated Group <attn.steven.kuo@gmail.com>
    Re: Capturing a Repeated Group <xicheng@gmail.com>
    Re: Difficulty manipulating hashes <rvtol+news@isolution.nl>
    Re: Difficulty manipulating hashes <invalid@invalid.net>
    Re: Difficulty manipulating hashes <dummy@example.com>
    Re: Difficulty manipulating hashes <tadmc@seesig.invalid>
    Re: How to turn off taint checking in cgi <savagebeaste@yahoo.com>
        How to undo a bless on a GLOB <yshtil@cisco.com>
    Re: Portable general timestamp format, not 2038-limited <nospam-abuse@ilyaz.org>
    Re: Portable general timestamp format, not 2038-limited <maravera@prodigy.net>
    Re: Portable general timestamp format, not 2038-limited <martin@see.sig.for.address>
    Re: Remove a specific element from an Array <rvtol+news@isolution.nl>
    Re: sysread vs read? <socyl@987jk.com.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 11 Jul 2007 20:23:28 -0000
From:  Xicheng Jia <xicheng@gmail.com>
Subject: Re: Capturing a Repeated Group
Message-Id: <1184185408.752017.133090@n2g2000hse.googlegroups.com>

On Jul 11, 3:56 pm, "per...@gmail.com" <per...@gmail.com> wrote:
> Hi!
>
> I'm new to perl/regular expressions but experience programmer. I'm
> trying to match a formatted number 123,456,789 and convert it into an
> integer. Thought the following would do, but it don't.
>
> $_ = "1,234,567,890";
> my @parts;
> (@parts = /(\d{1,3})(?:,(\d{3}))*/g) && do {

you probably want this:

   @parts = /(\d{1,3})(?=,(?:\d{3}))*/g  .....

Regards,
Xicheng


>     my $number = 0;
>     $number = $number * 1000 + $_ foreach (@parts);
>     print "$number\n";
>
> };
>




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

Date: Thu, 12 Jul 2007 01:55:11 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Capturing a Repeated Group
Message-Id: <5fl950F3d4e1gU1@mid.individual.net>

Xicheng Jia wrote:
> On Jul 11, 3:56 pm, "per...@gmail.com" <per...@gmail.com> wrote:
>> I'm trying to match a formatted number 123,456,789 and convert 
>>  it into an integer. Thought the following would do, but it don't.
>>
>> $_ = "1,234,567,890";
>> my @parts;
>> (@parts = /(\d{1,3})(?:,(\d{3}))*/g) && do {
> 
> you probably want this:
> 
>    @parts = /(\d{1,3})(?=,(?:\d{3}))*/g  .....

Let's see:

C:\home>type test.pl
use warnings;
$_ = '1,234,567,890';
@parts = /(\d{1,3})(?=,(?:\d{3}))*/g;
print @parts, "\n";

C:\home>test.pl
(?=,(?:\d{3}))* matches null string many times in regex; marked by
<-- HERE in m/(\d{1,3})(?=,(?:\d{3}))* <-- HERE / at C:\home\test.pl
line 3.
1234567890

Generates a warning; not so good...

C:\home>type test.pl
use warnings;
$_ = '1,234,567,890';
@parts = /(\d{1,3})(?=(?:,\d{3}|$))/g;
print @parts, "\n";

C:\home>test.pl
1234567890

That's better. :)

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Thu, 12 Jul 2007 02:59:32 -0000
From:  Xicheng Jia <xicheng@gmail.com>
Subject: Re: Capturing a Repeated Group
Message-Id: <1184209172.528987.69950@w3g2000hsg.googlegroups.com>

On Jul 11, 7:55 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> Xicheng Jia wrote:
> > On Jul 11, 3:56 pm, "per...@gmail.com" <per...@gmail.com> wrote:
> >> I'm trying to match a formatted number 123,456,789 and convert
> >>  it into an integer. Thought the following would do, but it don't.
>
> >> $_ = "1,234,567,890";
> >> my @parts;
> >> (@parts = /(\d{1,3})(?:,(\d{3}))*/g) && do {
>
> > you probably want this:
>
> >    @parts = /(\d{1,3})(?=,(?:\d{3}))*/g  .....
>
> Let's see:
>
> C:\home>type test.pl
> use warnings;
> $_ = '1,234,567,890';
> @parts = /(\d{1,3})(?=,(?:\d{3}))*/g;
> print @parts, "\n";
>
> C:\home>test.pl
> (?=,(?:\d{3}))* matches null string many times in regex; marked by
> <-- HERE in m/(\d{1,3})(?=,(?:\d{3}))* <-- HERE / at C:\home\test.pl
> line 3.
> 1234567890
>

err, I just copy/paste OP's code, and didnt test it. but the point was
there: capturing only when needed

> Generates a warning; not so good...
>
> C:\home>type test.pl
> use warnings;
> $_ = '1,234,567,890';
> @parts = /(\d{1,3})(?=(?:,\d{3}|$))/g;
> print @parts, "\n";
> C:\home>test.pl
> 1234567890
>
> That's better. :)

I havenot used (?=...) with '*' by myself, and did not notice that
before, but I think (?=....)? should be fine, like:

  @parts = /(\d{1,3})(?=,\d\d\d)?/g;

you don't need the extra parentheses inside the (?= ...), right. :-)

Regards,
Xicheng



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

Date: Thu, 12 Jul 2007 03:09:41 -0000
From:  "attn.steven.kuo@gmail.com" <attn.steven.kuo@gmail.com>
Subject: Re: Capturing a Repeated Group
Message-Id: <1184209781.603047.232320@o61g2000hsh.googlegroups.com>

On Jul 11, 12:56 pm, "per...@gmail.com" <per...@gmail.com> wrote:
> Hi!
>
> I'm new to perl/regular expressions but experience programmer. I'm
> trying to match a formatted number 123,456,789 and convert it into an
> integer. Thought the following would do, but it don't.
>
> $_ = "1,234,567,890";
> my @parts;
> (@parts = /(\d{1,3})(?:,(\d{3}))*/g) && do {
>     my $number = 0;
>     $number = $number * 1000 + $_ foreach (@parts);
>     print "$number\n";
>
> };
>
> The problem is that this expression doesn't save repeated groups, it
> discard captured repeated groups except the last repeat (so it works
> for "123,456" numbers.) If I instead match the below it works, but I
> can't understand the logic behind it (if there is any logic?)
>
> (@parts = /(\d{1,3})(?:,(\d{3})+)/g) && do { # not really equivalent
> to the above, but almost
>     my $number = 0;
>     $number = $number * 1000 + $_ foreach (@parts);
>     print "$number\n";
>
> };
>



The latter won't work for a target string like:

$_ = '123,456,789';

(i.e., anything with an odd number of comma delimited substrings).


You can try global match (//g) in scalar context:

$_ = "1,234,567,890";

my $n = 0;
while (/\G(\d{1,3})(?:,|$)/g)
{
    $n = $n * 1000 + $1;
}

print "$n\n";

tr/,//d;

if ($n == $_)
{
    print "A string of numbers is converted to a number automagically
\n";
}

--
Hope this helps,
Steven



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

Date: Thu, 12 Jul 2007 03:18:55 -0000
From:  Xicheng Jia <xicheng@gmail.com>
Subject: Re: Capturing a Repeated Group
Message-Id: <1184210335.319807.235130@57g2000hsv.googlegroups.com>

On Jul 11, 11:09 pm, "attn.steven....@gmail.com"
<attn.steven....@gmail.com> wrote:
> On Jul 11, 12:56 pm, "per...@gmail.com" <per...@gmail.com> wrote:
>
>
>
>
>
> > Hi!
>
> > I'm new to perl/regular expressions but experience programmer. I'm
> > trying to match a formatted number 123,456,789 and convert it into an
> > integer. Thought the following would do, but it don't.
>
> > $_ = "1,234,567,890";
> > my @parts;
> > (@parts = /(\d{1,3})(?:,(\d{3}))*/g) && do {
> >     my $number = 0;
> >     $number = $number * 1000 + $_ foreach (@parts);
> >     print "$number\n";
>
> > };
>
> > The problem is that this expression doesn't save repeated groups, it
> > discard captured repeated groups except the last repeat (so it works
> > for "123,456" numbers.) If I instead match the below it works, but I
> > can't understand the logic behind it (if there is any logic?)
>
> > (@parts = /(\d{1,3})(?:,(\d{3})+)/g) && do { # not really equivalent
> > to the above, but almost
> >     my $number = 0;
> >     $number = $number * 1000 + $_ foreach (@parts);
> >     print "$number\n";
>
> > };
>
> The latter won't work for a target string like:
>
> $_ = '123,456,789';
>
> (i.e., anything with an odd number of comma delimited substrings).
>
> You can try global match (//g) in scalar context:
>
> $_ = "1,234,567,890";
>
> my $n = 0;
> while (/\G(\d{1,3})(?:,|$)/g)

this should be the same as:

   while (/\G(\d{1,3}),?/g)

Regards,
Xicheng


> {
>     $n = $n * 1000 + $1;
>
> }
>
> print "$n\n";
>
> tr/,//d;
>
> if ($n == $_)
> {
>     print "A string of numbers is converted to a number automagically
> \n";
>
> }
>
> --
> Hope this helps,
> Steven- Hide quoted text -
>
> - Show quoted text -




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

Date: Wed, 11 Jul 2007 23:19:50 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Difficulty manipulating hashes
Message-Id: <f73ojo.12c.1@news.isolution.nl>

limitz schreef:

> Here is my script, followed by my question at the end:

Missing:

#!/usr/bin/perl
  use strict;
  use warnings;

Never leave those out!


> print "\nThere are a total of 18990 bases in the entire sequence\n";
> print "\nWhat is the starting base number? Keep in mind that Perl
> begins the tally";
> print "\nwith 0. So if you wanted to start from base 30, input in
> 29\n";

Why not just subtract 1 from the input?

BTW, where does $fastasequence get filled?


  $seq =~ s/[^ACGT]+//g;  # remove any garbage like whitespace or
newlines

  my $seq_len = length $seq;

  print <<"EOT";

There are a total of ${seq_len} bases in the entire sequence

What is the starting base number?
EOT


> #Here we can define where we want the sequence to begin and end
> print "Input Starting Number:\n";
> $beginning_of_sequence = <STDIN>;

  my $seq_begin = <STDIN>;


> print "Input Ending Base Number:\n";
> $end_of_sequence = <STDIN>;

  my $seq_end   = <STDIN>;


> $length_of_sequence = $end_of_sequence-$beginning_of_sequence+1;

  $seq_len      = $seq_end - $seq_begin + 1;


> %dinucleotidepair = (
> AT => 0,
> [...]
> GG => 0,
> );

  my %dinucleotidepair;
  $dinucleotidepair{
      qw( AA AC AG AT
          CA CC CG CT
          GA GC GG GT
          TA TC TG TT ) } = (0) x 16;


> for my $i (0 .. $length_of_sequence-1) {
>         foreach (keys %dinucleotidepair) {
>                 $dinucleotidepair{$_}++ if substr($fastasequence, $i,
> 2) =~ /$_/;
>         }

Because you step through it by 1 character, a ATA will count an AT and a
TA, is that what you want?

You could then also replace your loops by


  my %pair;

  $pair{$_}++ for
      (substr($seq, $seq_begin - 1, $seq_len) =~ /(..)/g);

  $pair{$_}++ for
      (substr($seq, $seq_begin, $seq_len - 1) =~ /(..)/g);


> while ( my($keys,$values) = each(%dinucleotidepair) ) {
>         print "$keys $values\n";
> }

  print "$_ $pair{$_}\n" for keys %pair;

There are in total ($seq_len - 1) pairs, so just divide by that.



#!/usr/bin/perl
  use strict;
  use warnings;

  my $seq = do { local $/; <DATA> };

  # remove any garbage like whitespace or newlines
  $seq =~ s/[^ACGT]+//g;

  my $seq_len = length $seq;

  print qq(
There are a total of ${seq_len} bases in the entire sequence.\n
Input Starting Number: );
  my $seq_begin = <>;

  print qq(
Input Ending Number  : );
  my $seq_end   = <>;

  $seq_len = $seq_end - $seq_begin + 1;
  print qq(
Sequence length      : $seq_len\n\n);

  my %pair;
  @pair{ qw( AA AC AG AT
             CA CC CG CT
             GA GC GG GT
             TA TC TG TT ) } = (0) x 16;

  $pair{$_}++ for
      (substr($seq, $seq_begin - 1, $seq_len) =~ /(..)/g);
  $pair{$_}++ for
      (substr($seq, $seq_begin, $seq_len - 1) =~ /(..)/g);

  printf "%d pairs:\n--\n", scalar keys %pair;

  for my $k (sort keys %pair) {
      my $v = $pair{$k};
      printf "%s %5d %5.3f\n", $k, $v, $v / ($seq_len - 1);
  }

__DATA__
ACGTGCATGCACGTAATGATCCATG
ACGTGCATGCACGTAATGATCCATG
ACGTGCATGCACGTAATGATCCATG
ACGTGCATGCACGTAATGATCCATG
ACGTGCATGCACGTAATGATCCATG
ACGTGCATGCACGTAATGATCCATG
ACGTGCATGCACGTAATGATCCATG
ACGTGCATGCACGTAATGATCCATG
ACGTGCATGCACGTAATGATCCATG
ACGTGCATGCACGTAATGATCCATG

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Wed, 11 Jul 2007 17:59:37 -0400
From: "merl the perl" <invalid@invalid.net>
Subject: Re: Difficulty manipulating hashes
Message-Id: <3b-dnY2P6ZRQzwjbnZ2dnUVZ_vWtnZ2d@comcast.com>


"Dr.Ruud" <rvtol+news@isolution.nl> wrote in message 
news:f73ojo.12c.1@news.isolution.nl...
> limitz schreef:
>
>> Here is my script, followed by my question at the end:
I have a different question.  I don't know what a hash literal is.  In my 
reference book, I can find out things about a hash, which apparently in perl 
has nothing to do with the character that I call "hash:" #.  "Literal" is no 
help in the index.  I'm thinking that a hash literal might be the spoken 
version of something else, probably with more words, in the literature, and 
seek comment on it.

> __DATA__
> ACGTGCATGCACGTAATGATCCATG
> ACGTGCATGCACGTAATGATCCATG
> ACGTGCATGCACGTAATGATCCATG
> ACGTGCATGCACGTAATGATCCATG
> ACGTGCATGCACGTAATGATCCATG
> ACGTGCATGCACGTAATGATCCATG
> ACGTGCATGCACGTAATGATCCATG
> ACGTGCATGCACGTAATGATCCATG
> ACGTGCATGCACGTAATGATCCATG
> ACGTGCATGCACGTAATGATCCATG
Why do you want the same gene over and over again?
-- 
merl




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

Date: Thu, 12 Jul 2007 00:51:20 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: Difficulty manipulating hashes
Message-Id: <cWeli.30709$Io4.29977@edtnps89>

Dr.Ruud wrote:
> limitz schreef:
> 
>> Here is my script, followed by my question at the end:
> 
> Missing:
> 
> #!/usr/bin/perl
>   use strict;
>   use warnings;
> 
> Never leave those out!
> 
> 
>> print "\nThere are a total of 18990 bases in the entire sequence\n";
>> print "\nWhat is the starting base number? Keep in mind that Perl
>> begins the tally";
>> print "\nwith 0. So if you wanted to start from base 30, input in
>> 29\n";
> 
> Why not just subtract 1 from the input?
> 
> BTW, where does $fastasequence get filled?
> 
> 
>   $seq =~ s/[^ACGT]+//g;  # remove any garbage like whitespace or
> newlines

Or do it more efficiently:

     $seq =~ tr/ACGT//cd;  # remove any garbage like whitespace or newlines

>   my $seq_len = length $seq;
> 
>   print <<"EOT";
> 
> There are a total of ${seq_len} bases in the entire sequence



John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Wed, 11 Jul 2007 19:02:16 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Difficulty manipulating hashes
Message-Id: <slrnf9ars8.9s5.tadmc@tadmc30.sbcglobal.net>

Dr.Ruud <rvtol+news@isolution.nl> wrote:

>   $seq =~ s/[^ACGT]+//g;  # remove any garbage like whitespace or newlines


   $seq =~ tr/ACGT//cd;  # same thing, only much faster


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Wed, 11 Jul 2007 17:26:30 -0700
From: "Clenna Lumina" <savagebeaste@yahoo.com>
Subject: Re: How to turn off taint checking in cgi
Message-Id: <5flaptF3dud4fU1@mid.individual.net>

anno4000@radom.zrz.tu-berlin.de wrote:
> Lars Eighner  <usenet@larseighner.com> wrote in comp.lang.perl.misc:
>
>> Well, apparently it is an apache problem -- or at least I have an
>> apache problem.  I cannot get suexec to work on 2.0.x; and nothing
>> containing backticks, system, etc. works.  Similar things also do not
>> work in sh scripts (although of course everything runs fine from the
>> commandline).  Perl (when taint is given sneering lip service) and sh
>> scripts work fine with apache 1.3.xx, but I don't have a php5 module
>> that works with that.  Likewise with versions of apache above 2.0.xx
>> -- no php handler.
>
> Off topic, and at the risk of belaboring the obvious, have you checked
> $PATH in the different runs of apache?

Global symbol "$PATH" requires explicit package name at line 1.

Maybe he should check $ENV{PATH} instead :)

This will give you a nice list:

   print join("\n", split /:/, $ENV{PATH}), "\n";

-- 
CL 




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

Date: Wed, 11 Jul 2007 15:56:35 -0700
From: Yuri Shtil <yshtil@cisco.com>
Subject: How to undo a bless on a GLOB
Message-Id: <1184194581.929802@sj-nntpcache-2.cisco.com>

The scenario is like this:
A GLOB was created via Symbol::gensym:

use Symbol
my $foo = gensym();

The reference was blessed to something:

bless $foo, 'Something';

I need to be able to revert $foo back to the glob.

How do I do it?

Detail:

The reason for all this trouble is that a module with a garbage 
collector (POE) keeps track of $foo in a hash keyed by $foo itself, 
which is a stringified reference. When I bless it, the garbage collector 
cannot find the reference.

The reason why I needed to bless the glob is too involved, I can post 
details if you think they are relevant.


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

Date: Wed, 11 Jul 2007 22:04:35 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Portable general timestamp format, not 2038-limited
Message-Id: <f73k5j$nvf$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Martin Gregorie 
<martin@see.sig.for.address>], who wrote in article <qkvem4-slt.ln1@zoogz.gregorie.org>:
> >> Its in "A Short History of Time". Sorry I can't quote chapter or page, 
> >> but a friend borrowed my copy and lent me Dawkins "Climbing Mount 
> >> Improbable" before vanishing, never to be seen since. Not an equal 
> >> exchange: I preferred ASHOT to CMI.

> Oops - I should have written "A Brief History of Time". It was the first 
> edition, so I don't know if it was altered/edited out of later versions.

> > I would prefer a reference to a peer-reviewed paper.  ;-)

> Sure, but I don't think you'll find one. It was in a descriptive, rather 
> than rigorous, passage. But then, the book famously had only one 
> equation in it.

[I've heard about this book.]

My point is that attributing something to SH due to it appearing in
ABHoT is like attributing it to you since it was mentioned in your
post...

Hope this helps,
Ilya


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

Date: Wed, 11 Jul 2007 16:42:43 -0700
From:  Michael Angelo Ravera <maravera@prodigy.net>
Subject: Re: Portable general timestamp format, not 2038-limited
Message-Id: <1184197363.256796.39820@k79g2000hse.googlegroups.com>

On Jun 22, 1:33 pm, James Harris <james.harri...@googlemail.com>
wrote:
> I have a requirement to store timestamps in a database. Simple enough
> you might think but finding a suitably general format is not easy. The
> specifics are
>
> 1) subsecond resolution - milliseconds or, preferably, more detailed
> 2) not bounded by Unix timestamp 2038 limit
> 3) readable in Java
> 4) writable portably in Perl which seems to mean that 64-bit values
> are out
> 5) readable and writable in Python
> 6) storable in a free database - Postgresql/MySQL
>
> The formats provided by the two database systems are such as 8-byte or
> 12-byte values which, even if I could get Perl to work with I guess it
> would be messy. Keeping to 32-bit values should give me portability
> and be easy enough to work with without obscuring the program logic.
> Since 32 bits of microseconds is less than 50 days I have to store two
> 32-bit values. How to split them? The option I favour at the moment is
> to split days and parts of days like this:
>
> a) store, as a 32-bit number, days since a virtual year zero (there is
> no year zero in common era time <http://en.wikipedia.org/wiki/
> Common_Era>). This allows over five million years plus and minus.
> Still not completely general, I know.
> b) store parts of days as another 32-bit value. Its range would have
> to go to 86401 seconds - the number of seconds in a leap day. This
> means each 'tick' would be around 21 microseconds. For regularity I
> could make the ticks 25 microseconds so there would be 40,000 in a
> second and 3,456,000,000 in a day; and, finally, the counter could
> tick about 5 hours into the next day if not caught.
>
> Any thoughts on a better way to do this? (Please reply-all. Thanks).

The best timestamp of which I am aware is microseconds since the
calendarical convergence back in 4713 BCE. This is the format used on
the old Tandem systems. Tandem chose to begin days at midnight, so
with some small tweaking, you can calculate the Julian day (by adding
12 hours) also, but you can choose to begin them at noon (as the
official Julian day does).

It is easily represented in 64 bits and won't overflow until well past
10000 CE. It also has the advantage of making for easy easy time
arithmetic and for reasonable conversion into any native format with
resolution no better than about 10 nanoseconds. You have to be
careful, if your resolution is better than that (you might overflow a
64-bit number if you try to go to your native format by multiplying
first), but it is quite useful.

The magic number for Unix-32 format is 210866760000000000 (or that
divided by 1000 or 1000000 depending upon which way you go)





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

Date: Thu, 12 Jul 2007 00:10:12 +0100
From: Martin Gregorie <martin@see.sig.for.address>
Subject: Re: Portable general timestamp format, not 2038-limited
Message-Id: <qj4gm4-9d5.ln1@zoogz.gregorie.org>

Ilya Zakharevich wrote:
> My point is that attributing something to SH due to it appearing in
> ABHoT is like attributing it to you since it was mentioned in your
> post...
>
OK, so who should it be attributed to?


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |


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

Date: Wed, 11 Jul 2007 23:43:45 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Remove a specific element from an Array
Message-Id: <f73q3e.ak.1@news.isolution.nl>

Petr Vileta schreef:

>  foreach $item (0..$#updateNames)
>  {
>     foreach $item2 (@tempArr)
>     {
>         if (@updateNames[$item] eq $item2)
>         {
>             splice @updateNames, $item, 1;

I think it is better to undef the array element here, 
and then remove the undefined elements by a grep, after the loop.

>         }
>     }
>  }

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: Wed, 11 Jul 2007 23:43:38 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: Re: sysread vs read?
Message-Id: <f73pva$t7k$1@reader2.panix.com>

In <20070711124042.743$z3@newsreader.com> xhoster@gmail.com writes:
>kj <socyl@987jk.com.invalid> wrote:
>> But, reading your reply between the lines a bit, I'm now guessing
>> that maybe Perl already does precisely this behind the scenes even
>> when one uses readline, meaning that I would not be gaining much
>> speed, and may even lose some, by switching from my naive <$fh>
>> implementation to one using read or sysread.  Did I get this right?

>Yes, read and readline already do chunking.

Cool.  Thanks!

kj

-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


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

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 V11 Issue 645
**************************************


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