[22526] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4747 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 23 03:05:40 2003

Date: Sun, 23 Mar 2003 00:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 23 Mar 2003     Volume: 10 Number: 4747

Today's topics:
        ANNOUNCE: CGI::Echo V 1.03 <ron@savage.net.au>
        ANNOUNCE: CGI::Formalware V 1.11 <ron@savage.net.au>
        ANNOUNCE: Class::Tree V 1.23 <ron@savage.net.au>
        ANNOUNCE: DBIx::Hash2Table V 1.03 <ron@savage.net.au>
        ANNOUNCE: DBIx::HTML::ClientDB V 1.03 <ron@savage.net.au>
        ANNOUNCE: DBIx::HTML::LinkedMenus V 1.04 <ron@savage.net.au>
        ANNOUNCE: DBIx::HTML::PopupRadio V 1.05 <ron@savage.net.au>
        ANNOUNCE: DBIx::MSSQLReporter V 1.02 <ron@savage.net.au>
        ANNOUNCE: DBIx::Table2Hash V 1.12 <ron@savage.net.au>
        ANNOUNCE: DFA::Command V 1.97 <ron@savage.net.au>
        ANNOUNCE: Getopt::Simple V 1.46 <ron@savage.net.au>
        ANNOUNCE: Lingua::EN::Infinitive V 1.07 <ron@savage.net.au>
        ANNOUNCE: X500::DN::Parser V 1.15 <ron@savage.net.au>
        Changeing Scope of a Sub Reference <aran@bluefeet.net>
    Re: Changeing Scope of a Sub Reference <steven.smolinski@sympatico.ca>
    Re: Changeing Scope of a Sub Reference <aran@bluefeet.net>
    Re: doubts on \n <goldbb2@earthlink.net>
    Re: doubts on \n <goldbb2@earthlink.net>
    Re: e-mail attachment. <trond@bwsnett.no>
    Re: How to interchange fields and sorting in perl <wksmith@optonline.net>
    Re: How to interchange fields and sorting in perl <goldbb2@earthlink.net>
    Re: Idea for holding a C++ pointer in a Perl scalar wit <goldbb2@earthlink.net>
    Re: Memory used by hashes <goldbb2@earthlink.net>
        Net::Telnet -> mysql login help <josh@zipcon.net>
    Re: Net::Telnet -> mysql login help <ndronen@io.frii.com>
    Re: regexp question <bart.lateur@pandora.be>
    Re: Text::ParseWords or Text::CSV <goldbb2@earthlink.net>
    Re: with ActivePerl, PPM "search" missing results that  (Jay Tilton)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 23 Mar 2003 03:28:03 GMT
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: CGI::Echo V 1.03
Message-Id: <b2e63dd98c2f37ee3008d3c8c19c5eb3@news.teranews.com>

The pure Perl module CGI::Echo V 1.03
is available immediately from CPAN, and from
http://savage.net.au/Perl-modules.html

1.03  Sun Mar 23 11:29:00 2003
 - No source code changes in this version
 - Patch to stop shipping blib/ directory in Unix distros, because the
  PAUSE indexer takes this directory to indicate a binary distro,
  which means it does not index the module, and this in turn means
  the module is not listed in the CPAN daily update list, etc.






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

Date: Sun, 23 Mar 2003 03:28:01 GMT
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: CGI::Formalware V 1.11
Message-Id: <94a32ccb0b2394931b12b2b439f7f97a@news.teranews.com>

The pure Perl module CGI::Formalware V 1.11
is available immediately from CPAN, and from
http://savage.net.au/Perl-modules.html

1.11  Sun Mar 23 11:29:00 2003
 - Move demos into examples/ directory
 - Change test.xml to use CSS /css/test.css rather than /test.css
 - No source code changes in this version
 - Patch to stop shipping blib/ directory in Unix distros, because the
  PAUSE indexer takes this directory to indicate a binary distro,
  which means it does not index the module, and this in turn means
  the module is not listed in the CPAN daily update list, etc.





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

Date: Sun, 23 Mar 2003 03:28:02 GMT
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: Class::Tree V 1.23
Message-Id: <b75a911ca69b1d82a4179be1a24c99df@news.teranews.com>

The pure Perl module Class::Tree V 1.23
is available immediately from CPAN, and from
http://savage.net.au/Perl-modules.html

