[10439] in Perl-Users-Digest
Perl-Users Digest, Issue: 4032 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 21 11:03:31 1998
Date: Wed, 21 Oct 98 08:01:29 -0700
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, 21 Oct 1998 Volume: 8 Number: 4032
Today's topics:
reg exp help, please <alexb@sig.net>
Re: reg exp help, please <jdf@pobox.com>
Re: round a value (Larry Rosler)
Re: round a value (Larry Rosler)
Re: Testing a date (David Alan Black)
Re: Testing a date (Larry Rosler)
Re: What are these? <aqumsieh@matrox.com>
Re: Where's the mailin "guru" certificate? <l.brocard@elsevier.nl>
Re: Who can help me write full-text search engine in Pe (Snowhare)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 21 Oct 1998 08:26:52 -0500
From: Alexander Bibighaus <alexb@sig.net>
Subject: reg exp help, please
Message-Id: <362DE11C.35EC1E9@sig.net>
Is there a way to find the shortest match between double-quotes that
neither of which
have a preceding backslash?
Any suggestions as to what reg exp to use would be gratefully
appreciated.
Here are the details:
I have a datafile that uses double quotes as a delimiter that is read in
paragraphs.
for instance:
key = "data"
key = "data"
key = "data"
key = "data"
key = "data"
key = "data"
etc...
Now, since double quotes are allowed within the data, they are escaped
upon data-entry.
key = "this is \"data\" with quotes inside"
key = "this is data"
How can I retrieve the part between the outer quotes w/o using a newline
in the regexp.
My problem is when I switch between /\"(.*)\"/ and /\"(.*?)\"/ it
matches the quotes at the end of the paragraph b/c I'm reading by
paragraphs
thanks in advance,
alexander
------------------------------
Date: 21 Oct 1998 16:11:30 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: Alexander Bibighaus <alexb@sig.net>
Subject: Re: reg exp help, please
Message-Id: <m3lnmadmy5.fsf@joshua.panix.com>
Alexander Bibighaus <alexb@sig.net> writes:
> Is there a way to find the shortest match between double-quotes that
> neither of which have a preceding backslash?
Is there any case in which the first quote in a given chunk will be
preceeded by a backslash? I don't think so. In which case this will
do:
@strings = /"((?:[^"\\]+|\\.)*)"/g
I got this from _Mastering Regular Expressions_.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Wed, 21 Oct 1998 06:14:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: round a value
Message-Id: <MPG.10977e2b935346df9898d4@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <70k7ba$3p9$1@nnrp1.dejanews.com> on Wed, 21 Oct 1998
08:51:54 GMT, dwiesel@my-dejanews.com <dwiesel@my-dejanews.com> says...
...
> I would like to know how to round a value so that if it is
> 2.499 it will become 2.5
> and if it is
> 2.999 it will become 3
>
> (I want the value to become a new value with 0.5 between (sorry for my bad
> english)
If I understand you correctly, this is a small elaboration on perlfaq4:
"Does perl have a round function?", enough different so that it is no
longer a Frequently asked question.
sprintf('%.0f', 2 * $value) / 2
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 21 Oct 1998 06:48:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: round a value
Message-Id: <MPG.10978620728ebbcf9898d6@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <hljk07.pqc.ln@flash.net> on Wed, 21 Oct 1998 07:22:09 -0500,
Tad McClellan <tadmc@flash.net> says...
...
> sub round_to_nearest_half {
> my($num) = @_;
> $num = sprintf '%.1f', $num; # round to tenths
> return $num if $num =~ /\.5$/; # done if a half
> return sprintf '%.0f', $num; # else round to integer
> }
That doesn't work. Try 2.4, for example. Result is 2, not 2.5 which is
the nearest half.
I'll repeat the correct answer:
sprintf('%.0f', 2 * $value) / 2
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 21 Oct 1998 09:06:43 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Testing a date
Message-Id: <70km93$adu$1@pilot.njin.net>
Hello -
(I haven't seen the original, so I'm piggybacking.... This is
also a very different approach from Matt's.)
Matt Pryor <matt@whiterabbit.co.uk> writes:
>Josep Jover wrote:
>>
>> Hello everybody,
>>
>> How can I verify if a date dd/mm/yyyy is a correct data ?
orpheus:~/perl$ perl -wMDate::Manip
Date_Init("DateFormat = nonUS");
die "Invalid date" unless ParseDate("29/2/1998");
^D
Invalid date at - line 2.
David Black
dblack@pilot.njin.net
------------------------------
Date: Wed, 21 Oct 1998 06:38:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Testing a date
Message-Id: <MPG.109783bb1e5bc1c39898d5@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <362DD6C6.9AFB9465@whiterabbit.co.uk> on Wed, 21 Oct 1998
13:42:46 +0100, Matt Pryor <matt@whiterabbit.co.uk> says...
> #!/usr/local/bin/perl -w
> use strict;
A good start, but may cause some problems below.
...
> my ($day,$month,$year) = split (/\//,$date);
> if ($year !~ /^\d{4}$/) {
This will produce a warning about undefined variable if the split did
not yield at least three values. Similarly for $month below if there
are no slashes in the input $date. The easiest fix might be to insert:
($date =~ tr#/##) == 2 or $error .= 'Wrong number of fields.'
and stop further processing on this error.
...
> if (($month < 1) || ($month > 12) || ($month =~ /\D/)) {
This will produce warnings if $month is not numeric. The test for valid
syntax should precede the test for valid semantics.
> $error=$error."The month is not valid.\n";
> } elsif (($day < 1) || ($day > $number_of_days[$month-1]) ||
> ($day=~/\D/)) {
Ditto.
...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 21 Oct 1998 09:47:45 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
To: avitala@macs.biu.ac.il
Subject: Re: What are these?
Message-Id: <x3yiuhegh6m.fsf@tigre.matrox.com>
[Posted and CC mailed]
"Avshi Avital" <avitala@macs.biu.ac.il> writes:
> perhaps it's best to view it this way:
> let @list be a list.
> the following actions are psbl:
> push($list, $val) - insert a value at the end of the list.
What list? $list is a scalar? perhaps you meant @list ??
> $foo = pop($list, $val) - take out a value from the end of the list
> and asign it to $foo.
which list again? The above statement won't even parse!! Besides,
pop() takes at most ONE argument and it HAS to be an array.
> shift($list, $val) - insert a value at the beginning of the list.
shift() has the exact same form as pop(). The above line is wrong.
> $foo = unshift($list, $val) - take out a value from the beginnig of
> the list and asign it to $foo.
WHAT? from perldoc -f unshift
=item unshift ARRAY,LIST
Does the opposite of a C<shift>. Or the opposite of a C<push>,
depending on how you look at it. Prepends list to the front of the
array, and returns the new number of elements in the array.
> [;-)
What's the smiley for?
>
> Avshalom Avital
> Information Retrieval Laboratory
> Bar-Ilan University, Israel
> avitala@macs.biu.ac.il
Are we talking about the same language? Perl? If so, then you
shouldn't post such non-sense.
--
Ala Qumsieh email: aqumsieh@matrox.com
ASIC Design Engineer phone: (514) 822-6000 x7581
Matrox Graphics Inc. (old) webpage :
Montreal, Quebec http://www.cim.mcgill.ca/~qumsieh
------------------------------
Date: Wed, 21 Oct 1998 15:41:43 +0100
From: Leon Brocard <l.brocard@elsevier.nl>
Subject: Re: Where's the mailin "guru" certificate?
Message-Id: <362DF2A7.48BC7A93@elsevier.nl>
Adam Turoff wrote:
> Someone else handles them transactions. If you hurry, you might
> be able to get 'Certified Perl Guru' certificate #500404 or #500502!
Hey! I got that one ;-)
Hmmm. The "(c) Klortho the Magnificent" looks a bit dogdy...
obperl:
#!/usr/bin/perl -wT
use strict; my($coded, $uncoded); $coded = unpack('b*', unpack('u*',
q|ME,>*44PBD8RT8HD3(\V8(DDD^8R<LB(?Y<C$*9)$$C&;31I1*E*1MFVC2+:M
<6)J(%2/-)DUQ8A2+6!I%2JRX6)$4CQ6C6)&()|)); $uncoded .=
(qw(10 11 00 01))[length $1] while ($coded =~ s|^(0*)1||);
print pack('b*', $uncoded); # JAPH (clean code!)
Leon
--
Leon Brocard...............................................Perl Hacker
l.brocard@elsevier.nl...........................http://www.astray.com/
... Neil Armstrong tripped.
------------------------------
Date: 21 Oct 1998 08:06:05 -0600
From: snowhare@xmission.xmission.com (Snowhare)
Subject: Re: Who can help me write full-text search engine in Perl with indexing
Message-Id: <70kpod$qg0$1@xmission.xmission.com>
Nothing above this line is part of the signed message.
In article <saryaqblynj.fsf@camel.fastserv.com>,
Uri Guttman <uri@camel.fastserv.com> wrote:
>>>>>> "DJ" == Darius Jack <dariusz@usa.net> writes:
>
> DJ> Who can help me write search engine to search kew words in full texts,
> DJ> in Perl, running locally under Perl for DOS.
> DJ> Or ready-made script please.
> DJ> jack
>
>only god (or larry wall) can do such a thing in perl. begone blasphemer
>or you will be forced to use DOS! oops, you are using DOS, ignore that
>last comment.
>
>this group is to help people with the perl language, not do work for
>people.
There is a way to do both. Actual use in live code and explanation of how
it works is left as an exercise for the student. :)
Benjamin Franz
"And no - I *don't* have the time to explain it to people nor will I
respond to comments about 'use strict' on it."
#!/usr/bin/perl -w
package InverseMap;
use GDBM_File;
1;
#
# &InverseMap'InsertIndexToKey($key,$index,$ranking);
# &InverseMap'DeleteIndexFromKey($key,$index);
# &InverseMap'OpenInverseMap($database,$mode,
# $minblockelements,$maxblockelements);
# &InverseMap'CloseInverseMap;
# &InverseMap'EnumToKey($enumvalue);
# &InverseMap'KeyToEnum($keystring);
# &InverseMap'EnumToIndex($enumvalue);
# &InverseMap'IndexToEnum($indexstring);
# $nmatches=&InverseMap'ReadEnumIndexesForKey($keystring,
# $IndexEnumValuesRef,$RankingValuesRef);
# The globals used within the package are:
#
# $PersistentInvMap - holds the name of the currently open
# inverted database. 'undef' if no database
# is open.
#
# %IndexStringToEnum - tied hash database containing the
# enum<->indexstring forward and reverse
# lookup data
#
# %KeyStringToEnum - tied hash database containing the
# enum<->keystring forward and reverse
# lookup data and the byteoffset and blocksize
# for each keyed block.
#
# %FreeChain - holds the free chain lists for available
# blocks that can be reused
#
# INVMAPFILE - file handle for the main inverted database.
#
# $MinEnumElements - smallest # of elements allowed to be allocated
# for an inverted data block.
#
# $MaxEnumElements - largest # of elements allowed to be allocated
# for an inverted data block.
#
sub EnumToIndex {
my ($indexstring,$enumstring,@CallingParms,$NCallingParms,
$IndexStringMapFile,$KeyStringMapFile);
@CallingParms=@_;
$NCallingParms=$#CallingParms + 1;
if ($NCallingParms != 1) {
die ("EnumToIndex: Incorrect number of calling parameters ($NCallingParms instead of 1)\n");
}
($enumstring)=@_;
if (defined($indexstring=$IndexStringToEnum{"r $enumstring"})) {
$result=$indexstring;
} else {
$result=undef;
}
$result;
}
sub IndexToEnum {
my ($indexstring,$enumstring,@CallingParms,$NCallingParms,
$IndexStringMapFile,$KeyStringMapFile);
$NCallingParms=$#_ + 1;
if ($NCallingParms != 1) {
die ("EnumToIndex: Incorrect number of calling parameters ($NCallingParms instead of 1)\n");
}
($indexstring)=@_;
if (defined($enumstring=$IndexStringToEnum{"f $indexstring"})) {
$result=$enumstring;
} else {
$result=undef;
}
$result;
}
sub EnumToKey {
my ($keystring,$NCallingParms,$result,$KeyStringMapFile,$enumstring);
$NCallingParms=$#_ + 1;
if ($NCallingParms != 1) {
die ("EnumToKey: Incorrect number of calling parameters ($NCallingParms instead of 1)\n");
}
($enumvalue)=@_;
if (defined($keystring=$KeyStringToEnum{"r $enumvalue"})) {
$result=$keystring;
} else {
$result=undef;
}
$result;
}
sub KeyToEnum {
my ($keystring,$NCallingParms,
$KeyData,$KeyEnum,$ByteOffset,$BlockSize);
$NCallingParms = $#_ + 1;
if ($NCallingParms != 1) {
die ("KeyToEnum: Incorrect number of calling parameters ($NCallingParms instead of 1)\n");
}
($keystring)=@_;
if (defined($KeyData=$KeyStringToEnum{"f $keystring"})) {
($KeyEnum,$ByteOffset,$BlockSize)=split(/:/o,$KeyData,3);
} else {
$KeyEnum = undef;
}
$KeyEnum;
}
sub CloseInverseMap {
my ($IndexStringMapFile,$KeyStringMapFile,$MapFile);
if (! $PersistentInvMap) {
die ("CloseInverseMap: No inverse map is currently open.\n");
}
untie(%IndexStringToEnum);
untie(%KeyStringToEnum);
untie(%FreeChain);
close(INVMAPFILE);
undef $PersistentInvMap;
undef $MinEnumElements;
undef $MaxEnumElements;
}
# Opens the Inverse Map for multiple accesses
# $database is the base file name and mode is either 'r' (read only)
# or 'u' (update - read and write). $MinEnumElements and $MaxEnumElenents
# determine the smallest and largest block size that can be used
# when growing the inverted map. They measure the number of
# elements stored in each cell. Setting $MaxEnumElemeents to zero
# places NO limit on the maximum number of elements in each inverted
# list. It is a fatal error to specify a $MaxEnumElements smaller
# than the $MinEnumElements, except for 0.
sub OpenInverseMap {
my ($database,$mode,$DatabaseDir,$IndexStringMapFile,
$KeyStringMapFile,$MapFile);
($database,$mode,$MinEnumElements,$MaxEnumElements) = @_;
$ncalling = $#_ + 1;
if ($ncalling != 4) {
die ("OpenInverseMap: Incorrect number of calling parameters ($ncalling instead of 4)\n");
}
if ((int($MinEnumElements) != $MinEnumElements) ||
(! ($MinEnumElements > 0))) {
die ("OpenInverseMap: An invalid minumum number of elements per inverted index cell was specified: $MinEnumElements\n");
}
if ((int($MaxEnumElements) != $MaxEnumElements) ||
(($MaxEnumElements != 0) &&
($MaxEnumElements < $MinEnumElements))) {
die ("OpenInverseMap: An invalid maximum number of elements per inverted index cell ($MaxEnumElements) was specified\n");
}
if (($mode ne 'r') && ($mode ne 'u')) {
die ("OpenInverseMap: Invalid mode selected: '$mode'\n");
}
if ($PersistentInvMap) {
die ("OpenInverseMap: Another inverse map ($PersistentInvMap) is already open.\n");
}
$PersistentInvMap=$database;
$DatabaseDir = $database;
$DatabaseDir =~ s#/[^/]+$#/#o;
if (! (-e $DatabaseDir)) {
die ("OpenInverseMap: Directory $DatabaseDir does not exist\n");
}
if (! (-d _)) {
die ("OpenInverseMap: $DatabaseDir is not a directory\n");
}
$IndexStringMapFile = "${database}.smap";
if ($mode eq 'u') {
if (! tie (%IndexStringToEnum,"GDBM_File",
$IndexStringMapFile,&GDBM_WRCREAT,0644)) {
die("OpenInverseMap: Unable to open database $IndexStringMapFile\n\$");
}
$KeyStringMapFile = "${database}.kmap";
if (! tie (%KeyStringToEnum,"GDBM_File",
$KeyStringMapFile,&GDBM_WRCREAT,0644)) {
die("OpenInverseMap: Unable to open database $KeyStringMapFile\n\$");
}
$FreeChainFile = "${database}.fmap";
if (! tie (%FreeChain,"GDBM_File",
$FreeChainFile,&GDBM_WRCREAT,0644)) {
die("OpenInverseMap: Unable to open database $FreeChainFile\n\$");
}
$MapFile = "${database}.imap";
# if the main inverse map file doesn't exist, create it
if (! -e $MapFile) {
if (! open(INVMAPFILE,">$MapFile")) {
die ("OpenInverseMap: $MapFile does not exist and could not be created\n$!");
}
chmod (0644,$MapFile);
}
if (! -f $MapFile) {
die ("OpenInverseMap: $MapFile is not a regular file\n");
}
if (! -r _) {
die ("OpenInverseMap: $MapFile exists but cannot be read (improper file permissions set?)\n");
}
if (! -w _) {
die ("OpenInverseMap: $MapFile exists but cannot be written to (improper file permissions set?)\n");
}
if (! open (INVMAPFILE,"+<$MapFile")) {
die ("OpenInverseMap: Could not open $MapFile for updating\n$!");
}
select (INVMAPFILE);
$|=1;
select (STDOUT);
} elsif ($mode eq 'r') {
if (! tie(%IndexStringToEnum,"GDBM_File",
$IndexStringMapFile,&GDBM_READER,0644)) {
die("OpenInverseMap: Unable to open database $IndexStringMapFile\n\$");
}
$KeyStringMapFile = "${database}.kmap";
if (! tie(%KeyStringToEnum,"GDBM_File",
$KeyStringMapFile,&GDBM_READER,0644)) {
untie %IndexStringToEnum;
die("OpenInverseMap: Unable to open database $KeyStringMapFile\n\$");
}
$MapFile = "${database}.imap";
# if the main inverse map file doesn't exist, bail
if (! -e $MapFile) {
untie %IndexStringToEnum;
untie %KeyStringToEnum;
die ("OpenInverseMap: $MapFile does not exist\n$!");
}
if (! -f _) {
untie %IndexStringToEnum;
untie %KeyStringToEnum;
die ("OpenInverseMap: $MapFile is not a regular file\n");
}
if (! -r _) {
untie %IndexStringToEnum;
untie %KeyStringToEnum;
die ("OpenInverseMap: $MapFile exists but cannot be read (improper file permissions set?)\n");
}
if (! open (INVMAPFILE,$MapFile)) {
untie %IndexStringToEnum;
untie %KeyStringToEnum;
die ("OpenInverseMap: Could not open $MapFile for reading\n$!");
}
}
}
sub InsertIndexToKey {
my ($keystring,$indexstring,$ranking,$NCallingParms,
$PackedRecordSize,$PackedLongSize,$BlockSize,
$MapFileOffset,$IndexStringMapFile,$KeyStringMapFile);
$NCallingParms = $#_ + 1;
if ($NCallingParms != 3) {
die ("InsertIndexToKey: Incorrect number of calling parameters ($NCallingParms instead of 3)\n");
}
($keystring,$indexstring,$ranking)=@_;
if (! $ranking) {
die ("InsertIndexToKey: Ranking of '0' is not allowed.\n");
} elsif ($ranking != int($ranking)) {
die ("InsertIndexToKey: Non-integer rankings are not allowed.\n");
}
if (! defined($IndexEnum=$IndexStringToEnum{"f $indexstring"})) {
if (! defined($IndexEnum=$IndexStringToEnum{"HighIndex"})) {
$IndexEnum=0;
}
$IndexStringToEnum{"r $IndexEnum"}=$indexstring;
$IndexStringToEnum{"f $indexstring"}=$IndexEnum;
$IndexStringToEnum{"HighIndex"}=$IndexEnum+1;
}
if (! defined($KeyEnum=&KeyToEnum($keystring))) {
if (! defined($KeyEnum = $KeyStringToEnum{"HighIndex"})) {
$KeyEnum = 0;
}
$KeyStringToEnum{"r $KeyEnum"} = $keystring;
$PackedLongSize = length(pack("L",1));
$PackedRecordSize = 2 * $PackedLongSize;
$BlockSize = $PackedRecordSize * $MinEnumElements;
$MapFileOffset = &PadValue(&RequestBlock($BlockSize),12);
$BlockSize = &PadValue($BlockSize,6);
$KeyStringToEnum{"f $keystring"} = "${KeyEnum}:${MapFileOffset}:${BlockSize}";
$KeyStringToEnum{"HighIndex"} = $KeyEnum+1;
}
&InsertEnumItem($KeyEnum,$keystring,$IndexEnum,$ranking);
}
sub DeleteIndexFromKey {
my ($keystring,$indexstring,$ranking,
$NCallingParms,$CallingParms,
$IndexStringMapFile,$KeyStringMapFile);
(@CallingParms)=@_;
$NCallingParms=$#CallingParms+1;
if ($NCallingParms != 2) {
die ("DeleteIndexFromKey: Incorrect number of calling parameters ($NCallingParms instead of 2)\n");
}
($keystring,$indexstring)=@_;
if (! defined($IndexEnum=$IndexStringToEnum{"f $indexstring"})) {
return;
}
if (! defined($KeyEnum=$KeyStringToEnum{"f $keystring"})) {
return;
}
&DeleteEnumItem($KeyEnum,$IndexEnum);
}
sub ReadEnumIndexesForKey {
my ($keystring,$IndexEnumValuesRef,$RankingValuesRef,
$KeyStringMapFile,$NCallingParms);
$NCallingParms=$#_+1;
if ($NCallingParms != 3) {
die ("ReadEnumIndexesForKey: Incorrect number of calling parameters ($NCallingParms instead of 3)\n");
}
($keystring,$IndexEnumValuesRef,$RankingValuesRef)=@_;
$matches=&ReadEnumMap($keystring,$IndexEnumValuesRef,$RankingValuesRef);
$matches;
}
sub InsertEnumItem {
my ($key,$keystring,$index,$ranking) = @_;
my ($MapChunkBuffer);
$MapChunkBuffer=&ReadRawEnumMap($keystring);
if(&InsertTopNRaw($index,$ranking,\$MapChunkBuffer)) {
&SaveRawEnumMap($keystring,$MapChunkBuffer);
}
}
sub DeleteEnumItem {
my ($key,$index) =@_;
my ($matches,@RankingValues,@IndexValues,$count);
@IndexValues=();
@RankingValues=();
$matches=&ReadEnumMap($key,\@IndexValues,\@RankingValues);
# Scan for the enumerated value and delete it when found
for ($count=0;$count<$matches;$count++) {
next if ($IndexValues[$count]!=$index);
splice(@IndexValues,$count,1);
splice(@RankingValues,$count,1);
last;
}
&SaveEnumMap($key,\@IndexValues,\@RankingValues);
}
sub ReadRawEnumMap {
my ($keystring)=@_;
my ($MapFileOffset,$ReadBytes,$dev,$inode,$mode,$nlink,$uid,$gid,
$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks,
$MapChunkBuffer,$KeyEnum,$BlockSize,$KeyData);
if (! defined($KeyData=$KeyStringToEnum{"f $keystring"})) {
return '';
}
($KeyEnum,$MapFileOffset,$BlockSize)=split(/:/o,$KeyData,3);
$MapFileOffset = 0 + $MapFileOffset;
$BlockSize = 0 + $BlockSize;
$MapChunkBuffer=pack("x$BlockSize");
($dev,$inode,$mode,$nlink,$uid,$gid,$rdev,
$size,$atime,$mtime,$ctime,$blksize,$blocks)=stat(INVMAPFILE);
if ($size < $MapFileOffset+$BlockSize) {
return '';
}
if (! &LongSeek(\*INVMAPFILE,$MapFileOffset)) {
die ("ReadRawEnumMap: Unexpectedly unable to seek to byte $MapFileOffset of $PersistentInvMap\n");
}
$ReadBytes=read(INVMAPFILE,$MapChunkBuffer,$BlockSize);
if ($ReadBytes != $BlockSize) {
die ("ReadRawEnumMap: Short read on $PersistentInvMap. Only $ReadBytes of $BlockSize bytes were read at offset $MapFileOffset\n");
}
$MapChunkBuffer;
}
sub ReadEnumMap {
my ($key,$IndexValuesRef,$RankingValuesRef)=@_;
my ($nmatches,$count,@RawMapList,$NElements,$PackedRecordSize,
$PackedLongSize);
@$IndexValuesRef=();
@$RankingValuesRef=();
# values are stored as pairs of signed long integers,
# RankingValue first, IndexValue second
$MapChunkBuffer=&ReadRawEnumMap($key);
return 0 if (length($MapChunkBuffer)==0);
$PackedLongSize=length(pack("L",1));
$PackedRecordSize = 2 * $PackedLongSize;
$NElements= length($MapChunkBuffer) / $PackedRecordSize;
(@RawMapList)=unpack("L*",$MapChunkBuffer);
# The field pairs are a bit inefficient on speed in Perl
# without structures - but should be ideal in C
$count=0;
$nmatches=0;
while($count<=$#RawMapList) {
# If the ranking=0, this is the end of the list
# because no actual entry will have a ranking of 0
if ($RawMapList[$count]==0) {
last;
}
push (@$RankingValuesRef,$RawMapList[$count]);
$count++;
push (@$IndexValuesRef,$RawMapList[$count]);
$count++;
$nmatches++;
}
$nmatches;
}
sub SaveEnumMap {
my ($keystring,$IndexValuesRef,$RankingValuesRef)=@_;
my (@RawMapList,$tcount,$scount,$MapChunkBuffer,$stopat);
# values are stored as pairs of signed long integers,
# RankingValue first, IndexValue second
$scount=0;
$tcount=0;
$stopat = $#$RankingValuesRef + 1;
$stopat = $MaxEnumElements if ($stopat > $MaxEnumElements);
while($tcount<$stopat) {
# If the ranking=0, this is the end of the list
# because no actual entry will have a ranking of 0
if (! defined($$RankingValuesRef[$tcount]) ||
($$RankingValuesRef[$tcount]==0)) {
last;
}
push (@RawMapList,$$RankingValuesRef[$tcount]);
$scount++;
push (@RawMapList,$$IndexValuesRef[$tcount]);
$scount++.
TAKETHIS <oTlX1.538$ob2.27852918@newsreader.digex.net>
Path: uunet!in5.uu.net!newsfeed.xcom.net!chnws02.mediaone.net!192.148.253.68!netnews.com!dca1-hub1.news.digex.net!digex!newsreader.digex.net!not-for-mail
Newsgroups: comp.jobs,comp.jobs.offered,prg.jobs
Subject: US-NJ-METUCHEN-Lead Software Architect
From: cshopinfo@careershop.com
Organization: Career Shop <http://www.careershop.com>
Lines: 41
Message-ID: <oTlX1.538$ob2.27852918@newsreader.digex.net>
Date: Wed, 21 Oct 1998 14:06:12 GMT
NNTP-Posting-Host: 207.87.32.174
X-Complaints-To: abuse@digex.net
X-Trace: newsreader.digex.net 908978772 207.87.32.174 (Wed, 21 Oct 1998 10:06:12 EDT)
NNTP-Posting-Date: Wed, 21 Oct 1998 10:06:12 EDT
Xref: uunet prg.jobs:1908591
Job Title: Lead Software Architect
Job Location: METUCHEN, NJ
Prime Associates, Inc., a leading provider of Messaging
Middleware solutions for the Financial Industry, seeks
a lead product developer. Strong experience in a combination
of C++, Visual Basic (VB), or SQL Server on Windows
NT required together with strong management and communications
skills.
High visibility among senior banking management.
Minimal travel.
Fantastic personal and financial growth oppty.
Leading edge development
Job Ref.# CAREERSHOP 67231
Company Information:
Prime Associates
Sal Cangialosi
495 Main St.
Mentuchen, NJ 08840
Phone: 732-603-0956
Fax: 732-603-9262
Email: scangialosi@primeassociates.com
URL:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Posted by CAREER SHOP <http://www.careershop.com>
LOCAL Online Job Fairs Now in Progress!
Top Local employers WANT YOU!
Search Jobs and Post your resume FREE!!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4032
**************************************