[13897] in Perl-Users-Digest
Perl-Users Digest, Issue: 1341 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 10 14:10:34 1999
Date: Wed, 10 Nov 1999 11:10:21 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942261021-v9-i1341@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 10 Nov 1999 Volume: 9 Number: 1341
Today's topics:
OO question <schmickl@magnet.at>
Re: Perl & Internal Date on Wintel (Eisen Chao)
Re: Perl and commonsense part 2 (M.J.T. Guy)
Re: perl as first language? (Tad McClellan)
Re: perl as first language? salvadorej@my-deja.com
Re: Perl Extensions. Arrgh. <dan@tuatha.sidhe.org>
Re: Perl Wizards <AgitatorsBand@yahoo.com>
Re: Perl Wizards (Kragen Sitaker)
perl_call_method and method existance <yacob@rcn.com>
Re: PERLHUMOR: self-printing resume (Chris Nandor)
Re: PERLHUMOR: self-printing resume (Kragen Sitaker)
Re: PERLHUMOR: self-printing resume <mhc@Eng.Sun.COM>
Re: Portable Perl Code (Chris Nandor)
printing 2 character hex as one byte binary? Lawrence.Lifshitz@ummed.edu
regular expression to parse html out <removethis_vod@writemail.com>
Re: replace " " with (Paul W. Hanbury, Jr.)
Re: replace " " with (Kragen Sitaker)
Re: script dumps core <eedalf@eed.ericsson.se>
Re: script dumps core (Kragen Sitaker)
Splitting at 255 bytes <bholdren@linkohio.com>
Re: urgent help please <AgitatorsBand@yahoo.com>
Re: Using Perl to fill in html fields (Randal L. Schwartz)
Re: Virus (Kragen Sitaker)
Re: weird bugs? (Kragen Sitaker)
Re: win32 timer/timeout workaround using perl/tk (Kragen Sitaker)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 10 Nov 1999 18:59:42 +0100
From: "Thomas Schmickl" <schmickl@magnet.at>
Subject: OO question
Message-Id: <80cc16$3do$1@newsmaster01.magnet.at>
Hi,
I have read the PERL OO-tutorials wrote by TC in the documentation and started a restructuring of my classes to fit those standards.
So I want to prevent public direct access to my objects attributes by writing Get/Set methods.
Instead of "$obj->{'filename'}= $a_filename;" I now have "$obj->filename($a_filename);".
This was easy done but I have more complicated objects.
For example I have a structure like this (I hope it looks like a tree):
$self
|------->@tagnames
|------->%tagname
|------->$pos_count
|------->%pos_index
| |-------->$start_pos
| |-------->$end_pos
|------->$arg_count
|------->%arg_index
|------>$arg_name
|------>$arg_type
|------>$arg_value
...
I use this to store information about tags and each tag can have several areas which all have one start and one end positions. Maybe
this could be stored better and I know I could create a own class called Tag and another one called tagPosition which are more flat,
but this would be an overkill.
My question is:
What would be a good way to have Get/Set methods for this kind of attributes:
You have to be able to set/delete Tags, To retrive tagnames and if a Tag exists, you have to be able to do the same thing with the
positions of a tag and their arguments.
I started to design the thing on a piece of papaer but I ended up with a bunch of methods (more than 30) and to replace about 10
line of codes where the attributes are directly set now.
Is there any major rule how this is being done normally ?
Thanx, thomas.
------------------------------
Date: Wed, 10 Nov 1999 17:43:44 GMT
From: echao@interaccess.com (Eisen Chao)
Subject: Re: Perl & Internal Date on Wintel
Message-Id: <s2jbmgnhsq43@corp.supernews.com>
Martien,
At the risk of appearing more of a dumb-ass than
already demonstrated, I've returned to e-mail
myself your documentation examples below.
Seems I forgot to write it down before leaving (duh).
Thanks Very Muchly
Eisen
Martien Verbruggen (mgjv@wobbie.heliotrope.home) wrote:
:
: both contain a full description of localtime
:
: C:\DOS> perldoc -f localtime
: C:\DOS> perldoc perlfunc
: C:\DOS> perldoc perldoc
:
: C:\WINDOWS> clickety->open(Start->Programs->Activestate documentation)
: C:\WINDOWS> clickety->NetscapeOpen(perlfunc-link)
:
------------------------------
Date: 10 Nov 1999 18:04:30 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Perl and commonsense part 2
Message-Id: <80cc3e$hf1$1@pegasus.csx.cam.ac.uk>
In article <80bur7$s5n$1@nnrp1.deja.com>, <ajmayo@my-deja.com> wrote:
> It would have helped if perl -w had rejected
>
>$a=\(1,2,3);
>
>but this is legal and will be silently accepted, even though what it
>appears to return is a reference to the scalar value 3.
This is a bug which has recently been discussed on p5p. Despite
what the FAQ says, the argument to \ is always evaluated in list
context[*], rather than the context in which it is evaluated. If it
were evaluated is scalar context as it ought to be, you would have
got "Useless use of ..." warnings.
When / if the bug will get mended, I dunno.
[*] Except in the syntactically special case when the argument is
an array or a hash.
Mike Guy
------------------------------
Date: Wed, 10 Nov 1999 05:54:13 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: perl as first language?
Message-Id: <slrn82ijml.r3f.tadmc@magna.metronet.com>
On Wed, 10 Nov 1999 06:05:22, Andrew Johnson <andrew-johnson@home.com> wrote:
>In article <slrn82huq8.6es.abigail@alexandra.delanet.com>,
> Abigail <abigail@delanet.com> wrote:
>[snip]
>! I think this group shows clearly Perl is not a suitable first language.
>
>hmm, I think this group shows more clearly that clpm is not a
>suitable first usenet group.
^^^^^^^^^^^^^^^^^^^^^^^^^^^
For those of you playing along at home who might be wondering
what _is_ a suitable first usenet group, that would be:
news.announce.newusers
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 10 Nov 1999 18:29:58 GMT
From: salvadorej@my-deja.com
Subject: Re: perl as first language?
Message-Id: <80cdj2$88i$1@nnrp1.deja.com>
> Seriously though, you *can* write very clean code in Perl, but to do
so
> you need a deep understanding of the traps, snares, and bottomless
pits
> of the language, in order to navigate around them. And that deep
> understanding is precisely what beginners don't have, and why they
> blunder into trouble.
>
> Of course, I'm coming from the point of view of someone who daily
> struggles to teach large classes (300+) of absolute novices how to
> program. I have ceased to be astounded at how easily subtleties of
> syntax and semantics can hopelessly befuddle them.
>
> Which is why I'm currently supervising a PhD project that has looked
> at these very issues. We just presented a paper:
>
> McIver, L and Conway, D.M., "Grail: A Zeroth Programming
Language",
> Proc. International Conference on Computers in Education '99.
>
> in which we describe a minimalist introductory language that avoids
> most of the problems of syntactic and semantic "ropiness".
Hmmmm. Where can those of us interested in educating beginers find
out more?
==================================================================
Email: iowa_so8ng@hot8mail.com
Remove eights to reach me by email
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 10 Nov 1999 18:11:44 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl Extensions. Arrgh.
Message-Id: <AziW3.2915$c06.24415@news.rdc1.ct.home.com>
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
> [A complimentary Cc of this posting was sent to Dan Sugalski
> <dan@tuatha.sidhe.org>],
> who wrote in article <7j1W3.2655$c06.23147@news.rdc1.ct.home.com>:
>> >> Nope. void in XS isn't the same as void in C. It means either "Go figure
>> >> out if I'm returning an SV". In this case it's OK. Better to be explicit
>> >> with a return type of SV *, but not an error.
>>
>> > I do not think you are right. Given CODE/PPCODE without output,
>> > return value specificator is most probably ignored.
>>
>> > How would you think RETVAL is going to be declared in your example?
>>
>> If you'll notice, I added in an OUTPUT: RETVAL to the example.
> I noticed. But my remark still stands: what do you think is the
> declaration of RETVAL? It is C, not Perl, variables have types...
It's not C, it's XS. C with a heap of funky preprocessing done.
>> The use of void to mean "well, go guess" is mildly depricated at this
>> point
> I "mildly depricated" it *several years* ago. Though probably we can
> continue supporting it for some more time.
We probably ought to just take it out of the docs entirely then, as on the
whole you're best off setting the return type properly.
Dan
------------------------------
Date: Wed, 10 Nov 1999 17:46:05 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Perl Wizards
Message-Id: <xbiW3.203$wJ6.41533@news.shore.net>
Nobody <nobody@logica.com> wrote:
: grep(m!$/bin/(.{10}) ! && $ps{$1}++, &safe_backtic("ps -ef"));
: I don't understand the first pattern matching statement (or if it is a
: pattern matching statement !) m! ....!
m! ... ! is indeed a pattern match. Although / .... / is the default way
of doing this, using the "m" allows you to choose different delimiters.
: Also are the results of this pattern matching being back substituted into
: $ps{$1} ??
Yes; or, more specifically, the items contained in the first set of parens
(i.e. ".{10}") get put into $1.
: Any help from perl wizards out there would be useful ..
No wizardry needed. See perldoc perlre and perldoc perlop for more info.
Hope this helps.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Wed, 10 Nov 1999 18:01:20 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Perl Wizards
Message-Id: <QpiW3.64253$23.2521756@typ11.nn.bcandid.com>
In article <80c49t$9r2@courier.xilinx.com>,
Jeff Stampes <stampes@xilinx.com> wrote:
>Please try and select more useful subject lines. This is not a
>question for a 'wizard', and indeed most 'wizards' will likely
>ignore it, or flame you for using such a poor subject line.
I"m not a wizard either.
>Nobody <nobody@logica.com> wrote:
>: grep(m!$/bin/(.{10}) ! && $ps{$1}++, &safe_backtic("ps -ef"));
>
>Let's see...this seems very strange to me...It is a pattern match, they
>are simply using m!! instead of m// so they won't have to escape their
>slashes. That part is easily understood.
>
>However, I'd be surprised if this works as expected. The match, as I
>understand it, is looking for an occurance of $/ (input record
>separator), followed by 'bin/' and then ten characters and a space.
Yes -- most bizarre. Presumably this is meant to match a user with an
8-char username that starts with 'bin/' -- an atypical string with
which to start a username, for sure. (It has to be 8-char -- at least
on Solaris, where the usernames in the first column are
right-justified.) Perhaps the $ is a mistake -- in that case, they
could be looking for commands in a bin directory.
Looks like crappy code to me, but maybe it's really good code doing
something I don't understand.
>I honestly have not seen the syntax above before though. Could
>someone help explain it? Specifically, what is it saying to use
>that && and a second expression in the grep?
x && y is evaluated as follows:
- x is evaluated. If it evaluates to false, its result is the result of the whole
expression.
- otherwise, y is evaluated, and its result is the result of the whole expression.
Normally grep is used to extract a subset of a list that satisfies some
pattern. The subset extracted in this case would be those items that
contained a '$/bin/.{10} ' and where those ten chars had been
encountered previously so $ps{$1} was positive before that one was
processed. This seems like a highly dubious thing to want, so my guess
would be that the result of the grep is thrown away, and the author
should have done a foreach loop instead.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 10 Nov 1999 18:43:57 GMT
From: Daniel Yacob <yacob@rcn.com>
Subject: perl_call_method and method existance
Message-Id: <80cedd$8nr$1@nnrp1.deja.com>
Greetings,
Is there a way to check if a method exists before calling it with
"perl_call_method"? I would like to not call the method and get warns
if the user didn't provide the callback.
thanks in advance,
/Daniel
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 10 Nov 1999 17:40:19 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: PERLHUMOR: self-printing resume
Message-Id: <pudge-1011991240230001@192.168.0.77>
In article <7veW3.4950$oW2.21248@news2.atl>, "Brian Landers"
<bcl914@bellsouth.net> wrote:
# Uri Guttman <uri@sysarch.com> wrote in message
# news:x7hfivylsg.fsf@home.sysarch.com...
# > >>>>> "BL" == Brian Landers <bcl914@bellsouth.net> writes:
# >
# >
# > BL> #!/usr/bin/perl
# > BL> # --------------------------------------------------------------
# >
# > no -w nor strict!
#
# Judgement call. I turned off warnings to stop a particular warning from
# allowing me to use the formatting I wanted to.
It is almost always better to fix your code instead. Or to catch the warning.
# Also, many people recommend
# leaving -w off in production code
Many people also recommend professional wrestling for the purposes of
entertainment.
# (I refuse to get into an argument about
# that one).
I don't think you do. You are making an argument for why you did what you
did, and included this as part of your argument. You _are_ about that
one.
# I always use strict, but in this case I removed it when the app was done for
# asthetics sake.
Consider, though, with both -w and strict, that a clued potential employer
(or geek asked by an employer to review the resume) may very well think
that without -w and strict that it is insufficient and incomplete. Better
in almost every case to add it; you are, after all, trying to impress the
employer. I cannot imagine any employer (at least, none I would consider
working for) saying, "he used -w and strict, we can't hire him!" I can
imagine the opposite.
# > BL> $work{ "1. SAPIENT CORPORATION" } = {
#
# > you sort on that key but if you ever get more than 10 jobs, it will not
# > work.
# >
#
# True, true...but I needed a quick way to make the keys come out in the order
# I inserted them.
Don't worry about it, just sort {$a <=> $b} and you are set. It doesn't
matter that the whole thing is not numerical, <=> is smart enough to only
take the numerical portion of the string from the beginning to the end.
#!perl -wl
@a = (' 2', 1, '3. Something', '0004');
{ local $^W;
print join "\n", sort { $a <=> $b } @a;
}
Of course, this is another -w issue. Oh well, I use local $^W a lot.
Lexical warnings will be better.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Wed, 10 Nov 1999 18:38:20 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: PERLHUMOR: self-printing resume
Message-Id: <wYiW3.64391$23.2526435@typ11.nn.bcandid.com>
In article <7veW3.4950$oW2.21248@news2.atl>,
Brian Landers <bcl914@bellsouth.net> wrote:
>Uri Guttman <uri@sysarch.com> wrote in message
>news:x7hfivylsg.fsf@home.sysarch.com...
>> >>>>> "BL" == Brian Landers <bcl914@bellsouth.net> writes:
>> BL> my( %work );
>> BL> $work{ "1. SAPIENT CORPORATION" } = {
>
>> you sort on that key but if you ever get more than 10 jobs, it will not
>> work.
>>
>
>True, true...but I needed a quick way to make the keys come out in the order
>I inserted them. If I had more than 10 jobs I would do (01. 02. etc.)
Couldn't you do 1. 2. etc. instead? That would be more pleasing to the eye.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 10 Nov 1999 10:43:53 -0800
From: Mike Coffin <mhc@Eng.Sun.COM>
Subject: Re: PERLHUMOR: self-printing resume
Message-Id: <8p6emdyqj9y.fsf@Eng.Sun.COM>
abigail@delanet.com (Abigail) writes:
> Well, it's documented at the most obvious place: perldoc -f sort.
"Hmmmm.. I wonder if $a or $b are somehow special in Perl. Let's
see: the index of the Camel book doesn't have anything relevant under
'a', 'b', '$a', or '$b'. And neither 'perldoc \$a' nor 'perldoc \$b'
return anything....
"However, just to be sure, I'll type 'perldoc -f sort'; maybe
$a and $b are documented there."
-mike
------------------------------
Date: Wed, 10 Nov 1999 17:29:06 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Portable Perl Code
Message-Id: <pudge-1011991229100001@192.168.0.77>
In article <3828B866.54447E45@ticom-geo.com>, Steven Glicker
<sglicker@ticom-geo.com> wrote:
# I would greatly appreciate knowing how one typically writes portable
# code in Perl in cases where a function (say alarm) exists in Linux but
# not in Windows. In C this is typically handled at compile-time with
# #ifdef's. Is there a convention for handling this (at run-time) in Perl?
In addition to the suggestions here, you may want to check the perlport
man page for more tips and an overview of writing portable Perl code.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Wed, 10 Nov 1999 17:36:21 GMT
From: Lawrence.Lifshitz@ummed.edu
Subject: printing 2 character hex as one byte binary?
Message-Id: <80cael$5rl$1@nnrp1.deja.com>
OK, I think is different from the slew of questions about
how to convert hex to "binary". I read in an ascii description
of a hex number (eg, "f4"). I then want to save it to a file
as the one byte "binary" equivalent (ie, the number 244 stored
in one byte). I tried doing $decimal = hex($hexstring) which
converts f4 to 244. But when I try to print it out it always comes
out as the ascii string "244". I tried syswrite $decimal+0,1
figuring the +0 would force conversion from a string to a number
and then I'd write that 1 byte out, but all I get is the first
character of the string (ie, "2"). So, what am I missing?
Thanks.
Larry
btw, I am actually reading in many 2 character hex numbers and trying
to convert each to one character binary. Then writing them all out.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 11 Nov 1999 00:35:54 +0530
From: vod <removethis_vod@writemail.com>
Subject: regular expression to parse html out
Message-Id: <3829C212.CCE9D2D4@writemail.com>
Hello,
Before u say anything, i want to say that
i know it may not be wise but never the less i am trying to make a
small search script for my web-site. I want the script to search
thru the .htm* pages but only the text that is outside the html tags,
i.e. that is outside < > tags.
At the moment i have the script ready that searches all the page
blindly what i was hoping to make a regular expression that could
eliminate html tags < >.
Basically i think the reg ex has to look for any word starting
with "<" followed by anything and ending with ">".
I am not very good at reg exes so i was hoping to find a
a reg exes from anyone of u guys/girls that would do the needfull
i.e. elimiate html tags in a .html page.
Thats it.
V0D
------------------------------
Date: Wed, 10 Nov 1999 18:51:54 GMT
From: pwhst@pitt.edu (Paul W. Hanbury, Jr.)
Subject: Re: replace " " with
Message-Id: <3829bdb0.186111484@usenet.pitt.edu>
On Wed, 10 Nov 1999 11:09:57 -0500, "Curtis Jones"
<curtisj@bannerfusion.com> wrote:
>For each item in the array @list, it globally replaces all occurences of " "
>with " ".
>
>I hope.... :-)
>
>my $lcnt = -1;
>foreach ( @list ) {
> $lcnt++;
> $list[$lcnt] =~ s/ /\ /g;
> print $list[$lcnt] . "\n";
>}
>
>-Curtis
>
>
Actaully, that will change all of the spaces in
the string to ' '. Blair asked for the following.
>> Basically if i had the line (without quotes) " Hello World!" I would
>want
>> the code to change it to " Hello World!".
>>
>> Thanks,
>> Blair
>
Try the following:
#! /bin/perl -w
use strict;
use vars qw<$string>;
$string = " Hello World";
$string =~ s/^( *)/' ' x length $1/e;
print $string, "\n";
__EOF__
You can build the loop yourself.
Paul
------------------------------
Date: Wed, 10 Nov 1999 18:13:04 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: replace " " with
Message-Id: <QAiW3.64327$23.2523813@typ11.nn.bcandid.com>
In article <003f01bf2b96$09903e00$8b00000a@aascatl.com>,
Curtis Jones <curtisj@bannerfusion.com> wrote:
>For each item in the array @list, it globally replaces all occurences of " "
>with " ".
Several other people already gave correct answers. Your answer was incorrect.
>I hope.... :-)
And you didn't even test it?
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 10 Nov 1999 18:06:43 +0100
From: Alex Farber <eedalf@eed.ericsson.se>
Subject: Re: script dumps core
Message-Id: <3829A623.6D564D62@eed.ericsson.se>
Hi Maarten,
Maarten Veerman wrote:
> $database = "data.db";
I'd specify the full path.
Maarten Veerman wrote:
> $db = tie(%hash, "DB_File", $database, O_CREAT|O_RDWR, 0666);
die "Can not tie $database: $!" unless $db;
I have also read on the p5p-list that it is better to use
$db = tie(%hash, "DB_File", $database, O_CREAT|O_RDWR|O_EXCL, 0666);
since DB_File unfortunately reads some data _before_ locking. But
it would only be useful if just once - when the file is being created
(man 2 open: "If O_CREAT is not set, the effect of O_EXCL is undefined")
Does anyone have comments on this matter?
> sub unlock {
> $db->sync; # to flush
> if ($use_flock eq "1") {flock(DB_FH, LOCK_UN);}
I think calling flock DB_FH is not needed - the lock is being
released on close(). And if you comment this line out then you
won't need the $db->sync() also since close() normally (man 2 close:
unless O_NONBLOCK or O_NDELAY flags set by ioctl) flushes the stream.
> undef $db;
> close(DB_FH);
> }
Regards
/Alex
------------------------------
Date: Wed, 10 Nov 1999 17:45:07 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: script dumps core
Message-Id: <DaiW3.64060$23.2520628@typ11.nn.bcandid.com>
In article <3829A3F9.D07DA774@eed.ericsson.se>,
Alex Farber <eedalf@eed.ericsson.se> wrote:
>Maarten Veerman wrote:
>> $db = tie(%hash, "DB_File", $database, O_CREAT|O_RDWR, 0666);
>
>die "Can not tie $database: $!" unless $db;
>
>I have also read on the p5p-list that it is better to use
>$db = tie(%hash, "DB_File", $database, O_CREAT|O_RDWR|O_EXCL, 0666);
>since DB_File unfortunately reads some data _before_ locking.
>Doe anyone have comments on it?
open(file, mode|O_CREAT|O_EXCL) fails if the file already exists. Is
that what O_EXCL means with DB_File's TIEHASH? (i.e. have you tested
your code?)
I am very interested to hear about DB_File's reading problem.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 10 Nov 1999 14:00:17 -0500
From: Thomas Brian Holdren <bholdren@linkohio.com>
Subject: Splitting at 255 bytes
Message-Id: <942261351.1424554723@news.linkohio.com>
Dear Perl Gentlemen/Ladies,
I know, of course, this is a silly question. I have looked through the docs
for pack, unpack, join, split, and substr. I cannot find details for what I
want to do.
All I want to do is... I have a big long $string. I want to break it up into
an @array, every 255 bytes for entry into mySQL. I have tried unpack with A,
but it only gets the first section (which the perl book said it would) like so:
@array = unpack 'A255', $string;
but only one element gets returned. *sigh*. I know I could probably do some
ugly hack with substr, but I want to make this code efficient.
Can anyone please help or point me to a FAQ/URL/Camel page. I have even tried
the data manipulation FAQ, strings section, extracting columns part. It said
"use unpack". An example would have been nice.
Thanks you very much in advance.
Sincerely,
Thomas B. Holdren, if ($anyone_cares) { print "Just another perl newbie." }
------------------------------
Date: Wed, 10 Nov 1999 17:49:15 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: urgent help please
Message-Id: <veiW3.204$wJ6.41533@news.shore.net>
Samadhi <samadhi@latinmail.com> wrote:
: Hi, I want to convert a string like this: "sample line 01<br>sample
: line
: 02<br>etc" in this other (to send a e-mail):
: sample line 01
: sample line 02
: etc
s/<br>/\n/g;
: can you help me please please please please?
you're welcome you're welcome you're welcome.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: 10 Nov 1999 10:03:16 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Using Perl to fill in html fields
Message-Id: <m13duez0kb.fsf@halfdome.holdit.com>
>>>>> "Greg" == Greg Bacon <gbacon@ruby.itsc.uah.edu> writes:
Greg> Heh. :-)
Egah! Bad abbrev macro. *Bad* abbrev macro. No dessert tonight.
print "Just another Perl hacker,";
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Wed, 10 Nov 1999 17:37:11 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Virus
Message-Id: <b3iW3.64055$23.2518983@typ11.nn.bcandid.com>
In article <slrn82ija4.6es.abigail@alexandra.delanet.com>,
Abigail <abigail@delanet.com> wrote:
> undef $/;
This should probably be local $/; undef $/ in a BEGIN is likely to make
most Perl scripts fail to run properly.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 10 Nov 1999 18:43:22 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: weird bugs?
Message-Id: <e1jW3.64406$23.2527225@typ11.nn.bcandid.com>
In article <slrn82kp70.7c.GiN@Avelon.net>, GiN <wablief@freemail.org> wrote:
>2 examples:
>
>i opened a socket "S"
>
>print S "HEAD \/ HTTP\/1.0\n\n"; # http
>and
>print S ".\n"; # (e)smtp
>
>if i do this in C, it works.
>but in perl it doesn't. i think the server couldn't get the "\n" so it
>just waits
>
>who can tell me what i'm doing wrong?
Are you autoflushing S? use IO::Handle; autoflush S 1;
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 10 Nov 1999 18:10:17 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: win32 timer/timeout workaround using perl/tk
Message-Id: <dyiW3.64319$23.2523421@typ11.nn.bcandid.com>
In article <38299353.62AA4D32@home.com>,
Darrin H <dthusma@home-del.com> wrote:
>Being it is a WORKAROUND, KISS applies, ie: if it works, no fancy stuff.
>
>In essence, it uses the tk command AFTER and runs a delta timer against
>the
>timeout(maxruntime) value. If a user wishes to reset this timeout (ie:
>cancel it),
>(s)he just sends across alarm2(0,$top).
after commands normally get run the next time you go into the event
loop after the command is scheduled, right? So this won't interrupt
any long-running system call, right?
>Here is ye olde code
>----------------------------------------------------------------
>use Tk;
>
>sub alarm2 {
> #($maxruntime)=@_;
> if ($maxruntime == 0 ) {
Is $maxruntime inherited from an enclosing scope? I don't see how it
is going to get a value, because there are no statements in this code
that assign to it.
> # resetting, just die out
>#print "<--reset alarm, exiting\n";
> } else {
> my $runtime=time-$^T;
Why are you using ^T?
> my $delta=$runtime-$maxruntime;
. . . $maxruntime is the time, measured from the script's start time,
that you want something to happen?
>#print "-->alarm is armed, delta is $delta max is $maxruntime run is
>$runtime\n"
>;
> if ($delta > 0) {
> die "ALARM MAXRUNTIME $maxruntime exceeded\n";
> };
> $id=$top->after(1000,\&alarm2);
Presumably this is to reschedule yourself? (Why didn't you just use repeat(), if so?)
If you're being run from after(), where is the die() going to end up?
Won't it be handled by popping up a dialog box with the message?
>eval {
> $id=$top->after(1000,\&alarm2);
> print "running cmd\n";
> #status=0 for success
> $stat=system($cmd); #obviously change this to read
What does that comment mean? It's not obvious to me.
> #use Win32::Process;
> #Win32::Process::Create($ProcAA,
> # "$full_path_of_command",
> # "$command +any ARGVS",
> # 0,
> # DETATCHED_PROCESS,
> # ".");
>
> die "adb pgm exit :$?" unless $stat == 0;
> #print "\t-->finished command, resetting alarm\n";
> alarm2(0);
You're passing an argument to a routine that ignores its arguments.
> };
>if ( $@ ) {
> print "Alarm triggered, event timedout\n";
>}else {
> print "finished command, all is well\n";
>};
So does this code do something useful when you ran it? What exactly did it do?
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 1341
**************************************