[25259] in Perl-Users-Digest
Perl-Users Digest, Issue: 7504 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 10 14:05:58 2004
Date: Fri, 10 Dec 2004 11:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 10 Dec 2004 Volume: 10 Number: 7504
Today's topics:
ANNOUNCE: WWW::Webrobot 0.62 <webrobot@abas.de>
ANNOUNCE: yagg 1.20 released <newspost@coppit.org>
Re: Cannot compile working perl on freebsd / amd64 <tassilo.von.parseval@rwth-aachen.de>
Re: Convert text to Hex <this.address@is.invalid>
Re: Convert text to Hex <jwillmore@fastmail.us>
Extracting encrypted in a table on DB2 with Perl rparimi@gmail.com
Re: Facile user-agent statistics tool (Anno Siegel)
File::Copy woes frisina@gmail.com
Re: File::Copy woes <james@emarch.net>
Re: File::Copy woes <mritty@gmail.com>
Re: Insert JavaScript into Perl <eon@hotmail.com>
Loop Logic Question <ccarpenter@erols.com>
Re: Loop Logic Question <rzilavec@tcn.net>
Re: Loop Logic Question <uri@stemsystems.com>
Re: Matching words and letters <mr@sandman.net>
multiple webpages sharing a dataset reference <sam.wun@authtec.net>
Re: multiple webpages sharing a dataset reference xhoster@gmail.com
Re: multiple webpages sharing a dataset reference <nospam@bigpond.com>
Re: multiple webpages sharing a dataset reference <sam.wun@authtec.com>
Re: multiple webpages sharing a dataset reference <sam.wun@authtec.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 9 Dec 2004 12:10:36 GMT
From: Stefan Trcek <webrobot@abas.de>
Subject: ANNOUNCE: WWW::Webrobot 0.62
Message-Id: <I8In9M.sz4@zorch.sf-bay.org>
Webrobot 0.62 is now available on CPAN.
For all changes to previous versions see the Changes file
http://search.cpan.org/dist/webrobot/Changes
Webrobot http://search.cpan.org/dist/webrobot/ is a data driven http
client heavily based on LWP. The client action specification format
ist XML. Though the module is pure Perl it uses some modules that are
not. It can be used
* for automating http requests
* for a kind of web based unit tests
* for stress tests of web servers (limited).
For more information see the README file in the distribution
http://search.cpan.org/dist/webrobot/lib/WWW/Webrobot/pod/README.pod
and the support page http://webrobot.abas.de containing screenshots
and tutorials.
The support page also contains instructions how to write test plans
with Mozilla by just visiting the desired pages.
Stefan
------------------------------
Date: Fri, 10 Dec 2004 16:33:06 GMT
From: David Coppit <newspost@coppit.org>
Subject: ANNOUNCE: yagg 1.20 released
Message-Id: <I8In94.1Fz9@zorch.sf-bay.org>
yagg - generate a C++ string generator from a grammar
Description:
Given YACC-like and LEX-like input files, yagg is a Perl program that
generates a C++ program that generates all strings of a user-specified
length. The YACC-like language grammar file provides the grammar
productions for string generation, along with optional action blocks that
can per- form context-sensitive checks in order to limit the generated
strings. The LEX-like terminal generator file provides specifications that
instruct the program how to generate strings for terminals in the gram- mar.
If the programmer already has a YACC or Bison parser file, he or she
only needs to add "unaction" blocks to allow the recursive generator to
undo the side effects of the action blocks. If the programmer already
has a LEX or FLEX lexer input file, he or she only needs to remove
extraneous code and replace any regular expressions with one of the
terminal generator specifications.
This program is useful if you want to see examples of strings recognized
by a YACC grammar. It can also be used to generate inputs for any program
that uses textual input.
Changes:
- Initial public release
Download:
- You can download yagg from CPAN:
http://www.cpan.org/authors/id/D/DC/DCOPPIT/yagg-1.20.tar.gz
- Until the file propagates to the mirrors, you can use the following URL:
http://prdownloads.sourceforge.net/yagg/yagg-1.20.tar.gz
A complete change log is at:
- http://yagg.sourceforge.net/CHANGES
Regards,
David
------------------------------
Date: Fri, 10 Dec 2004 07:23:58 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: Cannot compile working perl on freebsd / amd64
Message-Id: <slrncrig7u.rr.tassilo.von.parseval@localhost.localdomain>
Also sprach Mike Hunter:
> I'm hoping somebody out there has some advice for me.
>
> I cannot compile a working perl binary for freebsd 5.2.1, 5.3, or 6.0 on
> amd64. During the `make test` phase it gets into some kind of memory loop
> with Config.t: It sits on this test with 99% cpu and ever-increasing memory
> until finally runnnig the machine out of ram.
>
> I have the incomplete build sitting in /tmp, and I can envoke lib/Config.t
> and get it to do it straight away. kdump (strace on linux) shows it doing
> break after break:
>
> 23961 perl CALL break(0x1f86000)
> 23961 perl RET break 0
> 23961 perl CALL break(0x2254000)
> 23961 perl RET break 0
[...]
You should report that to perl5-porters@perl.org along with the output
of 'perl -V' of this incomplete perl. If that is not possible (because
the build is in fact too incomplete to even run perl -V), include
config.h as generated by Configure in your report.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Fri, 10 Dec 2004 09:01:13 +0000
From: Stephane CHAZELAS <this.address@is.invalid>
Subject: Re: Convert text to Hex
Message-Id: <slrncripep.4nf.stephane.chazelas@spam.is.invalid>
2004-12-9, 15:12(-08), Jim:
> Stephane CHAZELAS wrote:
> < ... >
>> I actually meant that "^@^X^@^A^@^AA" was actually the character
>> 0x00 followed by the character 0x18... Such characters can't be
>> included in newsgroup messages, neither can't they generally be
>> seen, hence the need of a representations such as ^@, ^X.
>
> But they can if they are part of the actual code - which is what the OP
> posted ... not a representation of what he wanted, but the actual code
> AFAIK. If the OP says I'm wrong, so be it.
[...]
Yes, it may, except that he said 0x18 was the "corresponding
hexadecimal code" of ^X, hence my assumption.
The corresponding code of ^X (the two characters ^ and X) would
be 5E58 (ASCII) or 5FE7 (EBCDIC).
When someone talks about ^M is a usenet message, I generally
assume he is speaking of the CR character, not the two
characters ^ and M.
Now, I may be wrong about the actual content of OP's input. We'd
need him to clarify it.
[...]
>> $ cat -vt input-file
>> 01 SYSOT VALUE '^@^X^@^A^@^AA' PIC X(07)
>> $ od -tc input-file
>> 0000000 0 1 S Y S O T V A
> L
>> 0000020 U E ' \0 030 \0 001 \0 001 A '
>> 0000040 P I C X ( 0 7 ) \n
>> 0000057
>> $ cat perl-script
>> s/VALUE '(.*?)'/"VALUE X'" . unpack("H*", $1) . "'"/e
>> ~$ perl -p perl-script input-file
>> 01 SYSOT VALUE X'00180001000141' PIC X(07)
[...]
> What OS are you running? Because I did the following and got different
> results. The OS I'm running is Linux (Fedora Core 2 and Red Hat 8.0 -
> not sure about the kernel version on the Fedora box, but it's using
> 5.8.3 Perl - since I'm at work right now, but the Red Hat box is
> running a 2.4.18 kernel and 5.8.0 Perl).
>
> This is what I got duplicating your commands and files ...
> [jim@oplinux tmp]$ cat -vt input-file
> 01 SYSOT VALUE '^@^X^@^A^@^AA' PIC X(07)
> [jim@oplinux tmp]$ od -tc input-file
> 0000000 0 1 S Y S O T V A L
> 0000020 U E ' ^ @ ^ X ^ @ ^ A ^ @ ^ A
> 0000040 A ' P I C X
> 0000060 ( 0 7 ) \n
> 0000065
You didn't have the same file as mine, as od suggests.
My file, I repeat is what I suspected the OP's one to be:
VALUE '^@...
Where ^@ is the ^@ character whose byte value is 0, not the two
characters ^ and @ as in your file.
cat -vt
represents the invisible characters (such as <NUL> or <TAB> or
<CTRL-X>) in the ^X notation. Of course for visible characters
such as ^ and @, it represents them as-is, that's why we get the
same output for cat -vt.
[...]
> This is starting to bug me that I got different results and executed
> the *same* commands.
different results because different inputs.
--
Stephane
------------------------------
Date: Fri, 10 Dec 2004 09:47:44 -0500
From: James Willmore <jwillmore@fastmail.us>
Subject: Re: Convert text to Hex
Message-Id: <pan.2004.12.10.14.47.42.990259@fastmail.us>
On Fri, 10 Dec 2004 09:01:13 +0000, Stephane CHAZELAS wrote:
< ... >
> Yes, it may, except that he said 0x18 was the "corresponding
> hexadecimal code" of ^X, hence my assumption.
>
> The corresponding code of ^X (the two characters ^ and X) would
> be 5E58 (ASCII) or 5FE7 (EBCDIC).
>
> When someone talks about ^M is a usenet message, I generally
> assume he is speaking of the CR character, not the two
> characters ^ and M.
>
> Now, I may be wrong about the actual content of OP's input. We'd
> need him to clarify it.
Agreed.
< ... >
> You didn't have the same file as mine, as od suggests.
>
> My file, I repeat is what I suspected the OP's one to be:
>
> VALUE '^@...
>
> Where ^@ is the ^@ character whose byte value is 0, not the two
> characters ^ and @ as in your file.
>
> cat -vt
>
> represents the invisible characters (such as <NUL> or <TAB> or
> <CTRL-X>) in the ^X notation. Of course for visible characters
> such as ^ and @, it represents them as-is, that's why we get the
> same output for cat -vt.
>
> [...]
>> This is starting to bug me that I got different results and executed
>> the *same* commands.
>
> different results because different inputs.
I understand now. Thanks for the clarification.
It's rather ironic that, when done at the command line, a single character
can be converted without issue. When done in a loop, the results are
different. This is where, for me, the disconnect started. I did the
following and got the following results:
[jim@localhost jim]$ perl -e 'printf "%x\n", ord("A");'
41
[jim@localhost jim]$ perl -e 'printf "%x\n", ord("\c@");'
0
[jim@localhost jim]$
The "\c" is representative of the control character in Perl. As you can
see, the results are (AFAIK) what is expected (in ASCII, not EBIDIC).
When I tried this same concept in a loop, the results were as I posted
before. Different variations yielded various warnings and syntax errors.
It was rather frustrating.
I hope I didn't come off as being difficult and have shown why I was
saying what I was saying and showed, maybe, where my head was at during
this discussion.
Jim
------------------------------
Date: 9 Dec 2004 22:32:12 -0800
From: rparimi@gmail.com
Subject: Extracting encrypted in a table on DB2 with Perl
Message-Id: <1102660332.020045.102830@f14g2000cwb.googlegroups.com>
Hi,
A table on my DB2 database has encrypted data, and I wish to extract
it. I have written the DBI code to connect to the database, and read
all values from the column I want. However, I am not sure if the data
that the perl script retrieves from the database is the "correct"
encrypted data. I know that DB2 has its own format for storing
encrypted data, but do not know how to process this data (using a pack
or unpack?)
When I run a select on the table from a db2 prompt, a row in the table
looks like as:
1 x'D6B6D2EE0C57ADF2'
What transformation do I need to apply to the binary data stored in a
perl scalar variable to make sure that I am working with the right
encrypted data?
Thanks a lot..
------------------------------
Date: 10 Dec 2004 12:51:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Facile user-agent statistics tool
Message-Id: <cpc63q$k0g$2@mamenchi.zrz.TU-Berlin.DE>
Robert Manea <rob@nova.hbx.us> wrote in comp.lang.perl.misc:
> Segfault in module "Christopher Nehren" - dump details are as follows:
>
> > On 2004-12-09, Robert Manea scribbled these
> > curious markings:
>
> > [...]
>
> >> 4. Mozilla Thunderbird : 33
>
> > [...]
>
> >> 12. trn : 6
Ah, so I'm not the only trn user here...
> > [...]
>
> >> 22. trn : 1
...or am I?
> >> 27. Thunderbird : 1
> >> 28. Sylpheed version : 1
>
> > [...]
>
> >> 30. Sylpheed-Claws : 1
>
> > I hope that you like dealing with inconsistencies. :)
>
> Well, since the 'User-Agent' header's format conforms to absolutly no
> standard or RFC one must be compromising.
>
> I understand, that that piece of information is most important in my
> programm but really can't come up with anything significantly better.
>
> Maybe you have a better RegEx or method to extract it? (see TODO)
>
> ( Some kind of comparision function which detects common words in
> different strings would be a solution, but still not the right
> one.
>
> E.g.: 'Mozilla Thunderbird' and 'Thunderbird' should be the same
> but 'Mozilla' and 'Mozilla Thunderbird' must not.
>
> How could one solve this without hardcoding the names? )
Use a (set of) rule(s) that gets most cases right and hold exceptions
in a config file. That ought to be maintainable -- if you really need
that kind of precision.
Anno
------------------------------
Date: 10 Dec 2004 06:32:28 -0800
From: frisina@gmail.com
Subject: File::Copy woes
Message-Id: <1102689148.739334.49880@f14g2000cwb.googlegroups.com>
Hi all:
I am writing some code in which I want to copy a file to a directory
periodically, and replace the existing file of the same name when it
does indeed exist. Is there any way to do this with File::Copy? It
seems to not replace if the file exists.
Help?
Thank you,
Francis
------------------------------
Date: Fri, 10 Dec 2004 14:42:38 GMT
From: "James Tolley" <james@emarch.net>
Subject: Re: File::Copy woes
Message-Id: <yBiud.2931$sU4.2165@trndny01>
> I am writing some code in which I want to copy a file to a directory
> periodically, and replace the existing file of the same name when it
> does indeed exist. Is there any way to do this with File::Copy? It
> seems to not replace if the file exists.
It replaces the file for me on XP, perl 5.8.3, File::Copy 2.07
------------------------------
Date: Fri, 10 Dec 2004 14:44:28 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: File::Copy woes
Message-Id: <gDiud.2935$sU4.706@trndny01>
<frisina@gmail.com> wrote in message
news:1102689148.739334.49880@f14g2000cwb.googlegroups.com...
> I am writing some code in which I want to copy a file to a directory
> periodically, and replace the existing file of the same name when it
> does indeed exist. Is there any way to do this with File::Copy? It
> seems to not replace if the file exists.
Your diagnosis is incorrect. File::Copy has no more trouble overwriting
an existing file than the cp system command. What is the error message
you are receiving? You *are* checking for the error message, aren't
you?
use File::Copy;
copy ('file.txt', 'otherdir/file.txt') or die "Cannot copy: $!";
As a hunch, I'd bet you don't have the needed permissions on the target
to overwrite the file.
Paul Lalli
------------------------------
Date: Fri, 10 Dec 2004 12:31:11 GMT
From: "Leon" <eon@hotmail.com>
Subject: Re: Insert JavaScript into Perl
Message-Id: <jGgud.588$lF1.104@newsfe2-win.ntli.net>
<alex.osinski@gmail.com> wrote in message
news:1102634212.258503.79110@c13g2000cwb.googlegroups.com...
> I have a site running off Perl. I know nothing of Perl and have been
> told to insert our standard intranet header and footer. (ack!) Our
> header and footer are included into our pages via:
>
> <script language="javascript"
> src="/GlobalInsideITNew/JS/InsideITGlobalHeader.js"></script>
>
> &
>
> <script language="javascript"
> src="/GlobalInsideITNew/JS/InsideITGlobalFooter.js"></script>
>
> When I try to insert this code into the Perl run site, it never shows
> up. This is the syntax I'm using for the header:
>
> print FILE"<SCRIPT language=\"JavaScript\"
> src=\"/GlobalInsideITNew/JS/InsideITGlobalHeader.js\"> \n";
> print FILE"</SCRIPT> \n";
>
> Help! What am I doing wrong?
>
Been mentioned already, but I'd always go for the trouble free option...
print <<EndOfHTML;
<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalHeader.js"></script>
EndOfHTML
print <<EndOfHTML;
<script language="javascript"
src="/GlobalInsideITNew/JS/InsideITGlobalFooter.js"></script>
EndOfHTML
Always ensure that there are absolutely no spaces following the closing
EndOfHTML line.
------------------------------
Date: Fri, 10 Dec 2004 09:15:05 -0500
From: "Chip" <ccarpenter@erols.com>
Subject: Loop Logic Question
Message-Id: <WqednYHNkv8UMiTcRVn-tw@adelphia.com>
Hi and thanks for reading this post.
I have a text file that I need to convert
from a vertical list to a horizontal comma
delimited file that will always have the
same number (12) items in it.
The first item in each line is a serial
number that is always 17 characters followed
by a model number, stock number, sale price,
cost, color, then a list of options which
can vary between 1 to 6.
I can split the vertical file on the "\n"
but will need a loop to add blank fields
to the end of the line if the options
do not total 6 so that the line always
has total of 12 fields even if there are
not a total of 6 options.
$filename = "vertical.txt";
open(FILE, "$filename") || die "Could not open $filename";
@array = <FILE>;
foreach $line (@array)
{
if ( $line =~ /[^\S{17}]/) #serial number
{
#code to make formatted file
}
}
Thanks for your time and any and all help
is appreciated.
Chip
Example files;
<vertical.txt>
2G1WF52E849457786
1WF19
9457786
24600.00
22988.78
White/Lt Gray/cloth
B34 FLOOR MATS
FE9 FEDERAL EMISSION EQUIPMENT
K34 ELECTRONIC SPEED CONTROL
2G1WF52EX49457241
1WF19
9457241
22725.00
21282.53
White/Light Gray Clth
B34 FLOOR MATS
FE9 FEDERAL EMISSION EQUIPMENT
K34 ELECTRONIC SPEED CONTROL
LA1 3.4 V6 ENGINE
MX0 4 SPEED AUTO W/OVERDRIVE
2G1WP551449281308
1WP19
9281308
32835.00
30542.19
Black/Lt Gray Leather
AW6 DRIVERS SIDE AIRBAG
CF5 ELECTRIC SUNROOF
FE9 FEDERAL EMISSION EQUIPMENT
L67 SUPERCHARGED 3.8L SFI V6
MX0 4 SPEED AUTO W/OVERDRIVE
UP0 AM/FM CASS/CD PLAYER
</vertical.txt>
<formatted file>
2G1WF52E849457786,1WF19,9457786,24600.00,22988.78,White/Lt Gray/cloth,B34
FLOOR MATS,FE9 FEDERAL EMISSION EQUIPMENT,K34 ELECTRONIC SPEED CONTROL,,,,
2G1WF52EX49457241,1WF19,9457241,22725.00,21282.53,White/Light Gray Clth,B34
FLOOR MATS,FE9 FEDERAL EMISSION EQUIPMENT,K34 ELECTRONIC SPEED CONTROL,LA1
3.4 V6 ENGINE,MX0 4 SPEED AUTO W/OVERDRIVE,,
2G1WP551449281308,1WP19,9281308,32835.00,30542.19,Black/Lt Gray Leather,AW6
DRIVERS SIDE AIRBAG,CF5 ELECTRIC SUNROOF,FE9 FEDERAL EMISSION EQUIPMENT,L67
SUPERCHARGED 3.8L SFI V6,MX0 4 SPEED AUTO W/OVERDRIVE,UP0 AM/FM CASS/CD
PLAYER,
</formatted file>
------------------------------
Date: Fri, 10 Dec 2004 09:57:50 -0500
From: "Richard Zilavec" <rzilavec@tcn.net>
Subject: Re: Loop Logic Question
Message-Id: <cpcdfc$nid$1@utornnr1pp.grouptelecom.net>
"Chip" <ccarpenter@erols.com> wrote in message
news:WqednYHNkv8UMiTcRVn-tw@adelphia.com...
> I can split the vertical file on the "\n"
> but will need a loop to add blank fields
> to the end of the line if the options
> do not total 6 so that the line always
> has total of 12 fields even if there are
> not a total of 6 options.
>
> $filename = "vertical.txt";
> open(FILE, "$filename") || die "Could not open $filename";
> @array = <FILE>;
> foreach $line (@array)
> {
> if ( $line =~ /[^\S{17}]/) #serial number
> {
> #code to make formatted file
> }
> }
>
> Thanks for your time and any and all help
> is appreciated.
>
> Chip
Try using map with the join statement.
for(0 .. 11) {
$array[$_] = $_;
$array[$_] =~ s/^(.*)$/'$1'/;
}
$string = join(',', map { $array[$_] }(0 .. 11));
This produces which may be useful.
'0','1','2','3','4','5','6','7','8','9','10','11'
Richard Zilavec
------------------------------
Date: Fri, 10 Dec 2004 16:21:05 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Loop Logic Question
Message-Id: <x7d5xi5dlb.fsf@mail.sysarch.com>
>>>>> "RZ" == Richard Zilavec <rzilavec@tcn.net> writes:
>> I can split the vertical file on the "\n"
>> but will need a loop to add blank fields
>> to the end of the line if the options
>> do not total 6 so that the line always
>> has total of 12 fields even if there are
>> not a total of 6 options.
RZ> Try using map with the join statement.
RZ> for(0 .. 11) {
RZ> $array[$_] = $_;
and how does that help pad the array to 12 elements?
RZ> $array[$_] =~ s/^(.*)$/'$1'/;
since you just assigned each element, you could have just assigned
"'$_'" instead.
RZ> }
RZ> $string = join(',', map { $array[$_] }(0 .. 11));
huh??? why the map/array thing? that is just the same as @array!!
RZ> This produces which may be useful.
RZ> '0','1','2','3','4','5','6','7','8','9','10','11'
doesn't look too useful to me. the OP wanted more than that.
and where is the critical logic that loops over the items and options
and converts each set to a single line?
what the OP needs is a double nested loop or similar to track when he
sees an item number. push the following lines into an array until the
next item number (and keep track of that). then pad the array with empty
elements using push( @array, () x (12 - @array) ) to get 12
elements. then do some postprocessing with map and join. i leave the
coding as an exercise.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 10 Dec 2004 10:04:59 +0100
From: Sandman <mr@sandman.net>
Subject: Re: Matching words and letters
Message-Id: <mr-0216E1.10045910122004@individual.net>
In article <Xns95B9F00E0493asu1cornelledu@132.236.56.8>,
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote:
> pile should be in that list as well.
Yes, sorry. :)
> Now, undoubtedly, there is a better way to do this, but here is something
> that works for the data you posted:
Yes, and I've adapted it for my uses - it works great!
##########################
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
exit unless $ARGV[0];
$|=1; # Dont buffer output
my %words;
open(FILE, "</home/sandman/conf/rim.db"); # file with legal words
while (<FILE>)
{
chomp;
my @list=split (/\t/);
foreach (@list){
# no need to include too long words.
next if length($_) > (length($ARGV[0])+1);
# And we don't care for too short words
next if length($_) < 3;
$words{lc($_)}++;
}
}
my $source = normalize($ARGV[0]);
my $prnr;
my $word;
LINE: foreach $word (keys %words){
chomp $word;
my $target = normalize($word);
for my $c (keys %{ $target }) {
next LINE unless(
defined($source->{$c}) && ($source->{$c} >= $target->{$c})
);
}
my @input = split //, $ARGV[0];
my @match = split //, $word;
if ($ARGV[1]){
foreach (split /,/, $ARGV[1]){
# for every fixed position
next LINE unless $input[($_-1)] eq $match[$_-1];
}
}
printf "%-12s ", $word;
$prnr++;
print "\n" if ($prnr % 6) == 0;
}
print "\n";
sub normalize {
my ($string) = @_;
my @letters = split //, $string;
my %count;
$count{$_}++ for (@letters);
return \%count;
}
##########################
sandman~> alfapet kamrslsi 1,2
kali kams kari karl karm kass
kal kam kar kas
##########################
These are swedish words, so it's quite correct.
Thank you!
--
Sandman[.net]
------------------------------
Date: Fri, 10 Dec 2004 16:25:59 +0800
From: sam <sam.wun@authtec.net>
Subject: multiple webpages sharing a dataset reference
Message-Id: <cpbo3v$6qt$1@news.hgc.com.hk>
Hi,
I m wondering how to fetch a dataset and hold it in the memory for used
by other webpages. Having everything written in one single page is much
easier, but it will look groove and not user friendly.
I will use MySQL as database.
For example, if I fetch records from the database with the following
perl codes:
$dataset->prepare(
q{SELECT name, ipaddr FROM hosts
WHERE (name = ? AND bldg = ? AND dept = ?)});
$dataset->execute($name,$bldg,$dept);
I would like the value of $dataset can be read from another webpage (a
result webpage). Assumed the perl code above is being executed by
pressing the Query button in a Query webpage.
Therefore the procedure may be:
Query webpage -> $dataset -> Result webpage
Thanks
Sam
------------------------------
Date: 10 Dec 2004 17:58:07 GMT
From: xhoster@gmail.com
Subject: Re: multiple webpages sharing a dataset reference
Message-Id: <20041210125807.117$Ag@newsreader.com>
sam <sam.wun@authtec.net> wrote:
> Hi,
>
> I m wondering how to fetch a dataset and hold it in the memory for used
> by other webpages.
Webpages traditionally do not use datasets. They use html. Are you
confusing the web page with the CGI program that generates that page?
> Having everything written in one single page is much
> easier, but it will look groove
What does it mean to "look groove"?
> and not user friendly.
You mean it is more user friendly to make someone click through hoops
to get the information they want then to just give it to them directly?
Please explain further.
> I will use MySQL as database.
>
> For example, if I fetch records from the database with the following
> perl codes:
> $dataset->prepare(
> q{SELECT name, ipaddr FROM hosts
> WHERE (name = ? AND bldg = ? AND dept = ?)});
> $dataset->execute($name,$bldg,$dept);
No fetch!
> I would like the value of $dataset can be read from another webpage
Webpages do not read values. Besides, the value of $dataset is something
like DBI::st=HASH(0x82349cc).
> (a
> result webpage). Assumed the perl code above is being executed by
> pressing the Query button in a Query webpage.
> Therefore the procedure may be:
>
> Query webpage -> $dataset -> Result webpage
The Query webpage has a form that submits to some_script.cgi.
some_script.cgi parses the form data submitted by the Query webpage,
gets a dataset from the database, and uses the dataset to
generate a Result webpage.
This is the way it generally works, no? So what is the problem?
Do you want the results to also be available is some page other than
the primary result page generated by the CGI? Well, how the is person
supposed to get to that other page? How you transport information to this
new page will depend on how you transport the user to this new page.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Fri, 10 Dec 2004 22:29:22 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: multiple webpages sharing a dataset reference
Message-Id: <31tj55F3f1gd7U1@individual.net>
sam wrote:
> Hi,
>
> I m wondering how to fetch a dataset and hold it in the memory for used
> by other webpages. Having everything written in one single page is much
> easier, but it will look groove and not user friendly.
> I will use MySQL as database.
>
> For example, if I fetch records from the database with the following
> perl codes:
> $dataset->prepare(
> q{SELECT name, ipaddr FROM hosts
> WHERE (name = ? AND bldg = ? AND dept = ?)});
> $dataset->execute($name,$bldg,$dept);
>
> I would like the value of $dataset can be read from another webpage (a
> result webpage). Assumed the perl code above is being executed by
> pressing the Query button in a Query webpage.
> Therefore the procedure may be:
>
> Query webpage -> $dataset -> Result webpage
>
>
> Thanks
> Sam
You could try http://en.wikipedia.org/wiki/Memcached
gtoomey
------------------------------
Date: Fri, 10 Dec 2004 23:49:09 +0800
From: sam <sam.wun@authtec.com>
Subject: Re: multiple webpages sharing a dataset reference
Message-Id: <cpci2o$kok$2@news.hgc.com.hk>
Gregory Toomey wrote:
> sam wrote:
>
>
>>Hi,
>>
>>I m wondering how to fetch a dataset and hold it in the memory for used
>>by other webpages. Having everything written in one single page is much
>>easier, but it will look groove and not user friendly.
>>I will use MySQL as database.
>>
>>For example, if I fetch records from the database with the following
>>perl codes:
>>$dataset->prepare(
>> q{SELECT name, ipaddr FROM hosts
>> WHERE (name = ? AND bldg = ? AND dept = ?)});
>>$dataset->execute($name,$bldg,$dept);
>>
>>I would like the value of $dataset can be read from another webpage (a
>>result webpage). Assumed the perl code above is being executed by
>>pressing the Query button in a Query webpage.
>>Therefore the procedure may be:
>>
>>Query webpage -> $dataset -> Result webpage
>>
>>
>>Thanks
>>Sam
>
>
> You could try http://en.wikipedia.org/wiki/Memcached
>
It can't be done in perl without invoke third-party intensive cache
implementation?
Thanks
Sam
> gtoomey
------------------------------
Date: Sat, 11 Dec 2004 00:18:18 +0800
From: sam <sam.wun@authtec.com>
Subject: Re: multiple webpages sharing a dataset reference
Message-Id: <cpcjpi$llt$1@news.hgc.com.hk>
Gregory Toomey wrote:
> sam wrote:
>
>
>>Hi,
>>
>>I m wondering how to fetch a dataset and hold it in the memory for used
>>by other webpages. Having everything written in one single page is much
>>easier, but it will look groove and not user friendly.
>>I will use MySQL as database.
>>
>>For example, if I fetch records from the database with the following
>>perl codes:
>>$dataset->prepare(
>> q{SELECT name, ipaddr FROM hosts
>> WHERE (name = ? AND bldg = ? AND dept = ?)});
>>$dataset->execute($name,$bldg,$dept);
>>
>>I would like the value of $dataset can be read from another webpage (a
>>result webpage). Assumed the perl code above is being executed by
>>pressing the Query button in a Query webpage.
>>Therefore the procedure may be:
>>
>>Query webpage -> $dataset -> Result webpage
>>
>>
>>Thanks
>>Sam
>
>
> You could try http://en.wikipedia.org/wiki/Memcached
>
I just installed the C/perl versions of the Memcached in the system.
Here I have a general question about perl. How can I write two perl
files that access a variable that reference the Memcached?
Thanks
Sam.
> gtoomey
------------------------------
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 7504
***************************************