[22436] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4657 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 3 18:06:25 2003

Date: Mon, 3 Mar 2003 15:05:10 -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           Mon, 3 Mar 2003     Volume: 10 Number: 4657

Today's topics:
    Re: '@' symbol confusion <tore@aursand.no>
        [REPOST] Using a (config) file relative to a module loc <bik.mido@tiscalinet.it>
    Re: Best way to learn perl? (Tad McClellan)
    Re: Best way to learn perl? <usenet@dwall.fastmail.fm>
    Re: Best way to learn perl? <newsfeed2@boog.co.uk>
    Re: Best way to learn perl? <olaf73NO@SPAMswbell.net>
        DBI - Manage multiple SELECT count(*) (Hunter)
    Re: DBI - Manage multiple SELECT count(*) <tore@aursand.no>
    Re: Early Perl source <krahnj@acm.org>
    Re: Guestbook Pro 1.0 <ajglist@izzy.net>
        how do I backup db files via FTP?? <aragorn@freemail.gr.gr>
    Re: how do I backup db files via FTP?? (Anno Siegel)
    Re: how do I backup db files via FTP?? <ethan@draupnir.gso.saic.com>
    Re: Need to trim word with parenthesis (Tad McClellan)
    Re: Need to trim word with parenthesis impervious@attbi.com
    Re: new Perl feature request: call into shared libs <nospam-abuse@ilyaz.org>
    Re: newbie array question <pirabhur@ufl.edu>
    Re: newbie array question <bigj@kamelfreund.de>
    Re: NEWBIE: PerlNET <flavell@mail.cern.ch>
    Re: NEWBIE: PerlNET <newsfeed2@boog.co.uk>
    Re: NEWBIE: PerlNET <bigj@kamelfreund.de>
    Re: Question about inline. <tore@aursand.no>
    Re: Question about inline. <bigj@kamelfreund.de>
    Re: Question about inline. (Brian Snyder)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 03 Mar 2003 20:12:09 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: '@' symbol confusion
Message-Id: <pan.2003.03.03.18.59.16.692675@aursand.no>

On Mon, 03 Mar 2003 13:02:50 +0000, Mike wrote:
> Thanks for responding but I do have a question:
> [...]

One more thing:  Please don't put your reply _above_ what you're
answering.  It's called "top-posting" and is very frustrating for others
who is trying to catch up with the thread.

> What is the advantage of using DBI over the method I chose?

DBI is Perl's database independent interface.  By using it, you can be
_almost_ sure that your code will work independently of what database you
prefer to use (ie. Oracle, PostgreSQL etc).


-- 
Tore Aursand - tore@aursand.no - http://www.aursand.no/



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

Date: Mon, 03 Mar 2003 23:52:50 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: [REPOST] Using a (config) file relative to a module location...
Message-Id: <ntm76vskmtc4e89rph5vlk7uigklssmfqo@4ax.com>

I hope not to be harassing this ng by reposting my question, but I
didn't get any answer and I suspect it somehow went "underseen".

# Original Message
# ================

If I want to "use" (say, open, write, or both) a file (e.g. a config
file) in the same dir as a script (or in a directory identified by a
path relative to that dir), browsing through the docs I found out that
I can use the FindBin module.

But then I thought that I might just stuff the relevant code in a
module assuming implicitly that a relative path would have been
interpreted relative to the module's location. By experimenting I
discovered that it is not the case.

In the end, reading some other docs, I wrote the following code:

# -*- mode: perl -*-
package foo;
use strict;
use warnings;
use File::Basename;
require Exporter;
our @ISA=qw/Exporter/;
our @EXPORT_OK=qw/foo/;

sub foo {
    open my($fh), "<", dirname($INC{'foo.pm'}) . "/foo.txt" 
      or die "Can't open config file 'foo.txt': $!\n";
    return <$fh>;
}

1;
__END__

Eventually, it works as intended, but are there any issues with it?
What is the "correct" way to accomplish this task, anyway?

Also, even if use File::Basename to get an OS-independent behaviour
(at an intermediate stage I just used 's|[^/]+$||'), I still use "/"
as a directory separator on the open() line (don't know how to do it
otherwise[*]).

As a side question, not that using a module is a major concern for me,
but both for what regards FindBin and my issue, aren't these matters
so important that a built-in facility should be provided by the
interpreter? (e.g. yet another built-in variable)


[*] OK: I'm aware that I can give a peek into File::Basename itself,
but... isn't this getting a bit too complicated?!?


Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


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

