[12133] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5733 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 20 11:07:13 1999

Date: Thu, 20 May 99 08:00:21 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 20 May 1999     Volume: 8 Number: 5733

Today's topics:
        A basic question about passing parameters on the comman <gsguillot@demandsolutions.com>
    Re: Binary image file reading or $x as a number. (Larry Rosler)
    Re: C superior to Perl in DB2 programming? (soybean)
        How do I get my IP without DNS resolution <Mark.Conlin@bridge.bellsouth.com>
    Re: How to catch the return value in Perl? <aqumsieh@matrox.com>
    Re: No classes.zip file found (Larry Rosler)
    Re: No classes.zip file found (Kevin Reid)
    Re: out of memory! <aqumsieh@matrox.com>
    Re: out of memory! <vvb@ibm.net>
    Re: Perl "constructors" zenin@bawdycaste.org
    Re: Perl "constructors" zenin@bawdycaste.org
    Re: Perl "constructors" <garethr@cre.canon.co.uk>
    Re: PERLFUNC: s/// - replace a pattern with a string (Bart Lateur)
        Problems with perlxs moodfarm@hotmail.com
        search and fetch from Newsgroup <yhu@mail.nih.gov>
    Re: search and fetch from Newsgroup (Alastair)
    Re: search and fetch from Newsgroup <gellyfish@gellyfish.com>
    Re: Seek on STDIN? <asharka@my-dejanews.com>
        seek works differently b/w Solaris and Linux? <tomko@xnet.com>
    Re: Tie Fighter (Chris Nandor)
    Re: TROLL ALERT (Re: Perl "constructors") <gellyfish@gellyfish.com>
    Re: undef of namespaces <g059@mailserv.uni-giessen.de>
    Re: undef of namespaces <anno4000@lublin.zrz.tu-berlin.de>
    Re: web access counters - off-topic (Michel Dalle)
    Re: Y2K.  localtime(time) (I R A Aggie)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 20 May 1999 09:29:47 -0500
From: "G. Scott Guillot" <gsguillot@demandsolutions.com>
Subject: A basic question about passing parameters on the command line.
Message-Id: <7i169t$5qm$1@ffx2nh3.news.uu.net>

'lo everyone.  Basic question about passing parameters to a perl script via
the command line.  Take the following example:

perl myscript.pl R E "This is a comment" Y "This is another comment"

There are five parameters being passed there; the letter R, the letter E, a
string "This is a comment", the letter Y, and then finally another string
"This is another comment".

My question is how to get those strings passed into my perl script as
strings and not individual words.  Right now $ARGV[0] = R, $ARGV[1] = E,
$ARGV[2] = This (Note the missing "), $ARGV[3] = is, etc.... and what I want
is

$ARGV[0] = R
$ARGV[1] = E
$ARGV[2] = "This is a comment"
$ARGV[3] = Y
$ARGV[4] = "This is another comment"

Thanks in advance for everyone's time and help !!

  -Scott.





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

Date: Thu, 20 May 1999 07:18:00 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Binary image file reading or $x as a number.
Message-Id: <MPG.11adb96d3a9919ae989aca@nntp.hpl.hp.com>

In article <7i0kks$jiv$1@nnrp1.deja.com> on Thu, 20 May 1999 09:29:01 
GMT, armchair@my-dejanews.com <armchair@my-dejanews.com> says...
> In article <MPG.11ad51697f06d7c3989ac4@nntp.hpl.hp.com>,
>   lr@hpl.hp.com (Larry Rosler) wrote:
 ...
> > Five lines to one:
> >
> >   printf '%.2x' x $bytes, unpack "C$bytes", $data; # or just 'C*'
> 
> (  "format specifier" x $value  )
> Very interesting. Reminds me of the ( (1) x @array )  I have been seeing
> elsewhere to assign values to hashes.

I posted that kind of thing yesterday in another thread.

> > Or (much more directly):
> >
> >   print unpack 'H*', $data;
> 
> "How's the programming group doing, Samuels?"
> "Not bad. Fine group, and we have one standout who is putting out about
> 5 times as many lines of code per day as the rest of them."

In the Bad Old Days when I was a (sssh!) manager, I'd rank people by 
'Lines of Code removed' instead of 'Lines of Code written'.  That 
included comments, too.  :-) 

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


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

Date: Thu, 20 May 1999 14:37:11 GMT
From: none@ever.net (soybean)
Subject: Re: C superior to Perl in DB2 programming?
Message-Id: <37441d01.262805013@news.supernews.com>

On Thu, 20 May 1999 00:41:20 GMT, "Bruce (the other) McCrea"
<bruce2@home.com> wrote:

