[15729] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3142 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 23 21:10:42 2000

Date: Tue, 23 May 2000 18:10:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <959130619-v9-i3142@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 23 May 2000     Volume: 9 Number: 3142

Today's topics:
    Re: join " ", do {$x++}, do {$x++}, do {$x++}; <Tbone@pimpdaddy.com>
    Re: join " ", do {$x++}, do {$x++}, do {$x++}; <Tbone@pimpdaddy.com>
    Re: join " ", do {$x++}, do {$x++}, do {$x++}; (Bart Lateur)
    Re: join " ", do {$x++}, do {$x++}, do {$x++}; <lr@hpl.hp.com>
        MaximizeWindow?? <eastnder1@NOSPAMaol.com>
    Re: MaximizeWindow?? <asound40NOasSPAM@hotmail.com.invalid>
    Re: MaximizeWindow?? <rootbeer@redcat.com>
    Re: MaximizeWindow?? (Abigail)
        MSSQL::* 1.006 available (Erland Sommarskog)
    Re: my algorythms suck (David Wall)
    Re: NT, perl, mySQL yes or no? (Kim Saunders)
        Objects, SUPER:: and parameters... <zapcs@icon.co.za>
    Re: parse a string question, regexp? <lr@hpl.hp.com>
    Re: parse a string question, regexp? (David Wall)
        Perl+Oracle 8 on Solaris <Luc-Etienne.Brachotte@wanadoo.fr>
        printing Perl version from script j555@my-deja.com
    Re: printing Perl version from script <tony_curtis32@yahoo.com>
    Re: printing Perl version from script <makarand_kulkarni@My-Deja.com>
    Re: Prototype mismatch <rootbeer@redcat.com>
    Re: Reading from file <jrthomsonNOSPAM@nneotsspcaampe.net>
        Split a number up? <streaking_pyro@my-deja.com>
    Re: Split a number up? <asound40NOasSPAM@hotmail.com.invalid>
    Re: Split a number up? <skuo@mtwhitney.nsc.com>
    Re: Split a number up? <lr@hpl.hp.com>
    Re: Split a number up? <asound40NOasSPAM@hotmail.com.invalid>
    Re: Split a number up? (Bart Lateur)
    Re: Split a number up? <lr@hpl.hp.com>
    Re: use english (Steven Smolinski)
    Re: use english <uri@sysarch.com>
    Re: use english <lr@hpl.hp.com>
        Use gd.pm <ppi@searchy.net>
    Re: Use gd.pm <rootbeer@redcat.com>
    Re: Use gd.pm <makarand_kulkarni@My-Deja.com>
    Re: Use gd.pm <jeff@vpservices.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 23 May 2000 23:00:33 GMT
From: Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
Subject: Re: join " ", do {$x++}, do {$x++}, do {$x++};
Message-Id: <8gf2ih$226v$1@news.enteract.com>

tjla@guvfybir.qlaqaf.bet writes:
>True...I realised afterwards I'd been talking about the wrong thing
>probably.

I was shocked! How could you say such a terrible thing?



------------------------------

Date: 23 May 2000 23:04:07 GMT
From: Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
Subject: Re: join " ", do {$x++}, do {$x++}, do {$x++};
Message-Id: <8gf2p7$22cd$1@news.enteract.com>

bart.lateur@skynet.be writes:
>Intergalactic Denizen of Mystery wrote:
>
>>The long and short of it seems to be that "sequential execution" is not
>>guaranteed by the language in the examples above
>
>No, it IS sequential in the examples above. Only, the assigned value is
>passed by reference, so changing the variable will also change the copy.

There are some crossed wires here, but it's not worth your while
to hear me straighten it out.

I do understand your point and your examples.



------------------------------

Date: Wed, 24 May 2000 00:22:16 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: join " ", do {$x++}, do {$x++}, do {$x++};
Message-Id: <392f2000.1347529@news.skynet.be>

Larry Rosler wrote:

> I *believe* that the 
>elements of a list are evaluated completely, left-to-right, and I have 
>read and written code that relies on that, but I don't find an explicit 
>statement of it.

Neither can I. And yet, the analogy with the comma operator in scalar
context would lead me to believe that it is the only logical choice.

Or would you rather have

	my($x) = (a(), b(), c());
and
	my $x = (a(), b(), c());

call the subs in a different sequence?

-- 
	Bart.


------------------------------