1.23  Sun Mar 23 11:29:00 2003
 - Move demos into examples/ directory
 - No source code changes in this version
 - Patch to stop shipping blib/ directory in Unix distros, because the
  PAUSE indexer takes this directory to indicate a binary distro,
  which means it does not index the module, and this in turn means
  the module is not listed in the CPAN daily update list, etc.





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

Date: Sun, 23 Mar 2003 03:28:03 GMT
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: DBIx::Hash2Table V 1.03
Message-Id: <5f161856f22b77a21194adb7832d9599@news.teranews.com>

The pure Perl module DBIx::Hash2Table V 1.03
is available immediately from CPAN, and from
http://savage.net.au/Perl-modules.html

1.03  Sun Mar 23 11:29:00 2003
 - No source code changes in this version
 - Patch to stop shipping blib/ directory in Unix distros, because the
  PAUSE indexer takes this directory to indicate a binary distro,
  which means it does not index the module, and this in turn means
  the module is not listed in the CPAN daily update list, etc.





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

Date: Sun, 23 Mar 2003 03:28:04 GMT
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: DBIx::HTML::ClientDB V 1.03
Message-Id: <dee6963ca885200e4269aa3d59800336@news.teranews.com>

The pure Perl module DBIx::HTML::ClientDB V 1.03
is available immediately from CPAN, and from
http://savage.net.au/Perl-modules.html

1.03  Sun Mar 23 11:29:00 2003
 - No source code changes in this version
 - Patch to stop shipping blib/ directory in Unix distros, because the
  PAUSE indexer takes this directory to indicate a binary distro,
  which means it does not index the module, and this in turn means
  the module is not listed in the CPAN daily update list, etc.





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

Date: Sun, 23 Mar 2003 03:28:04 GMT
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: DBIx::HTML::LinkedMenus V 1.04
Message-Id: <94ddc259c5938a5984bcd8602f3b3f57@news.teranews.com>

The pure Perl module DBIx::HTML::LinkedMenus V 1.04
is available immediately from CPAN, and from
http://savage.net.au/Perl-modules.html

1.04  Sun Mar 23 11:29:00 2003
 - No source code changes in this version
 - Patch to stop shipping blib/ directory in Unix distros, because the
  PAUSE indexer takes this directory to indicate a binary distro,
  which means it does not index the module, and this in turn means
  the module is not listed in the CPAN daily update list, etc.





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

Date: Sun, 23 Mar 2003 03:28:04 GMT
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: DBIx::HTML::PopupRadio V 1.05
Message-Id: <8aa21106f2ff5d6c8c4c1ff46f36a784@news.teranews.com>

The pure Perl module DBIx::HTML::PopupRadio V 1.05
is available immediately from CPAN, and from
http://savage.net.au/Perl-modules.html

1.05  Sun Mar 23 11:29:00 2003
 - No source code changes in this version
 - Patch to stop shipping blib/ directory in Unix distros, because the
  PAUSE indexer takes this directory to indicate a binary distro,
  which means it does not index the module, and this in turn means
  the module is not listed in the CPAN daily update list, etc.





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

Date: Sun, 23 Mar 2003 03:28:04 GMT
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: DBIx::MSSQLReporter V 1.02
Message-Id: <662fdbec2b94adacdd69fe3730568711@news.teranews.com>

The pure Perl module DBIx::MSSQLReporter V 1.02
is available immediately from CPAN, and from
http://savage.net.au/Perl-modules.html

1.02  Sun Mar 23 11:29:00 2003
 - No source code changes in this version
 - Patch to stop shipping blib/ directory in Unix distros, because the
  PAUSE indexer takes this directory to indicate a binary distro,
  which means it does not index the module, and this in turn means
  the module is not listed in the CPAN daily update list, etc.





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

Date: Sun, 23 Mar 2003 03:08:04 GMT
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: DBIx::Table2Hash V 1.12
Message-Id: <fae8c41a940e12fbb4b8459142547fc8@news.teranews.com>

The pure Perl module DBIx::Table2Hash V 1.12
is available immediately from CPAN, and from
http://savage.net.au/Perl-modules.html

1.12  Sun Mar 23 11:29:00 2003
 - Add a new constructor/method parameter: skip_columns. This is an
  array ref of columns names to ignore when calling select_tree()
 - Patch to stop shipping blib/ directory in Unix distros, because the
  PAUSE indexer takes this directory to indicate a binary distro,
  which means it does not index the module, and this in turn means
  the module is not listed in the CPAN daily update list, etc.





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