If this doesn't work, though I'm sure it will, you should do a
ldd /usr/local/lib/perl5/site_perl/5.005/aix/auto/DBD/DB2/DB2.so
to see what libraries it debends on.
Also since you are getting some sort of does not exist error, you
should do a
ls -l /usr/local/lib/perl5/site_perl/5.005/aix/auto/DBD/DB2/ (as well
on any other directory)
to see if the DB2.so in that dir is just a simlink to some other, more
real, DB2.so 

>You need the DB2 SDK to build the module DBD::DB2.
>To use the perl code on another machine, you'll need to copy the whole
>/usr/local/lib/perl5 directory tree and /usr/local/bin/perl and whatever
>gets installed when you install and compile perl or any module.
>You should do this anyway. You will keep your perl run time environment
>consistent throughout your enterprise.
>
>The only limitation is that the destination machine architecture MUST
>be the same as the source architecture. So you are limitted to any
>IBM RS/6000 Power machine. IBM lets you copy your derived libraries
>for nothing, which is good.
>
>Hope this helps.
>
>
>Tzadik Vanderhoof wrote in message <7hup3e$8vb$1@nnrp1.deja.com>...
>>I'm quite surprised that I have gotten no response to this question
>>(especially with such a provocotive subject :), so I'm reposting it.
>>
>>The customer allowed me to write this thing in Perl and is now
>>regretting it, because it seems like it cannot be installed on a machine
>>without the DB2 SDK, whereas had it been written in C, it would not have
>>this problem.  If this conclusion is wrong, PLEASE LET ME KNOW!  If my
>>conclusion is right, PLEASE LET ME KNOW!  Thanks!
>>
>>Here is the original post:
>>
>>----------
>>----------
>>Is there any way I can distribute my Perl script that uses DBD::DB2 to
>>machines that do not have the DB2 SDK installed?
>>
>>I know that the DB2 SDK is necessary to *build* DBD::DB2 but question
>>why it should be necessary for simply *running* a script that *uses*
>>DBD::DB2.
>>
>>One irritating aspect of this problem is that apparently a C program
>>that uses DB2 does not suffer from this problem.  You just "bind" the C
>>program with the DB2 database (on a machine that has the DB2 SDK) and
>>then you can distribute the compiled and "bound" C program to a machine
>>that does *not* have the SDK. Thus if this is true, programming DB2 apps
>>in C has a distinct advantage over programming them in Perl, which rubs
>>me the wrong way.
>>
>>One problem with this issue is how to copy a DBD::DB2 module from one
>>machine to the other (without building it on the second machine).  I
>>tried doing such a copy recently by simply using "tar" to package up the
>>relavant directorys in /usr/local/lib/perl5, but I could not run my
>>script on the second machine. I would get:
>>
>>Can't load
>>/usr/local/lib/perl5/site_perl/5.005/aix/auto/DBD/DB2/DB2.so' for
>>module DBD::DB2: dlopen:
>>
>>/usr/local/lib/perl5/site_perl/5.005/aix/auto/DBD/DB2/DB2 .so:
>>A file or directory in the path name does not exist. at
>>/usr/local/lib/perl 5/5.00502/aix/DynaLoader.pm line 168.
>>
>>(The "DB2.so" file it claims does not exist actually does exist...the
>>problem seems to be something that is called from "DB2.so".  The only
>>way I could come up with to solve this problem was to install the DB2
>>SDK on the second machine and rebuild DBD::DB2 there, which the customer
>>does not want as a production solution.  They do not want the SDK
>>installed in production)
>>
>>
>>--
>>
>>Thanks,
>>
>>Tzadik
>>
>>
>>--== Sent via Deja.com http://www.deja.com/ ==--
>>---Share what you know. Learn what you don't.---
>



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

Date: Thu, 20 May 1999 09:03:42 -0400
From: Mark Conlin <Mark.Conlin@bridge.bellsouth.com>
Subject: How do I get my IP without DNS resolution
Message-Id: <3744082E.D7F6F46E@bridge.bellsouth.com>

The FAQ states

> The Sys::Hostname module (part of the standard perl distribution) will 
> give you the hostname after which you can find out the IP address
> (assuming you have working DNS) with a gethostbyname() call. 
> 
>     use Socket;
>     use Sys::Hostname;
>     my $host = hostname();
>     my $addr = inet_ntoa(scalar gethostbyname($host || 'localhost'));

I do not have DNS resolution on these boxes, in fact there is also no
file /etc/resolv.conf for me to look into either, is there another way,
is it possible for me to strip it from the URL ?

Mark


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

Date: Thu, 20 May 1999 08:44:58 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: How to catch the return value in Perl?
Message-Id: <x3ypv3v29md.fsf@tigre.matrox.com>


"peary" <peary@ms1.url.com.tw> writes:

> And the '.' is not directory, it's the execution command on Redhat
> Linux(bash).
> I have to type "./filename" to execute a file.

Warning: this is off-topic and is not Perl related.

