[13803] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1213 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 28 15:06:16 1999

Date: Thu, 28 Oct 1999 12:05:21 -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: <941137520-v9-i1213@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 28 Oct 1999     Volume: 9 Number: 1213

Today's topics:
    Re: "1" end ? <lr@hpl.hp.com>
    Re: $formdata=~s/\s+$//; ? c_j_marshall@my-deja.com
    Re: Announce: BBDB.pm module nadine.and.henry@pobox.com
    Re: Can find (a,b) differentiate btn a and b directorie (Brett W. McCoy)
    Re: comparing text with words <lr@hpl.hp.com>
        embedding perl in C <leberre@convergence.de>
    Re: file sorting,, repeated <lr@hpl.hp.com>
        Help w/Error: 501 Protocol scheme 'http' is not support pdhayes@my-deja.com
    Re: Help w/Error: 501 Protocol scheme 'http' is not sup <gisle@aas.no>
    Re: How di I join a string together? (Craig Berry)
    Re: How parse a,b,"x,y",c <lr@hpl.hp.com>
        How to convert a a single char (from a string) to a int <duthler@tebenet.nl>
    Re: How to convert a a single char (from a string) to a <lr@hpl.hp.com>
    Re: HTML::Parser <dsparling@my-deja.com>
        Installing perl for apache on winnt !! <anis.benhamida@sesa.ucl.ac.be>
    Re: Installing perl for apache on winnt !! <duthler@tebenet.nl>
        open FH, "+<&STDOUT" <jtolley@bellatlantic.net>
    Re: Pack function in Active Perl (win32) buggy? <theglauber@my-deja.com>
        Perl binaries. <tony@incyte.com>
        perl script for file uploading <jazz108@yahoo.com>
    Re: perlguts question (Mitchell Morris)
    Re: perlguts question <rhomberg@ife.ee.ethz.ch>
    Re: perlguts question (Ilya Zakharevich)
        Q: Hashes of Hashes of Hashes <bexxx@hasiland.com>
    Re: regex match with empty string <xah@best.com>
    Re: regex match with empty string (Chris Nandor)
    Re: regex match with empty string <aqumsieh@matrox.com>
    Re: Regular Expression (Tad McClellan)
    Re: Stored procedure with parameters. <sg@midwal.ca>
    Re: sysread / syswrite ? <howitgolook@my-deja.com>
    Re: system() call hangs, child is defunct (M.J.T. Guy)
        Why can't I get this uniq/perl thing right? <shon@mad.scientist.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 28 Oct 1999 10:41:43 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: "1" end ?
Message-Id: <MPG.12822aae5a8dc0da98a14d@nntp.hpl.hp.com>

In article <aEVR3.28817$up3.44895@news21.bellglobal.com> on Thu, 28 Oct 
1999 10:33:42 GMT, ling <link@nowhere.org> says...
> Why most html page created using perl have an "1" character appear at the
> end of page ?
> How to make it disappear ?

Non-snide answer (in contrast to some of the other answers in this 
thread):

Perhaps the program is printing the results of a print operation; the 
value returned by the print function on success is 1.

    print 'foo', 'bar',
    print 'baz', 'quux';

Output:

bazquuxfoobar1

Surprise!  All that is missing in the code is 'half a character'.

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


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

Date: Thu, 28 Oct 1999 16:15:21 GMT
From: c_j_marshall@my-deja.com
Subject: Re: $formdata=~s/\s+$//; ?
Message-Id: <7v9sqk$1s7$1@nnrp1.deja.com>

In article <7v9pgr$va9$1@nnrp1.deja.com>,
  boris_bass@my-deja.com wrote:
> I have a question on a closely related topic:
>
> if I have a string with multiple newlines and I want to get
> rid of all of them , should I use /s or /m modifier?
>
> $mystringwithmanynewlines=~s/\s+$/m/

syntax should actually be:   s/\s+//m;

>
>   or
>
> $mystringwithmanynewlines=~s/\s+$/s/
>
> What is the meaning of /s and /m modifiers, I could never figure
> that out exactly?


Use g instead. (the global modifier)

e.g.

sysupcma% cat test23.pl
#!/dvlp/gnu/SunOS5/bin/perl5.00404 -w
use strict;
use diagnostics;

my $fred = "hello\nthere\nharry\n";
print ":$fred:\n";

$fred =~ s/\n//g;
print ":$fred:\n";


sysupcma% test23.pl
:hello
there
harry
:
:hellothereharry:


Oh and you should probably check a faq somewhere too.


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


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