Date: Mon, 3 Mar 2003 13:25:08 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Best way to learn perl?
Message-Id: <slrnb67b0k.49h.tadmc@magna.augustmail.com>

Olaf <olaf73NO@SPAMswbell.net> wrote:

> I am looking to learn perl. I have no programming experience to speak
> of.

> What would you guys recommend to me?


   "Elements of Programming with Perl" by Andrew Johnson


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 03 Mar 2003 20:34:53 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Best way to learn perl?
Message-Id: <Xns93339E7F8D91Adkwwashere@216.168.3.30>

Tad McClellan <tadmc@augustmail.com> wrote on 03 Mar 2003:

> Olaf <olaf73NO@SPAMswbell.net> wrote:
> 
>> I am looking to learn perl. I have no programming experience to
>> speak of.
> 
>> What would you guys recommend to me?
> 
>    "Elements of Programming with Perl" by Andrew Johnson

Also see http://learn.perl.org/ for other references.  You'll see that 
the web site recommends the same book, too.  :-)

-- 
David K. Wall - usenet@dwall.fastmail.fm
"Oook."


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

Date: Mon, 3 Mar 2003 20:36:59 -0000
From: "Peter Cooper" <newsfeed2@boog.co.uk>
Subject: Re: Best way to learn perl?
Message-Id: <R0P8a.11297$EN3.90218@newsfep4-glfd.server.ntli.net>

"Olaf" <olaf73NO@SPAMswbell.net> wrote:
> What would you guys recommend to me?  Looking for some specific book
> titles, or software, or even a progression path (with references) from
> an easier language on up to perl.

Well, I gotta say that Perl is an excellent choice for a 'first language'. Perl
is very much focused on results, rather than syntax or core concepts. With Perl
you don't have to worry about variable types (well, not as much as in, say, C).
Playing with data is a lot easier, so you can focus on what you want to get
done, rather than on how it's all done at the machine level.

However, some people might think this is a bad thing, as it encourages
'laziness' from the start. It all depends on your approach. I'd personally
advise you learn about how to get results first, then focus on the theory later.
But if you want to get a feel for how things work at the machine level, you
can't go wrong starting with C.

The question here is.. how do you want to learn? Are you interested in
programming academically? Or are you focused on the results?

Pete




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

Date: Mon, 03 Mar 2003 20:53:14 GMT
From: "Olaf" <olaf73NO@SPAMswbell.net>
Subject: Re: Best way to learn perl?
Message-Id: <_gP8a.120$u%7.87702683@newssvr11.news.prodigy.com>

"Peter Cooper" <newsfeed2@boog.co.uk> wrote in message
news:R0P8a.11297$EN3.90218@newsfep4-glfd.server.ntli.net...
> "Olaf" <olaf73NO@SPAMswbell.net> wrote:
> > What would you guys recommend to me?  Looking for some specific book
> > titles, or software, or even a progression path (with references)
from
> > an easier language on up to perl.
>
> Well, I gotta say that Perl is an excellent choice for a 'first
language'. Perl
> is very much focused on results, rather than syntax or core concepts.
With Perl
> you don't have to worry about variable types (well, not as much as in,
say, C).
> Playing with data is a lot easier, so you can focus on what you want
to get
> done, rather than on how it's all done at the machine level.
>
> However, some people might think this is a bad thing, as it encourages
> 'laziness' from the start. It all depends on your approach. I'd
personally
> advise you learn about how to get results first, then focus on the
theory later.
> But if you want to get a feel for how things work at the machine
level, you
> can't go wrong starting with C.
>
> The question here is.. how do you want to learn? Are you interested in
> programming academically? Or are you focused on the results?

I think results at this point.  I am a UNIX admin by trade, but I just
dont have any real technical competency with any kind of programming or
scripting.  I want to fix that so as to improve my employability, and
perhaps open a door to another career path if its something I enjoy or
take to.

olaf




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

Date: 3 Mar 2003 11:47:43 -0800
From: dave_h4@yahoo.com (Hunter)
Subject: DBI - Manage multiple SELECT count(*)
Message-Id: <27ad91d2.0303031147.aec27bd@posting.google.com>

Hi - I created an online survey and now I would like to view the
results. Most questions are either Yes or no answers. I started
writing the script to pull the data from the database. Is there a more
efficient way to store the results of the boolean question rather than
issuing a select count for every quesiotn:

print "2. Have you ever posted a request?";
  my $sth;
  my $query = "select count(*) from mysurvey where posted = 'Y'";
  $sth = $dbh->prepare($query);
  $sth->execute();
  while (@row = $sth->fetchrow_array) {
      ($one) = @row;
       print "$one people answered <b>YES</b> out of $total total
respondants";
  }

print "3. Are you aware we offer 24x7 service?";
  my $sth;
  my $query = "select count(*) from mysurvey where preference = 'Y'";
  $sth = $dbh->prepare($query);
  $sth->execute();
  while (@row = $sth->fetchrow_array) {
      ($one) = @row;
       print "$one people answered <b>YES</b> out of $total total
respondants";
  }

Thanks very much.

dave


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

Date: Mon, 03 Mar 2003 23:23:34 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: DBI - Manage multiple SELECT count(*)
Message-Id: <pan.2003.03.03.22.16.09.367267@aursand.no>

On Mon, 03 Mar 2003 11:47:43 -0800, Hunter wrote:
> print "2. Have you ever posted a request?";
>   my $sth;
>   my $query = "select count(*) from mysurvey where posted = 'Y'";
>   $sth = $dbh->prepare($query);
>   $sth->execute();
>   while (@row = $sth->fetchrow_array) {
>       ($one) = @row;
>        print "$one people answered <b>YES</b> out of $total total
> respondants";
>   }
> 
> print "3. Are you aware we offer 24x7 service?";
>   my $sth;
>   my $query = "select count(*) from mysurvey where preference = 'Y'";
>   $sth = $dbh->prepare($query);
>   $sth->execute();
>   while (@row = $sth->fetchrow_array) {
>       ($one) = @row;
>        print "$one people answered <b>YES</b> out of $total total
> respondants";
>   }

You don't have the questions stored in the database somewhere?  If so,
there would have been an easy task.

However; let's say you don't.  I would, first of all, have gathered the
question and the question's "keyword" in an array of hashes;

  my @questions = (
      {
         'question' => '2. Have you ever posted a request?',
         'keyword'  => 'posted',
      },
      {
         'question' => '3. Are you aware we offer 24x7 service?',
         'keyword'  => 'preference',
      },
  );

Then I would have process each element in that array;

  my $sth = $dbh->prepare('SELECT COUNT(*) FROM mysurvey WHERE ? = ?');
  foreach ( @questions ) {
      $sth->execute( $_->{'keyword'}, 'Y' );
      my ( $yes ) = $sth->fetchrow();
      print $_->{'question'} . "\n" . $yes . ' answered Yes' . "\n\n";
  }
  $sth->finish();

Or something like that, anyway.


-- 
Tore Aursand - tore@aursand.no - http://www.aursand.no/


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

Date: Mon, 03 Mar 2003 20:54:35 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Early Perl source
Message-Id: <3E63C105.2C58D53D@acm.org>

Peter Cooper wrote:
> 
> I like to collect old source code, simply to rummage through and get a feel for
> how some of the most exciting programs that came out 'back then' were made. I've
> got Wolf3D, Doom, Linux 0.1, and a bunch of other 'ground breaking' products
> (the Linux 0.1 is an /excellent/ reference if you want to make your own simple
> OS). Now I'm interested in finding an old version of Perl!

http://www.etla.org/retroperl/


John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 03 Mar 2003 22:46:37 GMT
From: Alan Gutierrez <ajglist@izzy.net>
Subject: Re: Guestbook Pro 1.0
Message-Id: <slrnb67nni.6s3.ajglist@izzy.net>

In article <e826f4aa.0303021922.75fef4e0@posting.google.com>, PCMedics wrote:
> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb5mt4d.40h.tadmc@magna.augustmail.com>...
>> PCMedics <sales@pcmedix.org> wrote:
>> 
>> > Guestbook pro is a unique guestbook,

That has got to be the stupidest thing I've ever heard.


>> And it was written by a spammer.
>> 
>> Commercial posts are not welcome in discussion newsgroups.
> 
> Thank you for your OPINION!... and it is disregarded! please keep your
> OPIONIONS to your self. I beg to differ on the "SPAMMER" remark...

*plonk*

-- 
Alan Gutierrez - ajglist@izzy.net
http://khtml-win32.sourceforge.net/ - KHTML on Windows


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

Date: Mon, 3 Mar 2003 22:02:34 +0200
From: "aragorn" <aragorn@freemail.gr.gr>
Subject: how do I backup db files via FTP??
Message-Id: <b40ccg$m8r$1@nic.grnet.gr>