The '.' does signify the current directory. When you type
"./filename", you are asking the shell to execute the file called
'filename' in the current directory.

Probably, the problem is with your path. If you do have the current
directory (either as a dot, or as a complete path name) in your $PATH
env variable, then you should be able to simply type "filename" and
the program will execute (unless, of course, there is another program
called "filename" whose path precedes the current path in your $PATH).

Ala



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

Date: Thu, 20 May 1999 06:52:22 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: No classes.zip file found
Message-Id: <MPG.11adb3641c952fbf989ac7@nntp.hpl.hp.com>

In article <slrn7k5rq3.e0u.cederstrom@vortex.cede.net> on Wed, 19 May 
1999 20:05:07 +0300, Juho Cederstrom 
<cederstrom@kolumbus.REMOVE_THIS.fi> says...
 ...
> print "$_ is Perl!\n"		if	/^[Pp]erl(\n)?$/;
> print "$_ is *NOT* Perl!\n"	unless	/^[Pp]erl(\n)?$/;
> 
> Now it recognises even perl and Perl\n (when somebody forgets to use
> chomp).

The regex can be written simply as:

    /^[Pp]erl$/

>From perlre:

    $   Match the end of the line (or before newline at the end)

> BTW: Are there better ways to write that one? I don't like using two
> same regexes that way. And I like this neither:
> 
> if( /^[Pp]erl(\n)?$/ ) {
> 	print ...
> } else {
> 	print ...
> }

You will like this, then:

  print "$_ is ", !/^[Pp]erl$/ && '*NOT* ', "Perl!\n";

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


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

Date: Thu, 20 May 1999 10:38:35 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: No classes.zip file found
Message-Id: <1ds3l14.8bxbxe6syfm8N@[192.168.0.1]>

Juho Cederstrom <cederstrom@kolumbus.REMOVE_THIS.fi> wrote:

> print "$_ is Perl!\n"         if      /^[Pp]erl(\n)?$/;
> print "$_ is *NOT* Perl!\n"   unless  /^[Pp]erl(\n)?$/;
> 
> BTW: Are there better ways to write that one? I don't like using two
> same regexes that way. And I like this neither:
> 
> if( /^[Pp]erl(\n)?$/ ) {
>       print ...
> } else {
>       print ...
> }

print "$_ is", ' *NOT*' x !/^[Pp]erl$/, " Perl!\n";

-- 
 Kevin Reid: |    Macintosh:      
  "I'm me."  | Think different.
    


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

Date: Thu, 20 May 1999 08:49:37 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: out of memory!
Message-Id: <x3yogjf29em.fsf@tigre.matrox.com>


Marc Eilens <M.Eilens@DeutschePost.de> writes:

> The task is to read a file and split different rows into different
> files.
> I open the file and then read the complete file with the while(<>) loop.
> Then I deal with the different rows.
> Running the script on a file of about 100 KB works fine. But when
> running it on a file of 2.5 Meg I get the message "out of memory!". It
> seems that the file was read in correctly (debug-statement is written
> out after the while-loop). But after that, there somewhere seems to be
> no more memory.

Most of my programs deal with text files that are over 300MB large, so
the size of your file isn't the problem.

Obviously, your problem has to do with your choice of data
structures. Or maybe you are keeping unnecessary information in
memory. Or it could be that you are reading your file over and over
again. The point is, it is very hard for anyone to help you unless you
show us some code that exhibits the behaviour you're talking about.

Ala



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

Date: Thu, 20 May 1999 16:10:00 +0200
From: "Vincent Vanbiervliet" <vvb@ibm.net>
Subject: Re: out of memory!
Message-Id: <37440859@news.uk.ibm.net>

Marc Eilens <M.Eilens@DeutschePost.de> wrote in message
news:3743CE12.2DE4@DeutschePost.de...
> Hi everybody,
>
> I've written one of my first perl-scripts and have got a question about
> memory usage.
>
> The task is to read a file and split different rows into different
> files.
> I open the file and then read the complete file with the while(<>) loop.
> Then I deal with the different rows.
> Running the script on a file of about 100 KB works fine. But when
> running it on a file of 2.5 Meg I get the message "out of memory!". It
> seems that the file was read in correctly (debug-statement is written
> out after the while-loop). But after that, there somewhere seems to be
> no more memory.
>
> Has anybody an idea. It's urgent.
> Pleas cc me as I'm not always on the list.
>
> Thank's in advance.
>
> Marc
> -----------------
> Marc Eilens, Student
> mailto: M.Eilens@DeutschePost.de

As you're first reading the while file, and then deal with it, it might be
worth to read the
file line by line, and do something with every line. Of course I don't know
if what you
need to do allows that, but this prevents the whole file being stored in one
(or more)
variables.

Basically I think you should use following:

while (<FILEHANDLE>) {
    #do whatever you have to do with $_
}

instead of:
@all_my_data=<FILEHANDLE>;
This stores the whole file in one array, and is of course memory consuming.

Vincent




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

Date: 20 May 1999 12:13:30 GMT
From: zenin@bawdycaste.org
Subject: Re: Perl "constructors"
Message-Id: <927202557.145405@localhost>

armchair@my-dejanews.com wrote:
: In article <927038345.900648@localhost>,
:   zenin@bawdycaste.org wrote:
	>snip<
:> 	Your browser still can't linewrap correctly.
: That's a DejaNews issue.

	Your choice of newsreader, thus it's your issue.

:> No, it has hashes, which have the same effect for nearly all
:> practical uses.
: 
: Except that they are never guaranteed to hold one field. And never
: guaranteed to have any "field name" or key.

	Has a key, doesn't have a key, '', undef, 0 or not, it all really
	doesn't matter in practice.  This is Perl, autovivification takes
	care of the nasty bits.

	my %hash; ## empty hash
	if ($hash{'Some non-existent key'}++) {
	    print "You won't see this\n";
	}
	if ($hash{'Some non-existent key'}++) {
	    print "But you will see this!\n";
	}

	If you want strict key names (to avoid typo errors, etc), see the
	fields pragma.  It's faster too (array index access vs string hash
	key).

	>snip<
:> 	my %time_record;
:> 	@time_record{qw(
:> 	    sec
:> 	    min
:> 	    hour
:> 	    mday
:> 	    mon
:> 	    year
:> 	    wday
:> 	    yday
:> 	    isdst
:> 	)} = localtime;
:>
:> 	What's your point?
: 
: I never would have figured out the above slightly longer and more
: complicated technique.

	Of course not, BECAUSE YOU DON'T KNOW Perl!

	Learn Perl first, and the above would be both obvious and intuitive.

	It is also both shorter and simpler.

: And at the end of the day, you gain nothing except slower access over a
: record.

	And at the end of the day, you'll never notice the difference.  Any
	talk about speed is academic until it proves to be a practical
	problem in the Real World[tm].

:> : And just what is the big horrid taboo about records?  What is so
:> : outrageous about the concept?
:>
:> There is none.  Quite the opposite actually, as perl has built
:> in support for hashs (records).
: 
: You mean hashs (maps).

	Semantics.

:> : What would happen to Perl programmers if you had my record ( $name,
:> : ^$address, $city, $state, $zip, $ref_other ); in the
:> : language?
:>
:> 	What would it gain over a hash?  Hint: nothing.
: 
: Matter of opinion. A hash has an unknown amount of fields, 0 to n, and
: they can be misassigned  - STATE key was put in as STATES. Record has a
: fixed set of fields that are always present, with a guaranteed name.

	And once again, for the billionth time, see the fields pragma.  See
	also the perltie man page.  The features you ask for already exist
	and have for quite some time (however useless they are in practice).

:> : I am not looking for a separate type for short, int, double, just one
:> : that holds numeric values.
:>
:> 	my $n;
: 
: my $n = "zenin";

	Go back to C++ little boy, you'll never be happy with Perl if the
	above is such a problem for you or indeed a problem at all.

:> if you want to be anal and blow chunks if anyone ever
:> tries to put
:> anything "non-numeric" into $n, make yourself a pretty
:> little tied scalar class.
: 
: Or use something called Fields.pm.

	It's called fields.pm actually, but it won't stop you from dropping
	"non-numeric" data into a hash.  It will simply stop you from using
	non-declared key names.

:> : What technique do you use to validate that the $var you
:> : as being
:> : passed is actually a numeric value?
:>
:> It depends; Define numeric.  Decimal, float?  Also note that in perl
:> "123 foo bar dog" == 123.  Of course under -w you'll get a warning
:> if you do that, however if $n = '0 but true' you won't.  It will all
:> "work" however.
: 
: Perl only has one numeric and that consists of numbers, whether whole or
: real.

	#!/usr/local/bin/perl -w
	use strict;
	my $n = "0 but true";
	if ($n == 0) {
	    print "$n is 0!\n";
	}
	$n = "1e+07";
	if ($n == 10000000) {
	    print "Man is $n big!\n";
	}
	
	use builtin 'dualvar';
	my $eleven = dualvar 11, "Eleven";
	if ($eleven == 11) {
	    print "Perl can be turned up to $eleven!\n";
	}
	__END__

	0 but true is 0!
	Man is 1e+07 big!
	Perl can be turned up to Eleven!

	Go back to C++ Armchair, you're way out of your league here.