Date: Thu, 28 Oct 1999 16:06:54 GMT
From: nadine.and.henry@pobox.com
To: rootbeer@redcat.com
Subject: Re: Announce: BBDB.pm module
Message-Id: <7v9saq$1dn$1@nnrp1.deja.com>

In article
<Pine.GSO.4.10.9910262028260.29843-100000@user2.teleport.com>,
  Tom Phoenix <rootbeer@redcat.com> wrote:
> On Tue, 26 Oct 1999 nadine.and.henry@pobox.com wrote:
>
> > All you insidious users out there, you know who you are.  Here is
> > a new PERL module I wrote that makes it relatively easy to read
> > and write Big Brother DataBase files.  If you're interested, go to
> >
> > http://www.maztravel.com/perl/
> >
> > and get your own copy.
>
> Why aren't you putting it on CPAN as well?
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>
>

Dear Tom,

It is in progress, I just thought I'ld get quicker bug feedback this
way.
Best wishes,
Henry Laxen


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


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

Date: Thu, 28 Oct 1999 18:48:01 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Can find (a,b) differentiate btn a and b directories ?
Message-Id: <slrn81h6s7.hsf.bmccoy@moebius.foiservices.com>

Also Sprach Adrian Chin <achin@inprise.com>:

>I wanted to know if any way that I can differentiate btn a and b
>directories and the files within a and b as well ?
>
>I want to write a script that do a compare btn each files within a and b
>directories.

Are you using anything resembling Unix?  cmp and diff are two command-line
filters that will do just what you are looking for.

-- 
Brett W. McCoy                             bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek)   http://www.foiservices.com
FOI Services, Inc./DIOGENES                301-975-0110
---------------------------------------------------------------------------


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

Date: Thu, 28 Oct 1999 11:00:34 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: comparing text with words
Message-Id: <MPG.12822f1d2262795f98a14e@nntp.hpl.hp.com>

In article <slrn81fdqf.66b.abigail@alexandra.delanet.com> on 27 Oct 1999 
21:39:45 -0500, Abigail <abigail@delanet.com> says...
> Larry Rosler (lr@hpl.hp.com) wrote on MMCCXLIX September MCMXCIII in
> <URL:news:MPG.12814ede7f626fa898a146@nntp.hpl.hp.com>:

 ...

> ^^ Randal's main objection is worth passing on.  In code like this:
> ^^ 
> ^^     join FOO => @bar;
> ^^ 
> ^^     join FOO,   @bar;
> ^^ 
> ^^ the semantics depend on whether FOO is a bareword or a (constant) 
> ^^ subroutine.  This may be a trap for the unwary.
> 
> Well, yes, while this is true, this isn't an argument about using =>
> in certain contexts. It would be an argument about *any* construct
> that autoquotes barewords - including hash indexing.
> 
>      $hash {FOO}
> 
> is the same trap for the same unware people.

Thank you for enlarging the scope of the discussion away from the auto-
quoting 'fat comma' to a less avoidable context.  Describing this 
syntactic ambiguity as a weakness in language design is a gross 
understatement.

Distinguishing a quotable bareword from a function call requires 
knowledge of whether a subroutine declaration has been encountered 
during the compilation to this point, including all included files.  Use 
of an undeclared identifier as a bareword in normal program contexts 
would be caught by 'use strict qw(subs);'.  But in hash keys or left of 
=>, nothing will save you.

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


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

Date: Thu, 28 Oct 1999 18:28:47 +0200
From: Claude Le Berre <leberre@convergence.de>
Subject: embedding perl in C
Message-Id: <381879BF.1BE2A1D0@convergence.de>


I try to run a Perl script from a C program.
The problem is that the perl script is using modules.

according to the perlembed manpage, in the section
"Using Perl modules, which themselves use C libraries, from
your C program", I have inserted the following lines in my C program :
  #ifdef __cplusplus
        #  define EXTERN_C extern "C"
        #else
        #  define EXTERN_C extern
        #endif

        static void xs_init _((void));

        EXTERN_C void boot_DynaLoader _((CV* cv));
        EXTERN_C void boot_Socket _((CV* cv));

        EXTERN_C void
        xs_init()
        {
               char *file = __FILE__;
               /* DynaLoader is a special case */
               newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader,
file);
               newXS("Socket::bootstrap", boot_Socket, file);
        }

but when I compile my C program with :
cc -o interp interp.c `perl -MExtUtils::Embed -e ccopts -e ldopts`