Date: Tue, 23 May 2000 17:43:49 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: join " ", do {$x++}, do {$x++}, do {$x++};
Message-Id: <MPG.1394c59fe432ca7098aac6@nntp.hpl.hp.com>

In article <392f2000.1347529@news.skynet.be> on Wed, 24 May 2000 
00:22:16 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Larry Rosler wrote:
> 
> > I *believe* that the 
> >elements of a list are evaluated completely, left-to-right, and I have 
> >read and written code that relies on that, but I don't find an explicit 
> >statement of it.
> 
> Neither can I. And yet, the analogy with the comma operator in scalar
> context would lead me to believe that it is the only logical choice.
> 
> Or would you rather have
> 
> 	my($x) = (a(), b(), c());
> and
> 	my $x = (a(), b(), c());
> 
> call the subs in a different sequence?

No, I wouldn't.  So tell me explicitly that it's documented as the way 
it ought to be.

In C, the order of evaluation of

      f(a(), b(), c());

may be chosen by the compiler-writer, based on the direction of stack 
growth or other such factors that would seem totally irrelevant to Perl.

The order of evaluation of

     x = (a(), b(), c());

is, as we have seen, deterministically left-to-right, with sequence 
points at each comma.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Tue, 23 May 2000 22:30:59 GMT
From: "Bill" <eastnder1@NOSPAMaol.com>
Subject: MaximizeWindow??
Message-Id: <DEDW4.9819$yi.51750@news02>

Knowing nothing about PERL I am trying to edit the script to maximize the
window when it opens in Netscape. I have made some successful changes but
this one puzzles me.




------------------------------

Date: Tue, 23 May 2000 15:37:06 -0700
From: asound <asound40NOasSPAM@hotmail.com.invalid>
Subject: Re: MaximizeWindow??
Message-Id: <27b16e00.9a0d07bb@usw-ex0104-033.remarq.com>

In article <DEDW4.9819$yi.51750@news02>, "Bill"
<eastnder1@NOSPAMaol.com> wrote:
>Knowing nothing about PERL I am trying to edit the script to
maximize the
>window when it opens in Netscape. I have made some successful
changes but

You should make some changes also in javascript in order to
control a browser.

HTH


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



------------------------------

Date: Tue, 23 May 2000 15:45:52 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: MaximizeWindow??
Message-Id: <Pine.GSO.4.10.10005231544420.23375-100000@user2.teleport.com>

On Tue, 23 May 2000, Bill wrote:

> I am trying to edit the script to maximize the window when it opens in
> Netscape.

It sounds as if you're wanting to tell a browser to do something. Perhaps
you should search for the docs, FAQs, and newsgroups about browsers and
how to talk to them. Reading comp.infosystems.www.authoring.cgi may be a
good place to start.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: 23 May 2000 22:57:02 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: MaximizeWindow??
Message-Id: <8gf2bu$dqh$1@news.panix.com>

On Tue, 23 May 2000 22:30:59 GMT, Bill <eastnder1@NOSPAMaol.com> wrote:
++ Knowing nothing about PERL I am trying to edit the script to maximize the
++ window when it opens in Netscape. I have made some successful changes but
++ this one puzzles me.


I never knew Netscape was written in Perl.


In many windowmanagers, one would click the window in a corner, then
drag untill one reaches the point where you cannot go further, after
which one releases the mouse button.

In some windowmanagers, there is no such point.



Abigail


------------------------------

Date: 20 May 2000 21:16:46 GMT
From: sommar@algonet.se (Erland Sommarskog)
Subject: MSSQL::* 1.006 available
Message-Id: <AuDW4.41609$g41.1835543@news-west.usenetserver.com>

I have released 1.006 of MSSQL::DBlib and MSSQL::Sqllib. The first
module is a port of Sybase::DBlib to MS SQL Server, the second is 
a high-level interface using MSSQL::DBlib. (The interface as such
is not very tied to MS SQL Server, but it is certainly not DBI/DBD.)

The two most important pieces of news are:
1) A memory leak in dbnextrow2 and dbretdata2 has been fixed. 
2) MSSQL::DBlib now compiles with Perl 5.6, and there is a precompiled
   binary for ActivePerl 5.6 at my web site.

Since dbnextrow2 is the routine you use for about any query, the impact
of the leak was signifcant, and I would urge all users of these modules
to download 1.006. Big thanks to Ilya Chelpanov who not only found
the leak, but also provided the fix.

