[19212] in Perl-Users-Digest
Perl-Users Digest, Issue: 1407 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 30 14:05:52 2001
Date: Mon, 30 Jul 2001 11:05:10 -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: <996516310-v10-i1407@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 30 Jul 2001 Volume: 10 Number: 1407
Today's topics:
Another Integer Regex - Ada (Moonshiner)
Re: Best way to have multiple colored-text output windo (Yves Orton)
Bug in fcntl support in 5.6??? <bernie@fantasyfarm.com>
Chainging specific part of a file <nathan.randle@ntlworld.com>
Re: compare two time blocks for scheduling (Karen J. Cravens)
Re: counting (Yves Orton)
Re: counting <mbudash@sonic.net>
Re: Finding a word in a sorted list. (M.J.T. Guy)
Re: Finding keywords in text files <mbudash@sonic.net>
Re: Finding keywords in text files <Tassilo.Parseval@post.rwth-aachen.de>
Re: Finding keywords in text files (Tad McClellan)
Re: Finding keywords in text files <mbudash@sonic.net>
Re: Iterating through an array (Yves Orton)
Re: Iterating through an array (Mario Rizzuti)
New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Jul 2001 09:27:40 -0700
From: Douglas.Neufeld@cisf.af.mil (Moonshiner)
Subject: Another Integer Regex - Ada
Message-Id: <1e6bfb24.0107300827.33a61575@posting.google.com>
Greetings,
I wish to add fuel to the 'find an integer' problem/question.
I need to find an integer in Ada code. This presents quite a few
challenges that the 'normal' integer does not present. While the
normal definition will work there are some special cases.
The underline is a valid character in an integer or float(real);
placement of the underline is not limited other than it cannot be the
first character in a number.
The number after the E in an exponent is an integer (along with the
sign if one is present.) I quess that would mean that the number in
front of the E, if not a float, would be an integer (but I have not
covered that yet.)
An integer in a range could be followed by double dots or a space then
the double dots. The second number of the range is preceeded by a
space or double dots.
An integer can be followed by a parenthesis or a semi-colon.
The plus or minus sign is part of the integer if the number is not
part of an equation.
Any number preceeded by an alpha character is an identifier not a
number unless it is a based integer (which is covered as a different
regex.)
Any number followed by a single dot and more numbers is a not an
integer.
(I am missing an integer at the end of a string with a period ie
anotherliteral := "This is a sentence that ends with an integer,
20.";)
I have developed the following regex -
$integer = gr/
(?<![_\da-df-zA-DF-Z])
[-+]?
\d[\d_]*
(?:
(?![\.\w#])|
(?=\.\.)
)
/x;
$integer is passed by reference to a subroutine called find_regex.
The variable $this is set to the value referenced by the scalar passed
to find_regex.
When used in a match statement as
$this_line =~ m/$this/gix
most of the integers in my test case are found. I am still missing
the integers lead by the double dots, some that are followed by a
parenthesis or a semi-colon, and at the end of a string followed by
a period.
So I tried a substitute command just to verify what I was actually
matching -
my $that = "INTEGER";
$that_line =~ s/$this/$that/g;
when run on my test cases the results were (input ==> output):
thisnum := thatnum + 543; ==> thisnum := thatnum + INTEGER;
thisone := 6; ==> thisone := INTEGER;
CE4 := 9 * CD6; ==> CEINTEGER := INTEGER * CD6;
K24 := 123; ==> K24 := INTEGER;
temp_min : constant integer := -54; ==>
temp_min : constant integer := INTEGER;
temp_max : constant integer := +8745; ==>
temp_max : constant integer := INTEGER;
thisexp := 27E-32; ==> thisexp := 27EINTEGER;
thatexp := -12_34.77E+6; ==> thatexp := -12_34.77EINTEGER;
twentyseven : constant integer 9**3; ==>
twentyseven : constant integer INTEGER**INTEGER;
anotherwierdbase := 66#78euyr#E12; ==>
anotherwierdbase := 66#78euyr#EINTEGER;
anotherstr := "there were 89_123_321 items"; ==>
anotherstr := "there were INTEGER items";
output_str := "the TOTAL cost was -34_231 dollars"; ==>
output_str := "the TOTAL cost was INTEGER dollars";
z := 34/45; ==> z := INTEGER/INTEGER;
type Short_Array is array (EXTENDED_INDEX range 10..49) of FLOAT;
==>
type Short_Array is array (EXTENDED_INDEX range INTEGER..49) of
FLOAT;
type GAME_BOARD is array (1..8, 1..8) of CHESS_PIECES; ==>
type GAME_BOARD is array (INTEGER..8, INTEGER..8) of
CHESS_PIECES;
type CHESS_BOARD is array (1 .. 8, 1.. 8) of CHESS_PIECES; ==>
type GAME_BOARD is array (INTEGER .. INTEGER, INTEGER..
INTEGER) of CHESS_PIECES;
type LIST is array (INTEGER range -100..10) of FLOAT; ==>
type LIST is array (INTEGER range INTEGER..INTEGER) of FLOAT;
type INDEX is range 1..50; ==> type INDEX is range INTEGER..50;
type MASS is digits 10; ==> type MASS is digits INTEGER;
The above is only a portion of the 124 test cases I have used.
This is not individual files but lines in a test file.
As you can see, I have achieved the ability to pull most of the
integers out from my samples. I am still having problems with getting
the last number of a range. I think it has more to do with the double
dots in front than the character following the integer. I will
continue to play with the regex but I figured I could put this out and
see if anyone else wants to "play". I will also be adding more
samples
to my test case because I noticed something else while typing this up.
I would appreciate any assistance in getting all the defined integers
found and if there are any ways to clean up the regex.
Well I think I have made this post long enough.
If anyone made it to here and still wants to play then have at it and
let me know what happens.
I appreciate all assistance in advance.
Moonshiner
(How 'bout Ralf Schumacher, Bobby Labonte, Kenny Brack and Jeff
Purvis?!)
------------------------------
Date: 30 Jul 2001 11:02:41 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: Best way to have multiple colored-text output windows?
Message-Id: <74f348f7.0107301002.65ea2a2a@posting.google.com>
Kevin Michael Vail <kevin@vaildc.net> wrote in message news:<290720010016119583%kevin@vaildc.net>...
> If you get perl2exe (http://www.indigostar.com/), you can just give
> your users a single .exe file and they don't have to install Perl at
> all. I have a bunch of internal utilities at work written in Perl/Tk,
> and I knew the chances of getting people to download even the basic
> Perl installation were pretty remote, but I managed to convince them to
> buy perl2exe for me. That's worked out pretty well.
You are one smart cookie. Why didnt I think of that?
Yves
------------------------------
Date: Mon, 30 Jul 2001 13:12:33 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Bug in fcntl support in 5.6???
Message-Id: <le3bmtc0tsahbohbva2pnhnu6j84q4poc5@news.supernews.net>
I'm going a bit nuts here trying to get fcntl file-locking to work. The
problem is that when I try to lock a file across an NFS mount [which is why
I'm using fcntl instead of flock], I get an "Invalid argument" error.
Here's the Perl code:
===============================
# use constant filename => "/tmp/lock.me" ;
use constant filename => "/mnt/tmp/lock.me" ;
lockfile(filename) or die "Couldn't lock!" ;
print "Say when --- " ;
<STDIN> ;
exit ;
use Fcntl ;
sub lockfile
{
open(FH, "+<$_[0]") or die("Error opening $_[0]: $!"), return undef ;
my $wrlock = pack("SSLLI", F_WRLCK, 0,0,0,0) ;
fcntl (FH, F_SETLKW, $wrlock)
or warn("Error locking: $!\n"), return undef;
return 1;
}
================================
when I try to lock /tmp/lock.me, it works perfectly. But when I try to
lock the [nfs mounted] /mnt/tmp/lock.me, I get:
===========================
$ tlock.perl
Error locking: Invalid argument
Couldn't lock! at ./tlock.perl line 7.
=============================
Now, just to make sure that it wasn't something strange in our Linux setup
[RH 7.1, NFS mounting a Reiserfs filesystem], I tried doing the SAME thing
in C:
======================================
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
int main()
{
int fd ;
struct flock L;
fd = open("/mnt/tmp/lock.me", O_RDWR) ;
if (fd < 0)
{
printf("Couldn't open the file: %s\n", strerror(errno)) ;
exit(1) ;
}
L.l_type = F_WRLCK ;
L.l_whence = 0 ;
L.l_start = 0 ;
L.l_len = 0 ;
if (fcntl (fd, F_SETLKW, &L) < 0)
{ printf("Error getting lock: %d->%s\n", errno, strerror(errno)) ;
exit(1) ;
}
printf("Got the lock\n") ;
system("sleep 60") ;
printf("Freeing the lock\n") ;
exit(0);
}
================================
And the C version works perfectly, so it doesn't look like a device driver
problem or anything like that. I don't *THINK* I'm overlooking the obvious
[again, sigh], but I just can't figure out why the Perl call to fcntl gets
an "Invalid Argument" [EINVAL I think] while the C call, as identical as I
could make it to the Perl call, just works perfectly.
Any advice, hints, workarounds, whatever, would be appreciated, since this
one has been driving me nuts... Version info is:
$ perl -V
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
Platform:
osname=linux, osvers=2.4.5, archname=i686-linux
[...]
OS is RedHat 7.1 Guess I've got to paw through the Perl sources to see
what it does with 'fcntl' that might cause the EINVAL error.
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: Mon, 30 Jul 2001 18:17:45 +0100
From: "Nathan Randle" <nathan.randle@ntlworld.com>
Subject: Chainging specific part of a file
Message-Id: <cGg97.9785$ip4.2832448@news2-win.server.ntlworld.com>
How do you make your program open a file and change a specific area of the
text. is there any way of flagging certain areas?
Thanks
Nathan
------------------------------
Date: Mon, 30 Jul 2001 15:31:05 +0000
From: silver+news@phoenyx.net (Karen J. Cravens)
Subject: Re: compare two time blocks for scheduling
Message-Id: <Xns90EE6B36769AFphoenyx@192.168.0.3>
"Jag Man" <jagman98@home.com> wrote in
<GcV87.25252$oh1.8055567@news2.rdc2.tx.home.com>:
> DATE::Manip can compare one timestamp at a time, but how can it be done
> with comparing hours?
You could probably do something creative with the Set::IntSpan module.
------------------------------
Date: 30 Jul 2001 10:35:27 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: counting
Message-Id: <74f348f7.0107300935.5cf54af7@posting.google.com>
Chris Micallef <cmicallef@playground.net> wrote in message news:<3B64EABF.9C132146@playground.net>...
> Give it a break!
Snip normal healthy response to extreme antagonism.
> As a pl beginner, I was referred to this group for support and help in developing an
> understanding of perl. I now realize that the noise level in this group makes it a
> waste of time. When a**holes such as yourself spend more time bitch'n and making
> demands than tending to the issues readers get nauseated and drop off.
>
> I wish you luck with your "freedom of speech" quest. See ya ... well maybe not!
>
> C
The lizard lady got to me like that for a while as well. Then I
learned a trick: Read her stuff first thing in the morning, before you
read the news. It makes the world seem much less depressing.
Cheers dude.
Yves
------------------------------
Date: Mon, 30 Jul 2001 17:44:35 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: counting
Message-Id: <mbudash-1BAF14.10444130072001@news.sonic.net>
In article <74f348f7.0107300935.5cf54af7@posting.google.com>,
demerphq@hotmail.com (Yves Orton) wrote:
> Chris Micallef <cmicallef@playground.net> wrote in message
> news:<3B64EABF.9C132146@playground.net>...
> > Give it a break!
>
> Snip normal healthy response to extreme antagonism.
>
> > As a pl beginner, I was referred to this group for support and help in
> > developing an
> > understanding of perl. I now realize that the noise level in this
> > group makes it a
> > waste of time. When a**holes such as yourself spend more time bitch'n
> > and making
> > demands than tending to the issues readers get nauseated and drop off.
> >
> > I wish you luck with your "freedom of speech" quest. See ya ... well
> > maybe not!
> >
> > C
>
> The lizard lady got to me like that for a while as well. Then I
> learned a trick: Read her stuff first thing in the morning, before you
> read the news. It makes the world seem much less depressing.
>
better still: since she offers nothing more than abuse, condescension
and perl4 code, just killfile the b***ch and enjoy your day...
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: 30 Jul 2001 15:40:35 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Finding a word in a sorted list.
Message-Id: <9k3v5j$hli$1@pegasus.csx.cam.ac.uk>
Bart Lateur <bart.lateur@skynet.be> wrote:
>Mario Rizzuti wrote:
>>
>>I am wondering what is the fastest possible way to find the associated
>>numbers of a given list of usernames?
>
>Theoretically: binary search. I would think.
Nope. Hash lookup will always beat it ( O(1) rather than O(log n), with
good constants ).
Provided you can afford the memory, of course.
Mike Guy
------------------------------
Date: Mon, 30 Jul 2001 15:09:24 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Finding keywords in text files
Message-Id: <mbudash-27A37C.08093130072001@news.sonic.net>
In article <74f348f7.0107300612.1550c901@posting.google.com>,
demerphq@hotmail.com (Yves Orton) wrote:
> Benjamin Goldberg <goldbb2@earthlink.net> wrote in message
> news:<3B64E3CF.3BD8E25@earthlink.net>...
>
> > delete @counts{qw(a is or of it the and)}; # delete "stopwords"
>
> Cool. Never thought of using delete with array slices.
> Nice trick.
er... isn't that a hash slice?
perldoc -f delete shows other pretty cool stuff...
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Mon, 30 Jul 2001 17:30:53 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Finding keywords in text files
Message-Id: <3B657DAD.90809@post.rwth-aachen.de>
Michael Budash wrote:
>>>delete @counts{qw(a is or of it the and)}; # delete "stopwords"
>>>
>>Cool. Never thought of using delete with array slices.
>>Nice trick.
>>
>
>er... isn't that a hash slice?
>
No, it is an array.
It is another way of dereferencing it:
$ref = \@array;
@dereferenced1 = @$ref;
@dereferences2 = @{$ref};
When accessing a particular element, one could do:
$elem1 = $$ref[0];
$elem2 = ${$ref}[0];
$elem3 = $ref->[0];
I guess, the Perl equivalent (as for complexity) of C-pointers are
references.
Tassilo
--
Collaboration, n.:
A literary partnership based on the false assumption that the
other fellow can spell.
------------------------------
Date: Mon, 30 Jul 2001 12:58:31 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Finding keywords in text files
Message-Id: <slrn9mb4hn.do3.tadmc@tadmc26.august.net>
Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> wrote:
>Michael Budash wrote:
>
>>>>delete @counts{qw(a is or of it the and)}; # delete "stopwords"
>>>>
>>>Cool. Never thought of using delete with array slices.
>>>Nice trick.
>>>
>>
>>er... isn't that a hash slice?
>>
>
>No, it is an array.
No, it *is* a hash slice.
>It is another way of dereferencing it:
There are NO references involved in the quoted code above!
Don't follow the red herrings.
[snip stuff about references which does not apply as there are
no references involved here.]
>I guess, the Perl equivalent (as for complexity) of C-pointers are
>references.
Yes, but references play no part in hash slices.
Perhaps you should have a look at the "Slices" section in perldata.pod...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 30 Jul 2001 17:49:58 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Finding keywords in text files
Message-Id: <mbudash-5B06D2.10500430072001@news.sonic.net>
In article <slrn9mb4hn.do3.tadmc@tadmc26.august.net>,
tadmc@augustmail.com wrote:
> Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> wrote:
> >Michael Budash wrote:
> >
> >>>>delete @counts{qw(a is or of it the and)}; # delete "stopwords"
> >>>>
> >>>Cool. Never thought of using delete with array slices.
> >>>Nice trick.
> >>>
> >>
> >>er... isn't that a hash slice?
> >>
> >
> >No, it is an array.
>
>
> No, it *is* a hash slice.
>
>
> >It is another way of dereferencing it:
>
>
> There are NO references involved in the quoted code above!
>
> Don't follow the red herrings.
>
>
> [snip stuff about references which does not apply as there are
> no references involved here.]
>
>
> >I guess, the Perl equivalent (as for complexity) of C-pointers are
> >references.
>
>
> Yes, but references play no part in hash slices.
>
> Perhaps you should have a look at the "Slices" section in perldata.pod...
thanks for clearing that up, tad. i thought it was a hash slice, so it's
nice to see i wasn't going crazy...
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: 30 Jul 2001 10:13:44 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: Iterating through an array
Message-Id: <74f348f7.0107300913.5b80cedf@posting.google.com>
Ron Smith <ronnet@mediaone.net> wrote in message news:<ir88mtk2ce9k1huq762iuu6o6hh023itih@4ax.com>...
> I need a little help with this one. I'm not finding exactly what I
> want in "The Cookbook" or the "Reference".
>
> I'm using the following 16 lines in a text file:
>
> -------------------snip------------------------------------
> a frame.0005.rgb
SNIP
> a frame_v12.0006.rgb
SNIP
> a frame_v3.0004.rgb
> -------------------snip------------------------------------
>
> What I've done is split each line so that the basename of the entries
> (frame, frame_v12, frame_v3) are in their own array; the numbers
> (0001, 0002, 0006, etc.) are in their own array, and all the "rgb"s
> are also in their own array.
Ok. Why? A hash seems to me to be a better approach. Essentially
you want to convert a list into a heirarchy so a hash is ideal.
> From here, I'd like to iterate over the arrays until a new element is
> encountered (one that doesn't match the previous element), then print
> to a new file, or the same file the same info as above, but only in
> the following format:
>
> 1 frame.%04d.rgb 1-5
> 2 frame_v12.%04d.rgb 1-6
> 3 frame_v3.%04d.rgb 1-4
I presume this is exactly what you looking for? (Ie literal output of
the sprintf string?)
> Here's what I have, so far. I'd like a little direction from here, or
> even a new approach, on the iteration part.
Ok. Im going for the new approach. But first a couple of
comments.....
Snipped some code...
> while (<FILE>) {
> ($leading_symbol, $filename) = split;
> foreach ($filename) {
Why the foreach over a list of 1 element? Makes no sense.
> ($basename, $pad, $ext) = split (/\./, $filename);
Double call on split? Hmm.
> @basename = $basename;
> @pad = $pad;
> @ext = $ext;
The above does NOT do what you think. Check on what is in @basename
by
print join(",",@basename)."\n";
So. Basically from what code you posted the way you are going ISNT the
way. Sorry. Ive made an attempt at something that does work, but
from the description and output you've given I've had to make some
assumptions:
If the number part of the filenames are not contiguous the output is a
comma seperated list of ranges or numbers. My approach involves using
an array as a checklist, which is probably NOT a good way if you have
number sequences that are long and/or many files. On the other hand
it easily handles gaps in the sequence numbers. Also I assumed that
the extension part of the filename need not be .rgb.
Hope this helps,
Yves
The program below the line should output the following:
1 frame.%04d.regb 8-10
2 frame.%04d.rgb 1-4,6
3 frame_v12.%04d.rgb 1-6
4 frame_v3.%04d.rgb 1-4
5 frame_v99.%04d.junk 8645-8646
_________________________________________________________________
#perl
use strict;
use warnings;
my %data;
while (<DATA>) {
if (
/^(\w+) #$1=word at the beginning of the line
\s+ #one or more spaces
([^.]+) #$2=anything that isnt a dot
\. #a dot
(\d+) #$3=a sequence of digits
\. #another dot
(\w+)$/x #$4=the word at the end of the line
) {
$data{$2}->{$4}->[$3]++; #existance use only..
#on the other hand, we could check for dupes as
well...
} else {
warn "Line $. did not match input criteria. Skipping!\n";
}
}
my $count=1; #why dont normal people count from 0 as well as hackers?
foreach my $type (sort keys %data) { #iterate through the frame bit...
foreach my $ext (sort keys %{$data{$type}}) { #now for the extensions
my $list=$data{$type}->{$ext}; #now the numbers
my $tmp=""; #for storing the beginning of a range
my @ranges; #all of the ranges for this file type and ext
for my $i (0..@$list) {
if (defined($list->[$i])) { #have we seen this one?
next if ($tmp); #skip if we are in a range
$tmp=$i; #strat the range
} else { #nope, we havent seen it
next if !$tmp; #skip if not in a range
if ($tmp) { #we need to finish a range
#range or singleton??
$tmp.="-".($i-1) if ($i-1)!=$tmp;
push @ranges,$tmp; #add to rangelist
$tmp=""; #reset $tmp
};
}
} #end for
#print it out....
print "$count $type.\%04d.$ext ".join(",",@ranges)."\n";
$count++;
}
}
__DATA__
a frame.0001.rgb
a frame.0002.rgb
a frame.0003.rgb
a frame.0004.rgb
a frame.0006.rgb
a frame.0008.regb
a frame.0009.regb
a frame.0010.regb
a frame_v12.0001.rgb
a frame_v12.0002.rgb
a frame_v12.0003.rgb
a frame_v12.0004.rgb
a frame_v12.0005.rgb
a frame_v12.0006.rgb
a frame_v3.0001.rgb
a frame_v3.0002.rgb
a frame_v3.0003.rgb
a frame_v3.0004.rgb
bobs frame_v99.8645.junk
bobs frame_v99.8646.junk
------------------------------
Date: 30 Jul 2001 10:46:22 -0700
From: mariorizzuti@yahoo.com (Mario Rizzuti)
Subject: Re: Iterating through an array
Message-Id: <42f3ee2.0107300946.6aaeb3f5@posting.google.com>
Ron Smith <ronnet@mediaone.net> wrote in message news:<ir88mtk2ce9k1huq762iuu6o6hh023itih@4ax.com>...
> I need a little help with this one. I'm not finding exactly what I
> want in "The Cookbook" or the "Reference".
>
> I'm using the following 16 lines in a text file:
>
> -------------------snip------------------------------------
> /directory/directory/directory/directory/
> a frame.0001.rgb
> a frame.0002.rgb
> a frame.0003.rgb
> a frame.0004.rgb
> a frame.0005.rgb
> a frame_v12.0001.rgb
> a frame_v12.0002.rgb
> a frame_v12.0003.rgb
> a frame_v12.0004.rgb
> a frame_v12.0005.rgb
> a frame_v12.0006.rgb
> a frame_v3.0001.rgb
> a frame_v3.0002.rgb
> a frame_v3.0003.rgb
> a frame_v3.0004.rgb
> -------------------snip------------------------------------
>
> What I've done is split each line so that the basename of the entries
> (frame, frame_v12, frame_v3) are in their own array; the numbers
> (0001, 0002, 0006, etc.) are in their own array, and all the "rgb"s
> are also in their own array.
>
> From here, I'd like to iterate over the arrays until a new element is
> encountered (one that doesn't match the previous element), then print
> to a new file, or the same file the same info as above, but only in
> the following format:
>
> 1 frame.%04d.rgb 1-5
> 2 frame_v12.%04d.rgb 1-6
> 3 frame_v3.%04d.rgb 1-4
>
> Here's what I have, so far. I'd like a little direction from here, or
> even a new approach, on the iteration part.
>
> -------------------snip------------------------------------
> #!/usr/bin/perl -w
> use strict;
>
> my($file, $leading_symbol, $filename, $basename, $pad, $ext);
> my(@basename, @pad, @ext);
> print "\nWhich file would you like to make a log from?: ";
> chomp($file = <STDIN>);
> open(FILE, "+<$file") || die "Could not open $file: $!\n";
> while (<FILE>) {
> ($leading_symbol, $filename) = split;
> foreach ($filename) {
You are already in the iteration ( while() ) so do your action on
$filename directly.
However to iterate through an array, you need an array first:
foreach my $filename (@filenames) {
print "$filename\n";
}
At every iteration a new element is read from @filenames and stored in
$filename and the action between the curly braces is performed.
> ($basename, $pad, $ext) = split (/\./, $filename);
> @basename = $basename;
> @pad = $pad;
> @ext = $ext;
>
to add an element to an array (at the end):
push @basename, $basename;
> }
> }
> close FILE;
---
Mario Rizzuti
------------------------------
Date: Mon, 30 Jul 2001 16:51:58 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <tmb45eebtbjoc0@corp.supernews.com>
Following is a summary of articles from new posters spanning a 7 day
period, beginning at 23 Jul 2001 17:58:52 GMT and ending at
30 Jul 2001 14:55:44 GMT.
Notes
=====
- A line in the body of a post is considered to be original if it
does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
- All text after the last cut line (/^-- $/) in the body is
considered to be the author's signature.
- The scanner prefers the Reply-To: header over the From: header
in determining the "real" email address and name.
- Original Content Rating (OCR) is the ratio of the original content
volume to the total body volume.
- Find the News-Scan distribution on the CPAN!
<URL:http://www.perl.com/CPAN/modules/by-module/News/>
- Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
- Copyright (c) 2001 Greg Bacon.
Verbatim copying and redistribution is permitted without royalty;
alteration is not permitted. Redistribution and/or use for any
commercial purpose is prohibited.
Totals
======
Posters: 147 (41.6% of all posters)
Articles: 247 (23.8% of all articles)
Volume generated: 426.2 kb (23.0% of total volume)
- headers: 194.5 kb (4,030 lines)
- bodies: 225.3 kb (8,022 lines)
- original: 160.8 kb (5,971 lines)
- signatures: 6.2 kb (160 lines)
Original Content Rating: 0.714
Averages
========
Posts per poster: 1.7
median: 1 post
mode: 1 post - 96 posters
s: 1.6 posts
Message size: 1767.0 bytes
- header: 806.5 bytes (16.3 lines)
- body: 934.0 bytes (32.5 lines)
- original: 666.8 bytes (24.2 lines)
- signature: 25.6 bytes (0.6 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
10 14.2 ( 9.7/ 4.4/ 3.1) Paul Johnston <paul.johnston@dsvr.co.uk>
8 15.4 ( 6.2/ 9.2/ 5.5) slash@dot.c.o.m.org
6 10.8 ( 5.9/ 5.0/ 1.7) "Johannes B." <johannes_be@gmx.de>
6 14.2 ( 4.9/ 7.7/ 5.2) Ilmari Karonen <usenet11530@itz.pp.sci.fi>
5 13.0 ( 3.9/ 8.7/ 4.3) Lawrence <lawrence@f-deans.freeserve.co.uk>
4 7.2 ( 3.0/ 4.2/ 1.9) badarik@yahoo.com
4 7.6 ( 3.7/ 3.9/ 1.0) "Lee" <tong_po_and_malene@hotmail.com>
4 5.3 ( 3.3/ 2.0/ 1.7) Marc Ulrich <mdulrich@unity.ncsu.edu>
4 6.3 ( 4.1/ 2.2/ 1.4) "Mike S." <yeah@right.com>
4 8.1 ( 4.2/ 3.9/ 3.9) "Jay" <ReplyToTheGroup@DoNotEmailMe.Com>
These posters accounted for 5.3% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
24.5 ( 3.2/ 20.6/ 15.6) 4 jbp <jpixton@dircon.co.uk>
15.4 ( 6.2/ 9.2/ 5.5) 8 slash@dot.c.o.m.org
14.2 ( 4.9/ 7.7/ 5.2) 6 Ilmari Karonen <usenet11530@itz.pp.sci.fi>
14.2 ( 9.7/ 4.4/ 3.1) 10 Paul Johnston <paul.johnston@dsvr.co.uk>
14.1 ( 3.9/ 9.0/ 4.8) 4 Jasper McCrea <jasper@guideguide.com>
13.0 ( 3.9/ 8.7/ 4.3) 5 Lawrence <lawrence@f-deans.freeserve.co.uk>
10.8 ( 5.9/ 5.0/ 1.7) 6 "Johannes B." <johannes_be@gmx.de>
8.1 ( 4.2/ 3.9/ 3.9) 4 "Jay" <ReplyToTheGroup@DoNotEmailMe.Com>
7.6 ( 3.7/ 3.9/ 1.0) 4 "Lee" <tong_po_and_malene@hotmail.com>
7.5 ( 1.4/ 6.1/ 6.1) 2 Moonshiner <douglas.neufeld@cisf.af.mil>
These posters accounted for 7.0% of the total volume.
Top 10 Posters by OCR (minimum of three posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
1.000 ( 3.9 / 3.9) 4 "Jay" <ReplyToTheGroup@DoNotEmailMe.Com>
0.974 ( 1.5 / 1.5) 3 shaz <ssa1701@yahoo.co.uk>
0.848 ( 1.7 / 2.0) 4 Marc Ulrich <mdulrich@unity.ncsu.edu>
0.807 ( 1.9 / 2.4) 3 Ilmari Karonen <usenet11531@itz.pp.sci.fi>
0.759 ( 15.6 / 20.6) 4 jbp <jpixton@dircon.co.uk>
0.716 ( 2.2 / 3.1) 3 Tracy Gentry <tracy_gentry@yahoo.com>
0.697 ( 3.1 / 4.4) 10 Paul Johnston <paul.johnston@dsvr.co.uk>
0.686 ( 2.7 / 3.9) 3 Mario Rizzuti <mariorizzuti@yahoo.com>
0.673 ( 5.2 / 7.7) 6 Ilmari Karonen <usenet11530@itz.pp.sci.fi>
0.668 ( 1.4 / 2.2) 4 "Mike S." <yeah@right.com>
Bottom 10 Posters by OCR (minimum of three posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.602 ( 5.5 / 9.2) 8 slash@dot.c.o.m.org
0.598 ( 1.2 / 2.0) 3 gbeymk@sgh.com.sg
0.538 ( 4.8 / 9.0) 4 Jasper McCrea <jasper@guideguide.com>
0.500 ( 1.7 / 3.4) 4 Balaji <srinivasanbala@netscape.net>
0.490 ( 4.3 / 8.7) 5 Lawrence <lawrence@f-deans.freeserve.co.uk>
0.441 ( 1.9 / 4.2) 4 badarik@yahoo.com
0.390 ( 1.2 / 3.1) 4 Mik Mifflin <NOSPAM.dogansmoobs@ctel.net>
0.351 ( 1.7 / 5.0) 6 "Johannes B." <johannes_be@gmx.de>
0.248 ( 1.0 / 3.9) 4 "Lee" <tong_po_and_malene@hotmail.com>
0.244 ( 0.6 / 2.6) 3 Bill Atkins <billatkins@bigfoot.com>
20 posters (13%) had at least three posts.
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
17 comp.lang.perl.modules
16 alt.perl
13 comp.lang.perl
8 gnu.emacs.help
5 comp.databases.informix
5 comp.lang.python
4 comp.databases.ms-sqlserver
4 comp.unix.shell
4 comp.infosystems.www.authoring.misc
4 comp.unix.questions
Top 10 Crossposters
===================
Articles Address
-------- -------
8 mnd999@hotmail.com
6 "Mike S." <yeah@right.com>
4 badarik@yahoo.com
3 Petasis George <petasis@iit.demokritos.gr>
2 tenpercenter <tenpercenter54@hotmail.com>
2 John Gordon <gordon@cwww.cso.uiuc.edu>
2 Thomas Volkmar Worm <worm@gdp-group.com>
2 Ruediger Soerensen <soerense@verwaltung.uni-mainz.de>
2 "Brad G" <bardley90@hotmail.com>
2 "Matjaz Ostroversnik" <matjaz.ostroversnik@zrs-tk.si>
------------------------------
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 1407
***************************************