I created a database using the dbm structure. My databases work fine
until I want to download them using FTP. The files is downloaded fine
and then I try to upload the same file into the same location. For a
strange reason this file does not work. I have check that it is bin
mode I am using both for downloading and uploading but the problem
remains. I want to backup my db files and be able to restore them
should anything odd happens to the server.

Does anybody know how to do that?
Thanks a lot.



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

Date: 3 Mar 2003 21:02:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how do I backup db files via FTP??
Message-Id: <b40ft0$iqr$2@mamenchi.zrz.TU-Berlin.DE>

aragorn <aragorn@freemail.gr.gr> wrote in comp.lang.perl.misc:
> I created a database using the dbm structure. My databases work fine
> until I want to download them using FTP. The files is downloaded fine
> and then I try to upload the same file into the same location. For a
> strange reason this file does not work.

So what happens?  Does the tie() (or, forfend, dbmopen()) fail?
If so, what does $! contain?

Is it something else that "doesn't work"?  We can't begin to guess
what's wrong if you don't give us some details.

>                                          I have check that it is bin
> mode I am using both for downloading and uploading but the problem
> remains. ...

Well, binary mode is correct for a database file.  Have you checked
permissions?

Anno


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

Date: 03 Mar 2003 13:52:55 -0800
From: Ethan Brown <ethan@draupnir.gso.saic.com>
Subject: Re: how do I backup db files via FTP??
Message-Id: <vrheakkthk.fsf@draupnir.gso.saic.com>

>>>>> "Anno" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

    Anno> aragorn <aragorn@freemail.gr.gr> wrote in comp.lang.perl.misc:
    >> I created a database using the dbm structure. My databases work fine
    >> until I want to download them using FTP. The files is downloaded fine
    >> and then I try to upload the same file into the same location. For a
    >> strange reason this file does not work.

    Anno> So what happens?  Does the tie() (or, forfend, dbmopen()) fail?
    Anno> If so, what does $! contain?

    Anno> Is it something else that "doesn't work"?  We can't begin to guess
    Anno> what's wrong if you don't give us some details.

    >> I have check that it is bin
    >> mode I am using both for downloading and uploading but the problem
    >> remains. ...

    Anno> Well, binary mode is correct for a database file.  Have you checked
    Anno> permissions?

    Anno> Anno

Do a "sum" on the local and remote versions to make sure that the
files are identical.  If they aren't, make sure you really, really are
doing a binary transfer, e.g.:

my $ftp = Net::FTP->new($backup_host,
                        Timeout => $timeout)
    || die "$0: Can't connect to Ftp host $backup_host: $@\n";
$ftp->login($usr, $pswd)
    || die "$0: Can't authenticate user $usr: $@\n";

$ftp->binary();
$ftp->put($infile, "$outfile");

Also, I've found it useful to do the operations "by hand" (without the
script) to help identify where the problems are.

--Ethan Brown
--In a band?  Use http://www.WheresTheGig.com for free.



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

Date: Mon, 3 Mar 2003 13:23:59 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Need to trim word with parenthesis
Message-Id: <slrnb67auf.49h.tadmc@magna.augustmail.com>

impervious@attbi.com <impervious@attbi.com> wrote:

> Alas, even with all the helpful suggestions I received, it seems that
> this substitution resulted in losing the rest of the line.  When I try
> to print $_ nothing is there.  <scratching head and pondering the
> great mysteries of Perlish>


Post a short and complete program that illustrates your problem,
as suggested in the Posting Guidelines, and we will help you fix it.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 03 Mar 2003 19:49:59 GMT
From: impervious@attbi.com
Subject: Re: Need to trim word with parenthesis
Message-Id: <5aa76vsoqkm18aqugt926qrj8v02bnk8lh@4ax.com>

On Mon, 03 Mar 2003 18:56:29 GMT, impervious@attbi.com wrote:

>Thanks to everyone who responded and if you have any ideas why the
>rest of the line disappears please let me know. I was under the
>assumption that a substitution only changes the matched pattern.

Ah, for once I get to answer my own question!  I needed $_ =~ instead
of the $_= that I was using.


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

Date: Mon, 3 Mar 2003 08:29:24 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <b3v3p4$2qnv$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Guenter 
<no.spam@gknw.de>], who wrote in article <3E623A70.4000704@gknw.de>:
> Hi all,
> although I dont like VBScript, what I really like from it is the 
> possibility to directly call into shared libs.