Date: Sun, 23 Mar 2003 03:28:05 GMT
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: DFA::Command V 1.97
Message-Id: <28450fa6f63c8c31ad5c6413995a331b@news.teranews.com>

The pure Perl module DFA::Command V 1.97
is available immediately from CPAN, and from
http://savage.net.au/Perl-modules.html

1.97  Sun Mar 23 11:29:00 2003
 - No source code changes in this version
 - Patch to stop shipping blib/ directory in Unix distros, because the
  PAUSE indexer takes this directory to indicate a binary distro,
  which means it does not index the module, and this in turn means
  the module is not listed in the CPAN daily update list, etc.





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

Date: Sun, 23 Mar 2003 03:28:05 GMT
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: Getopt::Simple V 1.46
Message-Id: <ec1bbe317e5c914a4d064f5d9e486a67@news.teranews.com>

The pure Perl module Getopt::Simple V 1.46
is available immediately from CPAN, and from
http://savage.net.au/Perl-modules.html

1.46  Sun Mar 23 11:29:00 2003
 - No source code changes in this version
 - Patch to stop shipping blib/ directory in Unix distros, because the
  PAUSE indexer takes this directory to indicate a binary distro,
  which means it does not index the module, and this in turn means
  the module is not listed in the CPAN daily update list, etc.





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

Date: Sun, 23 Mar 2003 03:28:05 GMT
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: Lingua::EN::Infinitive V 1.07
Message-Id: <bd7fcdc1c4748b206c4d125c592dd255@news.teranews.com>

The pure Perl module Lingua::EN::Infinitive V 1.07
is available immediately from CPAN, and from
http://savage.net.au/Perl-modules.html

1.07  Sun Mar 23 11:29:00 2003
 - No source code changes in this version
 - Patch to stop shipping blib/ directory in Unix distros, because the
  PAUSE indexer takes this directory to indicate a binary distro,
  which means it does not index the module, and this in turn means
  the module is not listed in the CPAN daily update list, etc.





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

Date: Sun, 23 Mar 2003 03:28:06 GMT
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: X500::DN::Parser V 1.15
Message-Id: <2618e598766077f194ae5d73e0cb6030@news.teranews.com>

The pure Perl module X500::DN::Parser V 1.15
is available immediately from CPAN, and from
http://savage.net.au/Perl-modules.html

1.15  Sun Mar 23 11:29:00 2003
 - No source code changes in this version
 - Patch to stop shipping blib/ directory in Unix distros, because the
  PAUSE indexer takes this directory to indicate a binary distro,
  which means it does not index the module, and this in turn means
  the module is not listed in the CPAN daily update list, etc.





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

Date: Sun, 23 Mar 2003 05:51:25 GMT
From: "Aran Deltac" <aran@bluefeet.net>
Subject: Changeing Scope of a Sub Reference
Message-Id: <xXbfa.13480$xE1.471616@twister.southeast.rr.com>

Hello beautiful Perl people.

I have this big lengthy program written that needs this ability.  Instead of
posting a bunch of meaningless code, here's a sample (conceptually) of what
I am trying to do:

use strict;
my $sub_ref = sub{ print $i; };
sub run_ref { my $i = 'Hello!'; &{$sub_ref}; }
run_ref();

Right now this produces the error:

Global symbol "$i" requires explicit package name at scope.pl line 3.
Execution of scope.pl aborted due to compilation errors.

Which, as from what I understand makes perfect sense.  Despite seeing the
logic in this, I want to get around this and scope a sub reference in to
whatever black/package I want to without having to re-reference the code.

Does my question make sense?

Any ideas?

Will I have to play with the internals of Perl?  (aaahahhhh!)

Thanks for any help,

Aran




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

Date: Sun, 23 Mar 2003 06:47:08 GMT
From: Steven Smolinski <steven.smolinski@sympatico.ca>
Subject: Re: Changeing Scope of a Sub Reference
Message-Id: <MLcfa.7024$lQ4.1467478@news20.bellglobal.com>

Aran Deltac <aran@bluefeet.net> wrote:
 
> I have this big lengthy program written that needs this ability.
> Instead of posting a bunch of meaningless code, here's a sample
> (conceptually) of what I am trying to do:
> 
> use strict;
> my $sub_ref = sub{ print $i; };
> sub run_ref { my $i = 'Hello!'; &{$sub_ref}; }
> run_ref();
> 
> Right now this produces the error:
> 
> Global symbol "$i" requires explicit package name at scope.pl line 3.
> Execution of scope.pl aborted due to compilation errors.