The modules are available on CPAN, and on my web site
http://www.algonet.se/~sommar/mssql/. CPAN only has source code.
My web site provides binary distributions for ActiveState's 3xx, 
5xx and 6xx. Simon Oliver has a PPM package for ActivePerl 5xx
on  http://www.bi.umist.ac.uk/packages. 

-- 
Erland Sommarskog, Stockholm, sommar@algonet.se






------------------------------

Date: 23 May 2000 20:00:57 -0400
From: darkon@one.net (David Wall)
Subject: Re: my algorythms suck
Message-Id: <8F3DC69B1darkononenet@206.112.192.118>

mjcarman@home.com (Michael Carman) wrote in <392ACEEC.D6205723@home.com>:
>klidge wrote:
>> 
>> I have the following database :
>> 
>> id | parent_id | name
>> ---------------------
>>  1 |  0        | msg1
>>  2 |  0        | msg3
>>  3 |  0        | msg7
>>  4 |  0        | msg8
>>  5 |  1        | msg2
>>  6 |  2        | msg4
>>  7 |  6        | msg5
>>  8 |  2        | msg6
>> [etc...]
>> 
>> That must build the following threads :
>> 
>> . msg1
>>   . msg2
>> . msg3
>>   . msg4
>>     . msg5
>>   . msg6
>> . msg7
>> . msg8
>> [etc...]
>> 
>> ======================
>> 
>> I have tried nearly everything : foreach of foreaches, hash of hashes,
>> while loops, etc... but nothing worked! :¨(
>
>I'd wager that you haven't tried a recursive algorithm, and that's what
>you need here.


That's just what I used in a basic little web board I wrote last year.  I was 
hoping that I could find a non-recursive way to do it, but you seem to be 
saying there's no other way to do it.   Bummer.  Doesn't stop me from trying to 
find one, but I suppose I could always /try/ to square the circle with compass 
and straightedge, too.  :-)


>> I spent DAYS looking for the algorithm so if anyone could help by
>> either redirecting me to a URL that offers help about this, or, 
>> better, write down the solution, that'd be great!
>
>I won't tell you how long it took me to do this, but it's not as hard as
>you're making it. :)
>
>-------------------------------------------------------
>#!/usr/local/bin/perl -w
>use strict;
>my (%msgs, %children);
>
>while (<DATA>) {
>        next unless /^\d/; # Skip comment line
>        my ($id, $pid, $name) = split(/\s+/, $_);
>        $msgs{$id}{parent} = $pid;
>        $msgs{$id}{name}   = $name;
>
>        push(@{$children{$pid}}, $id);
>}
>
>foreach (@{$children{0}}) {
>        Thread($_, 0);
>}
>
>
>sub Thread {
>        my $id    = shift;
>        my $depth = shift;
>
>        print "  " x $depth . "* $msgs{$id}{name}\n";
>
>        if (exists $children{$id}) {
>                foreach (@{$children{$id}}) {
>                        Thread($_, $depth + 1);
>                }
>        }
>}
>
>
>__DATA__
># ID    Parent ID   Name
>1       0           msg1
>2       0           msg3
>3       0           msg7
>4       0           msg8
>5       1           msg2
>6       2           msg4
>7       6           msg5
>8       2           msg6
>-------------------------------------------------------
>
>For my sample I put the data in the the script itself and changed the
>format a bit to suit me. You can easily change the while() loop to read
>your source file and parse the input appropriately. You may also want to
>incorporate some type of sorting at each thread level.
>
>Hmm. Looking back, I didn't ever need $msgs{$id}{parent}. It isn't
>necessary for the threading, but might be useful if you want to allow
>messages to refer to their parents, so I left it in. Also, I could have
>used an arrays instead of hashes for %msgs and %children, but since perl
>doesn't allow sparse arrays, I suspect a hash is better. (And necessary
>if your keys are not purely numeric.)


Hmm, that looks more complicated than what I did, but I wasn't worrying about 
producing text, but nested unordered lists in HTML.  I did use some information 
about what mesage was being responded to.  If you're interested, you can see 
the program at http://w3.one.net/~darkon/darkboard/.  I just finished making 
some changes to it, and was considering posting here to see if anyone would be 
kind enough to take a look at it and point out Bad Things in my programming.

Now that I think of it, I do know one possibly bad thing I did.  Not coming 
from a computing background, I didn't use parent and child as labels, instead 
using things like 'Replies' and 'ReplyTo'.  Not necessarily bad, but 'parent' 
and 'child' is much clearer.

-- 
David Wall
darkon@one.net


