[24368] in Perl-Users-Digest
Perl-Users Digest, Issue: 6557 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 13 00:05:53 2004
Date: Wed, 12 May 2004 21: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 Wed, 12 May 2004 Volume: 10 Number: 6557
Today's topics:
Re: A Stupid question. <usenet@morrow.me.uk>
Re: Books online???? <ebohlman@earthlink.net>
Finding the newest directory <sc0ri0n@hotmail.com>
Re: Finding the newest directory (Sam Holden)
Re: Finding the newest directory <usenet@morrow.me.uk>
Re: Finding the newest directory <sc0ri0n@hotmail.com>
Re: Finding the newest directory (Sam Holden)
Re: grep <ebohlman@earthlink.net>
Re: How to hide "if $DEBUG" code? <jboes@nexcerpt.com>
Re: module bad design?) <gnari@simnet.is>
Re: Module/recipe to resolve full pathnames? <usenet@morrow.me.uk>
Re: Perl distribution with threads support (Kevin Collins)
Re: Perl PGP <matthew.garrish@sympatico.ca>
Re: Unexpected sysread block <usenet@morrow.me.uk>
Using hashes to sort number sequences (Martin Foster)
Re: Using hashes to sort number sequences <invalid-email@rochester.rr.com>
Re: Using match variables ($1, $2 ...) as variables. <nospam-abuse@ilyaz.org>
Win32-GuiTest and waits (Tom)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 13 May 2004 01:09:33 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: A Stupid question.
Message-Id: <c7uhsd$pkj$1@wisteria.csv.warwick.ac.uk>
Quoth Chris Mattern <matternc@comcast.net>:
> >
> > (and English
> > is much closer phonetically to German than French, etc., etc., etc.).
>
> Well, of course; English still remains at its base a Germanic language.
> But the absorption of Norman French into the language changed it
> dramatically, turning it into something fairly close to what we call
> "English" today.
Far more than simply the absorbtion of Norman French: when a number of
peoples are thrown together with no common language they will develop a
very simplified form of communication called a 'pidgin', with no real
grammar. When the next generation of children are born, and grow up
hearing this, however, something rather remarkable happens: they
spontaneously invent a language with the same vocabulary but a complete,
if simple, grammar, called a 'creole'. This is the main reason for
English having lost the complications of its Germanic roots.
Ben
--
Joy and Woe are woven fine,
A Clothing for the Soul divine William Blake
Under every grief and pine 'Auguries of Innocence'
Runs a joy with silken twine. ben@morrow.me.uk
------------------------------
Date: 12 May 2004 18:44:07 GMT
From: Eric Bohlman <ebohlman@earthlink.net>
Subject: Re: Books online????
Message-Id: <Xns94E78C5D3A9D6ebohlmanomsdevcom@130.133.1.4>
newuser@newsrouter!.comcast.net (Default) wrote in
news:c7tkpk$j43$1@newsrouter!.comcast.net:
> How about: "Read The Faq and Manual?" Thats how I introduce the term to
> newbies. Only the nor'easters seem to get a bit offended. :-)
I prefer to use "Read The *Free* Manual" in order to emphasize the fact
that an awful lot of people put in an awful lot of *unpaid* time to create
Perl's comprehensive documentation. It's not very respectful to them to
ignore their fine work.
------------------------------
Date: Wed, 12 May 2004 22:52:42 -0400
From: "sc0ri0n" <sc0ri0n@hotmail.com>
Subject: Finding the newest directory
Message-Id: <l5KdnVH8SP9mfz_dRVn-sQ@comcast.com>
Hi,
If I have a bunch of directories and files (sun solaris). Is there a way to
find the newest directory (last one created not modified)?
TIA
------------------------------
Date: 13 May 2004 03:04:26 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Finding the newest directory
Message-Id: <slrnca5pdq.fnn.sholden@flexal.cs.usyd.edu.au>
On Wed, 12 May 2004 22:52:42 -0400, sc0ri0n <sc0ri0n@hotmail.com> wrote:
> Hi,
>
> If I have a bunch of directories and files (sun solaris). Is there a way to
> find the newest directory (last one created not modified)?
No (unless you are using a funky non-standard file system).
Creation time is not tracked by the filesystem.
You have (most recent) access time, modification time, and
file status time. File status time (ctime) is as close as
you'll get, but it is set by other operations that change
the file status (such as chmod(), link(), unlink(), etc.)
stat gives you access to the ctime.
perldoc -f stat
--
Sam Holden
------------------------------
Date: Thu, 13 May 2004 03:09:51 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Finding the newest directory
Message-Id: <c7uotv$r8q$1@wisteria.csv.warwick.ac.uk>
Quoth sholden@cs.usyd.edu.au:
> On Wed, 12 May 2004 22:52:42 -0400, sc0ri0n <sc0ri0n@hotmail.com> wrote:
> > Hi,
> >
> > If I have a bunch of directories and files (sun solaris). Is there a way to
> > find the newest directory (last one created not modified)?
>
> No (unless you are using a funky non-standard file system).
>
> Creation time is not tracked by the filesystem.
>
> You have (most recent) access time, modification time, and
> file status time. File status time (ctime) is as close as
> you'll get, but it is set by other operations that change
> the file status (such as chmod(), link(), unlink(), etc.)
>
> stat gives you access to the ctime.
...and you'll likely want File::Find to do the searching.
OTOH, you could probably do this more easily with find(1).
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk
------------------------------
Date: Wed, 12 May 2004 23:12:08 -0400
From: "sc0ri0n" <sc0ri0n@hotmail.com>
Subject: Re: Finding the newest directory
Message-Id: <ON2dnYElzZAXej_dRVn-sA@comcast.com>
Sam,
I am not interested in files at all. There is a process that creates
directories. What I need to do is to detect the one created last and move
all of its content.
Also, I am new to unix so I am not sure if there are other statistics for
directories like last modified or last accessed as in files?
Thanks,
Pete
"Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
news:slrnca5pdq.fnn.sholden@flexal.cs.usyd.edu.au...
> On Wed, 12 May 2004 22:52:42 -0400, sc0ri0n <sc0ri0n@hotmail.com> wrote:
> > Hi,
> >
> > If I have a bunch of directories and files (sun solaris). Is there a way
to
> > find the newest directory (last one created not modified)?
>
> No (unless you are using a funky non-standard file system).
>
> Creation time is not tracked by the filesystem.
>
> You have (most recent) access time, modification time, and
> file status time. File status time (ctime) is as close as
> you'll get, but it is set by other operations that change
> the file status (such as chmod(), link(), unlink(), etc.)
>
> stat gives you access to the ctime.
>
> perldoc -f stat
>
> --
> Sam Holden
------------------------------
Date: 13 May 2004 03:51:53 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Finding the newest directory
Message-Id: <slrnca5s6p.jnd.sholden@flexal.cs.usyd.edu.au>
On Wed, 12 May 2004 23:12:08 -0400, sc0ri0n <sc0ri0n@hotmail.com> wrote:
> Sam,
>
> I am not interested in files at all. There is a process that creates
> directories. What I need to do is to detect the one created last and move
> all of its content.
Directories are just files, just like block devices are just files.
>
> Also, I am new to unix so I am not sure if there are other statistics for
> directories like last modified or last accessed as in files?
Directories are just files. They have all the same metadata.
[snip full quote, sigs and all]
Please don't do that, put your reply after the text you
are replying to - trim irrelevant text if it's too long.
--
Sam Holden
------------------------------
Date: 12 May 2004 18:39:28 GMT
From: Eric Bohlman <ebohlman@earthlink.net>
Subject: Re: grep
Message-Id: <Xns94E78B929BB8Eebohlmanomsdevcom@130.133.1.4>
zipper59er@yahoo.com (chet) wrote in
news:3988d00.0405120802.252bc16e@posting.google.com:
> the following script will parse records out of a log file.
>
> my second grep doesn't find any records when it should
> anybody know why (they exist in the file).
>
> -thanx in advance.
>
>
> #!/usr/bin/perl
No "use warnings;".
No "use strict;".
>
> #make te function calls
Completely useless comment.
> parse_lab_share ();
>
> sub parse_lab_share ()
> {
> my @ins;
> my @outs;
> my @fields;
> my $record;
> my $login_str;
> my $logout_str;
> my $i;
It's best to declare your variables with as narrow a scope as possible.
>
> unless ( open VNTILOG, "./vnti.log" )
> {
> die "Cannot open the vector log file: $!";
> }
> @ins = grep /VECGI/
> && !/ERROR/
> && !/Error/
> && !/Fragment/,
> <VNTILOG>;
Here you've read through the entire contents of your logfile, filling @ins
with the entries that match your criteria.
> foreach ( @ins )
> {
> @fields = split;
> if ( $fields[14] eq "in" )
> {
> $login_str =
> "$fields[2]-$fields[1]-$fields[5]$fields[3]";
> $record =
> "$fields[23],$login_str,$fields[10],$fields[17]";
> @outs = grep /$fields[23]/, <VNTILOG>;
And now you're trying to read through what's left of your log file after
you've already read through all of it. Hmmm. Even worse, you're trying to
do it for every single matching record.
> foreach ( @outs )
> {
> @fields = split;
> print ( "$fields[23]\n" );
> }
> }
> }
>
> #close the vector log file
YAUC (Yet Another Useless Comment).
> close VNTILOG;
> }
Nowhere do you explain *what* you're trying to accomplish. I can only
guess that you're trying to do something resembling a relational join of
the logfile on itself, but it would really help to know why.
------------------------------
Date: Wed, 12 May 2004 20:34:24 GMT
From: Jeff Boes <jboes@nexcerpt.com>
Subject: Re: How to hide "if $DEBUG" code?
Message-Id: <3ca996ec34641bc1b47c3077757a4580@news.teranews.com>
Eric Schwartz wrote:
> I use a similar convention, developed in a shop I worked in a few
> years ago:
>
> DebugMsg($msg); # prints "$0: DEBUG: $msg" if $opt_debug is defined
> InfoMsg($msg); # prints "$0: INFO: $msg"
> ErrorMsg($msg); # prints "$0: ERROR: $msg"
> ProgressMsg($msg); # unusual; prints "$0: $msg"; mostly for semantics
> FatalMsg($msg); # same as ErrorMessage, then exit()s
> VerboseMsg($msg); # like ProgressMsg, but only prints when $opt_verbose
> # is defined.
Check out Log::Agent on CPAN. Similar kinds of functionality, lots of
bonus features ...
--
Jeff Boes vox 269.226.9550 ext 24
Database Engineer fax 269.349.9076
Nexcerpt, Inc. http://www.nexcerpt.com
...Nexcerpt... Extend your Expertise
------------------------------
Date: Wed, 12 May 2004 22:59:45 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: module bad design?)
Message-Id: <c7ua60$h8o$1@news.simnet.is>
"Richard Morse" <remorse@partners.org> wrote in message
news:remorse-F5C704.09544812052004@plato.harvard.edu...
> In article <c7soi8$bo2$1@news.simnet.is>, "gnari" <gnari@simnet.is>
> wrote:
>
> > in addition, let me add:
> > you should declare $a as lexical in parse_file():
> > my $a;
>
> Actually, isn't this one of those special cases where you want to use a
> different variable name, because $a is involved in sorting? Or does it
> not count because we're in a different package here?
that is not the problem here, as no sorting was involved, but $a and $b
are brobably avoided to reduce confusion.
in this case, $ a was used as an undeclared global, but is not checked
by 'use strict' because of it's special status. had the variable name been
$aa, then an error would have been thrown by strict
gnari
------------------------------
Date: Wed, 12 May 2004 18:43:49 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Module/recipe to resolve full pathnames?
Message-Id: <c7tr95$amg$2@wisteria.csv.warwick.ac.uk>
Quoth Darren Dunham <ddunham@redwood.taos.com>:
> kj <socyl@987jk.com> wrote:
>
> > Is there a module (or built-in) that will take an arbitary Unix
> > filename specification (either absolute or relative) and return
> > the "canonical" absolute full path to the file? For example:
>
> > input: ~jones/../foo/../../bar/./baz//frobozz/
> > output: /bar/baz/frobozz
>
> Do you want this to occur symbolically or by running the filesystem?
> Each has disadvantages.
<snip>
File::Spec will resolve logically, as you say; Cwd will resolve
physically (including symlinks).
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk
------------------------------
Date: Wed, 12 May 2004 18:14:49 GMT
From: spamtotrash@toomuchfiction.com (Kevin Collins)
Subject: Re: Perl distribution with threads support
Message-Id: <slrnca4qcp.o6.spamtotrash@doom.unix-guy.com>
In article <5a373b1d.0405120644.2fc646e0@posting.google.com>, Yash wrote:
> Hi,
>
> Can anyone point me to a Perl binary distribution for HP-UX 11i with support
> for threads? The one at
> http://hpux.connect.org.uk/hppd/hpux/Languages/perl-5.8.3/ has been compiled
> with threads support.
>
> Thanks
So what, exactly are you wanting? You ask for a binary with thread support and
then post a URL for a binary with thread support - I think you answered your
own question :)
Kevin
------------------------------
Date: Wed, 12 May 2004 19:03:34 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Perl PGP
Message-Id: <83yoc.25579$dr1.654788@news20.bellglobal.com>
"Gilian" <linux@colsen.org> wrote in message
news:f325939e.0405120618.5093245f@posting.google.com...
> Hello,
>
> I'm working on a Windows 2000 system. I have ActiveState Perl
> installed on the machine. Everything is working OK, so far.
>
> Now I need to write a script which will do some routines on a file and
> at the end it has to encrypt the file with PGP. I have downloaded the
> files from CPAN (Crypt::OpenPGP). Unfortunantly this refuses to be
> installed.
>
Probably because you didn't read the requirements. Finding Crypt modules for
ActivePerl is tricky at best. AS doesn't create ppd files for most of them
because they don't want the hassle of exporting cryptographic software. Your
best best whenever it comes to Crypt modules on Windows is to use perl with
cygwin and build them yourself.
Matt
------------------------------
Date: Wed, 12 May 2004 18:40:38 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Unexpected sysread block
Message-Id: <c7tr36$amg$1@wisteria.csv.warwick.ac.uk>
Quoth lathaswarna@yahoo.com (Swarna):
> When I execute test1.pl, test2.pl is blocking.
>
> Any ideas as to why the sysread is not returning immediately.
>
> ########## test1.pl #########
> #!perl
>
> open (FD, "|-", "perl test2.pl");
> sleep (100);
>
>
> ########### test2.pl ##########
>
> #!perl
>
> my $buffer;
>
> while (1) {
>
> print STDERR "before sysread \n";
> $bytes = sysread(STDIN, $buffer, 524288) || last;
> die "undef bytes \n" unless defined $bytes;
> print STDERR "after sysread \n";
>
> }
> print STDERR "last statement\n";
Ummm... because you aren't sending it any data? sysread is
un-*buffered*, not non-*blocking*. If you want a non-blocking read
(which will return 0 immediately if there is no data in the pipe to
read) then you will need to do
use IO::Handle;
STDIN->blocking(0);
in test2.pl. This is more portable than setting non-blocking mode
yourself using fcntl.
Ben
--
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based
on the strictest morality. [Samuel Butler, paraphrased] ben@morrow.me.uk
------------------------------
Date: 12 May 2004 16:31:52 -0700
From: mdfoster44@netscape.net (Martin Foster)
Subject: Using hashes to sort number sequences
Message-Id: <6a20f90a.0405121531.2862676d@posting.google.com>
Hi.
A few months ago, I posted to comp.lang.perl for help with a script
that
looks at number sequences. I'm revisiting the problem but with some
extra
data.
I have two files: a.txt & b.txt
a.txt=
191_6_270328 T1 4 10 19 34 55 72 88 116 157 200 280 332 388 451 756 4
0 5 0 4 0 6 2 6 2 8 0
191_6_270328 T2 4 9 17 22 34 56 83 112 146 181 266 320 376 431 665 3 0
5 0 4 0 6 2 6 0 22 2
191_6_270328 T3 4 10 17 23 35 56 83 115 149 188 274 324 381 437 681 4
0 5 0 4 0 6 0 6 0 6 2
191_6_270328 T4 4 12 24 35 49 68 92 123 157 196 288 347 409 464 761 5
0 8 0 5 0 8 0 6 0 18 8
191_6_270328 T5 4 10 19 32 44 57 83 118 158 197 281 331 380 445 723 4
0 5 0 4 0 5 0 6 0 6 2
191_6_270328 T6 4 9 14 18 26 48 83 114 142 178 260 312 375 434 637 3 0
4 0 6 0 6 2 6 0 6 2191_6_270330 T1 4 10 20 38 61 82 110 149 187 228
357 408 465 552 890 4 0 5 0 4 0 6 2 6 0 8 0
191_6_270330 T2 4 9 19 31 47 71 97 121 166 222 331 410 491 559 788 3 0
5 0 4 0 6 0 8 0 8 2
191_6_270330 T3 4 10 18 28 45 67 93 125 161 210 337 404 470 541 762 4
0 5 0 4 0 6 0 6 0 6 0
191_6_270330 T4 4 12 24 35 53 82 114 149 189 227 335 419 490 546 890 5
0 8 2 5 0 8 2 6 0 24 0
191_6_270330 T5 4 10 19 34 48 65 95 136 180 218 332 397 455 536 810 4
0 5 0 4 0 5 0 6 0 6 2
191_6_270330 T6 4 10 21 36 51 67 95 139 186 233 360 441 523 596 843 3
0 6 0 6 0 8 0 6 0 8 0
191_6_270334 T1 4 10 19 33 54 76 101 137 178 219 336 406 462 529 832 4
0 5 0 4 0 6 0 6 2 8 0
b.txt=
191_6_9908682 T1 4 8 14 25 41 60 83 115 153 190 276 321 374 437 694 4
0 4 0 4 0 6 0 4 0 8 0
191_6_9908682 T2 4 10 19 30 44 64 92 122 155 198 285 338 394 446 739 4
0 5 0 4 0 6 0 8 0 8 2
191_6_9908682 T3 4 10 20 33 51 69 88 123 164 199 295 341 398 465 762 4
0 5 0 4 0 6 0 7 0 18 0
191_6_9908682 T4 4 10 20 36 56 79 104 130 158 190 285 339 401 473 788
4 0 6 0 4 0 6 0 7 0 12 0
191_6_9908682 T5 4 9 18 33 51 68 89 118 153 195 280 334 387 448 739 4
0 5 0 4 0 7 0 4 0 7 0
191_6_9908682 T6 4 9 19 33 54 76 98 126 159 198 279 330 393 463 777 4
0 6 0 4 0 7 0 4 0 7 0
191_6_9908690 T1 4 8 14 25 41 61 87 119 153 189 275 331 393 452 702 4
0 4 0 4 0 6 0 4 0 8 0
191_6_9908690 T2 4 10 19 31 49 73 101 131 162 197 293 349 409 472 778
4 0 5 0 4 0 6 0 8 0 8 2
191_6_9908690 T3 4 10 21 36 55 77 98 126 163 201 291 344 413 482 792 4
0 5 0 4 0 6 0 7 0 18 0
191_6_9908690 T4 4 10 19 32 50 74 98 122 151 193 303 358 421 492 754 4
0 6 2 4 0 6 2 6 0 7 0
191_6_9908690 T5 4 10 20 36 55 72 94 122 152 194 290 347 404 471 760 4
0 7 0 4 0 7 0 5 0 6 2
191_6_9908690 T6 4 10 22 36 52 74 100 126 158 201 297 363 429 488 784
4 0 6 0 4 0 6 0 6 0 10 2
Each file contains in the first column an identifier, I call it $name.
The 2nd column contains an entry T1 or T2 or T3 ... until T6.
After these two columns each row contains a number sequence.
What I would like to do is to read file a.txt, six lines at a time
(from T1 to T6)
and search for similar number sequences in file b.txt.
The number sequences in file b.txt must also be within each block of
six lines,
but they can be in any order.
my script looks like this so far:
#!/usr/bin/perl
# Perl script to compare to files with T6 CS & VS
use strict;
use warnings;
my $infile1 = "a.txt";
open INFILE1, $infile1 or die "Shit! Couldn't open file
$infile1: $!\n";
my $infile2 = "b.txt";
open INFILE2, $infile2 or die "Shit! Couldn't open file
$infile2: $!\n";
do {
my %a_list;
# six lines at a time
for(0 .. 5){
$_ = <INFILE1>;
my ( $name, $nums ) = /^(\S+\s\S+)\s(.*)/ or
die;
push @{$a_list{$nums}}, $name;
}
# DEBUG : print out contents of hash
while ( my ($key, $value) = each(%a_list) ) {
print "$value->[0] $key\n";
}
# now check this block of sequences in file b.txt
do {
# first make a copy of a_list, to which you
feed the six lines of b.txt
my %b_list = %a_list;
for(0 .. 5){
$_ = <INFILE2>;
my ( $name, $nums ) =
/^(\S+\s+\S+)\s+(.*)/;
push @{$b_list{$nums}}, $name;
}
# OK, quick DEBUG print new hash b_list
print "\n\nb_list hash:\n";
while ( my ($key, $value) = each(%b_list) ) {
print "$value->[0] $key\n";
}
# Now check for the similar keys
print "\n\nmatches in b_list\n";
for ( values %b_list){
print "\t$_->[0] ",scalar(@$_),"\n";
}
} while (<INFILE2>);
} while (<INFILE1>);
Unfortunately, I'm stuck now. I can't get the script to keep running
the inner loop (b_list) for each "block" of a_list ( 6 lines of
a.txt). I come to the
end of file b.txt and get errors such as:
Use of uninitialized value in hash element at compare_files.plx line
33, <INFILE2> line 37.
Could anyone please help me?
Also, the files a & b are in fact huge, with 100,000s of 6 line
blocks. If
anyone has any suggestions for a faster method that would be awesome.
I've
tried coding it in C, but after finding out about the hash/keys
feature in Perl,
which is fantastic for this stuff, I think Perl is the way to go.
Many thanks in advance,
Martin.
------------------------------
Date: Thu, 13 May 2004 03:07:13 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Using hashes to sort number sequences
Message-Id: <40A2E65B.1020108@rochester.rr.com>
Martin Foster wrote:
...
> I have two files: a.txt & b.txt
>
> a.txt=
> 191_6_270328 T1 4 10 19 34 55 72 88 116 157 200 280 332 388 451 756 4
> 0 5 0 4 0 6 2 6 2 8 0
> 191_6_270328 T2 4 9 17 22 34 56 83 112 146 181 266 320 376 431 665 3 0
...
> b.txt=
> 191_6_9908682 T1 4 8 14 25 41 60 83 115 153 190 276 321 374 437 694 4
> 0 4 0 4 0 6 0 4 0 8 0
> 191_6_9908682 T2 4 10 19 30 44 64 92 122 155 198 285 338 394 446 739 4
> 0 5 0 4 0 6 0 8 0 8 2
...
> Each file contains in the first column an identifier, I call it $name.
> The 2nd column contains an entry T1 or T2 or T3 ... until T6.
> After these two columns each row contains a number sequence.
>
> What I would like to do is to read file a.txt, six lines at a time
> (from T1 to T6)
> and search for similar number sequences in file b.txt.
> The number sequences in file b.txt must also be within each block of
> six lines,
> but they can be in any order.
Why don't you just sort (using the Unix or maybe even the Win32 sort
command) the two files, and then, using Perl, read and compare from the
two sorted files? Or maybe the -u switch on Unix's sort could give you
what you want in one go. Or maybe (if the data for matching lines is
all the same), after the sorts, use diff to do the compare, and just
process the output of diff with Perl? Or if there is something in the
data which indicates if it from INFILE1 versus INFILE2, the files could
be concatenated, sorted, and processed as one file (I don't think that
last method would have any advantages).
That sort (punny, huh?) of method will avoid reading your $infile2 many
hundreds of thousands of times, which will take almost forever.
BTW, you would need to either close and reopen the file in your inner
loop, or seek() it back to the beginning every time you go though the
outer loop. Also recognize that your while(<INFILE1>) and
while(<INFILE2>) constructions will read a record from the corresponding
file and place it into $_. You are discarding that data, so you are
really reading data 7 records at a time, discarding the first of each
chunk of 7.
HTH.
...
> Martin.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Thu, 13 May 2004 04:02:54 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Using match variables ($1, $2 ...) as variables.
Message-Id: <c7us1e$1m6r$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Ravi Parimi
<parimi@none.nowhere.com>], who wrote in article <Pine.GSO.4.58.0405101802580.18191@shellfish.ece.arizona.edu>:
> Usage of ${$i} is incorrect and doesnt make sense.
Could you elaborate on this point?
>perl -wle "'abcde' =~ /(.)c(.)/ or die; $v=2; print $$v"
d
Yours,
Ilya
------------------------------
Date: 12 May 2004 14:05:52 -0700
From: ziggy.971485@bloglines.com (Tom)
Subject: Win32-GuiTest and waits
Message-Id: <5b3d1dd2.0405121305.592f6085@posting.google.com>
I'm trying to test an application using Win32-GuiTest, and I'm running
into a timing problem where I send keystrokes for a search and I need
to wait for a response before sending more keystrokes or mouseclicks.
Otherwise the next keystrokes are lost. I can't use the WaitWindow
functions because the window is already displayed. Since the OK
button is grayed out until the response comes back, I tried to use the
IsGrayedButton function, but it always returns 0.
Is there any other way I can detect a completed function so I can
continue? Possibly a way to test the mouse icon (hourglass means
busy)?
Thanks,
Tom
------------------------------
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 6557
***************************************