So pass arguments.  Globals are a pain to manage anyway.

  #!/usr/bin/perl

  use warnings;
  use strict;

  my $sub_ref = sub { my $i = shift; print $i; };
  sub run_ref { $sub_ref->('Hello!'); }
  run_ref();

Steve
-- 
Steven Smolinski => http://arbiter.ca/
GnuPG Public Key => http://arbiter.ca/steves_public_key.txt
                 => or email me with 'auto-key' in the subject.
Key Fingerprint  => 08C8 6481 3A7B 2A1C 7C26  A5FC 1A1B 66AB F637 495D


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

Date: Sun, 23 Mar 2003 07:05:47 GMT
From: "Aran Deltac" <aran@bluefeet.net>
Subject: Re: Changeing Scope of a Sub Reference
Message-Id: <f1dfa.13493$xE1.483678@twister.southeast.rr.com>


"Steven Smolinski" <steven.smolinski@sympatico.ca> wrote in message
news:MLcfa.7024$lQ4.1467478@news20.bellglobal.com...
> Aran Deltac <aran@bluefeet.net> wrote:
>
> > I have this big lengthy program written that needs this ability.
> > Instead of posting a bunch of meaningless code, here's a sample
> > (conceptually) of what I am trying to do:
[snip]
>
> So pass arguments.  Globals are a pain to manage anyway.

Steven,

Passing arguments is fine, and something any perl nympho understands.  I'm
actually looking for something a little more in depth, as I described in my
original question.

As you said, globals are a pain, and thats exactly where my question is
coming from.

Thank you anyways.

>   #!/usr/bin/perl
>
>   use warnings;
>   use strict;
>
>   my $sub_ref = sub { my $i = shift; print $i; };
>   sub run_ref { $sub_ref->('Hello!'); }
>   run_ref();
>
> Steve
> --
> Steven Smolinski => http://arbiter.ca/
> GnuPG Public Key => http://arbiter.ca/steves_public_key.txt
>                  => or email me with 'auto-key' in the subject.
> Key Fingerprint  => 08C8 6481 3A7B 2A1C 7C26  A5FC 1A1B 66AB F637 495D




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

Date: Sat, 22 Mar 2003 21:48:42 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: doubts on \n
Message-Id: <3E7D208A.E6E18C49@earthlink.net>

ctcgag@hotmail.com wrote:
> 
> helgi@decode.is (Helgi Briem) wrote:
> 
> > For myself, I wish the linefeed were standardised as so
> > many things have been standardised lately, but I suppose
> > that's a pipedream for now.
> 
> I have lower standards.  I just wish chomp would remove any OSs'
> notion of a line-ending off the end, not just the OS it is running
> under.

Chomp (if not set to undef, or "", or a reference to a number) will
always remove the contents of $/ from the end of its argument(s).

What you *really* want is a way of setting $/ to match any OSs' notion
of a line-ending -- in which case chomp would presumably DTRT.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sat, 22 Mar 2003 21:59:29 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: doubts on \n
Message-Id: <3E7D2311.82467D2B@earthlink.net>

Bart Lateur wrote:
> 
> Helgi Briem wrote:
> 
> >But linebreaks have nothing whatsoever to do with Perl
> >and everything to do with operating systems and their
> >conventions.
> 
> I can not agree. The conversion of CRLF to "\012" when reading from a
> text file, and vice versa, is typical for perl on Windows- and
> DOS-like systems. (I say typical for "perl", not for "Perl".) I don't
> think there are many other programming languages for DOS/Windows that
> do the same.

Umm, how about C?

If you use the open() function with O_TEXT as part of the mode, or if
you use fopen() without "b" as part of the modestring, then CRLF <=> LF
translation will occur.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 23 Mar 2003 07:54:20 +0100
From: "Trond Johansen" <trond@bwsnett.no>
Subject: Re: e-mail attachment.
Message-Id: <b5jlnp$2abhtg$1@ID-175630.news.dfncis.de>

Hi.



Sorry, should have checked it first. It was or is not in my intention
to use www.mysite.com for such things. I made it just as an
example for "MY own site"...
Since I'm working for an industry, I didn't want to use the