: My question is rhetorical as I have seen both the FAQ (uses regular
: expressions) and the "man page" where they show a technique (discussed in
: another post) where they add "this will cause warnings if you have the -w
: set." Since -w is highly recommended by people here, that "manual page"
: should be changed to show the FAQ technique.

	{ local $^W;  some_fancy_non_warning_compliant_code() }

	Even when you run under -w, not everything has to be "-w safe". 
	Same goes for use strict.

:> If you want to be anal, use a regexp to check it.
:>
:> There is a method to this madness however, that you don't
:> have the experience to understand as yet.
: 
: I'm just glad I don't understand your continued use of the term anal,
: and hope I never do.

	"anal-retentive" =~ /anal/

: sub a {
: my $scalar = $_[0];
: 
: }
: 
: what does $scalar contain zenin, number, string or reference?

	if (ref $scalar) {

	Use regexps on the rest, if you really need to know (hint: in
	practice, you normally don't).  Perl is a highly dynamic language,
	not an anal-retentive one.

	>snip<
: my $scalar = myObject->ReturnSomething();
: 
: what does $scalar hold at this moment zenin, number, string or
: reference?

	See perldoc myObject

-- 
-Zenin (zenin@archive.rhps.org)         Caffeine...for the mind.
                                        Pizza......for the body.
                                        Sushi......for the soul.
                                             -- User Friendly


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

Date: 20 May 1999 12:32:21 GMT
From: zenin@bawdycaste.org
Subject: Re: Perl "constructors"
Message-Id: <927203688.515452@localhost>

armchair@my-dejanews.com wrote:
	>snip<
: With function overloading, you can add new parameter lists and leave old
: code completely untouched and unmodified. It also makes you code more
: modular. And someone has mentioned a Perl module that somehow allows this.

	You don't need a module:

	#!/usr/local/bin/perl -w
	use strict;
	use Carp;
	sub foo {
	    ## Dispatcher only, no real code
	    for ($_[0]) {
	        ref             && goto &foo_ref;
	        /\D/            && goto &foo_string;
	        /^[+-]?\d+$/    && goto &foo_int;
	        /^-?\d+\.?\d*$/ && goto &foo_float;
	        confess "Invalid parameters";
	    }
	}

	sub foo_ref {
	    print "Ref is $_[0]";
	}
	my @foo;
	foo (\@foo);

	__END__

	You can get as fancy or as simple as you like.  You can even do
	translations such as converting foo("uno") to foo_int(1), on the
	fly.

	If you don't grasp introspection, you're going to hate Perl.

	>snip<
: The quicker you can see what someone's code is doing, the quicker you
: can get on to making your changes.

	Agreed.

: As much as I hate a standard being different from what I want to use, the
: more things are standardized the easier it becomes for people to
: comprehend each other's code. That of course does not mean that there
: cannot be complete comprehension of all code given infinite coding styles.
: But it does say that the comprehension will require less effort and occur
: faster. And could become significant if you have to look at large amounts
: of someone else's code.

	A myth.  Go play with Python if you beleave in it.

	Comming from C++ you shouldn't talk.  After the massive operator
	overloading C++ users take part in it's a wonder that anyone can
	understand anything...  And they say *Perl* looks like line noise!

:> > I am using size of the project to try and amplify a value or benefit.
:>
:> I don't think that's a very good technique.  The things that work well
:> for small projects don't necessarily work better for big projects, and
:> there are things one does for big projects that would be a disaster in
:> small projects.  I think small projects are completely different beasts
:> in a more fundamental way than that.
: 
: Regardless of if there are some cases where the above is true,
: if you had to look over a large amount of Perl programs that I had
: written, you would be muttering over and over again - "this is C code,
: this guy doesn't know how to code in Perl. What's he doing now....".

	You're probably right, we probably would...  Of course, you would
	have to actually have written a large amount of Perl programs
	first...

-- 
-Zenin (zenin@archive.rhps.org)         Caffeine...for the mind.
                                        Pizza......for the body.
                                        Sushi......for the soul.
                                             -- User Friendly


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

Date: Thu, 20 May 1999 12:57:15 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: Perl "constructors"
Message-Id: <siiu9new5w.fsf@cre.canon.co.uk>

armchair@my-dejanews.com wrote:
> > > I think there is some benefit to be looking at code and instantly
> > > see that a method is a constructor, or not.
> >
> > Why?  Seriously.
> 
> The quicker you can see what someone's code is doing, the quicker you
> can get on to making your changes.

In a language with automatic memory management, you don't need to know
when objects are being constructed.  It's generally none of your
business.  When I write

   $dbh = DBI->connect($datasource);

then a database handle may be constructed here, or a handle may be
available for re-use from a previous connection to the same datasource.
I don't need to know which, since I use the documented interface.

-- 
Gareth Rees


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

Date: Thu, 20 May 1999 14:19:28 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: PERLFUNC: s/// - replace a pattern with a string
Message-Id: <374519d1.12538663@news.skynet.be>

Tom Christiansen wrote:

>DESCRIPTION
>    The substitution operator. See the perlop manpage.

This must be one of the most useless posts in this series.

	Bart.


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

Date: Thu, 20 May 1999 13:03:44 GMT
From: moodfarm@hotmail.com
Subject: Problems with perlxs
Message-Id: <7i117f$rpu$1@nnrp1.deja.com>

I have been trying to link from perl to a C library, and it has not been
working, I have been getting an error about the DynaLoader modules (see
bottom)

The library I am trying to link is /sml/wip/libwip.a (on my system)

hopefully I have included enough of my source to let some one help me
out (if they feel inclined).
I have looked at a number of other perl modules that use xs and also the
perlxs and perlxstut man pages and everything seems to be right, so I
don't know what is going wrong please help, I have been bashing at this
for a week now !

thanks in advance
kevin@moodfarm.demon.co.uk

################
Makefile.PL

use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
    'NAME'	=> 'SML::Wip',
    'VERSION_FROM' => 'Wip.pm', # finds $VERSION
    'LIBS'      => ['-L/sml/lib -lwip'],   # e.g., '-lm'
    'INC' => '-I/sml/wip/',
#    'INST_LIB'	=> '/sml/lib/perl'
);

#############################
Wip.pm


package SML::Wip ;

require Exporter ;
require DynaLoader ;
require AutoLoader ;

use English ;
use IO::File ;
use IO::Socket ;
use IO::Handle ;
use IO::Select ;
use Socket ;
use File::Find ;

use vars qw($VERSION @ISA @EXPORT @EXPORT_OK) ;


@ISA = qw(Exporter AutoLoader DynaLoader) ;

# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
@EXPORT = qw( WIP_Server WIP_Client) ;
@EXPORT_OK = qw( $WIP_RECURSE $WIP_LONG) ;
$VERSION = '0.02' ;

# start up the link to libwip
package SML::Wip ;
bootstrap SML::Wip ;

### stuff missing
### down to using one of the linked library functions

sub ServerInc {
	my $socket = shift ;
	my $tmp = shift ;
	my %message = %$tmp ;
	my $file = $message{$BLOCK_0} ;
	my $error = $WIP_OK ;
	my $errorString = "Inc($file)" ;
	my $result = 0 ;
	my $buf ;

	$result = WIP_inc( $file, $buf) ;	# call the wip library function

	if( $result != 0) {					# 0 shows no error, < 0 is error
		$errorString .= " failed" ;
		$error = $WIP_BAD_FILE ;
	}
	LogError( $errorString) ;
	return ($error, $buf) ;
}




#############################
Wip.xs

#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef __cplusplus
}
#endif