This is not possible.  Shared libraries provide addresses of
C-callable functions, but do not describe which calling convention the
function implement.  Without this knowledge, it is not possible to
call such a function.  While Perl allows you to easily load a shared
library, and get the address of a function, you cannot provide
arguments to the function - unless via XS interface, which goes
through a C compiler, so is not a runtime method.

During the time of v5.000alpha, there was a discussion on p5p about
adding a functionality of a call to a function with the simplest,
cdecl, calling convention.  Again, this was not implemented due to
non-portability of such a call.  E.g., I do not know how to write i386
assembler which would call a C function with n long arguments; here n
is a variable number given as a parameter:

  void
  call_many_longs(void (*f)(), long n, long *array_of_arguments)
  {
    __asm__("???");
  }

But it is easy to write a wrapper which would work with e.g., n<20;
both for cdecl, and for regparam(3) calling conventions.  Actually,
doing this for the OS2 port is in my TODO list.  [Important since OS/2
API more or less always takes a series of longs (or compatibles) as
arguments.]

Hope this helps,
Ilya



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

Date: Mon, 3 Mar 2003 14:11:07 -0600
From: "Pirabhu Raman" <pirabhur@ufl.edu>
Subject: Re: newbie array question
Message-Id: <b40ctf$10mm$1@spnode25.nerdc.ufl.edu>

"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3E639E5A.AFB5DDE1@earthlink.net...
> Pirabhu Raman wrote:
> >
> > How can I declare fixed size arrays (eg a integer array with each
> > member of 4 bytes) in perl.
>
> You can't, really.
>
> The closest approximation you can do is create a string of the
> appropriate length, and access portions of that string using the vec()
> function.
>
>    my $lots_of_ints = "\0\0\0\0" x $n;
>    for my $i ( 0 .. $n - 1 ) {
>       print "The ${n}th int is : ";
>       print vec($lots_of_ints, $i, 32), "\n";
>    }
>
> Also, you can use pack/unpack and substr, if you want arrays of things
> other than simple ints.
>
> > How can I check the size of each element.
>
> For a vec() psuedo-array ... well, you just have to know what size
> numbers you've chosen to use.
>
> For a normal array, you can store any type of value, of any size.
>
> > ie is there any function equiv to sizeof function in c.
>
> Not really.  Why would you need one?
>
> (For some purposes, length(pack($templ)) might do.)
>
> --
> $;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
> my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
> $__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print



Is it possible to send  a 8 byte integer using pack function (long long) ?

Thanks
Pirabhu






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

Date: Mon, 03 Mar 2003 22:00:44 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: newbie array question
Message-Id: <pan.2003.03.03.20.42.56.139858@kamelfreund.de>

On Mon, 03 Mar 2003 11:12:08 -0600, Pirabhu Raman wrote:

> How can I declare fixed size arrays (eg a integer array with each member of
> 4 bytes) in perl. How can I check the size of each element. ie is there any
> function equiv to sizeof function in c.

Have also a look to the CPAN modules
Tie::CArray
Packed::Array

Perhaps they are what you are looking for.

Greetings,
Janek


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

Date: Mon, 3 Mar 2003 20:09:01 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: NEWBIE: PerlNET
Message-Id: <Pine.LNX.4.53.0303032006290.20847@lxplus081.cern.ch>

On Mon, Mar 3, Peter Cooper mischievously deleted the material that I
was following-up to, quoted me out of context:

> Alan J. Flavell wrote:
> > Looks like March is going to be a big-plonk month, based on the first
> > few days.

and then opined:

> If asking a valid question related to Perl,

Which part of what you deleted represented "a valid question related
to Perl", please?


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

Date: Mon, 3 Mar 2003 20:43:36 -0000
From: "Peter Cooper" <newsfeed2@boog.co.uk>
Subject: Re: NEWBIE: PerlNET
Message-Id: <sxP8a.11334$EN3.90675@newsfep4-glfd.server.ntli.net>

"Alan J. Flavell" <flavell@mail.cern.ch> wrote:

> > If asking a valid question related to Perl,
>
> Which part of what you deleted represented "a valid question related
> to Perl", please?

None, although the post you were commenting on was simply a rebuke to a pile of
FUD, so one (possibly incorrectly) assumed you were also considering the
poster's original post which did ask a valid question.

If I was incorrect with this assumption, I wonder why you chose to comment on
the rebuke, rather than on the post containing the OT comments and FUD that
kicked it off?