Correct address to our homepage.


So it has nothing to do with stonehenge.com or mysite.com



Ps...

I guess mysite is not a registered trademark?



And when you ask, yes! The people who will get the attachment want it.

It is 6 people in the firm where I'm working, who will get a report
mailed to them as soon as a new report is written.



Have a nice day!



-Trond Johansen.



"Randal L. Schwartz" <merlyn@stonehenge.com> skrev i melding
news:b7057b5c52006fc21fb9c8ad4ea9fd8e@news.teranews.com...
> >>>>> "Trond" == Trond Johansen <trond@bwsnett.no> writes:
>
> Trond> I have made a script that is sending e-mails with specified
> Trond> informations to several persons.
>
> Trond> I want to send them a html file that is created by the script I
> Trond> have made.
>
> Hooo boy.  Did you already *ask* all these people if they wanted HTML
> in their email?
>
> I know that if you tried to do that to me (or most of the addresses in
> the stonehenge.com domain), you'd get back the polite bounce message
> of:
>
>     You recently sent mail to $ADDRESS that contained something
>     other than plain text.  Perhaps you used "attachments", or enabled
>     "quoted printable" or "send as HTML".  Your message has been rejected
>     by the recipient.  Please resend the message as plain text.
>
>     For assistance in configuring your mailer, please see
>
>       http://www.expita.com/nomime.html
>
>     Thank you,
>     Randal L. Schwartz
>     postmaster@stonehenge.com
>
> HTML is *not* for email, unless specifically requested.
>
> 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: Sun, 23 Mar 2003 04:28:23 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: How to interchange fields and sorting in perl
Message-Id: <HJafa.173255$b8.37437078@news4.srv.hcvlny.cv.net>


"Michael Budash" <mbudash@sonic.net> wrote in message
news:mbudash-09C9EF.10513322032003@typhoon.sonic.net...
--snip--
> both your example and one in another earlier post sort the data by f2,
> f1, f3, which is not what the o.p. requires. it was easy to miss this
> fact, since the results will be the same due to the data. yours can be
> modified to do the job:
>
--snip code --

Thanks for pointing out my error in the sorting order.
You also implemented the second generalization that I mentioned.
(f2 does not have to be last) It is not necessary in this case.
Without the chomp, the original newline stays with the field f2.

I prefer to specify the sort order explicitly rather than
rearranging the fields twice.
Your use of map is a good idea.  Why not use it for the
main calculation?

use strict;
use warnings;
my @lines = map {[split(/:/)]} (<DATA>);
@lines = sort {$a->[1] cmp $b->[1] or $a->[2] cmp $b->[2]} @lines;
local $, = ':';
print @$_[1,0,2] for @lines;
__END__
siva:kumar:234
abcd:field:345
hydf:field:745


Thanks again,
Bill




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

Date: Sun, 23 Mar 2003 00:14:32 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How to interchange fields and sorting in perl
Message-Id: <3E7D42B8.FD5E7D65@earthlink.net>

siva wrote:
> 
> Hi
> 
> I am looking for following results through a perl program on a ascii
> file
> 
> f1    f2    f3
> siva:kumar:234
> abcd:field:345
> hydf:field:745
> 
> i want to read that file write back in sorting order f2,f3 and putting
> f2 in 1st postion f1 in second postion(inter change the files) . my
> output should look like this
> 
> field:abcd:345
> field:hydf:745
> kumar:siva:234

Here's a GRT which does what you want:

   #!/usr/bin/perl -w
   use strict;
   use warnings;
   print for
      grep s/:(.*?):(.*)/:$2:$1/,
      sort
      grep s/^([^:]*):([^:]*):([^:\n]*)$/$2:$3:$1/,
      <DATA>;
   __DATA__
   siva:kumar:234
   abcd:field:345
   hydf:field:745
[tested]

Note that this sorts alphabetically by fields f2 and f3.

If you wanted it to sort alphabetically by field 2, then numerically by
field 3, then you'd probably do it with an ST, instead of a GRT:

   print join( ":", @{$_}[1,0,2] ), "\n" for
      sort { $a->[1] cmp $b->[1] or $a->[2] <=> $b->[2] }
      map chomp $_ ? [split /:/] : (),
      <DATA>;
[untested]

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sat, 22 Mar 2003 22:09:58 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Idea for holding a C++ pointer in a Perl scalar with C++ type  information
Message-Id: <3E7D2586.4E9313B5@earthlink.net>