#include </sml/wip/wip.h>



MODULE = Wip		PACKAGE = Wip


int
WIP_inc(name,buf)
	char * name ;
	char * buf ;
	PROTOTYPE: $$
    CODE:

	RETVAL = WIP_inc(name,buf);

    OUTPUT:
   	buf
    RETVAL

int
WIP_read(name,maxlen,buf)
	char * name ;
	int maxlen ;
	char * buf ;
	PROTOTYPE: $$$
    CODE:

    RETVAL = WIP_read(name,maxlen,buf);

    OUTPUT:
   	buf
    RETVAL

int
WIP_write(name,value)
	char * name ;
	char * value ;
	PROTOTYPE: $$
    CODE:

    RETVAL = WIP_write(name,value);

    OUTPUT:
    RETVAL

########################

running the program

 ./wipd
Can't load '/usr/lib/perl5/site_perl/i386-linux/auto/SML/Wip/Wip.so' for
module SML::Wip:
/usr/lib/perl5/site_perl/i386-linux/auto/SML/Wip/Wip.so: undefined
symbol: stat at /usr/lib/perl5/i386-linux/5.00404/DynaLoader.pm line
168.

 at ./wipd line 6
BEGIN failed--compilation aborted at ./wipd line 6.


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Thu, 20 May 1999 08:41:17 -0400
From: Ying Hu <yhu@mail.nih.gov>
Subject: search and fetch from Newsgroup
Message-Id: <374402ED.20BB7796@mail.nih.gov>

Hi:
Which win32 module is with the function that can search newsgroups
and/or download some pieces of news from newsgroups by the subject?
For example, the perl script can search the Subject of comp.soft-sys.sas
with ANOVA key word and download the news (with ANOVA)
from the newsgroup.

Thanks!
Ying




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

Date: Thu, 20 May 1999 13:15:14 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: search and fetch from Newsgroup
Message-Id: <slrn7k86a0.5f.alastair@calliope.demon.co.uk>

Ying Hu <yhu@mail.nih.gov> wrote:
>Hi:
>Which win32 module is with the function that can search newsgroups
>and/or download some pieces of news from newsgroups by the subject?