------------------------------

Date: Wed, 24 May 2000 00:14:28 GMT
From: kims@tip.net.au (Kim Saunders)
Subject: Re: NT, perl, mySQL yes or no?
Message-Id: <392b1d87.3557054@news.magna.com.au>

On Tue, 23 May 2000 11:59:58 -0700, Makarand Kulkarni
<makarand_kulkarni@My-Deja.com> wrote:

>>  Is there a good GUI for MySQL,
>
>Try some GUI clients yourselves.
>Check at http://www.mysql.com/download.html

No, they're basically crap. No offence to anyone who wrote them or
whatever, but none of them provide a robust method to to 100% of the
database access, unfortunately.

I recently implemented a solution where I work for a dynamic website.

All the content is in a MySQL database, perl CGI scripts pull data
from there to dynamically build all the pages at runtime.

Get the MyODBC driver (only needs to be installed on the client side),
then use "Link Tables" in microsoft Access.

I have never used access much before, but I build a few forms for all
the sales/marketing types to make their updates in no time (30
mins???)

Even though access is supposedly crap as a actual database (never used
it), it was a real doddle making the forms. To program web-based forms
to update all the data would have taken hours. The forms too less than
an hour.

The form interface was easy for them to use, and easy for me to make,
but all the data was still being stored in a proper database on a
proper OS (MySQL on Linux), using a decent webserver (apache).

I had never tried a solution like that before, but I was very
impressed, and the users loved it. So, I would do it this way again.

KimS


------------------------------

Date: Wed, 24 May 2000 02:01:35 +0200
From: Zak McGregor <zapcs@icon.co.za>
Subject: Objects, SUPER:: and parameters...
Message-Id: <392B1BDF.E5A9F55B@icon.co.za>

Hi all

I don't usually post questions, but this one has me stuped. I'm sure
there's a silly mistake lurking in here somewhere, but I don't
understand why any parameters passed to connectdb() seem to get through
at all. The error I get always looks like the method gets called without
the parameters supplied.

Thanks for your help!

Ciao
<CODE>
use strict;
use Pg;
use vars qw(@ISA);
@ISA=qw(Pg);
my $_conn_options;
my $_conn;
sub new {
    my $proto = shift;
    my $class = ref($proto) || $proto;
    my $self  = bless {}, $class;
    if ($self->{_conn}) {
	$self->_parse();
    }
    else {
	$self->{_conn}=$self->SUPER::connectdb("dbname=xxxxxxxxx user=xxxxxx");
#                                              
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this doesn't seem to get passed on... :(
    }
    return bless $self, "Pg";
</CODE>
-- 
====================================================================
Zak McGregor
http://www.zap.co.za/zgas - On-line specifications of over 6700 cars
====================================================================


------------------------------

Date: Tue, 23 May 2000 15:14:21 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: parse a string question, regexp?
Message-Id: <MPG.1394a2997c3adee698aac3@nntp.hpl.hp.com>

In article <392AFC0D.7A000D4B@My-Deja.com> on Tue, 23 May 2000 14:45:49 
-0700, Makarand Kulkarni <makarand_kulkarni@My-Deja.com> says...
> > So, what I want to do is: where the script finds the word madman, it
> > should start looking for the first two newlines, it finds it, and
> > starts saving in a string until it reaches the next 2 newlines...
> 
> You can do that by changing the value of $/
> see below for a sample
> 
> while (<>) # read consecutive lines from appropriate source
> {
> next unless /madman/ ;
> $save_sep=$/; # save the value of $/
> $/="\n\n"; # change $/
> <>;
> $wanted=<>; # these are the lines you want
> print "\n---\n$wanted\n ----\n"; # the lines you want are printed here
> $/=$save_sep; # restore $/
> }

Something is wrong with your indenting key.  :-)

  while (<>) # read consecutive lines from appropriate source
  {
     next unless /\bmadman\b/;
     local $/ = "\n\n"; # change $/
     <>;
     chomp(my $wanted = <>); # these are the lines you want
     print "\n---\n$wanted\n ----\n";
  }

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 23 May 2000 20:32:52 -0400
From: darkon@one.net (David Wall)
Subject: Re: parse a string question, regexp?
Message-Id: <8F3DDDA37darkononenet@206.112.192.118>

bj0rn@my-deja.com wrote in <8geqnm$1t1$1@nnrp1.deja.com>:

