[10413] in Perl-Users-Digest
Perl-Users Digest, Issue: 4006 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 19 07:02:37 1998
Date: Mon, 19 Oct 98 04:00:22 -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 Mon, 19 Oct 1998 Volume: 8 Number: 4006
Today's topics:
call functions from within regexes <avitala@macs.biu.ac.il>
Re: call functions from within regexes <Tony.Curtis+usenet@vcpc.univie.ac.at>
CGI.pm :: Can't locate object method 'isaCGI' ?! <ted.dunstone@neis.com.au>
EDI and perl <philm@netvigator.com>
Re: File I/O <eugene@vertical.net>
Ftpmail (obviously from a non perl programmer) <Sales@the-net.co.uk>
Re: Getting Perl to forget - reinitialisation of variab dgris@rand.dimensional.com
Gratis: Mensagens para TMN <oscar@activenet.pt>
Re: How to write a recursive function <ebohlman@netcom.com>
Re: HTML Builder scripts <mbosnic@polaris.umuc.edu>
Info on crypt() (Bart Lateur)
Re: IO::Socket error <erhmiru@erh.ericsson.se>
Need help with perl pgm (Lisa Digregorio)
Re: Need help with perl pgm (Larry Rosler)
Re: Perl in the movie "Sphere"? (Brendan O'Dea)
Replacing multiply ":" with a string. <ava@softclub.net>
Re: Replacing multiply ":" with a string. <ava@softclub.net>
rounding off decimal numbers to integers <bench@surfshop.net.ph>
Re: rounding off decimal numbers to integers <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: rounding off decimal numbers to integers <perlguy@technologist.com>
serial port IO? module? <griessl@ihs.ac.at>
Re: Shell commands (Mark-Jason Dominus)
Re: Slow Sort? (Bart Lateur)
Re: sorting file entries by time <erhmiru@erh.ericsson.se>
Re: Storing object attributes in a DB_HASH? (Mark-Jason Dominus)
Re: The space deletion woes... (Bart Lateur)
Wanted: programming (humor?) stevenjm@olywa.net
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 19 Oct 1998 10:16:28 +0200
From: "Avshi Avital" <avitala@macs.biu.ac.il>
Subject: call functions from within regexes
Message-Id: <70eskb$ed0$1@cnn.cc.biu.ac.il>
hi,
is there some way of calling a function from within a regular expression?
e.g- s/^(.*?) .*$/<time=&foo($1)>/
(this obviously doesn't work, but you get the drift)
i have a situation where i want to perform a substitution but manipulate the
$1 var (or any other of course) via a function.
a simple way to solve this would be to perform a match first, manipulate the
data, and then perform the match using an intermediate variable, but that's
not very "Perlish".
appreciate any help,
Avshi
------------------------------
Date: 19 Oct 1998 10:47:16 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: call functions from within regexes
Message-Id: <834st12b1n.fsf@vcpc.univie.ac.at>
Re: call functions from within regexes, Avshi
<avitala@macs.biu.ac.il> said:
Avshi> hi, is there some way of calling a function from
Avshi> within a regular expression? e.g- s/^(.*?)
perldoc perlop
s/PATTERN/REPLACEMENT/egimosx
^
^
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Mon, 19 Oct 1998 19:49:13 +1000
From: ted <ted.dunstone@neis.com.au>
Subject: CGI.pm :: Can't locate object method 'isaCGI' ?!
Message-Id: <362B0B19.2E8CE990@neis.com.au.remove.this.to.mail>
I've checked archives, man pages and the FAQ's and I can't find a
reference to this error which I
get when using a perl script with the CGI.pm module and uploading a
file.
[Can't locate object method "isaCGI" via package "main" at (eval 14)
line 1.]
This occurs at the point that I use
$cgi_query = new CGI;
My non file upload scripts seem to work just fine ?
If I add the isaCGI method to main it complains.
[Can't call method "isaCGI" without a package or object reference at
(eval 17) line 1.]
Can anybody suggest a fix or what maybe going wrong.
Many thanks,
Ted.
------------------------------
Date: Sun, 18 Oct 1998 14:36:24 +0800
From: Philip Mak <philm@netvigator.com>
Subject: EDI and perl
Message-Id: <36298C68.1513A69D@netvigator.com>
Anybody know of a good resource on the web that talks about
implementation of EDI and perl? Specifically, I'm looking for info on
how dynamic updating of code with perl is the next step in building EDI
applications.
Thanks,
Phil.
------------------------------
Date: Mon, 19 Oct 1998 01:04:59 -0400
From: "Eugene Sotirescu" <eugene@vertical.net>
Subject: Re: File I/O
Message-Id: <362ac96d.0@news.dca.net>
Bob L. wrote in message <1puW1.172$H9.53270@proxye1.nycap.rr.com>...
>Hi and thank you:
>
>I have included the I/O code below. I tried +> when I open the file and it
>will not write to the file. Actually, the file gets wiped out. My first
>question was answered but now another short one. if 2 cgi's need to access
>the same text file and one of the cgi's is running, when the second
>executes, what happens when the file is locked as shown below?
In order for the flock() to take, all programs accessing the file have to
honor it. If your first program locks the file, but another program accesses
it without flocking, it's as if you hadn't locked it.
Also, the canonical way of locking/unlocking in Perl is:
open (FH, "<$file") or die "can't open $file: $!";
flock (FH, 2);
#do your thing here
close FH; #just closing the file unlocks it more safely than flock (FH, 8)
Eugene Sotirescu
------------------------------
Date: Mon, 19 Oct 1998 09:32:23 -0700
From: Lawrence Frewin <Sales@the-net.co.uk>
Subject: Ftpmail (obviously from a non perl programmer)
Message-Id: <362B6996.2B1155C4@the-net.co.uk>
RE: FTPMAIL.
I have found a script called ftpmail.pl on the web. There doesn't appear
to be much in the way of help files with it. Has anyone used it that can
let me know if it will do what I need it for?
I want to allow users to be able to FTP Gifs and Jpegs (of properties!)
as attachments directly to a dedicated directory on my website using
email - is ftpmail capable of doing this?
If not, can anyone recommend something that will do the job? Jeffrey R.
Drumm earlier mentioned Graham Barr's Net::FTP module - would this do
the job?
Thanks
Lawrence
------------------------------
Date: 19 Oct 1998 03:23:28 -600
From: dgris@rand.dimensional.com
Subject: Re: Getting Perl to forget - reinitialisation of variables
Message-Id: <m3ogr8zyzz.fsf@rand.dimensional.com>
jerh@my-dejanews.com writes:
> This is tricky to explain but here goes.
<snip>
> Any help would be appreciated.
I'm sorry, but it's impossible to help you without seeing
the code that you are having trouble with. Post it and
I'm sure someone can help.
--
Daniel Grisinger dgris@perrin.dimensional.com
Supporter of grumpiness where grumpiness is due on clpm.
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Mon, 19 Oct 1998 10:35:49 +0100
From: "Oscar Girco" <oscar@activenet.pt>
Subject: Gratis: Mensagens para TMN
Message-Id: <362B07F5.3EF1C2B9@activenet.pt>
Agora em http://www.bragavirtual.pt/sms
Ja pode novamente enviar mensagens gratuitas para a TMN
Veja tambim:
Vote no referendo da regionalizagco
http://www.bragavirtual.pt/referendo
Envie um postal a seu gosto (use imagens do seu computador)
http://www.bragavirtual.pt/postal
Obtenha desdobramentos de Totoloto gratuitamente
http://www.bragavirtual.pt/loto
------------------------------
Date: Mon, 19 Oct 1998 07:05:08 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: How to write a recursive function
Message-Id: <ebohlmanF12BoK.GxK@netcom.com>
Jonathan Stowe <gellyfish@btinternet.com> wrote:
: The problem is that you get all thinged up with your directory handles being
: globals like all other filehandle type things.
How so? He opens a directory handle, reads the filenames in in one big
gulp, and then closes the handle. He doesn't try to keep it open while
recursing (which would indeed cause the problem you mention).
------------------------------
Date: Sun, 18 Oct 1998 16:46:41 -0400
From: Meresia Bosnic <mbosnic@polaris.umuc.edu>
To: "Y. Kaganovich" <ykaganov@usa.net>
Subject: Re: HTML Builder scripts
Message-Id: <Pine.GSO.3.96.981018164228.11H-100000@polaris.umuc.edu>
HTML blocks in any order would be difficult for a novice.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On Thu, 30 Apr 1998, Y. Kaganovich wrote:
> Hi,
>
> I'm looking for cgi form-based HTML builders, similar to Tripod's
> builder to automate content upload on my company's website. We get a lot
> of content from people who don't want to learn HTML, plus we would like
> to enforce some layout rules. Most of the builders I've found are way
> too rigid to be of any use; I'm looking for ones that allow users to
> append HTML blocks in any order. So far, the builder at
> www.htmlcreator.com is the closest to what I need, but they don't seem
> to give out the program to others.
>
> Any ideas?
>
> Thanks,
>
> -Eugene
> ykaganov@usa.net
>
>
>
>
>
------------------------------
Date: Mon, 19 Oct 1998 09:59:22 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Info on crypt()
Message-Id: <362b0a69.7288382@news.ping.be>
I'm trying to figure out some properties of Perl's built-in crypt
function.
In particular I want to create my own password geberation/encryption
code. One requirement I put on it, is that generated passwords only
consist of upper case letter, and digits: [A-Z0-9].
So I'm trying to figure out the correlation between the input text, the
salt, and the possible resulting characters in the encrypted string.
I've looked at the crypt(3) man pages, but it doesn't even look like
it's the same functionality. For example: these man pages talk about a
4-bytes salt key, while I thought that Perl's crypt() uses only two
characters for salt.
Who can shed some light on this function?
Bart.
------------------------------
Date: 19 Oct 1998 11:50:16 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
To: 52g1clvgyr.fsf@odin.funcom.com
Subject: Re: IO::Socket error
Message-Id: <laaf2sq3s7.fsf@erh.ericsson.se>
Marius Kjeldahl <marius@odin.funcom.com> writes:
> I've got a perl based server process which accepts connection from
> clients. However, in some cases the server process dies (I have not
> been able to get this to happen when I control the clients, but when
> some of my external users connect/disconnect it triggers the error). From the log, the following error message is generated.
>
> Does anybody have a clue on what is going on, and how I can avoid the
> error from being triggered?
>
> Sun Oct 18 05:48:16 1998| xxxxxxxxxxxxxx| new connection
> Sun Oct 18 05:48:18 1998| xxxxxxxxxxxxxx| disconnect| forcing logout
> Use of uninitialized value at /usr/lib/perl5/i386-linux/5.00404/Socket.pm line 249, <GEN11> chunk 1.
> Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be 16 at /usr/lib/perl5/i386-linux/5.00404/Socket.pm line 249, <GEN11> chunk 1.
>
> Marius
>From your log I cannot see what condition causes the error. Perhaps you
should add more info to the log file. However, in order to prevent your
server to die you should use Perl exception handeling, i.e. eval {};
Read more about eval in perldoc.
Hope this helps.
Regards,
Michal
------------------------------
Date: 19 Oct 1998 08:26:18 GMT
From: VLHW15A@prodigy.com (Lisa Digregorio)
Subject: Need help with perl pgm
Message-Id: <70et3a$70ai$1@newssvr04-int.news.prodigy.com>
#!/usr/bin/perl
print "Content-type: text/html\n\n";
open (InFile, "Hw3.dat") || die;
$count = 0;
while ($line = <InFile>)
{
chop ($line);
$count+=1;
if ($line = ~/(a|e|i|o|u) {2}/)
{
print "This word contains two vowels in succession \n" %s,
$line;
}
if ($line = ~/ [aeiou] && [aeiou]/)
{
print "The word has exactly two vowels anywhere in the word
\n";
}
if ($line = ~/\b a|e|i|o|u \b/)
{
print "The word begins and ends with the same vowel \n";
}
}
print "the number of lines in the input file is $count \n";
close (InFile);
Here's the program. I need to
1) Keep track of the number of lines(words) in the input file.
2) Display the words on the file that contain two vowels in succession
3)Display the words that end with the same vowel with which they begin
4) Display hte words with exactly two vowels anywhere in the word.
Code doesn't work. Help please. Need this by tomorrow.
------------------------------
Date: Mon, 19 Oct 1998 03:03:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Need help with perl pgm
Message-Id: <MPG.1094ae4b5d07e8749898c3@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <70et3a$70ai$1@newssvr04-int.news.prodigy.com> on 19 Oct 1998
08:26:18 GMT, Lisa Digregorio <VLHW15A@prodigy.com> says...
...
> Code doesn't work. Help please. Need this by tomorrow.
Or else what? What makes you think your teacher doesn't read this
newsgroup also?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 19 Oct 1998 20:14:28 +1000
From: bod@compusol.com.au (Brendan O'Dea)
Subject: Re: Perl in the movie "Sphere"?
Message-Id: <70f3e4$unn$1@duende.compusol.com.au>
[posted & mailed]
[resurrecting an old thread from February]
In article <ORWANT.98Feb23162046@cyrano.media.mit.edu>, Jon Orwant
<orwant@cyrano.media.mit.edu> wrote:
>
>mcafee@battlezone.rs.itd.umich.edu (Sean McAfee) writes:
>
> I just got back from seeing the new movie "Sphere", and I think I saw part
> of a Perl script on a computer screen at one point. Perhaps someone else
> can verify this, having also seen it or looking for it in the future...
>
>If anyone can positively identify the code, I'd love to mention it
>in the next issue of The Perl Journal.
Heh. I though the same when I watched _Sphere_ on video last night, so
I paused the tape to see exactly what the magic `commands' Harry typed
to translate the message were:
$BSD = -f '/vmunix'; if ($BSD) { system "BIN
cbreak </dev/tty >/dev/tty 2>&1
appeared to be the first, and
set_cbreak(0)
local($on) = $_[0];
local($sgttyb,@ary);
require 'sys/ioctl.ph';
[snip]
is most of the second. After digging around, I found almost exact
matches for both fragments in an *old* version of Tom's FAQ:
Version: $Id: perl-intro,v 1.5 93/10/02 00:32:46 tchrist Exp Locker: tchrist $
[snip]
2.9) How can I read a single character from the keyboard under UNIX and DOS?
[snip]
$BSD = -f '/vmunix';
if ($BSD) {
system "stty cbreak </dev/tty >/dev/tty 2>&1";
}
[snip ~16 lines]
sub set_cbreak { # &set_cbreak(1) or &set_cbreak(0)
local($on) = $_[0];
local($sgttyb,@ary);
require 'sys/ioctl.ph';
[snip]
It seems unlikely that these were taken from a single script, since they
are different ways to do the same thing.
Given also that these fragments occurred in the same order as the two
examples given in the FAQ answer, maybe they were taken from it
directly.
Regards,
--
Brendan O'Dea bod@compusol.com.au
Compusol Pty. Limited (NSW, Australia) +61 2 9809 0133
------------------------------
Date: Mon, 19 Oct 1998 11:53:41 +0300
From: "Alexei V. Alexandrov" <ava@softclub.net>
Subject: Replacing multiply ":" with a string.
Message-Id: <362AFE15.897DC164@softclub.net>
Hello everyone,
i`ve ran into a problem.
suppose there is a string 1:2:3:4:5
and there is an expression $expr = " or id = ";
i have to replace every instance of symbol ":" with $expr;
standard perl substitute replaces onle the first instance,
what should i do with other?
Thanks in advance.
--
Best regards,
Alexei V. Alexandrov
Mail: ava@softclub.net
WWW: www.softclub.net
------------------------------
Date: Mon, 19 Oct 1998 11:58:10 +0300
From: "Alexei V. Alexandrov" <ava@softclub.net>
Subject: Re: Replacing multiply ":" with a string.
Message-Id: <362AFF22.8FF7C92B@softclub.net>
sorry, forgot about the faq.
$str =~ s/smth/$smth/g; :-)))
Alexei V. Alexandrov wrote:
>
> Hello everyone,
>
> i`ve ran into a problem.
> suppose there is a string 1:2:3:4:5
> and there is an expression $expr = " or id = ";
> i have to replace every instance of symbol ":" with $expr;
> standard perl substitute replaces onle the first instance,
> what should i do with other?
>
> Thanks in advance.
>
> --
> Best regards,
> Alexei V. Alexandrov
> Mail: ava@softclub.net
> WWW: www.softclub.net
--
Best regards,
Alexei V. Alexandrov
Mail: ava@softclub.net
WWW: www.softclub.net
------------------------------
Date: Mon, 19 Oct 1998 16:47:06 +0800
From: "Benjamin" <bench@surfshop.net.ph>
Subject: rounding off decimal numbers to integers
Message-Id: <70eu9m$job$1@tempo.news.iphil.net>
How do you round off a decimal number to an integer?
------------------------------
Date: 19 Oct 1998 11:06:20 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: rounding off decimal numbers to integers
Message-Id: <831zo43oqb.fsf@vcpc.univie.ac.at>
Re: rounding off decimal numbers to integers, Benjamin
<bench@surfshop.net.ph> said:
Benjamin> How do you round off a decimal number to an
Benjamin> integer?
(There's no such animal. Perhaps you mean a "decimal
numeral".)
perldoc -f int
perldoc -f sprintf
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Mon, 19 Oct 1998 10:42:29 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: rounding off decimal numbers to integers
Message-Id: <362B1795.E902911E@technologist.com>
Check the FAQ for:
"Does perl have a round function? What about ceil() and floor()? Trig
functions?"
For those who don't know, FAQ stand for "Frequently Asked Questions".
The perl FAQ was designed as a resource for Perl programmers to check
FIRST before posting questions that have been asked a thousand times
before in the newsgroup.
The FAQ can be found at:
http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html
Good luck!
Brent
--
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Mon, 19 Oct 1998 09:20:59 +0100
From: Peter Griessl <griessl@ihs.ac.at>
Subject: serial port IO? module?
Message-Id: <362AF66B.F1E0206C@ihs.ac.at>
Hi,
I need to talk to an external device connected to the serial
port using XON/XOFF flow control and I want to do this out
of perl (since the application is written in perl).
Does anyone know how to do it :-) ?
Is there any perl way (module?) to program the serial port
or do I have to switch over to C and use tcsetattr, ..... ?
Thanks for any hints!
Peter Griessl, griessl@ihs.ac.at
------------------------------
Date: 19 Oct 1998 02:35:21 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Shell commands
Message-Id: <70emj9$hd1$1@monet.op.net>
In article <GUpW1.23$OZ4.14896@news.shore.net>,
Nathan V. Patwardhan <nvp@shore.net> wrote:
>Jason Holland (jason.holland@dial.pipex.com) wrote:
>
>: Check the system() command.
>
>system() is not a command.
I don't see why not. I think `command' is a common locution for any
function or subroutine which is used primarily for its side effects.
I also think that if you were to study usage in this newsgroup, you'd
see that that's how people use it:
the `system' command
the `print' command
the `mkdir' command
Contrastingly, people never use `command' to indicate functions that
have no side effects; that is because `command' suggests the
imperative, and these functions aren't imperative:
the `sqrt' command (*)
the `sort' command (*)
the `readdir' command (*)
the `gethostbyname' command (*)
Anyway, it seems to me that whether or not `command' is correct or
even common usage in this case, that the meaning here is clear, and to
complain that `system is not a command' is nitpicking.
It used to drive me nuts when the Pascal programmers would say primly
`That is not a function. It is a subroutine.' and they had more of an
excuse to say that than you do to say that `system' is not a command.
------------------------------
Date: Mon, 19 Oct 1998 10:10:51 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: Slow Sort?
Message-Id: <362d0f2e.8509145@news.ping.be>
Steve Monson wrote:
> I have performed
>a few computaional sections, and ended up with a list @s containing
>102,442 small integers (ranging from 1 to about 100 or so).
which indicates that you have a lot of duplicate values. Maybe this is
part of the culprit.
And it probably won't give too useful results.
Couldn't you do something like:
for($i=1;@a<@b;$i++) {
push @a, grep { $_ == $i } @b;
}
Or similar. It looks like inefficient code, but I'm curious how it
compares.
Bart.
------------------------------
Date: 19 Oct 1998 09:31:09 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
To: jdporter@min.net
Subject: Re: sorting file entries by time
Message-Id: <lad87povnm.fsf@erh.ericsson.se>
John Porter <jdporter@min.net> writes:
>
> Of course it is.
>
> That's why the sort should use the built-in sort routine,
> rather than an explicitly defined one.
>
> Something like this will do nicely:
>
> @sorted_lines =
> map { substr($_,8) }
> sort
> map { substr($_,25,8).$_ }
> @unsorted _lines;
I see John that you like this construction which came from my post about
sorting the IPs. I like it too, and seems that other people too. I've got
few requires from guys that saw my post and wanted to find some refference
about it. I don't have any, as I 'invented' it on the fly. I wonder if it
was discussed before my post? Nevertheless, as I find it quite usefull
I am thinking about naming it. Because it is quite simillar to ST, maybe
I should call it FST -> Flat ST. Because, as opposite to ST, which uses
two dimensional arrays to sort, this one operates on one dimesional
arrays. Or maybe it should be named Linear ST?
Regards,
Michal
------------------------------
Date: 19 Oct 1998 03:54:45 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Storing object attributes in a DB_HASH?
Message-Id: <70er85$hf6$1@monet.op.net>
In article <36290567.48189EF@ix.netcom.com>,
Jeffery Cann <jc_cann@ix.netcom.com> wrote:
>my $obj = {
> key1 = value1,
> key2 = value2,
> ...
>};
>1. Concatenate the values of the hash into a single, comma-separated
>string:
> $rec="value1,value2";
1.
Why not concatenate the keys *and* the values?
$rec = join ',' , %$obj;
# To unpack:
my %obj = split /,/, $rec;
bless \%obj => ... ;
Or
2.
Define a list of field names in the order you want:
@STANDARD_FIELD_ORDER = qw(key1 key2 ...);
And take a slice to get the values in the standard order:
$rec = join ',' , @{$obj}{@STANDARD_FIELD_ORDER};
# To unpack:
my %obj;
@obj{@STANDARD_FIELD_ORDER} = split /,/, $rec;
bless \%obj => ... ;
3.
I like to use \0 as a separator for this sort of thing, because I
often need to store data that contains commas, and I don't usually
mind disallowing \0 characters. Drawback: Standard Unix tools often
do not work very well on files that contain \0.
------------------------------
Date: Mon, 19 Oct 1998 08:45:31 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: The space deletion woes...
Message-Id: <362af5a5.1974608@news.ping.be>
Sam Holden wrote:
>#1 - remopve leading whitespace
>#2 - remove trailing whitespace
>#3 - compress all remaining whitespace groups to a single space.
>
>So " Hi there " => "Hi there"
>
>Your last one would produce "Hithere" by removing all whitespace which
>I doubt is what is required (although as I said I missed the first post).
If that is indeed what is requested, try this on for size:
for($cgi_client{'upfile'}) { # access this var through $_
tr/\t / /s; # single space, for both spaces and tabs
s/^ //; # leading space (not "spaces"!)
s/ $//; # trailing space (ditto)
}
But if I look at the text from the original post, it says:
>The following code is supposed to delete any and all spaces from a
>string
All that trouble to delete the spaces?
$cgi_client{'upfile'} =~ tr/\t //d; #no spaces or tabs
Bart.
------------------------------
Date: Mon, 19 Oct 1998 07:45:21 GMT
From: stevenjm@olywa.net
Subject: Wanted: programming (humor?)
Message-Id: <70eqmg$4j5$1@nnrp1.dejanews.com>
(humor, sort of)
Can anybody here spend several (hours|days|weeks) writing me a program for my
use (which I fully intend to make money on) in exchange for something you
could get without my help, but that I will geneously offer as payment?
Note that I will require the script(s) do things or allow things to occur that
may be any or all of:
1. Extreme security risks,
2. Massive resource pigs in general,
3. Simply not feasible with CGI,
4. So stupid as to defy understanding,
5. Of no utility at all to any one but me.
Also note that I can not be talked out of anything, because I KNOW what I want
and you don't. You will be expected to design to my specifications exactly.
I won't be bothered with technical problems, since I need to focus on the big
picture and marketing my new scam (which you are going to implement for me)
and I don't have time to deal with your petty detail oriented mind.
I also don't have time to learn anything about perl, newsgroups in general,
internet business techniques, or life as we know it.
I have encrypted my email address with a secret process I developed. I have
done this to ensure only the best and brightest will be able to reply.
Reply to:
teveSay ayMay
tevenmsay@lackwaterbay-acificpay.omcay
##################
Ah..... that felt good....
Steve
blackwater-pacific.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
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 4006
**************************************