[18045] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 205 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 3 03:05:43 2001

Date: Sat, 3 Feb 2001 00:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981187508-v10-i205@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 3 Feb 2001     Volume: 10 Number: 205

Today's topics:
    Re: 'print' problem-again! <b0l4549@cs.tamu.edu>
        [help] multi-process at the same time?? <perl@dotexpress.com>
        `backticks` broken with fresh install of ActivePerl on  <tfbiv@SPAMMENOTerols.com>
    Re: Can't read entire file into string. (Garry Williams)
    Re: File time difference (Garry Williams)
    Re: File time difference <digicat@frag.this.mindspring.com>
    Re: Help about    perl -e '`ping server`' (Garry Williams)
    Re: Help about    perl -e '`ping server`' (Garry Williams)
    Re: Help about    perl -e '`ping server`' <ajborla@bigpond.com>
        help in converting time() into dd/mm/yyyy hh:mi format <vinaip@singnet.com.sg>
    Re: help in converting time() into dd/mm/yyyy hh:mi for <joe+usenet@sunstarsys.com>
    Re: help in converting time() into dd/mm/yyyy hh:mi for (Garry Williams)
    Re: help in converting time() into dd/mm/yyyy hh:mi for <tony_curtis32@yahoo.com>
    Re: How To Reverse 8 bit arithmetic value (Mark Jason Dominus)
    Re: How To Reverse 8 bit arithmetic value <krahnj@acm.org>
    Re: input parameters (Garry Williams)
        Is it possible for perl to open Dos programs? fenderstratocaster@my-deja.com
    Re: Is it possible for perl to open Dos programs? dtbaker_dejanews@my-deja.com
        LWP on win32 <varghese@dstmail.itg.ti.com>
    Re: Modules/Constants. (Garry Williams)
    Re: Modules/Constants. delanthear@my-deja.com
    Re: Modules/Constants. delanthear@my-deja.com
    Re: Newbie Q.  How I install DBI on win32? <bwalton@rochester.rr.com>
        Perl & arrays <tommylebrun@yahoo.com>
    Re: Perl & arrays (Gwyn Judd)
    Re: select and perlvar (Mark Jason Dominus)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 2 Feb 2001 20:30:45 -0600
From: Bin - Lu <b0l4549@cs.tamu.edu>
To: David Efflandt <efflandt@xnet.com>
Subject: Re: 'print' problem-again!
Message-Id: <Pine.SOL.4.10.10102022026300.18990-100000@robert>

David,

Your information is very helpful. But I need the print content-type line
because I use a socket before the redirection. The socket doesn't work
without the print "content-type: text/html\n\n";

The socket code is as follows:

#start socket
$remote = $LSERV_ADDR;
$port = $LSERV_PORT;
if ($port =~ /\D/) {$port = getservbyname($port, 'tcp') }
die "no port" unless $port;
$iaddr = inet_aton ($remote) or die "no host: $remote";
$paddr = sockaddr_in ($port, $iaddr);