>Hey there!
>
>I have a small problem... I want to search in a rather huge string, for
>a word, and then after that word start saving everything after the
>first 2 new lines (\n\n) until the next two new lines (\n\n)...
>
>Does anyone know how to do this?

Someone correct me if I'm wrong (now *there's* an unnecessary request), but 
how about

my $word='madman';
if ( $huge_string =~ /${word}.*?\n\n(.*?)\n\n/s ) {
   print $1;
}

This worked when I tested it, but it's probably grossly inefficient.

-- 
David Wall
darkon@one.net


------------------------------

Date: Wed, 24 May 2000 00:17:48 +0200
From: Luc-Etienne Brachotte <Luc-Etienne.Brachotte@wanadoo.fr>
Subject: Perl+Oracle 8 on Solaris
Message-Id: <392B038C.1AE958B9@wanadoo.fr>

I need a script for starting and stoping Oracle 8i listeners. Stopping
is easy.
For starting, the UNIX command line is
lsnrctl start LIST01
this command returns almost immediately.

So the Perl code is (2 solutions)
1) @Output=`lsnrctl start LIST01`;
2) system ("lsnrctl", "start", "LIST01");

The 2 solutions indeed starts the listener. What bother me, is the first
solution do NOT return: the listener is started, but the Perl code after
is not executed, and the small perl script (just 4 lines) never ends.
BTW the entire script is

#!/usr/local/bin/perl
@Output=`lsnrctl start LIST01`;
#the following code is never executed (script never ends)
foreach (@Output) {print}  #I would like to analyse
#more precisely all informations provided by the output
@Output=`lsnrctl start LIST02`;


Is anyone able to explain me why?

I temporarily use the second solution, but
-- I have not control on the output of the command (nearly 20 lines I
must suppress),
-- and the return code with $? is always 0.
So I would greatly prefer to use the first solution.

Thanks

LEB




------------------------------

Date: Tue, 23 May 2000 23:37:46 GMT
From: j555@my-deja.com
Subject: printing Perl version from script
Message-Id: <8gf4oa$8cu$1@nnrp1.deja.com>

Hi folks,
Can anybody tell me how I print the Perl interpreters
version from within a Perl script?
Thanks!


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 23 May 2000 18:58:02 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: printing Perl version from script
Message-Id: <87zopgn7jp.fsf@limey.hpcc.uh.edu>

>> On Tue, 23 May 2000 23:37:46 GMT,
>> j555@my-deja.com said:

> Hi folks, Can anybody tell me how I print the Perl
> interpreters version from within a Perl script?

Have you looked in "perldoc perlvar"?

       $]      The version + patchlevel / 1000 of the Perl
               interpreter.  This variable can be used to
               determine whether the Perl interpreter executing a
               script is in the right range of versions.

hth
t


------------------------------

Date: Tue, 23 May 2000 17:01:36 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: printing Perl version from script
Message-Id: <392B1BE0.4A402DCC@My-Deja.com>

> Can anybody tell me how I print the Perl interpreters
> version from within a Perl script?

$], or $PERL_VERSION
--



------------------------------

Date: Tue, 23 May 2000 15:34:54 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Prototype mismatch
Message-Id: <Pine.GSO.4.10.10005231532220.23375-100000@user2.teleport.com>

On 23 May 2000, Joerg Behrens wrote:

> Using perl, version 5.005_03 built for i586-linux, 

I think this is fixed in 5.6.0. Does that fix your problem?

Even if you can't (or shouldn't :-) install that version, you may be able
to apply a patch to 5.005_03 to fix the bug.

> In short, it seems the problem comes up like this:
> 
> eval 'sub __need_size_t() {1;}'  unless defined(&__need_size_t);
> undef(&__need_size_t) if defined(&__need_size_t);
> eval 'sub __need_size_t() {1;}'  unless defined(&__need_size_t);

Are you doing these definitions twice? Don't do that! :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Tue, 23 May 2000 16:12:20 -0700
From: Jim Thomson <jrthomsonNOSPAM@nneotsspcaampe.net>
Subject: Re: Reading from file
Message-Id: <392B1053.83B9D912@nneotsspcaampe.net>

I think you've also got to send 2 linefeeds after the mimetype

eg   print "Content-type: text/html\n\n";

good luck

Jim Thomson
jrthomson@netscape.net

Marko Nikulainen wrote:

> Is this code correct?
>
> #!/usr/bin/perl