Asfand Yar Qazi wrote:
> 
> Hello
> 
> I'm new to perlguts, so forgive my mistakes.
> 
> I'll reiterate the subject: Idea for holding a C++ pointer in a Perl
> scalar with C++ type information
> 
> The basic concept is to use a double typed SV: the UV holds the
> pointer value, and the PV holds the type name (as obtained from
> type_info).
> 
> The SV is then blessed into the 'CXXPtr' class, so that simply any
> double-typed SV is not used to represent a C++ pointer.
> 
> Then, when a perl sub that wraps a C++ function is called, it checks
> that the type of the CXXPtr given matches the one the sub expects, and
> thus calls the C++ function with the pointer value contained the the
> UV part of the argument.
> 
> Thoughts?

Yes -- Instead of storing the two things in two different fields of the
SV, put *nothing* in the SV, but store both the object pointer and the
typename pointer in a bit of magic, which would then be *attached to*
the SV.  This way, perl code won't be able to do harmful things (either
accidentally or maliciously) to your C++ object.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sat, 22 Mar 2003 22:05:53 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Memory used by hashes
Message-Id: <3E7D2491.99DC263A@earthlink.net>

Anno Siegel wrote:
> 
> Benjamin Goldberg wrote:
> > "Fr€d" wrote:
> > >
> > > I am running a simple perl program that sums 5 variables over
> > > 100Gb of data.  I have 5 hashes that use the same 12 character
> > > key.  There are about 4 million keys.  Basically the program is:
> > >
> > > while (<INPUT>) {
> > >   $key =substr($_,0,12);
> > >   extract 5 numbers from $_;
> > >   $sum1{$key} ++;
> > >   $sum2{$key} += $val;
> > >   ... (for all 5 sums)
> > > }
> > [snip]
> >
> > For reducing memory usage, consider the following:
> >
> > my %allsums;
> > while( <> ) {
> >    my $key = substr($_, 0, 12);
> >    my $sums = \$allsums{$key};
> >    my @vals = split ' ', substr $_, 12; # or whatever.
> >    vec( $$sums, $_, 32 ) += $vals[$_] for 0..4;
> >    vec( $$sums, 5 , 32 ) += 5;
>                               ^
> s/5/1/, if I remember the OP right.

I assumed that the OP's: "... (for all 5 sums)" applied to both of the
preceding lines.  I could be wrong.

> 
> > }
> 
> Yes, combining scalars is the way to go here.  However, the OP
> says "...all variables are double precision".  If so, vec() won't
> do, something like "(un)pack 'd*', ..." will have to go in its place.
> 
> [...]
> 
> Anno

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 23 Mar 2003 03:36:25 GMT
From: josh <josh@zipcon.net>
Subject: Net::Telnet -> mysql login help
Message-Id: <Pine.LNX.4.51L.0303221931490.26692@zipcon.net>

Hello,

excuse the super noobie question; i am trying to script some quality
assurance routines for an ISP.  One of the checks needs to be simulating a
user login via telnet and then logging into their mysql database and doing
a listing of their tables.  This is the code I have so far:

sub mysql
{
        my ($server,$username,$passwd,$dbname,$dbpassword) = @_;
        my $result = 0;
        $t = new Net::Telnet (Timeout => 20);
        $t->open($server);
        $t->login($username, $passwd);
        $t->cmd("mysql -u $username --password=$dbpassword $dbname");
        $t->waitfor('/mysql>/') or die "err mesg:", print $t->dump_log();
        ($table) = $t->print("show tables;");
        $t->print("quit");
        print $table;
        # insert result setting code here
        print "mysql test successful\r\n\r\n";
        return $result;
}

However, I recieve an infinite hang at the waitfor call.

Any suggestions / pointer would be appreciated.

tia,

josh


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

Date: 23 Mar 2003 04:24:54 GMT
From: Nicholas Dronen <ndronen@io.frii.com>
Subject: Re: Net::Telnet -> mysql login help
Message-Id: <3e7d3716$0$198$75868355@news.frii.net>

josh <josh@zipcon.net> wrote:
j> Hello,

j> excuse the super noobie question; i am trying to script some quality
j> assurance routines for an ISP.  One of the checks needs to be simulating a
j> user login via telnet and then logging into their mysql database and doing
j> a listing of their tables.  This is the code I have so far:

