[25478] in Perl-Users-Digest
Perl-Users Digest, Issue: 7723 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 1 21:05:37 2005
Date: Tue, 1 Feb 2005 18:05:16 -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 Tue, 1 Feb 2005 Volume: 10 Number: 7723
Today's topics:
Re: [OT] Perl Code which draws camel <stevenv@operamail.com>
Re: [OT] What does it mean? (WAS: Problem serving a PDF <shawn.corey@sympatico.ca>
Re: [OT] What does it mean? (WAS: Problem serving a PDF (Anno Siegel)
Re: [OT] What does it mean? (WAS: Problem serving a PDF <flavell@ph.gla.ac.uk>
[perl-python] string pattern matching <xah@xahlee.org>
Re: Boolean ? <jl_post@hotmail.com>
Calendar output in HTML - PlotCalendar::Month? peterkayatwork@yahoo.com
Re: Calendar output in HTML - PlotCalendar::Month? <NoSPAM@cox.net>
Re: Calendar output in HTML - PlotCalendar::Month? chris-usenet@roaima.co.uk
Calling a COM object from Perl <hannington@gmail.com>
Calling a COM object from Perl <hannington@gmail.com>
Re: cgi and cgi-bin <antbyte.The.Flow@gmail.com>
Re: cgi and cgi-bin <sholden@flexal.cs.usyd.edu.au>
converting vertical text to horizontal text <magreen@atintel.com>
Re: converting vertical text to horizontal text <abigail@abigail.nl>
Re: converting vertical text to horizontal text <1usa@llenroc.ude.invalid>
Re: converting vertical text to horizontal text <magreen@atintel.com>
Re: converting vertical text to horizontal text <1usa@llenroc.ude.invalid>
Re: converting vertical text to horizontal text (Anno Siegel)
Re: converting vertical text to horizontal text <matternc@comcast.net>
Re: converting vertical text to horizontal text <magreen@atintel.com>
Re: converting vertical text to horizontal text <flavell@ph.gla.ac.uk>
Re: converting vertical text to horizontal text <abigail@abigail.nl>
Re: converting vertical text to horizontal text <larry_wallet@yahoo.com>
Generating a Hash Problem <stephanie.kroeplin@office.xerox.com>
Re: Generating a Hash Problem <noreply@gunnar.cc>
Re: Generating a Hash Problem (Anno Siegel)
Re: Generating a Hash Problem ioneabu@yahoo.com
Re: Generating a Hash Problem ioneabu@yahoo.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 01 Feb 2005 16:38:15 -0500
From: Steven Vasilogianis <stevenv@operamail.com>
Subject: Re: [OT] Perl Code which draws camel
Message-Id: <86lla8ufjs.fsf@thrym.kmrrec.org>
Bernhard Walle <bernhard.walle@gmx.de> writes:
> somewhere I've seen Perl code which is very small (i. e. can be put in a
> signature of a mail) which draws a camel on the screen. Does anybody
> have the source?
I know of this one, but it's not small enough to fit in a sig, unless
you want to be annoying.
http://www.perlmonks.org/index.pl?node_id=45213
http://www.thinkgeek.com/tshirts/coder/321a/ (mentioned by another poster)
------------------------------
Date: Tue, 01 Feb 2005 14:45:04 -0500
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: [OT] What does it mean? (WAS: Problem serving a PDF)
Message-Id: <N_QLd.1142$lw4.435390@news20.bellglobal.com>
Anno Siegel wrote:
> In German, we have an expression for what you're doing: "Du lügst dir in
> die eigene Tasche".
>
> Anno
OK, what does it mean? I ran it thru Google's translation tool and got,
"You lie yourself into the own bag." Something is lost in the translation.
--- Shawn
------------------------------
Date: 1 Feb 2005 22:45:50 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: [OT] What does it mean? (WAS: Problem serving a PDF)
Message-Id: <ctp0qu$4qs$1@mamenchi.zrz.TU-Berlin.DE>
Shawn Corey <shawn.corey@sympatico.ca> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > In German, we have an expression for what you're doing: "Du lügst dir in
> > die eigene Tasche".
> >
> > Anno
>
> OK, what does it mean? I ran it thru Google's translation tool and got,
> "You lie yourself into the own bag." Something is lost in the translation.
It's about as good as mechanical translation can get. "You are lying into
your own purse" would come closer. As popular sayings do, it doesn't quite
conform to regular grammar -- you can't lie "into" something, not even in
German. The idea is for someone to exaggerate the amount of cash they own,
but again typical for popular sayings, the literal meaning doesn't quite
cover the range of situations it would be used in. It is said when someone
is grasping for aspects that make their situation seem more favorable than
it really is. "I'm sure the red light hasn't been on for long. We'll
make it!" -- "Du lügst dir doch in die eigene Tasche".
Anno
------------------------------
Date: Tue, 1 Feb 2005 22:56:22 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: [OT] What does it mean? (WAS: Problem serving a PDF)
Message-Id: <Pine.LNX.4.61.0502012253000.5279@ppepc56.ph.gla.ac.uk>
On Tue, 1 Feb 2005, Anno Siegel wrote:
| Shawn Corey of unsympatico.ca wrote:
> > OK, what does it mean?
ist ja idiomatisch...
> > I ran it thru Google's translation tool and got, "You lie yourself
> > into the own bag." Something is lost in the translation.
>
> It's about as good as mechanical translation can get.
"You're only fooling yourself" would, I think, be as near as we need
in this context.
------------------------------
Date: 1 Feb 2005 12:45:07 -0800
From: "Xah Lee" <xah@xahlee.org>
Subject: [perl-python] string pattern matching
Message-Id: <1107290707.549792.199860@c13g2000cwb.googlegroups.com>
# -*- coding: utf-8 -*-
# Python
# Matching string patterns
#
# Sometimes you want to know if a string is of
# particular pattern. Let's say in your website
# you have converted all images files from gif
# format to png format. Now you need to change the
# html code to use the .png files. So, essentially
# you want to replace strings of the form
#
# img src=3D"*.gif"
# to
# img src=3D"*.png"
#
# Python provides string pattern matching by the
# "re" module. (String Pattern Matching is
# inanely known as Regular Expression (regex) in
# the computing industry. It is a misnomer and
# causes great unnecessary confusion.)
=A9import re
=A9
=A9text=3D'''<img src=3D"../Icons_dir/icon_sum.gif" width=3D"32"
height=3D"32">'''
=A9
=A9pattern =3D r'''src=3D"([^"]+)\.gif"'''
=A9
=A9result =3D re.search(pattern, text)
=A9
=A9if result:
=A9 print 'yes'
=A9 print result.expand(r"\1") # the captured pattern
=A9else:
=A9 print 'no'
#-------------
# if re.search(pattern, text) does not match, then the result is
None. If it matches, an object is returned. One can then use methods
such as .groups(), .expand(), .split() ... to find the matched parts,
or a given replacement string, or split the text into multiple part
by the regex...
# regex is quite confusing for beginners, but
# isn't really difficult to understand. It comes
# with practice.
# see
# http://python.org/doc/lib/module-re.html
# for detail.
# i'll have to study more to make complet example. Try it yourself.
-----------------
# in perl, regex is its mainstay.
# very expressive with syntax, but not so in semantic,
# when compared to Python.
# for syntax variability, for example the following are all the same.
$text =3D "what ever is here to be matched";
if ( $text =3D~ ever) { print 'yes'} else {print "no"}
if ( $text =3D~ /ever/) { print 'yes'} else {print "no";}
if ( $text =3D~ m/ever/) { print 'yes'} else {print "no"}
if ( $text =3D~ m(ever)) { print 'yes'} else {print "no"}
if ( $text =3D~ m@ever@) { print 'yes'} else {print "no"}
# for detail of its much ado about nothing nature,
# see perldoc perlre
--------
this is perl-python a-day mailing list. To subscribe, see
http://xahlee.org/perl-python/python.html
Xah
xah@xahlee.org
http://xahlee.org/PageTwo_dir/more.html
------------------------------
Date: 1 Feb 2005 12:11:47 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: Boolean ?
Message-Id: <1107288707.161880.169920@z14g2000cwz.googlegroups.com>
A. Sinan Unur wrote:
>
> You can do this:
>
> my $isbeforenow = 0 + ($testtime > time);
>
> if you really want to force the result to be numeric.
Another alternative suggestion is this:
my $isbeforenow = ($testtime > time) || 0;
(This way it's guaranteed to be zero if it turns out
to be false.)
-- Jean-Luc
------------------------------
Date: 1 Feb 2005 11:53:47 -0800
From: peterkayatwork@yahoo.com
Subject: Calendar output in HTML - PlotCalendar::Month?
Message-Id: <1107287627.399973.18190@f14g2000cwb.googlegroups.com>
I was looking for a way to create HTML calendar months in some form,
and came across PlotCalendar::Month in CPAN. Looking at the POD, I see
the following line:
"This is a pure perl replacement for Date::Calc"
Is this correct? If so, where on earth in Date::Calc can one do these
sorts of things??
Is this the best way to handle data-hashes -> html calendar output? I
want to be able to print out months with several lines of events in
each month. (Maybe do a Palm -> html utility?). Thoughts/comments
welcome!
Thanks
--Peter
------------------------------
Date: Tue, 01 Feb 2005 13:05:48 -0800
From: Dylan <NoSPAM@cox.net>
Subject: Re: Calendar output in HTML - PlotCalendar::Month?
Message-Id: <76SLd.25449$B95.5837@lakeread02>
peterkayatwork@yahoo.com wrote:
> I was looking for a way to create HTML calendar months in some form,
> and came across PlotCalendar::Month in CPAN.
I have been meaging to look for somthing like this also, thanks ;-)
> Looking at the POD, I see
> the following line:
>
> "This is a pure perl replacement for Date::Calc"
>
> Is this correct? If so, where on earth in Date::Calc can one do these
> sorts of things??
In the readme the line reads :
DateTools.pm is a pure perl replacement for parts of Date::Calc
so you can use DateTools.pm to do the same thing Date::Calc without
installing Date::Calc.
Dylan
------------------------------
Date: Tue, 1 Feb 2005 21:02:45 +0000
From: chris-usenet@roaima.co.uk
Subject: Re: Calendar output in HTML - PlotCalendar::Month?
Message-Id: <lc75d2-5em.ln1@moldev.cmagroup.co.uk>
peterkayatwork@yahoo.com wrote:
> I was looking for a way to create HTML calendar months in some form,
> and came across PlotCalendar::Month in CPAN. Looking at the POD, I see
> the following line:
> "This is a pure perl replacement for Date::Calc"
...immediately below the dependency warning for PlotCalendar::DateTools :-)
Chris
------------------------------
Date: 1 Feb 2005 11:37:35 -0800
From: "hannington@gmail.com" <hannington@gmail.com>
Subject: Calling a COM object from Perl
Message-Id: <1107286655.776097.208730@c13g2000cwb.googlegroups.com>
We have a commercial product developed in VB 6 and they have dll's that
I would like to access from Perl. I have tried the perl extended route
with success. I do not have access to the source code. Here is a sample
code:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <stdio.h>
int Login( char *, char *);
MODULE = Mtest PACKAGE = Mtest
char *
ffcbtest()
CODE:
HINSTANCE hLib=LoadLibrary("mydll.dll");
printf ("Attempted to Load Library \n");
if(hLib==NULL) {
printf("Unable to load library!\n");
getch();
return;
}
Login( "usr", "passwd" );
getch();
OUTPUT:
RETVAL
------------------------------
Date: 1 Feb 2005 11:43:18 -0800
From: "Topman" <hannington@gmail.com>
Subject: Calling a COM object from Perl
Message-Id: <1107286998.444275.232390@c13g2000cwb.googlegroups.com>
We have a commercial product developed in VB 6 and they have=AD dll's
that I would like to access from Perl. I have tried the perl exte=ADnded
route without success. I do not have access to the source code. Here
=ADis a sample
code:
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <stdio.h>
int Login( char *, char *);
MODULE =3D Mtest PACKAGE =3D Mtest
char *
ffcbtest()
CODE:
HINSTANCE hLib=3DLoadLibrary("mydll.dll");
printf ("Attempted to Load Library \n");
if(hLib=3D=3DNULL) {
printf("Unable to load library!\n");
getch();
return;
}=20
Login( "usr", "passwd" );=20
getch();=20
OUTPUT:=20
RETVAL
------------------------------
Date: 1 Feb 2005 13:52:53 -0800
From: "The Flow" <antbyte.The.Flow@gmail.com>
Subject: Re: cgi and cgi-bin
Message-Id: <1107294773.709265.129760@l41g2000cwc.googlegroups.com>
Do not use a symlink. Instead, it is advisable that you actually go
through the conf file (sometimes the "default" of
/etc/apache2/sites-enabled) and change the cgi bin to whatever you want
it to be.
------------------------------
Date: 2 Feb 2005 01:46:19 GMT
From: Sam Holden <sholden@flexal.cs.usyd.edu.au>
Subject: Re: cgi and cgi-bin
Message-Id: <slrnd00c7b.sup.sholden@flexal.cs.usyd.edu.au>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Gregory Toomey <nospam@bigpond.com> wrote in comp.lang.perl.misc:
>> zippy wrote:
>
>> Make a symbolic link from cgi-bin to scgi-bin, or move cgi-bin to scgi-bin.
>> Any system admin with 1/4 of a brain could work this out.
>
> Patching a configuration error with a symlink is *not* what good
> sysadmins do.
But good sysadmins have more than 1/4 of a brain.
--
Sam Holden
------------------------------
Date: Tue, 01 Feb 2005 14:16:24 -0700
From: Mike Green <magreen@atintel.com>
Subject: converting vertical text to horizontal text
Message-Id: <ctorj9$tck$1@news01.intel.com>
I have file that contains text formated like horizontal
H
e
B l
i p P
g e
r
m l
P y
a
i b i
n r s
a
i i t
n n h
e
t i
h s a
e n
m s
r e w
e l e
a t r
r i
! n
g
Does anyone have a good way to convert this to horizontal text like such
below? Thanks.
Big Pain in the rear!
Help my brain is melting
Perl is the answer
I've search CPAN and found some Text modules to rotate the text, but I'm
stuck trying to figure out how to read this text in. I'm thinking using
unconstrainted 2D array. Thank you.
--
I am not an Intel spokesperson.
------------------------------
Date: 01 Feb 2005 21:51:36 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: converting vertical text to horizontal text
Message-Id: <slrncvvuf8.a9.abigail@alexandra.abigail.nl>
Mike Green (magreen@atintel.com) wrote on MMMMCLXXII September MCMXCIII
in <URL:news:ctorj9$tck$1@news01.intel.com>:
^^ I have file that contains text formated like horizontal
^^ H
^^ e
^^ B l
^^ i p P
^^ g e
^^ r
^^ m l
^^ P y
^^ a
^^ i b i
^^ n r s
^^ a
^^ i i t
^^ n n h
^^ e
^^
^^ t i
^^ h s a
^^ e n
^^ m s
^^ r e w
^^ e l e
^^ a t r
^^ r i
^^ ! n
^^ g
^^
^^ Does anyone have a good way to convert this to horizontal text like such
^^ below? Thanks.
^^
^^ Big Pain in the rear!
^^
^^ Help my brain is melting
^^
^^ Perl is the answer
It's not at all clear what you want. If I rotate the text, I get:
!
Big Pain in the rear
H m ng
e a s elti
l rmy br i s
p in a wer
Pe th n
So you have 7 columns, which need to be squashed into 3. And some columns
contain letters that go to different lines.
Abigail
--
my $qr = qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
$qr =~ s/$qr//g;
print $qr, "\n";
------------------------------
Date: Tue, 01 Feb 2005 22:04:50 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: converting vertical text to horizontal text
Message-Id: <Xns95F0ADCBADDC0asu1cornelledu@127.0.0.1>
Mike Green <magreen@atintel.com> wrote in news:ctorj9$tck$1
@news01.intel.com:
> I have file that contains text formated like horizontal
Where does the text come from?
Sinan.
------------------------------
Date: Tue, 01 Feb 2005 15:41:51 -0700
From: Mike Green <magreen@atintel.com>
Subject: Re: converting vertical text to horizontal text
Message-Id: <ctp0jf$vpo$1@news01.intel.com>
This works:
chomp(@lines = <FILEHANDLE>);
print join("", map { s/(.)//s ? $1 : " " } @lines), "\n" while length
+ join "", @lines;
I found the solution here: http://www.perlmonks.org/index.pl?node_id=46551
It takes what you see below:
I O
t h
w b
o o
r y
k
s t
h
f i
i s
n
a w
l a
l s
y
h
a
r
d
And prints this
It works finally
Oh boy this was hard
Mike Green wrote:
> I have file that contains text formated like horizontal
> H
> e
> B l
> i p P
> g e
> r
> m l
> P y
> a
> i b i
> n r s
> a
> i i t
> n n h
> e
>
> t i
> h s a
> e n
> m s
> r e w
> e l e
> a t r
> r i
> ! n
> g
>
> Does anyone have a good way to convert this to horizontal text like such
> below? Thanks.
>
> Big Pain in the rear!
>
> Help my brain is melting
>
> Perl is the answer
>
> I've search CPAN and found some Text modules to rotate the text, but I'm
> stuck trying to figure out how to read this text in. I'm thinking using
> unconstrainted 2D array. Thank you.
>
--
I am not an Intel spokesperson.
------------------------------
Date: Tue, 01 Feb 2005 23:06:25 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: converting vertical text to horizontal text
Message-Id: <Xns95F0B83C17C7Fasu1cornelledu@127.0.0.1>
Mike Green <magreen@atintel.com> wrote in
news:ctp0jf$vpo$1@news01.intel.com:
[ Please don't top-post ]
> This works:
>
> chomp(@lines = <FILEHANDLE>);
> print join("", map { s/(.)//s ? $1 : " " } @lines), "\n" while length
> + join "", @lines;
...
> I O
> t h
But you changed the data!!!
Are you just toying with people here?
Here is what I get when I run the code above on your original data:
D:\Home\asu1\UseNet\clpmisc> cat f.pl
use strict;
use warnings;
chomp(my @lines = <DATA>);
print join("", map { s/(.)//s ? $1 : " " } @lines), "\n" while length
+ join "", @lines;
__DATA__
H
e
B l
i p P
g e
r
m l
P y
a
i b i
n r s
a
i i t
n n h
e
t i
h s a
e n
m s
r e w
e l e
a t r
r i
! n
g
D:\Home\asu1\UseNet\clpmisc> f
Warning: Use of "length" without parentheses is ambiguous at
D:\Home\asu1\UseNet\clpmisc\f.pl line 6.
Big Pain in the rear!
H m g
e a s eltin
l rmy br i s
p in a wer
l is e
Pe th n
Sinan
------------------------------
Date: 1 Feb 2005 23:09:03 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: converting vertical text to horizontal text
Message-Id: <ctp26f$4qs$3@mamenchi.zrz.TU-Berlin.DE>
Mike Green <magreen@atintel.com> wrote in comp.lang.perl.misc:
> This works:
>
> chomp(@lines = <FILEHANDLE>);
> print join("", map { s/(.)//s ? $1 : " " } @lines), "\n" while length
> + join "", @lines;
>
> I found the solution here: http://www.perlmonks.org/index.pl?node_id=46551
>
>
> It takes what you see below:
[snip]
> And prints this
>
> It works finally
> Oh boy this was hard
No, it doesn't, and it breaks down entirely with the text you originally
posted. Do you have a point?
Anno
------------------------------
Date: Tue, 01 Feb 2005 18:57:53 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: converting vertical text to horizontal text
Message-Id: <KMydndtnKtIcip3fRVn-3g@comcast.com>
Mike Green wrote:
> This works:
>
> chomp(@lines = <FILEHANDLE>);
> print join("", map { s/(.)//s ? $1 : " " } @lines), "\n" while length
> + join "", @lines;
>
> I found the solution here: http://www.perlmonks.org/index.pl?node_id=46551
>
>
> It takes what you see below:
>
> I O
> t h
>
> w b
> o o
> r y
> k
> s t
> h
> f i
> i s
> n
> a w
> l a
> l s
> y
> h
> a
> r
> d
>
>
> And prints this
>
> It works finally
> Oh boy this was hard
>
>
And how does it know not to print
It works finally
h hard
Oh boy t is was
or
It workshfinallyhard
Oh boy t is was
?
YOU can do it, because you understand English and
can pull out the phrases that make sense. I think
writing a Perl script that does that is likely to
be a somewhat larger project than you really want
to tackle at the moment...
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Tue, 01 Feb 2005 17:13:29 -0700
From: Mike Green <magreen@atintel.com>
Subject: Re: converting vertical text to horizontal text
Message-Id: <ctp5v9$2sb$1@news01.intel.com>
Sorry. The editor I'm using to enter this news message must be screwy.
Assume the two columns of text line up perfectly, then try the snipet of
code below.
Mike Green wrote:
> This works:
>
> chomp(@lines = <FILEHANDLE>);
> print join("", map { s/(.)//s ? $1 : " " } @lines), "\n" while length
> + join "", @lines;
>
> I found the solution here: http://www.perlmonks.org/index.pl?node_id=46551
>
>
> It takes what you see below:
>
> I O
> t h
>
> w b
> o o
> r y
> k
> s t
> h
> f i
> i s
> n
> a w
> l a
> l s
> y
> h
> a
> r
> d
>
>
> And prints this
>
> It works finally
> Oh boy this was hard
>
>
> Mike Green wrote:
>
>> I have file that contains text formated like horizontal
>> H
>> e
>> B l
>> i p P
>> g e
>> r
>> m l
>> P y
>> a
>> i b i
>> n r s
>> a
>> i i t
>> n n h
>> e
>>
>> t i
>> h s a
>> e n
>> m s
>> r e w
>> e l e
>> a t r
>> r i
>> ! n
>> g
>>
>> Does anyone have a good way to convert this to horizontal text like such
>> below? Thanks.
>>
>> Big Pain in the rear!
>>
>> Help my brain is melting
>>
>> Perl is the answer
>>
>> I've search CPAN and found some Text modules to rotate the text, but I'm
>> stuck trying to figure out how to read this text in. I'm thinking using
>> unconstrainted 2D array. Thank you.
>>
>
--
I am not an Intel spokesperson.
------------------------------
Date: Wed, 2 Feb 2005 00:41:47 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: converting vertical text to horizontal text
Message-Id: <Pine.LNX.4.61.0502020039380.5374@ppepc56.ph.gla.ac.uk>
On Tue, 1 Feb 2005, Mike Green wrote:
> Sorry. The editor I'm using to enter this news message must be screwy.
Wake us up again when you've done the news.newusers.questions thing,
and have got yourself into a position to post something coherent.
bye
------------------------------
Date: 02 Feb 2005 01:02:19 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: converting vertical text to horizontal text
Message-Id: <slrnd009kq.a9.abigail@alexandra.abigail.nl>
Mike Green (magreen@atintel.com) wrote on MMMMCLXXIII September MCMXCIII
in <URL:news:ctp5v9$2sb$1@news01.intel.com>:
.. Sorry. The editor I'm using to enter this news message must be screwy.
Then get a better editor. Preferably one that doesn't toppost either.
Until then, goodbye.
*PLONK*
Abigail
--
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
------------------------------
Date: 1 Feb 2005 17:31:22 -0800
From: "Larry" <larry_wallet@yahoo.com>
Subject: Re: converting vertical text to horizontal text
Message-Id: <1107307882.840958.270670@l41g2000cwc.googlegroups.com>
I tried writing a script that would collect all of the letters together
and feed them into a web based anagram solver. Maybe the anagram site
I chose was no good, but it couldn't solve it. You might need a
customized anagram solver that can make intelligent choices based on
the partial order of the text.
------------------------------
Date: Wed, 02 Feb 2005 01:09:20 GMT
From: "Stephanie Kroeplin" <stephanie.kroeplin@office.xerox.com>
Subject: Generating a Hash Problem
Message-Id: <4LVLd.3$496.227@news-west.eli.net>
All,
I have an array of strings lets say @records. The strings are records that
are comma-separated (i am shortening them to save typing though). IE:
$records[0] = '77856, LP3-13,stephk,1234'
$records[1] = '77857,LP3-13,stephk,1235'
...and so on
I also have an array of strings (@field_names) =
[record_id,printer_name,user_name,print_count]. These correspond to each
comma-seperated string in @records.
I would like to step thru each element in @records, using split turn each
comma-separated string into an array, an generate a hash that is like this:
%HASH {
record0 =>{ record_id=>77856
printer_name=>'LP3-13'
user_name=>'stephk'
print_count=>1234
}
record1 =>{ record_id=>77857
printer_name=>'LP3-13'
user_name=>'stephk'
print_count=>1235
}
}
What is the best way to get this done? I have a lot of records.
Any help would be awesome! Thanks,
stephanie
------------------------------
Date: Wed, 02 Feb 2005 02:16:48 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Generating a Hash Problem
Message-Id: <36ao9fF4v8qphU1@individual.net>
Stephanie Kroeplin wrote:
> I have an array of strings lets say @records. The strings are records that
> are comma-separated (i am shortening them to save typing though). IE:
> $records[0] = '77856, LP3-13,stephk,1234'
> $records[1] = '77857,LP3-13,stephk,1235'
> ...and so on
>
> I also have an array of strings (@field_names) =
> [record_id,printer_name,user_name,print_count]. These correspond to each
> comma-seperated string in @records.
>
> I would like to step thru each element in @records, using split turn each
> comma-separated string into an array, an generate a hash that is like this:
>
> %HASH {
> record0 =>{ record_id=>77856
> printer_name=>'LP3-13'
> user_name=>'stephk'
> print_count=>1234
> }
> record1 =>{ record_id=>77857
> printer_name=>'LP3-13'
> user_name=>'stephk'
> print_count=>1235
> }
> }
>
> What is the best way to get this done?
Let us know which ways you are choosing between, and I'm sure people
will let you know which one they prefer.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 2 Feb 2005 01:37:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Generating a Hash Problem
Message-Id: <ctpas3$aki$1@mamenchi.zrz.TU-Berlin.DE>
Stephanie Kroeplin <stephanie.kroeplin@office.xerox.com> wrote in comp.lang.perl.misc:
> All,
>
> I have an array of strings lets say @records. The strings are records that
> are comma-separated (i am shortening them to save typing though). IE:
> $records[0] = '77856, LP3-13,stephk,1234'
> $records[1] = '77857,LP3-13,stephk,1235'
> ...and so on
>
> I also have an array of strings (@field_names) =
> [record_id,printer_name,user_name,print_count]. These correspond to each
> comma-seperated string in @records.
>
> I would like to step thru each element in @records, using split turn each
> comma-separated string into an array, an generate a hash that is like this:
>
> %HASH {
> record0 =>{ record_id=>77856
> printer_name=>'LP3-13'
> user_name=>'stephk'
> print_count=>1234
> }
> record1 =>{ record_id=>77857
> printer_name=>'LP3-13'
> user_name=>'stephk'
> print_count=>1235
> }
> }
>
> What is the best way to get this done? I have a lot of records.
The best? Would you settle for one way?
You could use a sub that converts one record to a hashref:
sub convert_record {
my %h;
@h{ @field_names} = split /,\s*/, shift;
\ %h;
}
To convert the whole list in place:
$_ = convert_record( $_) for @records;
That gives you a list of hashes, not a hash of hashes. You may want
to leave it at that, but if you actually need the hash structure with
"artificial" keys, you can build it from there:
my %hash = map { "record$_" => $records[ $_] } 0 .. $#records;
(All untested)
Anno
------------------------------
Date: 1 Feb 2005 17:46:36 -0800
From: ioneabu@yahoo.com
Subject: Re: Generating a Hash Problem
Message-Id: <1107308796.807614.179050@o13g2000cwo.googlegroups.com>
tested:
#!/usr/bin/perl
use strict;
use warnings;
my @records = (<>);
chomp @records;
for (@records)
{
my %hash;
@hash{('record_id', 'printer_name', 'user_name',
'print_count')} =
split ',';
$_ = \%hash;
}
use Data::Dumper;
print Dumper $_ for @records;
# put your data in a file.txt and do: cat file.txt | ./this.pl
------------------------------
Date: 1 Feb 2005 17:49:28 -0800
From: ioneabu@yahoo.com
Subject: Re: Generating a Hash Problem
Message-Id: <1107308968.744846.10270@l41g2000cwc.googlegroups.com>
hey,
I just realized I did it the same way you did but your code is fancier
:-)
wana
------------------------------
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 7723
***************************************