>
> [ ... deleted ...]
> {
> Print "Content-type: text/html\n";
> print "blaa blaa blaa...\n";
> }
> else
> {
> Print "Content-type: text/html\n";
> Print "blaa blaa blaa...\n";
> }
>
> And that .passwd -file contains only test:test.
> It always print out that else { blaa blaa blaa }.
> Where is the problem? Reading from file or reading user input?



------------------------------

Date: Tue, 23 May 2000 22:53:15 GMT
From: R.Joseph <streaking_pyro@my-deja.com>
Subject: Split a number up?
Message-Id: <8gf24m$6la$1@nnrp1.deja.com>

OK, so say I have a number like the one below:

81024501256520124012507200

Now, what I really want to do it split this number into two-digit
chunks, ie:

81 02 45 01 25 65 20 12 40 12 50 72 00

I tried:

@nums = split(/\d{2}/,$number);

but that didn't work...I thought of using substr(), but then I would
have to run through two for() loops to split it up and assign it to an
array...wouldn't I?  I don't know...PLEASE HELP!!


--
R.Joseph


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Tue, 23 May 2000 16:11:02 -0700
From: asound <asound40NOasSPAM@hotmail.com.invalid>
Subject: Re: Split a number up?
Message-Id: <033f6878.71a8901a@usw-ex0103-086.remarq.com>

In article <8gf24m$6la$1@nnrp1.deja.com>, R.Joseph
<streaking_pyro@my-deja.com> wrote:
>OK, so say I have a number like the one below:
>
>81024501256520124012507200
>
>Now, what I really want to do it split this number into
two-digit
>chunks, ie:
>
>81 02 45 01 25 65 20 12 40 12 50 72 00
>
>I tried:
>
>@nums = split(/\d{2}/,$number);

Don't know how to use split here. But this works.
@nums = $number=~/(\d\d)/g;

HTH

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



------------------------------

Date: Tue, 23 May 2000 16:19:57 -0700
From: Steven Kuo x7914 <skuo@mtwhitney.nsc.com>
Subject: Re: Split a number up?
Message-Id: <Pine.GSO.4.21.0005231619010.20735-100000@mtwhitney.nsc.com>

On Tue, 23 May 2000, R.Joseph wrote:

> OK, so say I have a number like the one below:
> 
> 81024501256520124012507200
> 
> Now, what I really want to do it split this number into two-digit
> chunks, ie:
> 
> 81 02 45 01 25 65 20 12 40 12 50 72 00
> 
> I tried:
> 
> @nums = split(/\d{2}/,$number);
> 
> but that didn't work...I thought of using substr(), but then I would
> have to run through two for() loops to split it up and assign it to an
> array...wouldn't I?  I don't know...PLEASE HELP!!

#! /usr/local/bin/perl -w

use strict;

my $number = q/81024501256520124012507200/;

my (@num) = $number =~ /\G(\d{2})/g;
my (@num2) = grep {($_)} split (/(\d{2})/,$number);

print "One way to do it: @num \n";
print "There more than one way: @num2 \n";




------------------------------

Date: Tue, 23 May 2000 16:42:41 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Split a number up?
Message-Id: <MPG.1394b7507749a70f98aac5@nntp.hpl.hp.com>

In article <Pine.GSO.4.21.0005231619010.20735-100000@mtwhitney.nsc.com> 
on Tue, 23 May 2000 16:19:57 -0700, Steven Kuo x7914 
<skuo@mtwhitney.nsc.com> says...
> On Tue, 23 May 2000, R.Joseph wrote:
> > OK, so say I have a number like the one below:
> > 
> > 81024501256520124012507200
> > 
> > Now, what I really want to do it split this number into two-digit
> > chunks, ie:
> > 
> > 81 02 45 01 25 65 20 12 40 12 50 72 00

 ...

> #! /usr/local/bin/perl -w
> 
> use strict;
> 
> my $number = q/81024501256520124012507200/;
> 
> my (@num) = $number =~ /\G(\d{2})/g;
> my (@num2) = grep {($_)} split (/(\d{2})/,$number);
> 
> print "One way to do it: @num \n";
> print "There more than one way: @num2 \n";

OK, cool.  Now, what about dealing with an odd-length string, especially 
with the final digit 0?

Stripped of some extra punctuation, these should handle that situation 
also:

  my @num = $number =~ /\d{1,2}/g;

  my @num2 = grep { length } split /(\d{2})/ => $number;

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Tue, 23 May 2000 17:03:40 -0700
From: asound <asound40NOasSPAM@hotmail.com.invalid>
Subject: Re: Split a number up?
Message-Id: <03be2378.b0a14227@usw-ex0104-033.remarq.com>