Regards,
Pete




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

Date: Mon, 03 Mar 2003 22:02:05 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: NEWBIE: PerlNET
Message-Id: <pan.2003.03.03.20.34.44.703561@kamelfreund.de>

On Tue, 04 Mar 2003 00:36:05 +1000, Derek Thomson wrote:

> Jason Hood wrote:
> "use namespace" is a C++ declaration, not to be confused with Perl's 
> "use" statement which performs a function analagous to Java's "import". 
> You are telling Perl to import a module named "namespace". That explains 
> the error that you get.

Well, there's a namespace pragma on CPAN.
It description also explains that the similarity to C++ isn't randomness:

                                                              NAME ^

   namespace - Perl pragma to use like C++ namespace aliasing

                                                          SYNOPSIS ^

  use namespace File => IO::File;

  my $fh = new File "foo", O_CREAT|O_WRONLY;
  if( defined $fh )
  {
      print $fh "bar\n";
      $fh->close;
  }


                                                        DESCRIPTION ^

   Allow aliasing namespace. May be useful for reusability increase.

[...]

> 
> And I've never heard of a "System" module for Perl.
> 
> Perhaps you meant:
> 
> use System;

I also have never seen exactly a "System" module, but in CPAN there are a
lot of similar called ones, like:
Register::System
System2
SystemC::*
CPANPLUS::Internals::System
and so on


Cheerio,
Janek


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

Date: Mon, 03 Mar 2003 20:12:09 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Question about inline.
Message-Id: <pan.2003.03.03.19.09.45.696413@aursand.no>

On Mon, 03 Mar 2003 08:41:43 -0800, Brian Snyder wrote:
> use Inline C => << 'END_C';
> void greet(){
>   printf("Hello, world\n");
> }
> END_C
> 
> greet;

Should work, but...

> I havent installed my own module before [...]

 ...maybe you after all haven't managed to install the module needed
correctly?

I strongly suggest that you use the CPAN module to download and install
other CPAN modules.  Try this command as 'root';

  'perl -MCPAN -e shell'


-- 
Tore Aursand - tore@aursand.no - http://www.aursand.no/



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

Date: Mon, 03 Mar 2003 22:00:42 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Question about inline.
Message-Id: <pan.2003.03.03.20.49.41.766126@kamelfreund.de>

On Mon, 03 Mar 2003 08:41:43 -0800, Brian Snyder wrote:

> Hi all.  Im exploring different ways of linking C and perl together,
> Ive played around with swig a bit, and now i'm playing around with
> inline.  I have a problem though, which I'm hoping someone can give me
> some tips about:
> 
> I copied the function found in this tutorial :
> http://www.perl.com/pub/a/2001/02/inline.html
> 
> The function is the following:
> 
> use Inline C => << 'END_C';
> void greet(){
>   printf("Hello, world\n");
> }
> END_C
> 
> greet;
> 
> 
> (Of course I added the #!/usr/bin/perl as the first line).
> 
> Anyway, when I run the script I get no output at all.  It doesn't
> print the hello, world and it doesnt print any errors.

You never call the greet function in your Perl part.
Try this script:

#!/usr/bin/perl
greet();   # Now it's called
use Inline C => << 'END_C';
void greet(){
  printf("Hello, world\n");
}
END_C


Greetings,
Janek



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

Date: 3 Mar 2003 14:38:32 -0800
From: bsnyder030174@yahoo.com (Brian Snyder)
Subject: Re: Question about inline.
Message-Id: <668c9529.0303031438.1cc35096@posting.google.com>

Thank you for replying. I did indeed figure out that it was my module
installation and once that was fixed I got my example INLINE::C
scripts to work with no additional headache.  I was unaware of the
CPAN module that you mentioned and am playing with it now. Thanx.
 --brian

"Tore Aursand" <tore@aursand.no> wrote in message news:<pan.2003.03.03.19.09.45.696413@aursand.no>...
> On Mon, 03 Mar 2003 08:41:43 -0800, Brian Snyder wrote:
> > use Inline C => << 'END_C';
> > void greet(){
> >   printf("Hello, world\n");
> > }
> > END_C
> > 
> > greet;
> 
> Should work, but...
> 
> > I havent installed my own module before [...]
> 
> ...maybe you after all haven't managed to install the module needed
> correctly?
> 
> I strongly suggest that you use the CPAN module to download and install
> other CPAN modules.  Try this command as 'root';
> 
>   'perl -MCPAN -e shell'


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

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


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