I get xml2C.c:7: warning: `EXTERN_C' redefined
/usr/lib/perl5/5.00502/i586-linux/CORE/perl.h:151: warning: this is the
location of the previous definition
/tmp/ccy9yoZl.o: In function `xs_init':
/tmp/ccy9yoZl.o(.text+0x28): undefined reference to `boot_Socket'
collect2: ld returned 1 exit status.

I don't know what to you and the less I can say is that the manpage not
really clear is.
any help would be appreciated.

Claude


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

Date: Thu, 28 Oct 1999 11:45:34 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: file sorting,, repeated
Message-Id: <MPG.128239aa9ebb3fa998a150@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <3818126a_1@newsread3.dircon.co.uk> on 28 Oct 1999 10:07:54 
+0100, Jonathan Stowe <gellyfish@gellyfish.com> says...

 ...

> @rate = map   { substr($_, 1 + rindex $_,"\0" ) }
>         sort  { $b <=> $a }
>         map   { (split /;/)[5] . "\0" }
>         <FILE>;
> 
> (Sorry Larry but I just had to lose those '=>' )

That's not all you lost.  You also lost the concatenation of the input 
line, so that the data make it through to the end.  And you lost the 
statement to turn off warnings about numerical comparisons on strings 
that include stuff after the numbers.  So:

  { local $^W = 0;
    @rate = map   { substr($_, 1 + rindex $_, "\0" ) }
            sort  { $b <=> $a }
            map   { (split /;/)[5] . "\0$_" }
            <FILE>;
  }
 
But, as I said in my response, if one has to resort to a sortsub, why 
not just go back to using the Schwartz instead of doing the 
concatenation and substringing:

  @rate = map   { $_->[1] }
          sort  { $b->[0] <=> $a->[0] }
          map   { [ (split /;/)[5], $_ ] }
          <FILE>;

Use the Schwartz, /J\.

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


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

Date: Thu, 28 Oct 1999 17:54:46 GMT
From: pdhayes@my-deja.com
Subject: Help w/Error: 501 Protocol scheme 'http' is not supported
Message-Id: <7va2l4$6h3$1@nnrp1.deja.com>

The following code will work when executed on a test machine with a
modem, but will not on remote hosting server.  We get the following
error:

Error: 501 Protocol scheme 'http' is not supported

Here is the code:

**

#!/usr/local/bin/perl

use LWP::UserAgent;

my $URL = 'http://www.cnn.com';
print "Fetching $URL ...\n";

$ua = new LWP::UserAgent;
$req = new HTTP::Request 'GET' => "$URL";
$res = $ua->request($req);

**

Can anyone help?


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


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

Date: 28 Oct 1999 20:41:36 +0200
From: Gisle Aas <gisle@aas.no>
Subject: Re: Help w/Error: 501 Protocol scheme 'http' is not supported
Message-Id: <m3n1t3qqe7.fsf@eik.g.aas.no>

pdhayes@my-deja.com writes:

> The following code will work when executed on a test machine with a
> modem, but will not on remote hosting server.  We get the following
> error:
> 
> Error: 501 Protocol scheme 'http' is not supported

This means that LWP is not properly installed on that machine.  Did
you install it with 'make install'?

-- 
Gisle Aas


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

Date: Thu, 28 Oct 1999 17:41:09 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How di I join a string together?
Message-Id: <s1h2lljvr0878@corp.supernews.com>

Steven Filipowicz (steven@*REMOVE*filipowicz.com) wrote:
: I'm a webpage I have a form with 2 text fields. 1 called domain1 and the
: other domain2
: For example :
: 
: $FORM{'domain1'} = hello
: $FORM{'domain2'} = bye

This suggests you're parsing form fields in a CGI app using some technique
other than CGI.pm.  This is almost always a bad idea.

: Now I want to join 'hello' and 'bye' together and put them in $hostname.
: Like hostname = 'hello' + 'bye'
: 
: Print $hostname.
: Output will then be : hellobye
: 
: This is what I tried :
: ------------------------------------------------
: $domain1  =  $FORM{'domain1'};
: $domain2  =  $FORM{'domain2'};
: $hostname =  $FORM{'domain1'} + $FORM{'domain2'};
: ------------------------------------------------

Why did you try that, when your reading of perlop clearly shows that the +
operator doesn't do string joins?

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "They do not preach that their God will rouse them
      a little before the nuts work loose." - Kipling


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

Date: Thu, 28 Oct 1999 11:19:47 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How parse a,b,"x,y",c
Message-Id: <MPG.1282339eddbba89998a14f@nntp.hpl.hp.com>

In article <7v9ous$7n$1@sally.sik-gmbh.de> on 28 Oct 1999 15:09:16 GMT, 
Holger Marzen <hm@sik-gmbh.de> says...
> How can I split a line into words. The word separator is ,
> However it can be part of words if they are surrounded with "
> 
> Any ideas?
 
perlfaq4: "How can I split a [character] delimited string except when 
inside [character]? (Comma-separated files)"

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


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

Date: Thu, 28 Oct 1999 20:20:27 +0200
From: "jan smit" <duthler@tebenet.nl>
Subject: How to convert a a single char (from a string) to a int (decimal)???
Message-Id: <7va455$1mt$1@porthos.nl.uu.net>

id like to know how to convert a char to a decimal value ..
if id have a stringe like so : "hallo" ..
and id were to use regular expression to get the chat h .. then how could i
get its decimal value?? .. like @ = 64 if i remember correctly ..




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

Date: Thu, 28 Oct 1999 11:47:05 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How to convert a a single char (from a string) to a int (decimal)???
Message-Id: <MPG.12823a078d58816698a151@nntp.hpl.hp.com>

In article <7va455$1mt$1@porthos.nl.uu.net> on Thu, 28 Oct 1999 20:20:27 
+0200, jan smit <duthler@tebenet.nl> says...
> id like to know how to convert a char to a decimal value ..
> if id have a stringe like so : "hallo" ..
> and id were to use regular expression to get the chat h .. then how could i
> get its decimal value?? .. like @ = 64 if i remember correctly ..

perldoc -f ord

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


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

Date: Thu, 28 Oct 1999 18:07:06 GMT
From: dsparling <dsparling@my-deja.com>
Subject: Re: HTML::Parser
Message-Id: <7va3c8$71q$1@nnrp1.deja.com>

In article <7v4t1i$bs9$1@news.ipartners.pl>,
  "XeoN" <xeon@g-em.com> wrote:
> Hi,
>
> How do I use HTML::Parser module to get text from html file?
> I used HTML::Parse module (it was easy to me) but i've got some
troubles
> with HTML::Parser.
> ie.
>
> use HTML::Parse;
> use HTML::FormatText;
> .....
> print HTML::FormatText->new->format(parse_html($content));
>
> How to change it into one used HTML::Parser.
>
> XeoN
>
>

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

package MyHTMLparser;
use HTML::Parser;
@ISA = qw(HTML::Parser);

sub text {
   my ($self,$text) = @_;
   $self->{myText} .= $text;
}

package main;

# Select file to be parsed.
$in_file = "test.html";

# Parse file.
my $p = MyHTMLparser->new;
$p->parse_file("$in_file");
print $p->{myText};

# Save parsed file to output file.
$out_file = "test2.txt";
open(FILE, ">$out_file") || die "Cannot open $out_file for writing $!";
print FILE $p->{myText};
close FILE;




--
"Only two things are infinite: the universe and human stupidity."
Albert Einstein


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


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

Date: Thu, 28 Oct 1999 18:54:17 +0200
From: "anis benhamida" <anis.benhamida@sesa.ucl.ac.be>
Subject: Installing perl for apache on winnt !!
Message-Id: <7v9v8t$2cn$1@ail.sri.ucl.ac.be>

Hi all !!
Could somebody help me for installing perl modules under Apache for Winnt4
!!
thanx !!




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

Date: Thu, 28 Oct 1999 20:26:14 +0200
From: "jan smit" <duthler@tebenet.nl>
Subject: Re: Installing perl for apache on winnt !!
Message-Id: <7va4fn$1rd$1@porthos.nl.uu.net>

check out the documentation of apache (or perl) .. in one of the config
files ya hafta write down the directories and virtual directories of the cgi
and then ya can tell it that the .pl or .cgi or what eva is linked to perl
 ..
when ur done with that .. ya hafta change the location of perl.exe at the
top of everyscript ..  to the location where ur perl is installed..

but if ya ask me
get Win NT4 server with service pack5 and Internet information server 4 (3
is already installed).. altho its full of holes it is good =] .. or try
omnihttpd .. i like the options on it ...

ME =]

anis benhamida <anis.benhamida@sesa.ucl.ac.be> wrote in message
news:7v9v8t$2cn$1@ail.sri.ucl.ac.be...
> Hi all !!
> Could somebody help me for installing perl modules under Apache for Winnt4
> !!
> thanx !!
>
>




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

Date: Thu, 28 Oct 1999 17:51:10 GMT
From: James Tolley <jtolley@bellatlantic.net>
Subject: open FH, "+<&STDOUT"
Message-Id: <38188C87.DF3959BC@bellatlantic.net>

Hello All,

[Sorry if this is a repost - I thought I sent this already, but it's not
showing up...]

I'm trying to copy any old filehandle, without first knowing whether
that filehandle is open for reading, writing, or both... is there a way
to find this information?
I've tried to copy STDOUT as "+<&STDOUT", but get strange behavior,
depending on whether I execute the script as 'test.pl' (works fine) or
'test.pl | more' (dies on open()) - on win32. `perldoc -f open` only
says that you 'should' copy in the same mode as the original. I'd like
to follow that advice, if I can find out what that mode is...?

Thanks,

James





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

Date: Thu, 28 Oct 1999 16:28:31 GMT
From: The Glauber <theglauber@my-deja.com>
Subject: Re: Pack function in Active Perl (win32) buggy?
Message-Id: <7v9tj8$2da$1@nnrp1.deja.com>

In article <6sXR3.233$ZB5.3758@read2.inet.fi>,
  "Lars Soderstrom" <lars.soderstrom@capgemini.fi> wrote:
> Hello,
>
> I came across a awkward feature (I think) of the pack-function when
> programming a cgi-script in Active Perl. The web server is IIS.
> It seems to work Ok in a UNIX-based web server.
>
> It seems that the pack-function converts %0D%0A (CR-LF) in IIS to
_two_
> linefeeds when it is in UNIX converted to only one linefeed.
> Is this a bug? Makes porting UNIX->WIN a bit harder.


Could you post a short example?

--
Glauber Ribeiro
theglauber@my-deja.com
"Opinions stated are my own and not representative of Experian"


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


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

Date: Thu, 28 Oct 1999 11:29:20 -0700
From: Tony Higgins <tony@incyte.com>
Subject: Perl binaries.
Message-Id: <38189600.54CC9445@incyte.com>

Hi all,
    I am looking either to distribute via CD or point my
clients to the URL of perl binaries. The following
platforms are needed:

Sun 2.6 /  7        www.sunfreeware.com
Dec 4.0x
SGI 6.2 / 6.4 / 6.5
freeware.sgi.com/1999Nov/index-by-alpha.html

And the version of perl?? 5.005_03

Questions:
Are the above web pages the best / right place to go?
Where to go for DEC? digital unix / Tru64 / dec??
Is it legal to distribute perl on CD?

Thanks
--
Tony



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

Date: Thu, 28 Oct 1999 18:55:28 GMT
From: "n.thiyagarajan" <jazz108@yahoo.com>
Subject: perl script for file uploading
Message-Id: <38189F3D.177A881@yahoo.com>

i'm new to perl so go easy on me...

i have an html form that will be used for uploading a file.  i want to
write a perl script to upload the file and place the file in a specific
directory.  i'm having troble with enctype= multipart-formdata.

thanks

------------------------------------------
"be a light unto yourself" -gautama buddha

nandakumar
 thiyagarajan

   jazz108@yahoo.com




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

Date: 28 Oct 1999 16:13:29 GMT
From: mgm@unpkhswm04.bscc.bls.com (Mitchell Morris)
Subject: Re: perlguts question
Message-Id: <slrn81gth9.mmc.mgm@unpkhswm04.bscc.bls.com>

In article <38185F94.E5999ABD@ife.ee.ethz.ch>, Alex Rhomberg wrote:
>I'm having some fun with perlguts...
>
>What is the best way to duplicate a reference?
>is the reference count of the referenced object increased, if I make a
>copy with newSVsv(reference) or do I have to make a new reference of the
>original object? (like newRV_inc(svRV(reference)))
>
>- Alex

As always, it depends on what you want. If you only want a copy of the
reference itself, you can use newSVsv(). If you want another reference to
the underlying object, newSVsv isn't going to accomplish that, you'll
want newRV_inc(SvRV(thing)) instead.

I'm going to guess you really want another reference to the underlying
object, but that's my fallible human ESP, not the famed PSI::ESP module
speaking.

+Mitchell


-- 
Mitchell Morris

If at first you don't succeed, see if the loser gets anything.


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

Date: Thu, 28 Oct 1999 18:54:11 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: perlguts question
Message-Id: <38187FB3.9BD37607@ife.ee.ethz.ch>

Mitchell Morris wrote:
> 
> In article <38185F94.E5999ABD@ife.ee.ethz.ch>, Alex Rhomberg wrote:
> >I'm having some fun with perlguts...
> >
> >What is the best way to duplicate a reference?
> >is the reference count of the referenced object increased, if I make a
> >copy with newSVsv(reference) or do I have to make a new reference of the
> >original object? (like newRV_inc(svRV(reference)))
> >
> >- Alex
> 
> As always, it depends on what you want. If you only want a copy of the
> reference itself, you can use newSVsv(). If you want another reference to
> the underlying object, newSVsv isn't going to accomplish that, you'll
> want newRV_inc(SvRV(thing)) instead.
> 
> I'm going to guess you really want another reference to the underlying
> object, but that's my fallible human ESP, not the famed PSI::ESP module
> speaking.

Your ESP is correct. (It wasn't that easy to guess, as I asked
explicitly about incrementing the reference count)
I'm implementing some stuff to construct complex Perl structures with
all bells an whistles from nested C-structures of pointers to structures
to arrays etc.

I can now give a representation of a struct in Perl and automatically
create a C++ function that converts this struct to a Hashref
(recursively if must be)

Is there an easy way to check if the reference count of such a data
structure is correct?

- Alex


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

Date: 28 Oct 1999 18:16:58 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: perlguts question
Message-Id: <7va3uq$rv1$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Mitchell Morris
<mitchell@morrisland.com>],
who wrote in article <slrn81gth9.mmc.mgm@unpkhswm04.bscc.bls.com>:
> As always, it depends on what you want. If you only want a copy of the
> reference itself, you can use newSVsv().

In most cases this is an overkill.  

  return SvREFCNT_inc(rv);

is usually OK.

Ilya


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

Date: Thu, 28 Oct 1999 19:55:21 +0200
From: Ralf Beckers <bexxx@hasiland.com>
Subject: Q: Hashes of Hashes of Hashes
Message-Id: <38188E09.1F8CFB00@hasiland.com>

Hi,

dummy question:
how can I access (read/write) hashes of hashes of hashes?

In the docs I only found "hashes of hashes" ...

Thanks in advance,
Ralf Beckers


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

Date: Thu, 28 Oct 1999 09:08:12 -0500
From: "Xah Lee" <xah@best.com>
Subject: Re: regex match with empty string
Message-Id: <381874f0$0$231@newsreader.alink.net>

>     If the PATTERN evaluates to a null string, the last
>     successfully executed regular expression is used instead.

But what happens if there is no regex call before? as in

#!/usr/local/bin/perl -w
use strict;
if ('some' =~ m//) {print 'match'} else {print 'no'}

the delightfully detailed and accurace and precise perl
documentations didn't say?

You have to understand that the above test code matches yet
the one posted before doesn't. It's a giant mystery to perhaps all except
a few implementors.

<rant>
fucking, fuck, all fucked, fucking stupid Perl.

In other languages, one looks up docs and moves on.
In Perl, testing is in practice a necessacity, because
 fucking perl docs are so poor a quality that the best it
can do is give one a guide of things. Poor quality docs is
just a side effect. The source problem is Perl and it's
following culture. Precision and docs are discouraged.
Mumble jumble magic or TIMTOWTDI (on the level of stupid
sugar syntax) or whatnot shit are encouraged and loved by all here.
</rant>

> In the specific case below, I don't honestly see the point.  Maybe if we
> had some idea of what you were trying to accomplish, we'd have better
> suggestions.  Are you maybe putting a variable inbetween the //, which
> sometimes evaulates to the empty string?

 ...yes, but I'm not really interested in getting a solution
to whatever I was doing. I have plenty know-how to do what I want.
Suffice it to say that a bug in my program traced down to that, and fucking
wasted my time. I am interested in why perl hehaved the way it did, in
precise terms.
(god help us if Larry or Tom couldn't answer that.)

Thanks for the pointer to the perlop. (I've read a million perl
literatures... (and I CAN prove it to you) but you know how it is.)

Who wrote Find::File? It's such a crap in quite a few perspectives.

To the other guy who was *plonking* me: Don't be a moron, I'm not
interested in perl sugar syntax timtowtdies. Does not perl's freedom also
allow
people to not use whatever shortcut it has? I'll put a fucking m in //
anytime!
and if next time you can make a sound criticism on someone's code at the
algorithm level, that would perhaps decreases perl community's stupidity
a little bit on the whole.

Finally, to those unix weenies: Flame me, please do. I love it. Go ahead and
post a message about how you plonked me or killfiled me or how I'm a fucking
troll or how you've send me to /dev/nul. I love it. I'll be waiting to read
those messages and thank you.

 Xah
 xah@best.com
 http://www.best.com/~xah/PageTwo_dir/more.html
 The three principle virtues of Perl programers: mundaneness, sloppiness,
and fatuousness.
  -- Larry Wall, from antimatter universe


Eric The Read <emschwar@rmi.net> wrote in message
news:xkfn1t4h1g1.fsf@valdemar.col.hp.com...
> "Xah Lee" <xah@best.com> writes:
> > Normally an empty regex will match a string.
>
> Normally?  Maybe I'm reading the wrong part of perlop, but I see:
>
>     If the PATTERN evaluates to a null string, the last
>     successfully executed regular expression is used instead.
>
> In this case, you haven't used a regex before the empty one, so I'm not
> surprised it doesn't behve the way you want it to.
>
> > But not so in the following code that uses File::Find.
> >
> > I couldn't figure it out. Anyone?
>
> In the specific case below, I don't honestly see the point.  Maybe if we
> had some idea of what you were trying to accomplish, we'd have better
> suggestions.  Are you maybe putting a variable inbetween the //, which
> sometimes evaulates to the empty string?
>
> > Fucking stupid Perl.
>
> Seems rude to blame Perl when you don't even know what the problem is.
> Especially when it's 90% likely to be programmer error.
>
> <snip example>
>
> -=Eric
> --
> "Cutting the space budget really restores my faith in humanity.  It
> eliminates dreams, goals, and ideals and lets us get straight to the
> business of hate, debauchery, and self-annihilation."
>                 -- Johnny Hart




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

Date: Thu, 28 Oct 1999 16:29:46 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: regex match with empty string
Message-Id: <pudge-2810991229530001@192.168.0.77>

In article <381874f0$0$231@newsreader.alink.net>, "Xah Lee" <xah@best.com>
wrote:

# >     If the PATTERN evaluates to a null string, the last
# >     successfully executed regular expression is used instead.
# 
# But what happens if there is no regex call before? as in
# 
# #!/usr/local/bin/perl -w
# use strict;
# if ('some' =~ m//) {print 'match'} else {print 'no'}
# 
# the delightfully detailed and accurace and precise perl
# documentations didn't say?

Submit a patch to the docs.  How hard is that?


# <rant>
# fucking, fuck, all fucked, fucking stupid Perl.

s/Perl/Xah/


# In other languages, one looks up docs and moves on.
# In Perl, testing is in practice a necessacity, because
#  fucking perl docs are so poor a quality that the best it
# can do is give one a guide of things. Poor quality docs is
# just a side effect. The source problem is Perl and it's
# following culture. Precision and docs are discouraged.

I think the problem is that you can't read.


# ...yes, but I'm not really interested in getting a solution
# to whatever I was doing. I have plenty know-how to do what I want.

Obviously not, since you are blaming Perl and the docs for your ignorance,
thaty for a normally intelligent person could be cleared up by reading
said docs.


# Suffice it to say that a bug in my program traced down to that, and fucking
# wasted my time. I am interested in why perl hehaved the way it did, in
# precise terms.

"Why"?  Because that is how it is designed.


# Who wrote Find::File? It's such a crap in quite a few perspectives.

Patches welcome.


# Finally, to those unix weenies: Flame me, please do. I love it. Go ahead and
# post a message about how you plonked me or killfiled me or how I'm a fucking
# troll or how you've send me to /dev/nul. I love it. I'll be waiting to read
# those messages and thank you.

You are not a troll, you are simply being a jerk who can't take
responsibility on himself but would rather blame others for his
inadequacies.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Thu, 28 Oct 1999 11:15:47 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: regex match with empty string
Message-Id: <x3yk8o78qjh.fsf@tigre.matrox.com>


"Xah Lee" <xah@best.com> writes:

> Normally an empty regex will match a string.
> But not so in the following code that uses File::Find.
> 
> I couldn't figure it out. Anyone?
> 
> Fucking stupid Perl.

*Someone* is stupid alright. But it's NOT Perl.



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

Date: Thu, 28 Oct 1999 07:39:09 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Regular Expression
Message-Id: <tkc9v7.6ig.ln@magna.metronet.com>

Apisilp Trunganont (b39ast@ku.ac.th) wrote:

: I have this variable.

: $a = "[b]abc[/b] [b]def[/b]";
   ^
   ^

   Poor choice of variable name.

   The $a and $b package global variables are used for sorting.

   I never use them for anything else.


: And I want to change the value of this variable to "<b>abc</b>
: <b>def</b>".


   You don't need a regex to do what you have asked for.

   (though you might have asked for the wrong thing...)


      $str =~ tr/[]/<>/;  # change _all_ square brackets to angle brackets


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 28 Oct 1999 17:36:44 GMT
From: SG <sg@midwal.ca>
Subject: Re: Stored procedure with parameters.
Message-Id: <3818878C.1BB9823@midwal.ca>

Sorry... It was typing error at my message, not in my script. The actual
codes look like the following:


use DBD::Sybase;
$first = "N";
$second = "";
$dbh = DBI->connect ("dbi:Sybase:server=name", $user, $pass,
{RaiseError=>1,AutoCommit=>1});
$sth = $dbh->prepare ("BEGIN sp_name(:1,:2); END;") or die "Error";
$sth->bind_param (1, $first);
$sth->bind_param_inout (2, \$second, 10);
$rv = $sth->execute();



Tom Phoenix wrote:

> On Wed, 27 Oct 1999, SG wrote:
>
> > $dbh = DBI->connect ("dbi:Sybase:server=name, $user, $pass,
> > {RaiseError=>1,AutoCommit=>1});
> > $sth = $dbh->prepare ("BEGIN sp_name(:1,:2); END;) or die "Error";
>
> Are those quote marks doing what you really intend? Cheers!
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/





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

Date: Thu, 28 Oct 1999 18:30:13 GMT
From: fred <howitgolook@my-deja.com>
Subject: Re: sysread / syswrite ?
Message-Id: <s1h5hlier0869@corp.supernews.com>

Thanx.
Turns out it was a misreported Null Reference error (arrgh!). =)

Happy computing.


David Cassell wrote:
> 
> fred wrote:
> > 
> > 1. What are they?
> 
> Just type the following to get complete discussions:
> 
> perldoc -f sysread
> perldoc -f syswrite
> 
> > 2. Are they Un*x-specific?
> 
> No.  Give them a try.  Hey, what could happen?
> 
> > 3. Are there alternatives for them in Perl for Win95?
> 
> [See answer to #2]  No alternative needed.
> 
> But... you may want to look at the angle operator <FILE>
> and the print() function too.  They may do what you want.
> 
> David
> -- 
> David Cassell, OAO                     cassell@mail.cor.epa.gov
> Senior computing specialist
> mathematical statistician


--
Posted via CNET Help.com
http://www.help.com/


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

Date: 28 Oct 1999 17:51:51 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: system() call hangs, child is defunct
Message-Id: <7va2fn$972$1@pegasus.csx.cam.ac.uk>

Tom Phoenix  <rootbeer@redcat.com> wrote:
>On 27 Oct 1999, M.J.T. Guy wrote:
>
>> Set to 'DEFAULT' or better ensure it's not set at all.
>
>What do you mean by "not set at all"? Does some system offer a different
>behavior than 'IGNORE' or 'DEFAULT' provides?

Ambiguous use of "it" resolved to "$SIG{CHLD}".

I meant

       delete $SIG{CHLD};

Or alternatively, scan through your program looking for settings of
$SIG{CHLD} and cross them out.


Mike Guy


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

Date: Thu, 28 Oct 1999 18:25:02 GMT
From: mr_geek <shon@mad.scientist.com>
Subject: Why can't I get this uniq/perl thing right?
Message-Id: <7va4dq$7st$1@nnrp1.deja.com>

O.K. Here goes:

I have an html file I read in (which is generated by a command)
 This is a sample line:
 <td>BLM03 | 2594 | Bloom, Lip Balms </td>

open FILE, "command |";
while ($line = <FILE>) {
  if ($line =~ /\|/) {            #match line with a | in them
    $line =~ s/<td>//;            #strip off the <td> tags
    $line =~ s/<\/td>//;          #same as above
    $line =~ s/^\s+//;            #kill all the white space
    $line =~ s/$\s+//;            #you get the idea
    @fields = (split /\|/, $line);
    $base = @fields[0];           #getting BLM03 from the sample line
    $base =~ s/\s+//;             #no whitespace required
    push(@bases,$base);           #putting $base into an array
  }
  @bases = sort(@bases);          #this SHOULD sort the array (doesn't)
  $prev = 'nonesuch';             #these SHOULD cut away duplicate lines
  @bases = grep($_ ne $prev && ($prev = $_), @bases);
  while (@bases) {
    $base1 = pop(@bases);
    $base1 =~ s/\s+//;
    print "$base1\n";
  }
}
close STREAM;

This is not working for me. I am getting this:
BLM03
BLM03
BLM03
PLY01
PLY01
BLM03
PLY01

I want this:
BLM03
PLY01

What can I do? I know TMTOWTDI. If anyone can help me with this I would
appreciate it. I know this is long and very specific, but I've been
working on it for 36 hours (not consecutively)

Thanks,
Shon


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


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

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


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