It might be worth looking into the Net::NNTP module. It isn't a Win32 specific
module. You should find it on CPAN (http://www.cpan.org).

Thanks,

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: 20 May 1999 15:23:42 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: search and fetch from Newsgroup
Message-Id: <37441aee@newsread3.dircon.co.uk>

Ying Hu <yhu@mail.nih.gov> wrote:
> Hi:
> Which win32 module is with the function that can search newsgroups

OK OK you dont need to keep posting it ....

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Thu, 20 May 1999 09:46:37 -0500
From: Al Sharka <asharka@my-dejanews.com>
Subject: Re: Seek on STDIN?
Message-Id: <3744204D.6C0@my-dejanews.com>

Ronald J Kimball wrote:
> Al Sharka <asharka@my-dejanews.com> wrote:
> 
> > open(README, "zcat $ARGV[0] |") || die "Couldn't fork: $!\n";
> >
> > $RECORDSIZE=68;
> > $TEMPLATE="i H14 i a5 s H16 H14 H4 H14 H16 H14 H14";
> >
> > #this doesn't work to skip records.  What's wong here?
> > seek(README, $RECORDSIZE * $ARGV[1], 0) if $ARGV[1];
> 
> which will die with the message:
> Can't seek: Illegal seek 
> You can't seek on a pipe.

Thank you.  Now, is there a way to accomplish skipping through
$ARGV[1] records without performing a read statement (literally
could be a million times), or is that how I have to do it?


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

Date: 20 May 1999 13:55:56 GMT
From: Paul Tomko <tomko@xnet.com>
Subject: seek works differently b/w Solaris and Linux?
Message-Id: <7i149c$sms$1@flood.xnet.com>

I had some CGI scripts which were working perfectly in Solaris, that suddenly
went nuts under Linux. I found that what is happening is that after doing a
seek to a specific byte location, if I do a read or write, it does not write
at the location I seeked to, but it writes at the next higher multiple of 
4K. If I use print, it writes at the correct location, but it moves the 
file pointer to the next higher multiple of 4K. Has anyone else seen this sort
of behaviour?
Paul

-- 
Paul Tomko        tomko@xnet.com    http://www.tomkoinc.com  
8000+ Humorous Quotes               http://www.tomkoinc.com/quotes.html 
"Invent a clever saying, and the world will remember your name forever."
 - Anonymous


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

Date: Thu, 20 May 1999 12:10:04 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Tie Fighter
Message-Id: <pudge-2005990810080001@192.168.0.77>

In article <37438267.185122451@news.oz.net>, tgy@chocobo.org wrote:

# On Wed, 19 May 1999 12:02:15 GMT, pudge@pobox.com (Chris Nandor) wrote:
# 
# >Well, it is no use for a general-purpose solution, certainly, because many
# >of us want to use globals only when globals are specifically called for,
# 
# And when are the use of globals (actually package variables) called for?
# Perhaps when they are the only solution.  No other solution has been given,
# general-purpose or otherwise.

Oops, I meant to respond to this.  What I meant (and apparently did not
express well) is that I want to use globals only when the solution, by
definition, requires globals.  For instance, in manipulating the symbol
table, or getting a reference to a filehandle.  These are solutions that
by their nature must use globals and globs.

The question at hand, passing a tied scalar, is not one that inherently
requires using globals, though that is currently the only solution
available.  I would prefer that there be another method available that
allowed the use of lexicals, as there is nothing inherent about tied
scalars that requires the use of globals.  Using globals is a hack to get
around a problem, it is not an adequate solution to the problem.

If you want to use globals, feel free.

By the way, if you don't believe me (still!) that package variables are
always global, and you've grepped perlsub for all instances of 'global'
and 'package' and STILL don't believe me, then see mjd's article "Coping
with Scoping".

    http://www.plover.com/~mjd/perl/FAQs/Namespaces.html

Don't know why you'd believe him and not me, though ;-), so maybe it won't help.

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


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

Date: 20 May 1999 13:45:07 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: TROLL ALERT (Re: Perl "constructors")
Message-Id: <374403d3@newsread3.dircon.co.uk>

armchair@my-dejanews.com wrote:
> In article <927142546.431844@localhost>,
>   zenin@bawdycaste.org wrote:
>> armchair@my-dejanews.com wrote:
>> 	>snip<
>> : And the documentation does still have me baffled. For instance:
>> :
>> : "localtime - convert UNIX time into record or string using local
> time"
>> :
>> : Maybe you can explain why they are using the term record in Perl
>> : documentation?
>>
>> That's easy, it doesn't:
>>
>> $ perldoc -tf localtime | grep record | wc
>> 	       0       0       0
>> $ perldoc -tf localtime
>>
>>    localtime EXPR
>>    Converts a time as returned by the time function to a 9-element
>>    array with the time analyzed for the local time zone. Typically
>>    used as follows:
>>
> 
> Well, you may not believe me on this, but I cut and paste my text from
> an entry in the "online manual" that you can get to via www.perl.com.