In article <MPG.1394b7507749a70f98aac5@nntp.hpl.hp.com>, Larry
Rosler <lr@hpl.hp.com> wrote:
>In article
<Pine.GSO.4.21.0005231619010.20735-100000@mtwhitney.nsc.com>
>on Tue, 23 May 2000 16:19:57 -0700, Steven Kuo x7914
><skuo@mtwhitney.nsc.com> says...
>> On Tue, 23 May 2000, R.Joseph wrote:
>> > OK, so say I have a number like the one below:
>> >
>> > 81024501256520124012507200
>> >
>> > Now, what I really want to do it split this number into
two-digit
>> > chunks, ie:
>> >
>> > 81 02 45 01 25 65 20 12 40 12 50 72 00
>
>....
>
>> #! /usr/local/bin/perl -w
>>
>> use strict;
>>
>> my $number = q/81024501256520124012507200/;
>>
>> my (@num) = $number =~ /\G(\d{2})/g;
>> my (@num2) = grep {($_)} split (/(\d{2})/,$number);
>>
>> print "One way to do it: @num \n";
>> print "There more than one way: @num2 \n";
>
>OK, cool.  Now, what about dealing with an odd-length string,
especially
>with the final digit 0?
>
>Stripped of some extra punctuation, these should handle that
situation
>also:
>
>  my @num = $number =~ /\d{1,2}/g;
>
>  my @num2 = grep { length } split /(\d{2})/ => $number;

Ok cool, but who said that you have to print out the last odd 0?



* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



------------------------------

Date: Wed, 24 May 2000 00:49:29 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Split a number up?
Message-Id: <393022d1.2068585@news.skynet.be>

Larry Rosler wrote:

>OK, cool.  Now, what about dealing with an odd-length string, especially 
>with the final digit 0?
>
>Stripped of some extra punctuation, these should handle that situation 
>also:
>
>  my @num = $number =~ /\d{1,2}/g;
>
>  my @num2 = grep { length } split /(\d{2})/ => $number;

What if you want an odd length number to have the left-over digit on the
left? Like

	12345 -> 1 23 45


This works, but it looks rather inefficient to me.

	$number = '12345';
	@parts = $number =~ /(\d{1,2})(?=(?:\d\d)*$)/g;
	print "@parts\n";

Er... reverse the string, split it as you did, reverse the resulting
list, and reverse each string in the list?

	@parts = map { scalar reverse $_ } 
	  reverse reverse($number) =~ /\d{1,2}/g;

Cute.

-- 
	Bart.


------------------------------

Date: Tue, 23 May 2000 17:54:20 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Split a number up?
Message-Id: <MPG.1394c817b46862a998aac8@nntp.hpl.hp.com>

In article <03be2378.b0a14227@usw-ex0104-033.remarq.com> on Tue, 23 May 
2000 17:03:40 -0700, asound <asound40NOasSPAM@hotmail.com.invalid> 
says...
> In article <MPG.1394b7507749a70f98aac5@nntp.hpl.hp.com>, Larry
> Rosler <lr@hpl.hp.com> wrote:

 ...

> >OK, cool.  Now, what about dealing with an odd-length string,
> >especially with the final digit 0?
> >
> >Stripped of some extra punctuation, these should handle that
> >situation also:
> >
> >  my @num = $number =~ /\d{1,2}/g;
> >
> >  my @num2 = grep { length } split /(\d{2})/ => $number;
> 
> Ok cool, but who said that you have to print out the last odd 0?

No one.  Incomplete specification.  But the original regex approach 
would have lost any trailing single digit, not just a zero.  And the two 
original approaches were described as alternate Ways To Do It, so they 
should Do It the same Way for all data.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Tue, 23 May 2000 23:44:07 GMT
From: sjs@yorku.ca (Steven Smolinski)
Subject: Re: use english
Message-Id: <slrn8im5pi.5uu.sjs@john.sympatico.ca>

On Tue, 23 May 2000, Brad Baxter <bmb@dataserv.libs.uga.edu> wrote:
>On Tue, 23 May 2000, Michael Carman wrote:
>...
>> For one, the long names are there for a reason -- they're descriptive
>> and easier to remember than secret code of $!^*& stuff. What you use in
>...
>
>     1  #!/usr/local/bin/perl -w
>     2  use strict;
>     3
>     4  print $!^*&;
>     5
>     6  __END__
>     7  Output:
>     8
>     9  *main::&

