[13366] in Perl-Users-Digest
Perl-Users Digest, Issue: 776 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 13 11:07:24 1999
Date: Mon, 13 Sep 1999 08:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 13 Sep 1999 Volume: 9 Number: 776
Today's topics:
Calls from HTML <krajzewicz@inx.de>
Re: Calls from HTML (Kragen Sitaker)
Re: Calls from HTML <espen@nextel.no>
Re: concurrent GDBM_File access? (Steve van der Burg)
Re: Deleting spaces in a string <latsharj@my-deja.com>
Re: Deleting spaces in a string <jeffp@crusoe.net>
directory pb <f-breuiller@ti.com>
Re: Discussion: compiled perl program as shareware (Kragen Sitaker)
Re: Discussion: compiled perl program as shareware <rra@stanford.edu>
Re: Good way to learn PERL <AgitatorsBand@yahoo.com>
Help : DBD::ODBC ? <alrope@zaz.com.br>
How to know how many users are connected on a NT server <vbezard@atos-group.com>
Re: how to tag a pattern match from a filehandle (Kragen Sitaker)
Is anyone capable of explaining this?? ladlad@my-deja.com
Re: parsing a record at specific columns (Kragen Sitaker)
Re: parsing a record at specific columns <mgoheen@noname.com>
perl regex's <picaza@chsi.com>
Re: Problem with PGP::Sign in a CGI script <grimoire@twisted.gothicdreams.net>
Re: Problems with Net::POP3->list (Kragen Sitaker)
Re: Question about @_ / $_ <krajzewicz@inx.de>
Re: Question about @_ / $_ (Kragen Sitaker)
Re: Question about @_ / $_ <tbornhol@prioritytech.com>
Question about split (Matthew Miller)
Re: Question about split (Kragen Sitaker)
Re: Regular Expresions <jeffp@crusoe.net>
Re: Searching by date problem. (Benjamin Franz)
Re: Searching by date problem. (Sam Holden)
Re: Text::FixedRecField - proposal for new module. (Kragen Sitaker)
Re: thanks!! parsing a record at specific columns <pleduc@your_finger.home.com>
Re: where to write perl??? <georg.weissenbacher@altavista.net>
Re: Why perlcrt.dll needed? (G Crowder)
Re: Will an apology end this mess? <AgitatorsBand@yahoo.com>
Re: Win32::MAPI problem - reading and sending shapirojNOSPAM@logica.com
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 13 Sep 1999 15:28:43 +0200
From: Daniel Krajzewicz <krajzewicz@inx.de>
To: Daniel Krajzewicz <krajzewicz@inx.de>
Subject: Calls from HTML
Message-Id: <37DCFC0B.C0C38D37@inx.de>
Hello !!!
Is it possible to make direct Perl-calls from HTML without having to
press any
buttons ??
Maybe in the Head of the document ??
thanks for an answer,
Daniel Krajzewicz
--
__________________________
< Daniel Krajzewicz >
>------------------------<
< krajzewicz@inx.de >
>------------------------<
< http://www.art-so-far.de >
>------------------------<
<__________________________>
------------------------------
Date: Mon, 13 Sep 1999 14:20:04 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Calls from HTML
Message-Id: <oK7D3.7720$N77.620573@typ11.nn.bcandid.com>
In article <37DCFC0B.C0C38D37@inx.de>,
Daniel Krajzewicz <krajzewicz@inx.de> wrote:
>Is it possible to make direct Perl-calls from HTML without having to
>press any buttons ??
>Maybe in the Head of the document ??
HTML is not a programming language. HTML is a document markup language.
Different things interpret HTML in different ways. Perhaps you want
PHP, perlembed, or SSI?
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 13 Sep 1999 16:20:56 +0200
From: Espen Myrland <espen@nextel.no>
Subject: Re: Calls from HTML
Message-Id: <37DD0847.B50194FE@nextel.no>
use HTML::Embperl; very nice. you have to install it first, of course.
se also perl.apache.org, ->some embperl stuff
perldoc HTML::Embperl;
You have to submit a button if you gonna submit something, og course
espen
Daniel Krajzewicz wrote:
> Hello !!!
>
> Is it possible to make direct Perl-calls from HTML without having to
> press any
> buttons ??
> Maybe in the Head of the document ??
>
> thanks for an answer,
> Daniel Krajzewicz
>
> --
> __________________________
> < Daniel Krajzewicz >
> >------------------------<
> < krajzewicz@inx.de >
> >------------------------<
> < http://www.art-so-far.de >
> >------------------------<
> <__________________________>
------------------------------
Date: 13 Sep 1999 13:30:15 GMT
From: steve.vanderburg@lhsc.on.ca (Steve van der Burg)
Subject: Re: concurrent GDBM_File access?
Message-Id: <8E4061CCCstevevanderburglhsco@newshost.uwo.ca>
joern@netcologne.de (Joern Reder) wrote in
<37DB7CA7.39062EDA@netcologne.de>:
>I've got problems with concurrent accesses on GDBM_File's. I made a
>module for this purpose long time ago, using DB_File successfully.
>Now I switched to GDBM_File and strange things happen.
>
>I use an extra file to set an flock on it to control the access on
>the original GDBM_File.
>
...[snip]...
>
>I don't understand this at all! The first program unlocks *after*
>untieing the GDBM_File (in the destructor method of the class), so
>what's the problem? It seems that as long as the first process lives
>the second is unable to open the GDBM_File.
>
>Here's my testcode:
...[snip]...
Your first program (the one that writes to the database) doesn't
release the lock on the database until the untie happens because...
gdbm does its own file locking.
The second program, which also opens the database in write mode(?),
blocks until the first process has released its write lock.
man gdbm should clear all of this up.
...Steve
--
Steve van der Burg
Technical Analyst, Information Services
London Health Sciences Centre
London, Ontario, Canada
Email: steve.vanderburg@lhsc.on.ca
------------------------------
Date: Mon, 13 Sep 1999 12:56:44 GMT
From: Dick Latshaw <latsharj@my-deja.com>
Subject: Re: Deleting spaces in a string
Message-Id: <7risa6$i4e$1@nnrp1.deja.com>
In article <7rimes$dee$1@jaydee.iway.fr>,
"Vincent BEZARD" <vbezard@atos-group.com> wrote:
> I have a string witch looks like "23 6659 478", and I want to del all
>the spaces, in order to get a interger like "236659478". I tried =~
>s/\s+//, but I still not work.
What you have will delete the first space(s). To delete all, you need
=~ s/\s+//g; Or better for individual characters: =~ tr/ //d; if all you
are trying to delete is space characters, not tabs or other whitespace.
--
Regards,
Dick
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 13 Sep 1999 09:14:51 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Deleting spaces in a string
Message-Id: <Pine.GSO.4.10.9909130908200.19013-100000@crusoe.crusoe.net>
[posted & mailed]
On Sep 13, Nick Condon blah blah blah:
> Jeff Pinyan wrote:
>
> > Such a popular question, it's in the FAQ.
>
> I know that this group is full of people who *love* to jump down people's throats
> with "it's in the the FAQ", but you could at least read what he actually posted.
Ok, here is my take on the whole "It's in the FAQ" thing.
When I tell a person the answer is in the FAQ, I do my best to tell them
which FAQ section, and which heading to look under. I do not read them
what it says, nor do I give them the answer flat out.
It is by reading the documentation that one finds the answers to questions
one didn't think one had. I'm stealing this from #perl, but it's a good
example:
You want to know the meaning of the word "pretentious."
1) The Fish Method (giving you the answer)
"Mom! What's 'pretentious' mean?"
"It means a person assumes too much."
"Ok."
2) The Learn Something New Method (you learn something unexpected)
"Mom! What's 'pretentious' mean?"
"We've got a dictionary, and you know how to read, so look it up."
"Ok..."
While reading the dictionary entry, perhaps you see words you don't
understand, and you look them up as well. Or maybe -- just maybe -- your
eyes happen to wander, and you see a word you didn't plan on looking up,
but you read its definition anyway. You know ANOTHER word. Learning is
fun.
That is my take on it. I didn't just jump down your throat. And the
person I answered was very satisfied with the reading he did. He thanked
me, and did not bark at me.
I've never known a teacher who didn't challenge me to answer my own
question. It's a good way to learn.
Pretentious \Pre*ten"tious\, a. [Cf. F. pr['e]tentieux. See
Pretend.]
Full of pretension; disposed to lay claim to more than is
one's; presuming; assuming. -- Pre*ten"tious*ly, adv. --
Pre*ten"tious*ness, n.
--
jeff pinyan japhy@pobox.com
perl stuff japhy+perl@pobox.com
CPAN ID: PINYAN http://www.perl.com/CPAN/authors/id/P/PI/PINYAN
------------------------------
Date: Mon, 13 Sep 1999 15:49:30 +0200
From: Francois Breuiller <f-breuiller@ti.com>
Subject: directory pb
Message-Id: <37DD00EA.CD6295D@ti.com>
Hello
Could someone send to me an exemple of CGI script in to create a
directory $name_dir into path $path_dir ?
Could someone explain me the use of the "system" command to copy file
between two directories ??
Thanks for your reply
Francois Breuiller
------------------------------
Date: Mon, 13 Sep 1999 14:15:19 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Discussion: compiled perl program as shareware
Message-Id: <XF7D3.7707$N77.619925@typ11.nn.bcandid.com>
In article <37DB713A.59EF1C2E@hiz.de>, Werner Diwischek <werner@hiz.de> wrote:
>What do you think about it?!
I used to like shareware, back before 1992, when I found the Internet.
Now I realize:
1. most software is crap;
2. dealing with crappy software is painful;
3. most good software is either proprietary commercial software or free
software, although there is also a lot of crap software in both
of these categories;
4. shareware has the worst of both worlds: developed as a hobby in somebody's
spare time, like free software, and only worked on by a small number
of people and not trustworthy, like proprietary software.
5. almost no shareware authors make any money at it.
That's what I think about it. Others may disagree.
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 13 Sep 1999 07:20:03 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Discussion: compiled perl program as shareware
Message-Id: <yl906a3ncc.fsf@windlord.stanford.edu>
Kragen Sitaker <kragen@dnaco.net> writes:
> 4. shareware has the worst of both worlds: developed as a hobby in somebody's
> spare time, like free software, and only worked on by a small number
> of people and not trustworthy, like proprietary software.
> 5. almost no shareware authors make any money at it.
> That's what I think about it. Others may disagree.
There are a few fairly notable exceptions, but nearly all of them are
games, where the utility of multiple people working on the program after
it's first been written is somewhat diminished compared to other types of
programs (since there's mostly no such thing as a new feature, just a new
game, so the only additional coding is portability and bug fixes).
Scorched Earth and Snood are the only two shareware programs to this day
that I've considered worth registering.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Mon, 13 Sep 1999 13:55:52 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Good way to learn PERL
Message-Id: <In7D3.350$n82.59595@news.shore.net>
Jim Carison <matthew357@hotmail.com> wrote:
: Hello. I am fairly new to PERL and CGI. Although I understand enough to make
: small scripts that do a little bit of stuff, I am interested in making my
: skills good enough to use on the commercial level. If you can give me any
: information as to how I can learn PERL much better without a lot of upfront
: costs (like IT schools) but things like webpages or good books.
Step 1: Don't worry too much about semantics on usenet (PERL/Perl/perl):
the semantics of the language will keep you busy enough.
Step 2: Find some task that you need to automate with Perl. Most people
agree that any language is easier to learn when you have a concrete task
to accomplish.
Step 3: I wouldn't try to learn perl by reading the man pages. That
strikes me as similar to trying to learn how to fix your car by reading
the Chilton manual. The man pages are references, not (for the most part)
tutorials. I (and most people on this ng) would recommend "Learning Perl"
(or the Win32 version) as the best book to get started with.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Mon, 13 Sep 1999 10:11:37 -0300
From: "Alexandre" <alrope@zaz.com.br>
Subject: Help : DBD::ODBC ?
Message-Id: <7rissb$6to$1@srv4-poa.nutecnet.com.br>
Please Programmers,
I installed the DBD-ODBC in my system, and when a run a simple programm
appear the message:
" Install_driver(ODBC) failed: DBD::ODBC object version 0.21 does not match
bootstrap parameter
0 at C:\Perl\5.005\lib/MSWin32-x86-object/DynaLoader.pm line 187."
What should i make ?
The package was installed by VMP in the Internet.
Tanks,
Alexandre Roberto Perestrelo
alrope@zaz.com.br
------------------------------
Date: Mon, 13 Sep 1999 16:07:57 +0200
From: "Vincent BEZARD" <vbezard@atos-group.com>
Subject: How to know how many users are connected on a NT server
Message-Id: <7rj0p0$jah$1@jaydee.iway.fr>
I work on NT, and I like to know if there is a module (or command line) that
can give me the number of connected users on my server.
Thanks in advance
-----------------------------------------------------------
Vincent BEZARD
641, Avenue du Grain d'Or
41350 VINEUIL
Tel: 02-54-52-51-87
Fax: 02-54-52-52-70
-----------------------------------------------------------
------------------------------
Date: Mon, 13 Sep 1999 13:24:05 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: how to tag a pattern match from a filehandle
Message-Id: <VV6D3.7570$N77.612899@typ11.nn.bcandid.com>
In article <37DBF750.B5BEC08C@ccrs.nrcanDOTgc.ca>,
Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> wrote:
>This may seem like a simple question, but I can't seem to figure out how
>to do this. I have done the same when the filehandle is STDIN, as in:
>
>while (<>)
In this case, the filehandle is ARGV, actually.
>I know the (<>) takes STDIN as 'stuff', but how can I do this if I have
>a file represented by a scalar (eg. $file)?
I'm assuming $file is a filehandle, not the contents of a file.
(Someone already answered the case where it's the contents.) <$file>.
Man perlop.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 13 Sep 1999 14:07:00 GMT
From: ladlad@my-deja.com
Subject: Is anyone capable of explaining this??
Message-Id: <7rj0dr$l70$1@nnrp1.deja.com>
Hi,
I have a file. I need to read it (to find a regular expression) and
after few calculations write back to the file.
Here is a part.
open(search,"+<searchEC.htm"); #open searchEc.htm file both for
#reading and writting
while (<search>)
{
$_= '123'; #modify
print search $_; # and print back to the searchEC.htm
}
close(search);
The problem is that it is not written back to the file, in other words
I can not update the file. But if I use print
(to write to STDOUT)
it writes the changed value properly.
Where do I make a mistake or is it a bug?. Thank you very much for help.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 13 Sep 1999 13:06:56 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: parsing a record at specific columns
Message-Id: <QF6D3.7555$N77.610933@typ11.nn.bcandid.com>
In article <37DCEBB5.BC656964@your_finger.home.com>,
Paul Leduc <pleduc@your_finger.home.com> wrote:
>The question is: how do I parse a record at specific columns?
>
>The only way I can see is using /(.....)(.*)/
>where $1 gets the first 5 cols (or however many dots I use) and $2 gets
>the rest of the record.
>While this works well for short columns, it would not be so convenient
>to split a record at say col 50
You could use (.{50}) instead of
(..................................................).A But (as someone
else posted) you really want unpack.
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 13 Sep 1999 09:50:43 -0400
From: "Matt Goheen" <mgoheen@noname.com>
Subject: Re: parsing a record at specific columns
Message-Id: <Ai7D3.11112$r6.280034@typhoon.nyroc.rr.com>
Paul Leduc <pleduc@your_finger.home.com> wrote in message
news:37DCEBB5.BC656964@your_finger.home.com...
> I tried various incantations range (such as /(.*){1,5}(.*)/ ), but can't
> get it to work correctly.
(.*){1,5} means 1 to 5 occurances of 0 or more characters - probably not too useful.
Use .{1,5}, or, as everyone else mentioned, use unpack.
- Matt Goheen
------------------------------
Date: Mon, 13 Sep 1999 09:12:03 -0400
From: "Peter Icaza" <picaza@chsi.com>
Subject: perl regex's
Message-Id: <7rit6b$1npo$1@pike.uhc.com>
hi,
im going nutz trying to figure out what seems to be a simple reg ex problem.
can you help? please reply via clpm and picaza@chsi.com
description of problem:
match the first occurence of a word, (upper case), on the line. the word
may be preceded by 0 or more ('s. followed by one space, other stuff, a
space and a newline,(\n for illistration purposes)
data:
((((ABC == '9' || \n
DEF == '2' ) && \n
GHI == 1 ) && \n
JKLM == '6' && \n
NOPQR include file/name && \n
ST include 'otherfile.name' )) \n
sample regex's:
# $subsetCriteria[$X] =~ m/.*(\w) *.\n/;
# $subsetCriteria[$X] =~ m/(\(*)(\w)+( *.*)\n/;
# $subsetCriteria[$X] =~ m/(^\w)+( *.*)\n/;
# $subsetCriteria[$X] =~ m/^([A-Z]+) (.*)\n/;
# $subsetCriteria[$X] =~ m/^[(*|(\w+)]( .*)+\n/;
# $subsetCriteria[$X] =~ m/^(\()*(\w+)\b ([\||&])* \n/;
# $subsetCriteria[$X] =~ m/\(*([A-Z]+) *.\n/;
# $subsetCriteria[$X] =~ m/^(.*)([A-Z])+ (.* )+(\n)/;
$subsetCriteria[$X] =~ m/(.*)([A-Z])+\b( .*)+ \n/;
------------------------------
Date: Mon, 13 Sep 1999 13:17:36 GMT
From: Alex Page <grimoire@twisted.gothicdreams.net>
Subject: Re: Problem with PGP::Sign in a CGI script
Message-Id: <7rith4$j0e$1@nnrp1.deja.com>
In article <7rirpo$hnl$1@nnrp1.deja.com>,
Alex Page <grimoire@twisted.gothicdreams.net> wrote:
> More specifically, when I call the pgp_verify method, the script
> appears to reset itself - the output starts again at the header
> level
A friend of mine has looked into the problem, and discovered that the
pgp_verify method makes use of open2, meaning that this is another
variant on the CGI / open2 problem which can be solved by flushing
STDOUT. For more details:
http://x31.deja.com/getdoc.xp?AN=520066836&search=thread&CONTEXT=937228301.1802960910&HIT_CONTEXT=937228301.1802960910&hitnum=0
Thanks anyway,
Alex
--
Diet Techno - You need it, because you beep.
(with thanks to Dooferlad)
MancGoff: http://www.gothicdreams.net/grimoire
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 13 Sep 1999 14:33:58 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Problems with Net::POP3->list
Message-Id: <qX7D3.7763$N77.622479@typ11.nn.bcandid.com>
In article <7rfpbc$i52$1@nnrp1.deja.com>, <marcza@my-deja.com> wrote:
>How do I get all the 6 announced msgid's ???
There is a bug in your code, as another poster told you. What he
didn't mention is that if you used strict and myed all your variables,
Perl would have caught the bug automatically.
As getting a bunch of compile errors might be discouraging, I am
including the changes you will need to get this subroutine to compile
under use strict.
(You could probably have done this yourself; it appears from your code
that you have quite a bit of experience with Perl. Which makes me
wonder why you were puzzled by the %messages thing and didn't use
strict in the first place.)
>sub get_mail {
>
> $pop = Net::POP3->new($mailserver, 'Debug' => 9) or die "Can't open
>connection to $mailserver : $!\n";
I like the 'or die'. Should be my $pop =, not just $pop =, IMHO.
> $pop->login($username, $password) or die "Can't authenticate: $!\n";
Presumably $username and $password should be parameters; otherwise you
will need to my them somewhere higher up.
> $messages = $pop->list or die "Can't get list of undeleted messages:
>$!\n";
my $messages =, not $messages =
> print "m=$messages N=".(keys %messages)."#".(%messages)."#"\n");
And of course here you will use %$messages, not %messages; if you
haven't declared a %messages, and have used strict, Perl will catch
this for you.
You can replace all the . with , in this statement; print accepts a
list of things to print. This may avoid some precedence hassles in the
future, and it theoretically makes your code faster.
"#"\n" puzzles me. Did that code really compile? It looks like you
have a runaway string there that will include the whole loop, and \n is
outside of any quotes.
> foreach $msgid (keys %messages) {
foreach my $msgid
> $message = $pop->get($msgid);
my $message
The rest of the code is OK.
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 13 Sep 1999 15:41:29 +0200
From: Daniel Krajzewicz <krajzewicz@inx.de>
To: Daniel Krajzewicz <krajzewicz@inx.de>
Subject: Re: Question about @_ / $_
Message-Id: <37DCFF09.60466CC4@inx.de>
Hello !!!
Ok, I see, you just misunderstood, my english=B4s propably not the best.
So, what I wanted to know is how can I OMIT the use of \| ???
Is the following possible :
@array =3D split(=B4 =B4, _$);
$object =3D $array[0];
$attributes =3D @array[1];
?????
thanks for help,
Daniel Krajzewicz
Mark Winder wrote:
> =
> No This will not work as the string will be passed into the object.
> A good way to do this is to say
> =
> ($object,$attributes)=3Dsplit("|","car|yellow fast low");
> =
> so that your subroutine would look like
> =
> sub do_things_with_objects
> {
> $p=3D@_;
> ($object,$attributes)=3Dsplit("|",$p);
> ....
> }
> =
> and this would be called with a single string parameter.
> =
> The only time in simple perl that parameters can change with a
> subroutine call is if you supply a list (something with an @ on it) to =
a
> subroutine. As what is passed to the subroutine is itself a single list=
> all of the following do NOT work:
> =
> passing more than one list.
> passing a list followed by one or more values.
> =
> Note that passing one or more values first and then a list does work
> however.
> =
> Hope this is helpful,
> =
> Mark Winder.
> =
> Daniel Krajzewicz wrote:
> >
> > Dear Friends,
> >
> > I just hav a little question about the use of @_ / $_...
> > When a string is passed to a subroutine which schould hold two
> > parameters,
> > where the second features spaces, for example "car yellow fast low", =
can
> > I parse it by using the following command into these two parameters :=
> > ($object, $attributes) =3D @_;
> > or what is the correct syntax.
> > By now, I=B4m using the character =B4|=B4 to seperate between the dif=
ferent
> > parameters,
> > so it would look like : "car|yellow fast low" and would be splitted a=
nd
> > the assigned...
> >
> > Thanks for help,
> > Daniel Krajzewicz
> >
> > --
> > __________________________
> > < Daniel Krajzewicz >
> > >------------------------<
> > < krajzewicz@inx.de >
> > >------------------------<
> > < http://www.art-so-far.de >
> > >------------------------<
> > <__________________________>
-- =
__________________________
< Daniel Krajzewicz >
>------------------------<
< krajzewicz@inx.de > =
>------------------------<
< http://www.art-so-far.de >
>------------------------<
<__________________________>
------------------------------
Date: Mon, 13 Sep 1999 14:09:40 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Question about @_ / $_
Message-Id: <EA7D3.7689$N77.617925@typ11.nn.bcandid.com>
In article <37DCFF09.60466CC4@inx.de>,
Daniel Krajzewicz <krajzewicz@inx.de> wrote:
>Ok, I see, you just misunderstood, my english´s propably not the best.
>So, what I wanted to know is how can I OMIT the use of \| ???
>Is the following possible :
>@array = split(´ ´, _$);
>$object = $array[0];
>$attributes = @array[1];
#!/usr/bin/perl -w
use strict;
my $string = "car yellow fast hidden";
my ($object, $attributes) = split / /, $string, 2;
print "$object\n$attributes\n";
Output:
car
yellow fast hidden
Source:
perldoc -f split
HTH.
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 13 Sep 1999 09:25:08 -0500
From: "Tim Bornholtz" <tbornhol@prioritytech.com>
Subject: Re: Question about @_ / $_
Message-Id: <694B8A407135E8F5.C0AA441E569870D2.AA02B46A9C2D5EFC@lp.airnews.net>
Daniel Krajzewicz <krajzewicz@inx.de> wrote in message
news:37DCCB19.C8A6ED5F@inx.de...
>Dear Friends,
>
>I just hav a little question about the use of @_ / $_...
>When a string is passed to a subroutine which schould hold two
>parameters,
>where the second features spaces, for example "car yellow fast low", can
>I parse it by using the following command into these two parameters :
>($object, $attributes) = @_;
>or what is the correct syntax.
>By now, I´m using the character ´|´ to seperate between the different
>parameters,
>so it would look like : "car|yellow fast low" and would be splitted and
>the assigned...
Here is one way to parse it and not use the | as a delimiter:
$arg = "car yellow fast low";
foo($arg);
sub foo {
my($object, @attributes) = split / /, shift;
print "Object: $object\n";
foreach (@attributes){
print "Attribute: $_\n";
}
}
hth,
Tim Bornholtz
tbornhol@prioritytech.com
------------------------------
Date: 13 Sep 1999 14:47:49 GMT
From: namille2@news.vt.edu (Matthew Miller)
Subject: Question about split
Message-Id: <7rj2ql$4ta$1@solaris.cc.vt.edu>
Hello,
I'm working on a program and I'm having some problems with the split function.
What happens is split returns a list that contains an undefined element at
position 0. The offending code is below.
$expression = "f(a,b,c)";
@variables = split /[\(\),]/, substr( $expressions, 1);
I strip off the first charactor from the string and split around () and ,. The
contents of @variables is now ('', a, b, c). What causes this? This was a hard
bug to track down. While I could write some code to remove the '' from the
list, I would rather know why the first element is undefined. Do I need to
change my regexp? If so, what would provide the match I want i.e (a, b, c)?
Thanks, Matthew
--
It has long been an axiom of mine that the little things are infinitely the most
important. -- Sir Arthur Conan Doyle, "A Case of Identity"
------------------------------
Date: Mon, 13 Sep 1999 15:03:21 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Question about split
Message-Id: <Zm8D3.7855$N77.625983@typ11.nn.bcandid.com>
In article <7rj2ql$4ta$1@solaris.cc.vt.edu>,
Matthew Miller <namille2@REMOVE.vt.edu> wrote:
>I'm working on a program and I'm having some problems with the split function.
>What happens is split returns a list that contains an undefined element at
>position 0. The offending code is below.
>
>$expression = "f(a,b,c)";
>@variables = split /[\(\),]/, substr( $expressions, 1);
I note that you're taking a substring from $expressions. What is in
$expressions? I take it this code isn't cut-and-pasted?
You are unnecessarily backslashing () in [].
>I strip off the first charactor from the string and split around () and ,. The
>contents of @variables is now ('', a, b, c). What causes this?
Well, there is a null string before the first (, so split gives it to you.
perl -e 'print ((map { "<$_>" } split /x/, "xyzxyzx"), "\n")' gives
<><yz><yz>
It is emphatically *NOT* an undefined element. It is well-defined as
being the empty string.
Note that split doesn't give you the null string after the last x in
the above string.
This behavior is described in the first two lines of text in 'perldoc
-f split'.
> This was a hard
>bug to track down. While I could write some code to remove the '' from the
>list, I would rather know why the first element is undefined. Do I need to
>change my regexp? If so, what would provide the match I want i.e (a, b, c)?
I don't know the answer to that.
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 13 Sep 1999 09:06:29 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Regular Expresions
Message-Id: <Pine.GSO.4.10.9909130902340.19013-100000@crusoe.crusoe.net>
[posted & mailed]
On Sep 13, Rory C-L blah blah blah:
> Sorry to be a bother, but could you point me to the modules in question?
> The module 'long list' is rather awe-inspiring for a beginner.
Not a bother at all.
HTML::Parser
HTML::LinkExtor
Those modules will also direct you to others.
--
jeff pinyan japhy@pobox.com
perl stuff japhy+perl@pobox.com
CPAN ID: PINYAN http://www.perl.com/CPAN/authors/id/P/PI/PINYAN
------------------------------
Date: Mon, 13 Sep 1999 14:13:00 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: Searching by date problem.
Message-Id: <MD7D3.936$814.64075@typhoon01.swbell.net>
In article <MPG.12464835178f56b8989f44@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>In article <P%%C3.761$814.51277@typhoon01.swbell.net> on Mon, 13 Sep
>1999 05:32:31 GMT, Benjamin Franz <snowhare@long-lake.nihongo.org>
>says...
>> In article <7rhpa7$ipm$1@m2.c2.telstra-mm.net.au>,
>> Adtec <adtec@vic.bigpond.net.au> wrote:
>...
>> >I'm asking the user to enter a date at the prompt, (dd/mm/yy)
>>
>> I hope you meant dd/mm/yyyy....
>
>Why, he asked, naively but in all seriousness?
>
>...
>
>> Yah. What you want to do is prepend each line with the date formatted
>>
>> yyyymmdd Data goes here
>
>Just because an explicit year designation is needed here for efficient
>sorting or lookup, that is no reason to demand it from the user.
>
>Why add to the confusion between internal and external representations,
>as your 'I hope you neant dd/mm/yyyy....' comment does? There will be
>no ambiguity in most problem domains. In those few where there is
>ambiguity, your comment is appropriate, and unambiguous input is
>required.
Because this kind of thinking is what _led_ to the issue in the
first place. 'Ah. It's a restricted problem. No need to solve
the general case.' If you take the extra time up front, you
don't get burned 25 years later when your assumptions are
violently violated. How do you know, for example, that _historical_
data will never be input into his system? Or future data?
"Ok - long term projections go to 2090..."
"Let's see, we are entering people's birth dates..."
My great-grandmother was born in 1896. She only died about 8 years
ago. I remember a recent case from Sweden of a 100+ year old man who
recieved notices regarding his 'upcoming' enrollment into elementary
school....
--
Benjamin Franz
------------------------------
Date: 13 Sep 1999 14:23:46 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Searching by date problem.
Message-Id: <slrn7tq27i.8c8.sholden@pgrad.cs.usyd.edu.au>
On Mon, 13 Sep 1999 14:13:00 GMT, Benjamin Franz
<snowhare@long-lake.nihongo.org> wrote:
>In article <MPG.12464835178f56b8989f44@nntp.hpl.hp.com>,
>Larry Rosler <lr@hpl.hp.com> wrote:
>>In article <P%%C3.761$814.51277@typhoon01.swbell.net> on Mon, 13 Sep
>>1999 05:32:31 GMT, Benjamin Franz <snowhare@long-lake.nihongo.org>
>>says...
>>> In article <7rhpa7$ipm$1@m2.c2.telstra-mm.net.au>,
>>> Adtec <adtec@vic.bigpond.net.au> wrote:
>>...
>>> >I'm asking the user to enter a date at the prompt, (dd/mm/yy)
>>>
>>> I hope you meant dd/mm/yyyy....
>>
>>Why, he asked, naively but in all seriousness?
>>
>>...
>>
>>> Yah. What you want to do is prepend each line with the date formatted
>>>
>>> yyyymmdd Data goes here
>>
>>Just because an explicit year designation is needed here for efficient
>>sorting or lookup, that is no reason to demand it from the user.
>>
>>Why add to the confusion between internal and external representations,
>>as your 'I hope you neant dd/mm/yyyy....' comment does? There will be
>>no ambiguity in most problem domains. In those few where there is
>>ambiguity, your comment is appropriate, and unambiguous input is
>>required.
>
>Because this kind of thinking is what _led_ to the issue in the
>first place. 'Ah. It's a restricted problem. No need to solve
>the general case.' If you take the extra time up front, you
>don't get burned 25 years later when your assumptions are
>violently violated. How do you know, for example, that _historical_
>data will never be input into his system? Or future data?
The fact that the date was specified at dd/mm/yy indicates that it is
dealing with 'current' dates not 'historical' dates...
14/9/99 obviously means 14/9/1999 if I entered it now. 14/9/12 is more
ambiguous but that can be solved by checking if we are entering past
dates or future dates and the program can compensate.
>
>"Ok - long term projections go to 2090..."
Which would be entered as 14/9/90 now, since it is a projection and hence
a future date. No ambiguity at all. If it was 2101 then it would be entered
as 14/9/2101 since people would think 01 was 2001.
>
>"Let's see, we are entering people's birth dates..."
>
>My great-grandmother was born in 1896. She only died about 8 years
>ago. I remember a recent case from Sweden of a 100+ year old man who
>recieved notices regarding his 'upcoming' enrollment into elementary
>school....
Then her birth date would be entered as ??/??/1896. If she was born four
years later then ??/??/00 would do just fine thanks.
There is no problem with this. This is simple a user interface. When I fill
out a deposit spip at my bank I enter the year as 99. The bank understands
what I mean. Next year I'll write it as 00. The bank will still understand
what I mean.
There is a difference between a user interface and data storage. Of course the
dates will be stored as 1999 and 2000 respectively (or 99 and 100 or whatever
offset the bank uses).
I would not be happy if every date I had to enter had to have a four digit
year. It would slow me down bu at least half (since 99 and 00 are so easy and
thus fast for slow typers like me to type).
Computers are there to work. Let them add the context when it is obvious what
it should be.
--
Sam
Remember that the P in Perl stands for Practical. The P in Python
doesn't seem to stand for anything.
--Randal Schwartz in <8cemsabtef.fsf@gadget.cscaper.com>
Sam
It is inappropriate to require that a time represented as seconds
since the Epoch precisely represent the number of seconds between
the referenced time and the Epoch
--IEEE Std 1003.1b-1993 (POSIX) Section B.2.2.2
------------------------------
Date: Mon, 13 Sep 1999 14:03:13 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Text::FixedRecField - proposal for new module.
Message-Id: <Bu7D3.7669$N77.618397@typ11.nn.bcandid.com>
In article <19990912145737.29234.00002462@ngol04.aol.com>,
RonaldWS <ronaldws@aol.com> wrote:
> . . .
>Note that we expect PHONE_NUMBER in the examples above to
>be a constant declared with "use constant" or "use enum".
> . . .
>I am therefore proposing a solution that would allow efficient
>access to fields in fixed length records by field name. I do
>module development part time but, if there is interest, I could
>probably have something ready for testing sometime in (late) November.
Here's my hack at it. First a sample program that uses it:
#!/usr/bin/perl -w
use strict;
use lib '.';
use Fixlen;
my $rec = 'Kragen Javier Sitaker ';
my @rec;
tie @rec, 'Fixlen', \$rec, 0, 10, 20, 30;
print "rec[0] is $rec[0]; rec[1] is $rec[1]; rec[2] is $rec[2]\n";
print "rec[3] is $rec[3];\n";
# print "rec[4] is $rec[4]; oops!\n";
$rec[1] = "J.";
print "rec[1] is $rec[1]; rec[2] is $rec[2]\n";
print "rec is $rec\n";
Explanation: the numbers I passed in indicate where fields begin. The
last number indicates the end of the string; in order to force the
record to really be fixed-length, that field cannot be assigned to,
since the module has no way of knowing how long it's supposed to be.
So it's a good idea to let it be the length of the string.
You can, as you suggested above, 'use Constant' to give you symbolic,
rather than numeric, field names.
$rec[1] = "J." requires some explanation; we're putting a two-character
string in a 10-character field. The traditional way of handling this
is to pad the field with blanks on the right; that is the solution I
have adopted in the module below.
Here's Fixlen.pm.
# Perl module to allow access to fixed-length fields of a string as if the
# string was an array.
package Fixlen;
use Carp;
use strict;
# field 0 is between char positions $self->[1] and $self->[2]
# max field number is $#$self-1; it can only be read.
sub TIEARRAY {
my ($class, $stringref, @lengths) = @_;
return bless [$stringref, @lengths], $class;
}
sub FETCH {
my ($self, $i) = @_;
if ($i > $#$self - 1) {
croak "Out of bounds Fixlen fetch: index $i > " .($#$self-1);
} elsif ($i == $#$self-1) {
return substr ${$self->[0]}, $self->[$i+1]; # to end of string
} else {
return substr ${$self->[0]}, $self->[$i+1],
$self->[$i+2] - $self->[$i+1];
}
}
sub STORE {
my ($self, $i, $val) = @_;
if ($i > $#$self - 1) {
croak "Out of bounds Fixlen store: index $i > " .($#$self-1);
} elsif ($i == $#$self-1) {
# if we allow this, there will be no way to prevent users
# from accidentally changing the length of the last field.
# accordingly, you should specify the position of the end
# of the last field when you create the Fixlen.
croak "Attempt to modify last element in Fixlen ($i $val)";
} else {
my $len = $self->[$i+2] - $self->[$i+1];
if (length $val > $len) {
carp "Attempt to insert '$val' into field of length $len" if $^W;
$val = substr $val, 0, $len;
} elsif (length $val < $len) {
$val .= ' ' x ($len - length $val);
}
substr(${$self->[0]}, $self->[$i+1], $len) = $val;
}
}
1;
(End of Fixlen.pm.)
I note that it took me about half an hour, mostly because I'd never
written a tie module before, and you were planning on a seven-week
schedule; perhaps you had something fancier in mind?
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 09 1999
60 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 13 Sep 1999 13:20:47 GMT
From: Paul Leduc <pleduc@your_finger.home.com>
Subject: Re: thanks!! parsing a record at specific columns
Message-Id: <37DCF9B6.9DDBCF3E@your_finger.home.com>
Thanks for the very prompt replies!!
--
Paul Leduc - pleduc@home.com
(remove YOUR FINGER from my address when replying)
------------------------------
Date: Mon, 13 Sep 1999 15:25:45 +0200
From: Georg Weissenbacher <georg.weissenbacher@altavista.net>
Subject: Re: where to write perl???
Message-Id: <37DCFB59.CB1EEAF3@altavista.net>
A really good editor for Perl is XEmacs (www.xemacs.org).
It is available for WinXX, too, and it is free (GPL).
According Linux: You should buy a distribution that is
really easy to install (e.g. SuSE Linux || RedHat).
cu,
Georg
Andy Huang wrote:
>
> when i write C/C++ , i use either Borland or microsoft compiler, but i never
> see any compiler for perl, some one told me develop it under win32, but it
> is going to be extremely difficult without any editor's help. Some one tell
> me to install linux, but i have tried so many times to install linux and
> failed, please tell me a easiet way to develop perl thanx man.
------------------------------
Date: Mon, 13 Sep 1999 14:43:09 GMT
From: nospam@all.uk (G Crowder)
Subject: Re: Why perlcrt.dll needed?
Message-Id: <7riv1h$ggs$1@glencoe.hw.ac.uk>
>I notice that my Perl/Tk programme now requires perlcrt.dll when it is
>run as an exe generated by perl2exe. I don't know which of the latest
>additions to the programme triggered this but I'm curious to know.
Embarrassing as it is to answer one's own post, I found the answer in
the docs (more embarrassment) and it is the use of Sockets that
requires the perlcrt.dll.
------------------------------
Date: Mon, 13 Sep 1999 13:51:46 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Will an apology end this mess?
Message-Id: <Sj7D3.349$n82.59595@news.shore.net>
Jonathan Stowe <gellyfish@gellyfish.com> wrote:
: Cool, I get to kill-file two dick-heads for the price of one.
: *plonk* *plonk*
Who cares? You want to kill-file them, kill-file them. Why should it
matter to the rest of us?
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Mon, 13 Sep 1999 10:19:15 -0400
From: shapirojNOSPAM@logica.com
Subject: Re: Win32::MAPI problem - reading and sending
Message-Id: <MPG.1246d1f0af77b6cc989680@news>
In article <FHvA0G.6nD@news.boeing.com>, ryan.h.bark@boeing.com says...
> Where is the Win32::MAPI module? I can't find it anywhere?
>
http://www.Generation.NET/~aminer/Perl/
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 776
*************************************