Look Nigel it doesnt even say 'record' in the *Perl 4* manpage so I very
much doubt that you saw it in any documentation pertaining to the
current release.

What you quoted there doesnt even like Perl documentation at all.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Thu, 20 May 1999 15:08:31 +0200
From: Marc Dietrich <g059@mailserv.uni-giessen.de>
To: Ronald J Kimball <rjk@linguist.dartmouth.edu>
Subject: Re: undef of namespaces
Message-Id: <Pine.A41.4.05.9905201507150.18328-100000@c2.hrz.uni-giessen.de>


Hello Ronald,

I wrote this script:

#!/usr/local/bin/perl

$Q::a = "Hello World!";
undef %Q::;
print "$Q::a\n";

the output is:

$./hello.pl
Hello World!
$

I'am using perl 5.004_04 on aix 4.2
It works correct in debugger mode (as you show it).

greetings 

Marc

Ronald J Kimball wrote:
> 
> Marc Dietrich <marc.dietrich@physik.uni-giessen.de> wrote:
> 
> > can someone please tell me, how to undefine complete namespaces (like
> > Q::). I have some variables in the Q namespace ($Q::a, @Q::b, ...) and
> > undef(%Q::) doesn't work.
> 
>   DB<1> $Q::bar = 'a'
> 
>   DB<2> V Q
> $bar = 'a'
>   DB<3> x %main::Q::
> 0  'bar'
> 1  *Q::bar
>   DB<4> undef %Q::
> 
>   DB<5> V Q
>   DB<6> x %main::Q::
>   empty array
>   DB<7>
> 
> Works for me.  What happened when you tried it?
> 




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

Date: Thu, 20 May 1999 16:26:00 +0200
From: Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
Subject: Re: undef of namespaces
Message-Id: <37441B78.C43FB79D@lublin.zrz.tu-berlin.de>

Marc Dietrich wrote:
> 
> Hello Ronald,
> 
> I wrote this script:
> 
> #!/usr/local/bin/perl
> 
> $Q::a = "Hello World!";
> undef %Q::;
> print "$Q::a\n";
> 
> the output is:
> 
> $./hello.pl
> Hello World!
> $
> 
> I'am using perl 5.004_04 on aix 4.2
> It works correct in debugger mode (as you show it).

Try this:

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

  $Q::a = "hi there";
  @Q::b = qw( hi there);
  %Q::c = ( 1 => "hi", 2 => "there" );

  print "before: ", $Q::a, ", ",  @Q::b, ", ",  %Q::c, "\n";

  foreach $key ( keys %Q:: ) { # the keys are the symbol names
    undef $Q::{$key};          # the values are typeglobs
  }

  print "after: ", $Q::a, ", ",  @Q::b, ", ",  %Q::c, "\n";

Output:

  before: hi there, hithere, 1hi2there
  Use of uninitialized value at ./x line 13.
  after: , , 

Why does undef()ing the whole symbol table in one fell swoop
not work?  I have no idea, I agree it should.

Anno


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

Date: Thu, 20 May 1999 12:03:54 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: web access counters - off-topic
Message-Id: <7i0tm6$5oi$1@news.mch.sbs.de>

In article <hyE03.7938$Gn3.1390@news.rdc1.il.home.com>, "Igor Fedulov" <ifedulov@outlook.net> wrote:
>Hello world of Perl gurus!
>
>Help please to newbie in Perl. Does anybody know where can I get a free
>counter .cgi script for my home page. Server running Apache under Unix.

Have a look at the CGI Resource Index at http://www.cgi-resources.com/,
and if you have any more CGI questions, go to the correct newsgroup :
        comp.infosystems.www.authoring.cgi

Ciao,

Michel.

--
aWebVisit - extracts visitor information from WWW logfiles and shows
the top entry, transit, exit and 'hit&run' pages, the links followed
inside your website, the time spent per page, the visit duration etc.
For more details, see http://gallery.uunet.be/Michel.Dalle/awv.html


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

Date: 20 May 1999 13:22:02 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Y2K.  localtime(time)
Message-Id: <slrn7k8393.cdb.fl_aggie@thepentagon.com>

On Wed, 19 May 1999 23:19:17 -0400, Ronald J Kimball
<rjk@linguist.dartmouth.edu>, in
<1ds2qvd.w2rqomrhaoa7N@p18.block1.tc4.state.ma.tiac.com> wrote:

+ >> Solaris 2.6, Perl 5.005_02
+ What was that about this being "the Microsoft way"?

Reaching for the newsreader before the man page is more microsludge
than unix...

James


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5733
**************************************

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