j> sub mysql
j> {
j>         my ($server,$username,$passwd,$dbname,$dbpassword) = @_;
j>         my $result = 0;
j>         $t = new Net::Telnet (Timeout => 20);
j>         $t->open($server);
j>         $t->login($username, $passwd);
j>         $t->cmd("mysql -u $username --password=$dbpassword $dbname");
j>         $t->waitfor('/mysql>/') or die "err mesg:", print $t->dump_log();

j>         ($table) = $t->print("show tables;");
j> }

j> However, I recieve an infinite hang at the waitfor call.

Perhaps something like this?

	$t->cmd("echo 'show tables;' | mysql -u $u --password=$dbp $dbname");

Regards,

Nicholas

-- 
"Why shouldn't I top-post?"    http://www.aglami.com/tpfaq.html
"Meanings are another story."  http://www.ifas.org/wa/glossolalia.html


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

Date: Sun, 23 Mar 2003 03:54:27 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: regexp question
Message-Id: <9hbq7v8efcmp5o4mfjpo8ios5q47r2bvj9@4ax.com>

Mike wrote:

>if I have
>
>Line 1:<start>Hello World#
>Line 2:This is what I want
>Line 3: blah
>Line 4: blah blah
>Line 5:<stop>
>Line 6:<start>Hello Again#
>Line 7: I want this too !
>Line 8: blah
>Line 9: blah blah
>Line 10:<stop>
>
>etc
>
>So that I know the content I want will always be preceded by a line which
>ends in a '#'.  Is it possible to do it this way, or will I have to read in
>/ slurp the whole file and then parse it ?

May I suggest looking into the ".." range operator? For example:

	while(<>) {
	    if(my $count = (/^<start>/ .. /^<stop>/)) {
	         print "Found: $_" if $count == 2;
	    }
	}

Actually, it's quite interresting to see how $count correlates to the
input data, so maybe change the print line to:

	print "$count: $_";

which results in:

	1: <start>Hello World#
	2: This is what I want
	3:  blah
	4:  blah blah
	5E0: <stop>
	1: <start>Hello Again#
	2:  I want this too !
	3:  blah
	4:  blah blah
	5E0: <stop>

Note the special format of the value at the last line of the condition.
And just for fun, insert some other lines between the <stop> and the
next <start>.

p.s. Sorry I didn't focus on your starting point. I though your data had
some more interesting qualities than just "the first line ends in '$'".
:)

-- 
	Bart.


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

Date: Sat, 22 Mar 2003 21:44:09 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Text::ParseWords or Text::CSV
Message-Id: <3E7D1F79.DB7A10A5@earthlink.net>

david wrote:
> 
> Benjamin Goldberg wrote:
>> david wrote:
>>> Benjamin Goldberg wrote:
>>  [snip]
>>>>    my ($field0, $field1, $field2, @fields34) = split /,/, $_, -1;
>>>>    my $field4 = pop @fields34;
>>>>    my $field3 = join(",", @fields34);
>>  [snip]
>>>      my ($field0, $field1, $field2, @fields34) = split /,/, $_, -1;
>>>      my $field4 = @fields34;
>>>      my $field3 = join("+", @fields34);
>> [snip]
>>
>> Notice something missing?
> 
> You are right, I am missing the 'pop' command. If I run the script
> with the pop command this is what I get:
> dlepage,engineer,mn,
> aidan,support,va,infrastructure+engineering

That is because you have:

    @test = ($field0, $field1, $field2, "$field3\n");

And are not including $field4.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


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

Date: Sun, 23 Mar 2003 04:51:59 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: with ActivePerl, PPM "search" missing results that match regular expression?
Message-Id: <3e7d3bd8.867500@news.erols.com>

bennett@peacefire.org (Bennett Haselton) wrote:

: Good idea...  I assumed that the Crypt::SSLeay was available for
: Windows because I actually already have Crypt::SSLeay installed (I was
: searching for it because I'm trying to write a batch file that will
: check if the user has Crypt::SSLeay installed, and if they don't, will
: run the ppm install command to install it for them).  But PPM says
: it's no longer available for this platform:
 
: Is that normal, for ActivePerl to remove a PPM for a package that was
: there previously?  Why would they do that?

I cannot guess.  Asking Activestate about it would be more likely to
get an answer.  Perhaps it was simply a mistake of omission, and they
would be willing to update the file in their repository.



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 4747
***************************************


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