$proto = getprotobyname ('tcp');
socket (SOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
connect (SOCK, $paddr)                      or die "connect: $!";    

Maybe I can change the socket code to make it work without the print line?
I don't know how to do it. Do you have any clue? Thanks very much!

Bin

On Fri, 2 Feb 2001, David Efflandt wrote:

> On Fri, 2 Feb 2001 14:27:26 -0600, Bin - Lu <b0l4549@cs.tamu.edu> wrote:
> >
> >But I can't use if-else since I need to run them both. Any clue again???
> 
> But you do not need them both.  You need one or the other.  You cannot
> print anything else if you are going to redirect.  Once you decide whether
> you are going to redirect you will know whether to print the content-type
> or not.  One thing you can do to trap many errors or see the output of or
> die statements is to add near the beginning of your script:
> 
> use CGI::Carp qw(fatalsToBrowser);
> 
> And the CGI module function method can make it easy to add headers if you
> are going to print something other than the redirect by simply:
> 
> print header,start_html('Error'),h1('Error'),hr,
> "You forgot to do something";
> 
> >On Thu, 1 Feb 2001, it was written:
> >
> >> if() {
> >>     # redirect
> >> } else {
> >>     # don't redirect
> >> }
> >> 
> >> j.
> >> 
> >> "Bin - Lu" <b0l4549@cs.tamu.edu> wrote in message
> >> news:Pine.SOL.4.10.10102010006070.3492-100000@robert...
> >> >
> >> > I have such a problem:
> >> >
> >> > At the beginning of my code I have to use
> >> > print "content-type: text/html\n\n";
> >> >
> >> > But then I want to use:
> >> > print "Location: $link\n\n";
> >> > exit;
> >> >
> >> > which achieves redirection and requires not to use the first 'print' line.
> >> > How can I 'deactivate' the first 'print' line or change the print content
> >> > type?
> >> >
> >> 
> >> 
> >> 
> >> 
> >
> 
> 
> -- 
> David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
> http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
> http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/
> 
> 



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

Date: Sat, 3 Feb 2001 14:49:34 +0800
From: "Tommy Au" <perl@dotexpress.com>
Subject: [help] multi-process at the same time??
Message-Id: <95g9jb$suo$1@taliesin.netcom.net.uk>

my problem is:
how can i create more than one process at the same time in one script?
(i am using win98)

who can help me?
thanks!




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

Date: Fri, 02 Feb 2001 22:08:46 -0500
From: Tom Bates <tfbiv@SPAMMENOTerols.com>
Subject: `backticks` broken with fresh install of ActivePerl on Win98
Message-Id: <99qm7t0i6utqt1hb9kb5ln13o7ct1j41v0@4ax.com>

I installed ActivePerl on my Win98SE WinBook XL3 and found that the
backtick is broken - the output of the command is displayed rather
than captured by perl. This worked fine before my hard drive crashed
and I had to have it replaced (under warranty thank god). I also have
ActivePerl installed on another machine at another location, and
things all seem to be working fine (including scripts with backticks).

I removed and reinstalled it (it's build 523 on CD that I bought back
in Nov 99), and it still does it.

If I run this little test:

	$test = `cd`;
	print "\$test = \"$test\"\n";
	print $?;
	print $!;
	print "--";

This is what I get:

C:\Util\Perl>perl -w test.pl
C:\Util\Perl
$test = ""
$? = 0, $! = "No such file or directory"
--

Note that the result of the CD command is not grabbed by perl and
placed in the variable.

I had hoped that the error would be helpful, but I haven't come up
with anything yet. The environment variables temp and tmp both point
to an existing directory.

Any ideas?
Thanks
Tom



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

Date: Sat, 03 Feb 2001 02:25:01 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Can't read entire file into string.
Message-Id: <1_Je6.572$Sn3.22756@eagle.america.net>

On Fri, 02 Feb 2001 17:58:31 GMT, LK <lkenny@fisheries.org> wrote:
>On Fri, 02 Feb 2001 17:47:02 GMT, Ala Qumsieh <aqumsieh@hyperchip.com>
>wrote:

[snip]

>>Checkout perlfaq3: How can I read in an entire file all at once?
>>
>>and checkout perlvar ... look for $/ ..
>
>I went several different pl;aces looking for this faq, but I couldn't
>find it.  perhaps I am looking in the wrong places.  Would you be able
>to point me in the right direction?

It's on _your_ machine.  Use man and/or perldoc to display the Perl
manual pages.  "Checkout perlfaq3" means execute the command `perldoc
perlfaq3' or `man perldoc3'.  

The fine manual comes with every perl distribution.  

-- 
Garry Williams


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

Date: Sat, 03 Feb 2001 03:31:00 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: File time difference
Message-Id: <UXKe6.581$Sn3.22756@eagle.america.net>

On Fri, 2 Feb 2001 15:34:14 -0800, Jürgen Exner <juex@deja.com> wrote:
>"Ashley M. Kirchner" <ashley@pcraft.com> wrote in message
>news:3A7B3D0E.A3DF58B8@pcraft.com...
>> John Joseph Trammell wrote:
>>
>> > man find
>>
>> Yeah, I'd like for you to explain for me exactly how 'man find' is
>> going to help me write a perl script.  If you can't come up with a
>> better answer, why bother answering at all.
>>
>You are absolutely right. John should have said
>
>    perldoc File::find


I guess this thread would be amusing, if it weren't so sad.  


The last modification time for a file can be retrieved from the stat()
function.  You can learn how to use it in the perlfunc manual page.  

[I would put the locking code into a subroutine that
"garbage-collected" stale locks so that another script would be
unnecessary.]  

-- 
Garry Williams


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

Date: Sat, 03 Feb 2001 06:02:43 GMT
From: Kevin Counts <digicat@frag.this.mindspring.com>
Subject: Re: File time difference
Message-Id: <2c7n7tgjt821r3o614gr7ihcaqtfv1s46d@4ax.com>

Here's an idea. Feedback appreciated.

It uses Tom Christiansen's interface to the stat() command.

Regards,

Kevin Counts
digicat@{ZAPTHIS}mindspring.com

--

#!/usr/bin/perl

use File::Find;
use File::stat;

find ( \&purge, "lock.dir" );

sub purge
{
   $file = stat($_);

   $mtime_min = (time() - $file->mtime) / 60;

   if ( (! -d) && ($mtime_min > 60) )
   {
     print "do something with: $_" . "\n";

     #
     # unlink ($_);
     #
   }
}




On Fri, 02 Feb 2001 14:57:05 -0700, "Ashley M. Kirchner"
<ashley@pcraft.com> wrote:

>
>    I have a program that creates lock files whenever it's run, however
>sometimes these locks become stale.  I'd like to write a script that
>will scan that particular directory and determines if a lock file is
>older than a preset time, before deleting it.  Considering there may be
>more than one single lock file, it needs to check each file, and if
>they're, say over 60 minutes old, it can go ahead and delete the file.
>
>    Any suggestions/pointers?



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

Date: Sat, 03 Feb 2001 02:59:48 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Help about    perl -e '`ping server`'
Message-Id: <EuKe6.575$Sn3.22756@eagle.america.net>

On Sat, 3 Feb 2001 08:41:02 +1100, Anthony Borla <ajborla@bigpond.com>
wrote:
>"Ken Laird" <kenlaird@yahoo.com> wrote in message
>news:ftFe6.5752$335.28575@amsnews03.chello.com...
>> I'd like to see the result of this command :
>>
>> perl -e '`ping server`'
>>
>> it works , but is it possible to see the output on the screen ?
>>
>
>Try redirecting output to a specific device:
>
>   (UNIX) perl -e '`ping server > /dev/tty`'


Why are you using qx// in a void context?  

Check the perlop manual page to see what qx// (or backtics) does.
It's used to *assign* the output of a command to a variable.  

You should do: 

  perl -e 'print `ping system`'

If you simply want the captured output printed.  

-- 
Garry Williams


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

Date: Sat, 03 Feb 2001 03:12:10 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Help about    perl -e '`ping server`'
Message-Id: <eGKe6.578$Sn3.22756@eagle.america.net>

On Sat, 3 Feb 2001 00:29:11 +0000 (UTC), David Efflandt
<efflandt@xnet.com> wrote:
>On Fri, 02 Feb 2001 21:16:59 GMT, Ken Laird <kenlaird@yahoo.com> wrote:
>
>>perl -e 'system ping server' 
>>is not working at all?
>
>system() only returns the return code (or error code if any) from running
>the command and you are not printing that either.  If you don't print any
>output, you get no output, duh!

What's your point?  If the program were corrected, the ping command
*would* print its output to the terminal.  The OP is clearly not
interested in the return status of the command -- only in the output
it produces.  

Did you try the one-liner above?  It won't compile.  *That* is the
problem.  

  perl -e 'system "ping server"'

If you don't print anything, you get output.  Duh!  

-- 
Garry Williams


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

Date: Sat, 3 Feb 2001 16:06:48 +1100
From: "Anthony Borla" <ajborla@bigpond.com>
Subject: Re: Help about    perl -e '`ping server`'
Message-Id: <YaMe6.15607$65.82817@newsfeeds.bigpond.com>

"Garry Williams" <garry@zvolve.com> wrote in message
news:EuKe6.575$Sn3.22756@eagle.america.net...
> On Sat, 3 Feb 2001 08:41:02 +1100, Anthony Borla <ajborla@bigpond.com>
> wrote:
> >"Ken Laird" <kenlaird@yahoo.com> wrote in message
> >news:ftFe6.5752$335.28575@amsnews03.chello.com...
> >> I'd like to see the result of this command :
> >>
> >> perl -e '`ping server`'
> >>
> >> it works , but is it possible to see the output on the screen ?
> >>
> >
> >Try redirecting output to a specific device:
> >
> >   (UNIX) perl -e '`ping server > /dev/tty`'
>
>
> Why are you using qx// in a void context?
>
> Check the perlop manual page to see what qx// (or backtics) does.
> It's used to *assign* the output of a command to a variable.
>
> You should do:
>
>   perl -e 'print `ping system`'
>
> If you simply want the captured output printed.
>

The OP gave examples of code that did not work as expected. So, each of the
'non-working' examples was, altered, tested, and *made* to work, with,
perhaps, little thought given to showing the 'right' way to do things (as
regards the 'backtick' code, anyway).

You are, of course, quite correct on what is 'recommended / correct /
acceptable' practice, as documented; I fully agree with your view on this.

Cheers,

Anthony Borla.





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

Date: Sat, 3 Feb 2001 11:56:09 +0800
From: "Vinai Prakash" <vinaip@singnet.com.sg>
Subject: help in converting time() into dd/mm/yyyy hh:mi format
Message-Id: <95fv3t$1fm$1@violet.singnet.com.sg>

Hi,

There is a time() function in perl, that gives a long number which is not
easy to understand.

Is there a function or quick way to decode it in dd/mm/yyyy hh:mi format?

Thanks for your help.

Regards,
Kamni Prakash
Editor, Recipe Secrets NewsLetter
http://recipesecrets.tripod.com/home/
To subscribe send email to recipe-secrets-subscribe@egroups.com
FREE Current issue of Recipe Secrets mailed to you.
Just send an empty email to RecipeSecrets@Fastfacts.net





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

Date: 02 Feb 2001 23:23:28 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: help in converting time() into dd/mm/yyyy hh:mi format
Message-Id: <m3puh04cov.fsf@mumonkan.sunstarsys.com>

"Vinai Prakash" <vinaip@singnet.com.sg> writes:

> Hi,
> 
> There is a time() function in perl, that gives a long number which is not
> easy to understand.

To understand what that long number represents, RTFM:

% perldoc -f time 

> Is there a function or quick way to decode it in dd/mm/yyyy hh:mi format?

% perldoc -f localtime

See

% man perldoc
% man perl
% man perfunc

for how to find useful information about your perl installation.

-- 
Joe Schaefer


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

Date: Sat, 03 Feb 2001 04:30:33 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: help in converting time() into dd/mm/yyyy hh:mi format
Message-Id: <JPLe6.599$Sn3.24237@eagle.america.net>

On Sat, 3 Feb 2001 11:56:09 +0800, Vinai Prakash <vinaip@singnet.com.sg> wrote:
>Hi,
>
>There is a time() function in perl, that gives a long number which is not
>easy to understand.
>
>Is there a function or quick way to decode it in dd/mm/yyyy hh:mi format?

You need to learn how to use the manual.  Look at the perlfunc manual
page in the section on localtime().  

While you're there, you might check the time() section.  It explains
the meaning of that "long number which is not easy to understand".  

-- 
Garry Williams


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

Date: 02 Feb 2001 22:57:50 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: help in converting time() into dd/mm/yyyy hh:mi format
Message-Id: <87elxg5po1.fsf@limey.hpcc.uh.edu>

>> On Sat, 3 Feb 2001 11:56:09 +0800,
>> "Vinai Prakash" <vinaip@singnet.com.sg> said:

> Hi, There is a time() function in perl, that gives a
> long number which is not easy to understand.

Waddya mean?  Isn't it obvious? :-)

> Is there a function or quick way to decode it in
> dd/mm/yyyy hh:mi format?

perldoc -f localtime
perldoc POSIX                see "strftime"

    use POSIX 'strftime';
    my $datestr = strftime('%d/%m/%Y %H:%M', localtime);

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Sat, 03 Feb 2001 03:16:16 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: How To Reverse 8 bit arithmetic value
Message-Id: <3a7b77fe.7288$3e0@news.op.net>

In article <95ffk3$t8v$1@nnrp1.deja.com>,  <gipperca@my-deja.com> wrote:
>How would I reverse an 8 bit value???

Use a table:

        @reverse = (0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, ... , 0xFF);

To generate the table, look into the 'pack "B*"' command.
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Sat, 03 Feb 2001 07:13:16 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How To Reverse 8 bit arithmetic value
Message-Id: <3A7BB090.2F1991EF@acm.org>

gipperca@my-deja.com wrote:
> 
> How would I reverse an 8 bit value???
> 
> If the binary value were 01110001, or 0x71, I want the reversed
> value, 10001110, or 0x8e.

$ perl -e '$x = "\x71"; $y = ~$x; printf "%X  %X\n", ord $x, ord $y;'
71  8E


John


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

Date: Sat, 03 Feb 2001 03:49:06 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: input parameters
Message-Id: <ScLe6.587$Sn3.22756@eagle.america.net>

On Sat, 3 Feb 2001 00:59:57 -0000, Derek Paterson
<derek@dpat.fsnet.co.uk> wrote:

>I' a turorial and some help files but no-where does it mention parameter
>passing...

You probably want to read the @ARGV section of the perlvar manual
page.  After that, you might want to read the Getopt::Std manual page.  

-- 
Garry Williams


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

Date: Sat, 03 Feb 2001 02:41:48 GMT
From: fenderstratocaster@my-deja.com
Subject: Is it possible for perl to open Dos programs?
Message-Id: <95fr5b$6js$1@nnrp1.deja.com>

Hi

I have a DOS program that changes .pcx file types to .tpc. In the
program, you type at the command line:

picpac -p Phurtex.pcs Phurrtex.tpc

There are two files that must be converted for each image (one hi-res,
and one low-res). The problem is it is very time consuming to copy the
files to the desktop, convert them, and copy all the files back to my
working folder.

I am currently reading a book on "How to teach yourself Perl" and have
made it to the chapter on Hashes. With my limited knowledge of this
language, I do not know the limits of what can be done. So I was
wondering if it is at all possible for Perl to open this program, and
type this line for me (maybe with the "print" function?)?

I am not asking for anyone to write this program for me. I would just
like to know if it can be done, and if so, can you steer me in the right
direction to where I can find out how it is done.

Thank you for you Time.

Fender Stratocaster.


Sent via Deja.com
http://www.deja.com/


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

Date: Sat, 03 Feb 2001 03:57:27 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Is it possible for perl to open Dos programs?
Message-Id: <95fvj4$a3k$1@nnrp1.deja.com>

In article <95fr5b$6js$1@nnrp1.deja.com>,
  fenderstratocaster@my-deja.com wrote:

> wondering if it is at all possible for Perl to open this program, and
> type this line for me (maybe with the "print" function?)?
-----------
read about the built-in functions exec() and system() in the included
documentation... it might be a fit for you.

D


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 02 Feb 2001 23:31:35 -0600
From: Regy <varghese@dstmail.itg.ti.com>
Subject: LWP on win32
Message-Id: <3A7B97B7.8C5EFE92@dstmail.itg.ti.com>

This is an example in the ORielly Web Client Programming book:

#!perl/bin/perl
use LWP::Simple;

print (get $ARGV[0]);

This works perfectly when I used it to download a webpage, using a linux
machine but does not return anything on a winnt machine. There are no
errors either. Any ideas as to why?



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

Date: Sat, 03 Feb 2001 04:19:24 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Modules/Constants.
Message-Id: <gFLe6.593$Sn3.24228@eagle.america.net>

On Sat, 03 Feb 2001 01:08:07 GMT, delanthear@my-deja.com
<delanthear@my-deja.com> wrote:

>I'm playing with a script which uses quite a lot of constants.
>(declared with "use constant CONSTANT_NAME => VALUE;")  I'd prefer to
>keep them in a separate file than the main scripts.   What's the
>easiest way of doing this?  I've played with creating a module, but I'm
>unsure how to use the exporter to export constants and how to make them
>visible to the other modules I'm using.
>
>Anyone got any clues?  Or am I going about this the wrong way?

You're going about it in the right way.  You just need to go back to
the Exporter manual page.  

  package Something_h;
  use strict;
  use warnings;
  use Exporter;
  our (@ISA) = 'Exporter';

  @EXPORT = qw( CONSTANT_NAME ANOTHER_CONSTANT_NAME );

  use constant CONSTANT_NAME         => 'VALUE';
  use constant ANOTHER_CONSTANT_NAME => 'ANOTHER_VALUE';
  1;

In a script that wants the constants: 

  use strict;
  use warnings;
  use Something_h;
  ...
  print CONSTANT_NAME;

This approach forces the constant names on the using modules.  Some
would say that the decision is better left to the using modules.  For
that, you will want to populate the @EXPORT_OK array and/or the
%EXPORT_TAGS hash instead of the @EXPORT array.  See the Exporter
manual page.  

Another approach would be to ignore the Exporter module and just place
your constants in a separate module without a package statement and
just require that module in the script that wants the constants.  Now
there would be no choice on what the require'ing module could choose
to import.  

Incidentally, you can place common subroutines in the module that
exports, too.  

-- 
Garry Williams


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

Date: Sat, 03 Feb 2001 04:50:48 GMT
From: delanthear@my-deja.com
Subject: Re: Modules/Constants.
Message-Id: <95g2n7$cbm$1@nnrp1.deja.com>


> On Sat, 03 Feb 2001 01:08:07 GMT, delanthear@my-deja.com
> <delanthear@my-deja.com> wrote:
>
> >I'm playing with a script which uses quite a lot of constants.
> >(declared with "use constant CONSTANT_NAME => VALUE;")  I'd prefer to
> >keep them in a separate file than the main scripts.   What's the
> >easiest way of doing this?  I've played with creating a module, but
I'm
> >unsure how to use the exporter to export constants and how to make
them
> >visible to the other modules I'm using.

 Garry Williams wrote:

> Another approach would be to ignore the Exporter module and just place
> your constants in a separate module without a package statement and
> just require that module in the script that wants the constants.  Now
> there would be no choice on what the require'ing module could choose
> to import.
> Incidentally, you can place common subroutines in the module that
> exports, too.

thanks.  Thats really useful.

Its there any reason why I shouldn't use this approach?   These modules
are only being used because they are helping to break down quite a
large scripts.

Thanks again.
k

> --
>


Sent via Deja.com
http://www.deja.com/


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

Date: Sat, 03 Feb 2001 05:03:44 GMT
From: delanthear@my-deja.com
Subject: Re: Modules/Constants.
Message-Id: <95g3fd$cqv$1@nnrp1.deja.com>


> <delanthear@my-deja.com> wrote:
>
> >I'm playing with a script which uses quite a lot of constants.
> >(declared with "use constant CONSTANT_NAME => VALUE;")  I'd prefer to
> >keep them in a separate file than the main scripts.   What's the
> >easiest way of doing this?  I've played with creating a module, but
> >I'm unsure how to use the exporter to export constants and how to
> >make them
> >visible to the other modules I'm using.
> >
> >Anyone got any clues?  Or am I going about this the wrong way?

> Garry Williams wrote:
> Another approach would be to ignore the Exporter module and just place
> your constants in a separate module without a package statement and
> just require that module in the script that wants the constants.  Now
> there would be no choice on what the require'ing module could choose
> to import.
> Incidentally, you can place common subroutines in the module that
> exports, too.

I've just tried this out and run into a problem.

I've got the constants in a .pm file, and I'm requiring that file.
Later on I'm doing this:

$command = CONSTANT_NAME;
my $header = pack("C4N", $command, $param1, $param2, $param3, datasize);

where CONSTANT_NAME is defined as 1 in the required file.

When the script is run, it bombs out on that line with the error:

'Argument "CONSTANT_NAME" isn't numeric in pack'

I'm baffled!


Sent via Deja.com
http://www.deja.com/


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

Date: Sat, 03 Feb 2001 04:54:48 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Newbie Q.  How I install DBI on win32?
Message-Id: <3A7B8FC7.854830B9@rochester.rr.com>

vortex wrote:
> 
> Hello, my name is Geoffrey Gertken, my email is at vortex@inetfree.net.  My
> question is how do I install the DBI module or DB_File module on my win32
> machine running win98se.  Thanks.
At a DOS prompt, try:

   ppm install DBI
   ppm install DB_File

assuming you are running ActiveState Perl.  But I believe those modules
should both be installed by default if you have a recent version of
Perl.  Are you sure they're not already there?
-- 
Bob Walton


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

Date: Sat, 03 Feb 2001 05:31:43 GMT
From: T <tommylebrun@yahoo.com>
Subject: Perl & arrays
Message-Id: <95g53v$e2q$1@nnrp1.deja.com>

Does anyone know if Perl has a limitation on the number of elements an
array can have? Thanks,      T.


Sent via Deja.com
http://www.deja.com/


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

Date: Sat, 03 Feb 2001 06:14:10 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl & arrays
Message-Id: <slrn97n8dh.am9.tjla@thislove.dyndns.org>

I was shocked! How could T <tommylebrun@yahoo.com>
say such a terrible thing:
>Does anyone know if Perl has a limitation on the number of elements an
>array can have? Thanks,      T.

Only insofar as the amount of memory your computer can support.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Paranoia is simply an optimistic outlook on life.


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

Date: Sat, 03 Feb 2001 03:12:03 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: select and perlvar
Message-Id: <3a7b7702.7274$2e@news.op.net>

In article <MPG.14e54ee2a634a07a989827@news.btx.dtag.de>,
Thoren Johne  <thoren@southern-division.com> wrote:
>is there a place in perldoc, where i can see if a special variable is on 
>a 'per filehandle basis',

If there were, it would be in 'perlvar'. For example:

           $~      The name of the current report format for the cur-
                   rently selected output channel. 

I believe the answer is that $|,$^, and $~ are per-filehandle, and the
rest aren't.

 
>does 'select' actual work as expected with '$|' but not with '$\'?

Right.  Sucks, doesn't it?
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

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 V10 Issue 205
**************************************


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