Brad, that's just fscked up.  Can anyone give me a short tutorial
on this?

Steve


------------------------------

Date: Wed, 24 May 2000 00:29:19 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: use english
Message-Id: <x7u2fobxk1.fsf@home.sysarch.com>

>>>>> "SS" == Steven Smolinski <sjs@yorku.ca> writes:

  SS> On Tue, 23 May 2000, Brad Baxter <bmb@dataserv.libs.uga.edu> wrote:
  >> 4  print $!^*&;

  >> 9  *main::&

  SS> Brad, that's just fscked up.  Can anyone give me a short tutorial
  SS> on this?

very simple. that is the xor of $! (perl system error var) and the
typeglob *&. typeglobs return their expanded selves (package added) when
assigned to regular scalar. now $! is empty (undef?) at the start so it
is false so the xor returns the expanded typeglob. since it is in
package main is becomes *mail::& which is printed.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


------------------------------

Date: Tue, 23 May 2000 17:49:19 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: use english
Message-Id: <MPG.1394c6ef224900ba98aac7@nntp.hpl.hp.com>

In article <x7u2fobxk1.fsf@home.sysarch.com> on Wed, 24 May 2000 
00:29:19 GMT, Uri Guttman <uri@sysarch.com> says...
> >>>>> "SS" == Steven Smolinski <sjs@yorku.ca> writes:
> 
>   SS> On Tue, 23 May 2000, Brad Baxter <bmb@dataserv.libs.uga.edu> wrote:
>   >> 4  print $!^*&;
> 
>   >> 9  *main::&
> 
>   SS> Brad, that's just fscked up.  Can anyone give me a short tutorial
>   SS> on this?
> 
> very simple. that is the xor of $! (perl system error var) and the
> typeglob *&. typeglobs return their expanded selves (package added) when
> assigned to regular scalar. now $! is empty (undef?) at the start

It is the null string "".  If it were undef, there would be a conversion 
warning.

>                                                                    so it
> is false

That is irrelevant, as there is no Boolean test involved, just a string-
wise xor of a null string against another string, which is an identity 
operation.

>           so the xor returns the expanded typeglob. since it is in
> package main is becomes *mail::& which is printed.

s/mail/main/

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Wed, 24 May 2000 00:14:20 +0200
From: Penpal International <ppi@searchy.net>
Subject: Use gd.pm
Message-Id: <392B02BC.8E6BBAAF@searchy.net>

Does anyone know a place where I can find some documentation on the GD
library for Perl?



-- 
Penpal International
http://ppi.searchy.net/
ppi@searchy.net


------------------------------

Date: Tue, 23 May 2000 15:24:06 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Use gd.pm
Message-Id: <Pine.GSO.4.10.10005231523230.23375-100000@user2.teleport.com>

On Wed, 24 May 2000, Penpal International wrote:

> Does anyone know a place where I can find some documentation on the GD
> library for Perl?

Do you mean the GD module, GD.pm?

There is documentation which comes with the module. In what way is it
insufficient for your needs?

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Tue, 23 May 2000 15:25:22 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Use gd.pm
Message-Id: <392B0552.960A688F@My-Deja.com>

> Does anyone know a place where I can find some documentation on the GD
> library for Perl?

perldoc GD

you can find some samples in "Perl5 Unleashed"
available online

http://www.fdd.co.uk/jos/perl5/index-1.htm
chapter 32
-





------------------------------

Date: Tue, 23 May 2000 15:26:28 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Use gd.pm
Message-Id: <392B0594.C40499D4@vpservices.com>

Penpal International wrote:
> 
> Does anyone know a place where I can find some documentation on the GD
> library for Perl?

You have been asking quesitons on this newsgroup for quite a while now. 
Have you missed the many many times people have described how to use
perldoc to find the documentation for Perl modules?  Or the many times
people have described where on the net the documentation for all CPAN
modules is found (hint: it has the word cpan in the address)?  If you
can explain how you managed to miss those pointers or what about those
pointers you didn't understand, I am sure we would be glad to repeat or
explain them.  Failing that, you might see what happens when you type
"perl GD module documentation" into any internet search engine and I
would be surprised if you didn't stumble onto the answer to your own
question within the first three clicks.

-- 
Jeff


------------------------------

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 3142
**************************************


home help back first fref pref prev next nref lref last post