[15465] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2875 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 27 03:12:16 2000

Date: Thu, 27 Apr 2000 00:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <956819110-v9-i2875@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 27 Apr 2000     Volume: 9 Number: 2875

Today's topics:
        Any electronic perl book to share (pdf will be a bonus) <norazman@ti.com>
    Re: backslash escaping not metacharacters in a char cla <fjherna@europa3.com>
    Re: closing cursors with DBD::Oracle <rereidy@indra.com>
    Re: form to email <a@b.com>
        help with a request morlou@my-deja.com
        i think i may not know perl any more <uri@sysarch.com>
    Re: i think i may not know perl any more <elaine@chaos.wustl.edu>
    Re: Installing Perl <nospam@uwtc.net>
        Internal Error? <mouimet@direct.ca>
    Re: Need help understanding references, specifically wh <care227@attglobal.net>
    Re: Need help understanding references, specifically wh <uri@sysarch.com>
        Need help understanding references, specifically when d <care227@attglobal.net>
    Re: Newbie question <madebeer@igc.apc.org>
    Re: oracle client instalation <rereidy@indra.com>
    Re: Perl compiler <harris_m@yahoo.com>
        Perl Parse Error dantzjn@my-deja.com
    Re: Put Variable Initializations In Other File <godzilla@stomp.stomp.tokyo>
    Re: Put Variable Initializations In Other File <uri@sysarch.com>
    Re: Put Variable Initializations In Other File <jeff@vpservices.com>
    Re: Put Variable Initializations In Other File <nobody@newsfeeds.com>
    Re: Put Variable Initializations In Other File <uri@sysarch.com>
    Re: Put Variable Initializations In Other File <nobody@newsfeeds.com>
    Re: Put Variable Initializations In Other File <mjcarman@home.com>
        Question on overload module <Frederic.Aussedat@Alcatel.fr>
        RFD: comp.lang.perl.oop <medi@cybershell.com>
        searching database fields <todd@mrnoitall.com>
    Re: searching database fields <mjcarman@home.com>
        substitution question <csis@geocities.com>
    Re: substitution question <mjcarman@home.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 27 Apr 2000 12:40:48 +0800
From: Norazman Abu Sahir <norazman@ti.com>
Subject: Any electronic perl book to share (pdf will be a bonus)
Message-Id: <3907C4D0.31CFE058@ti.com>

Hi,

I was currently in a stage of studying perl. Unfortunately, as a student I
don't have
much money to invest on buying lots of book. 

Do you have any "electronic version" that I can use. I prefer to read more than
I source/book
no matter what's the level. or can you point to any site that have the
electronic version (downloadable 
will be better). Thanks.


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

Date: Thu, 27 Apr 2000 08:42:26 +0200
From: Javier Hernandez <fjherna@europa3.com>
To: Tad McClellan <tadmc@metronet.com>
Subject: Re: backslash escaping not metacharacters in a char class
Message-Id: <Pine.LNX.4.21.0004270805090.792-100000@aridane.lcv.es>

Hi Tad,

Thanks for your reply.

On Mon, 24 Apr 2000, Tad McClellan wrote:
> On Mon, 24 Apr 2000 12:54:15 +0200, Javier Hernandez <fjhernandez@recol.es> wrote:
> >I have read something about a backslash trying to escape a
> >non-metacharacter
> What "about" it?
> Did it say it was bad?
> Good?
> Benign?
 
It said that depending on the tool, it could produce some 
extrange effects (I read it at "Mastering Regular Expressions" Book).
I was not sure about the effect in Perl.
 
I have learnt a lot from your email.

Best regards, 

Javi,         _____           fjherna@europa3.com
                |             http://www.europa3.com/users/fjherna/
     \_____(X)_(_)_(X)_____/  http://www.valux.org/
____________!___!___!_________Valencia(Spain)


If it wasn't for Newton, we wouldn't have to eat bruised apples.






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

Date: Wed, 26 Apr 2000 22:32:30 -0600
From: Ron Reidy <rereidy@indra.com>
Subject: Re: closing cursors with DBD::Oracle
Message-Id: <3907C2DE.91DBAC1F@indra.com>

mchavel@my-deja.com wrote:
> 
> using the DBD::Oracle module
> i can use $sth->bind_param_inout
> to return a cursor from a PL/SQL procedure
> and fetch from it.
> 
> but how do i close the cursor?
> 
> i am running out of open cursors fast!
> here is my code:
> 
> sub execute_function {
> 
>     my ($func_name, @params_in) = @_;
>     my ($params, $sth, $curh);
> 
>     for (0..$#params_in) {
>         $params .= ":in$_, ";
>     }
>     $params = substr($params, 0, -2);
> 
>     $sth = $dbh->prepare(qq{
>         BEGIN :curout := $func_name($params); END;
>     }) or warn($dbh->errstr);
> 
>     $sth->bind_param_inout(":curout", \$curh, 1,
> { ora_type => ORA_RSET } );
>     for (0..$#params_in) {
>         $sth->bind_param(":in$_", $params_in[$_]);
>     }
> 
>     $sth->execute() or warn($dbh->errstr);
>     $sth->finish;
> 
>     DBI::dump_results($curh);
> 
>     $curh->finish;
> }
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

Your statement $curh->finish should close the cursor.  

How do you know the cursor isn't closed?  Are you looking at the any of
the V$ views (v$open_cursor, et. al.)?  Just a suggestion...

-- 

Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.


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

Date: Thu, 27 Apr 2000 02:49:34 +0200
From: "[@@]~" <a@b.com>
Subject: Re: form to email
Message-Id: <8e8664$8krei$1@fu-berlin.de>

thanks for the tip.  Do you know of any resources inparticular that you have
found useful?



--
       |\/\/\/\/|
       |        |
       | (o)(o)
=========OOOO==========OOOO==--------------------------------------------


Tom Phoenix wrote in message ...
>On Wed, 26 Apr 2000, [@@]~ wrote:
>
>> Anyone point me in the right direction to a free form to email script?
>
>If you're wishing merely to _find_ (as opposed to write) programs,
>this newsgroup may not be the best resource for you. There are many
>freeware and shareware archives which you can find by searching Yahoo
>or a similar service. Hope this helps!
>
>--
>Tom Phoenix       Perl Training and Hacking       Esperanto
>Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>




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

Date: Thu, 27 Apr 2000 04:45:15 GMT
From: morlou@my-deja.com
Subject: help with a request
Message-Id: <8e8gkp$r3r$1@nnrp1.deja.com>

Ok, I'm buiding a site to allow its user to buy computers. I'm doing
the following CGI request to add a record in my Filemaker database and
it works fine:

@array = [-DB=>'MyDatabase.fp3', -Lay=>'COMPUTER_ORDER','-new'];
$user_agent = LWP::UserAgent->new;
$request=POST 'http://xxx:yyy@255.255.255.255/FMPro',@array;
$response = $user_agent->request($request);
print $response->as_string;

Ok, my problem is that I have to save computer items and their prices
etc... in the database, but I got to do it dynamically, I mean that I
want to insert other elements in @array after its initialization, I
would like to insert something like ---> part_price=>'199' <--- etc...
I tried but I can't make it works (the preliminary code specified above
works though), notice that I am a Perl newbie and I'm really stucked at
this point... So do you know how to do it??? Please! Thanks a lot!

Louis Morin


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


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

Date: Thu, 27 Apr 2000 04:24:09 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: i think i may not know perl any more
Message-Id: <x7u2go2mu0.fsf@home.sysarch.com>


Your Perl Programmer Brainbench Certification 
dated 1999-04-16 , has expired.These certifications are only valid for one year, after 
which you must retake the online exam.  All certification 
exams are still free, and to take them, you should go to 
http://www.brainbench.com , logon to your individual
account, and select "Order Exams ..." to obtain 
another FREE exam and FREE certificate.

<note the high quality formatting and spacing. i didn't touch it>

i just got that in the mail. i am so worried about having to take this
test again. i may fail. i may be proven as dumb as shit (or worse! -
pg).

so i will just have to rest on my laurels and not be able to show to any
prospective phb's that i actually know how to take a perl test.

what will i do?

i'm going on the perl whirl in alaska!! (just don't tell any electricians)

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Thu, 27 Apr 2000 05:29:54 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: i think i may not know perl any more
Message-Id: <B52D48D0.319B%elaine@chaos.wustl.edu>

in article x7u2go2mu0.fsf@home.sysarch.com, Uri Guttman at uri@sysarch.com
quoth:

> i'm going on the perl whirl in alaska!! (just don't tell any electricians)

Is this a warning? :) Avast ye Perl people.

/me mumbles something about Moby Dick and wanders off.

e. 




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

Date: Wed, 26 Apr 2000 19:41:24 -0700
From: Pat Pridgen <nospam@uwtc.net>
Subject: Re: Installing Perl
Message-Id: <Pine.LNX.4.21.0004261939480.490-100000@localhost.localdomain>

On Wed, 26 Apr 2000, Marcus wrote:

>     I have a dedicated server with Red Hat Linux 6.1 and I need to install
> perl to work with my /home/httpd/cgi-bin directory. I have no idea where to
> start.... Is perl a free program? I have only previously edited scripts and
> uploaded them to a cgi-bin. Any help would be very appreciated.

If this is YOUR machine, then fire up XWindow if it isn't already, and
in Control panel go down to the package manager. Put in your
Installation CD and Install Perl.


-- 
Pat - La Grande, OR.  Biker, Blackbelt, Progger
ppridgen<at>greencis<dot>net - www.greencis.net/~ppridgen
RedHat 5.2 - Warp 3.0 FixPak 40(dual boot) Windows?? Bwahahahahaha
[Old-Tag] This message is made of 100% recycled electrons.





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

Date: Wed, 26 Apr 2000 22:57:50 -0700
From: "Marcus Ouimet" <mouimet@direct.ca>
Subject: Internal Error?
Message-Id: <pDQN4.18121$H7.1138055@brie.direct.ca>

I am getting an internal server error when running my script for my web
browser. I have checked the perl path by typing "which perl" in Red Hat
Linux. The path was "/usr/bin/perl" so that is correct in my script. The
script runs perfectly locally with no errors by typing "perl myscript.cgi".
I am rather confused on why this would be happening (I had this script on
another web server and it worked fine) Any suggestions would be most
appreciated as I am puzzled and may be overlooking something.




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

Date: Thu, 27 Apr 2000 02:48:43 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Need help understanding references, specifically when dealing with    subroutines
Message-Id: <3907E2CB.123CB9A3@attglobal.net>



Uri Guttman wrote:

>   DS> &print_forms(\@pages); #passing by reference using "standard" means.
>   DS> print_forms(@pages);   #passing the whole load calling as a function.
> 
> why the & in one? it is not needed and has no effect on the args.

Habit, i guess.  


> how do you know you are passing in good data. how do we know as you
> don't show how you stuff @pages. so the code above needs to have the
> PSI::ESP module loaded which will tell you the bug is on line 17.

I couldn't find that module at CPAN or in my module reference.  I did,
however find an interesting one... USENET::Sarcasm  =)
 
> any more code from you? your snippet is too out of context to debug.

OK, the array is built like this:


if (param('spec_num') eq 'on'){
	$num_ammt = param('spec_num_q');
	$spec_num = "spec_num";
	my $joined = join(':', $num_ammt,$spec_num);
	push @pages, $joined;
	
}

if (param('spec_proc') eq 'on'){
	$proc_ammt = param('spec_proc_q');
	$spec_proc = "spec_proc";
	my $joined = join(':', $proc_ammt,$spec_proc);
	push @pages, $joined;
}

if (param('price_plan') eq 'on'){
	$price_ammt = param('price_plan_q');
	$price_plan = "price_plan";
	my $joined = join(':', $price_ammt,$price_plan);

}
again and again...

this is input from a web CGI form, and im sure that the form is good and
that data is being passed from the form to the script.  If it wasn't,
the script would never get to this step, and would continually prompt
for the initial information.  But, not to overlook anything:

print radio_group(-name=>'price_plan',
                  -values=>['no','yes'],
                  -default=>'no',
                  ),br,

"If yes, enter the number of price plans here.&nbsp;", 
textfield(-name=>'price_plan_q', -size=>'2',
-maxlength=>'2'),"&nbsp;price plans.",


p();
		
is an example of how the form is being created.  


So, I am almost 100% certain that the array is being written to 
but just to ease my new nagging suspicion, I'll add a statment to 
print each element to a log after the array has been completed.

As a sidebar question, could the block:

if (param('spec_num') eq 'on'){
	$num_ammt = param('spec_num_q');
	$spec_num = "spec_num";
	my $joined = join(':', $num_ammt,$spec_num);
	push @pages, $joined;
	
}

be re-written as:

if (param('spec_num') eq 'on'){
	$num_ammt = param('spec_num_q');
	push @pages, (join(':', $num_ammt,'spec_num'));
	
}

??  I tend to use extra variables just to be safe.  Curiousity here, 
really.

So there it is, I hope that I have, this time, provided enough.  BUT,
just in case, ive put a text file online at 

http://rrtools.ibm.net/addpage.txt

Its ugly, and some of the code is doing different things and is broken.
the blocks that I am testing are all in this post.  FYI, im using this
as a learning tool, which explains in advance the choppy nature of the 
code.  what I need to work has been coded in a way that I believe to 
be correct.  

-DS


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

Date: Thu, 27 Apr 2000 04:52:02 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Need help understanding references, specifically when dealing with   subroutines
Message-Id: <x7og6w2ljj.fsf@home.sysarch.com>

>>>>> "DS" == Drew Simonis <care227@attglobal.net> writes:

  DS> Ive tried this calling the subroutine as a sub and as a function:

the terms sub and function are the same in perl. you don't need to
change the term based on how you pass arguments.

  DS> &print_forms(\@pages); #passing by reference using "standard" means.
  DS> print_forms(@pages);   #passing the whole load calling as a function.

why the & in one? it is not needed and has no effect on the args.

  DS> sub print_forms{
  DS> my $page = shift;
  DS> my $now = $page->[0];

that looks ok

  DS> the above method does not read the first element.  The script does 
  DS> not return an error.  it processes as if that value were undef and 
  DS> calls my &done sub, which is what I'd expect if that value were empty.

how do you know you are passing in good data. how do we know as you
don't show how you stuff @pages. so the code above needs to have the
PSI::ESP module loaded which will tell you the bug is on line 17.

  DS> Any insight from the masters?

any more code from you? your snippet is too out of context to debug.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Thu, 27 Apr 2000 00:43:26 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Need help understanding references, specifically when dealing with  subroutines
Message-Id: <3907C56E.D2826A15@attglobal.net>

All,
I have written a script that is not behaving as I would expect.
This is probably because im not telling it to do the correct thing,
but Ive tried several different methods, read all the FAQ's and 
even consulted my many Perl books.  As far as I can see, I am 
doing it right, but I am near sighted.  

I am calling a subroutine from within another subroutine.  The first
sub generates an array based on the user input.  I need to pass
that array to the second sub for it to act upon the array.  

Ive tried this calling the subroutine as a sub and as a function:

&print_forms(\@pages); #passing by reference using "standard" means.
print_forms(@pages);   #passing the whole load calling as a function.

Neither method allows the called subroutine to see the elements of
the array.  When calling via the first method, I am using this syntax
to access the elements:

sub print_forms{
my $page = shift;
my $now = $page->[0];

blah blah blech;}

the above method does not read the first element.  The script does 
not return an error.  it processes as if that value were undef and 
calls my &done sub, which is what I'd expect if that value were empty.

I used the same method to call the array value when using the function
like call to the subroutine, although Im notsure if this is the correct
way, in fact, Im almost certain its not.  


Any insight from the masters?


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

Date: Wed, 26 Apr 2000 21:06:37 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: Newbie question
Message-Id: <APC&1'0'50775de0'1a5@igc.apc.org>

maciek wrote:
>I was also thinking about the following:
>The script (running as nobody) records the actions to be performed in 
>say a fileor database.
>Crond is polling the database and if it finds a request invokes another 
>script as root to do the job.

Sounds good.  The cron-invoked script should use taint checking and 
clean any user-tainted data before doing anything sensitive with it.

>Does it sound any better?

Yes.

Cheers,
-Michael


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

Date: Wed, 26 Apr 2000 22:21:09 -0600
From: Ron Reidy <rereidy@indra.com>
Subject: Re: oracle client instalation
Message-Id: <3907C035.EE0EF4D0@indra.com>

jumac@my-deja.com wrote:
> 
> Hi,
> 
> I need install an perl Oracle client in a Linux box to make querys
> to a Oracle database installed in another machine (running HPUX).
> 
> Somebody knows what packages I need install?
> 
> I need files/packages form Oracle?
> 
> Ing. Juan Manuel Calvo
> System administrator
> Universidad del CEMA
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

You need to do a client install from the Oracle distribution CD. 
Contact your DBA.
-- 

Ron Reidy
Oracle DBA
Reidy Consulting, L.L.C.


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

Date: Wed, 26 Apr 2000 21:29:41 -0700
From: harish mahindrakar <harris_m@yahoo.com>
Subject: Re: Perl compiler
Message-Id: <3907C234.CCC91F42@yahoo.com>

I use Perl on NT from ActiveState.
The Perl compiler which comes with binary distribution simply does not
work! It is puzzling why this non functional compiler is distributed.
Any way if you are using NT don't waste your time.
Harris
Ravinder Kumar wrote:

> How effective it is, can someone share his/her experience.
> Where can I find "perlcc" ?.
>
> Thanks
> Ravi



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

Date: Thu, 27 Apr 2000 04:30:17 GMT
From: dantzjn@my-deja.com
Subject: Perl Parse Error
Message-Id: <8e8foq$qdf$1@nnrp1.deja.com>

I'm getting the following error while running a Perl script: "Can't
find '_hparser_xs_state' element in HTML::Parser hash at ./test4.cgi
line 10."

Here's the code from the script that is producing this error:

#!/usr/bin/perl

use LWP::Simple;
use HTML::TreeBuilder;
use HTML::FormatText;

$html = get('http://www.hardwarenewsnet.com');
$formatter = HTML::FormatText->new;
$tree_builder = HTML::TreeBuilder->new;
$tree_builder->parse($html);
$text = $formatter->format($tree_builder);
print $text;


Am I missing something from my Linux install that is stopping the parse
from working?


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


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

Date: Wed, 26 Apr 2000 18:33:10 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Put Variable Initializations In Other File
Message-Id: <390798D6.449EC09E@stomp.stomp.tokyo>

Jim Monty wrote:
 
> All I want to do is move several lengthy hash initializations
> out of my script into a separate file. How can I do this simply,
> easily, and quickly?
 
> I'm using 'use strict;' in my script. 

(strictly snipped)

> What's the short answer?

Short answer is to get rid of strict.pm and
do it your way. This usually works very well!
Keep in mind when you use strict your program
is abiding by rules the author of strict.pm
decided for you. These rules are inherently
tainted by human ego and personal preference.
So, why do it according to another's rules?
Delete use strict and write your own rules!
If you do something wrong, you will certainly
know right away, yes? You wrote your code, you
will know where you made a mistake, if you are
a halfway aware programmer. ;)

Hmm.. seems to me the author of strict.pm
stated his rules could be too strict for
most average programs. This is a pretty
strong hint to not use strict.

Associative arrays are not too difficult with
which to work if you violate some common rules.
Access and print your data base in a slightly
different way than the ranted norm.

Find a delimiter in your data base, even just
a space or a tab will do, a colon, even better.
A capital letter at the beginning of each word
can be used, with some imagination and tricky
programming not allowed by strict.

Pretend hash which is sorta not delimited:

red apple
yellow banana
green kiwi

open your data base, make an array:

@Fruit_Array = ("red apple", "yellow ... etc.

foreach $fruit (@Fruit_Array)
 {
  local ($fruit_key, $fruit_value) = split (/ /, $fruit);

There ya go! You have key and value pairs sorted
and ready to do whatever you want with them. Print
to a file and add a more logical delimiter such
as ¦ while you are at it! Maybe print to your screen.
Heck, serve them for after dinner desert!

Shorter answer, get rid of strict and do it your way.


Godzilla!



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

Date: Thu, 27 Apr 2000 03:22:55 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Put Variable Initializations In Other File
Message-Id: <x7ya602po0.fsf@home.sysarch.com>

>>>>> "JM" == Jim Monty <monty@primenet.com> writes:

  JM> I gave up and read two-column, tab-separated values text files,
  JM> parsed them, and initialized the hashes in a while loop. Blech!

what is wrong with that? show your code for that and i bet it can be
shortened and simplified to almost the same as loading a file of
initialization stuff.

%hash = map { chomp ; split /\t/ } <INIT_FILE> ;

not too hard.

as for the other way, just showing you won't teach you why you have to
do it that way. other than holding your hand all the way how do you
expect us to proceed?

and there are initialization modules in cpan as well.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 26 Apr 2000 20:47:36 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Put Variable Initializations In Other File
Message-Id: <3907B858.F32EC62@vpservices.com>

Jim Monty wrote:

> the answer to my problem is not as
> trivial as simply reading about it somewhere.

You could say that about anything in programming (or nothing in
programming).  Why don't you just bite the bullet and read the
references people have told you about?

That said, since the troll is telling you to drop strict, here is one of
several simple ways to do what you want and preserve strict:

% cat > t.cfg
  sub init { (
       author => 'Vernor Vinge',
       title  => 'A Deepness in the Sky',
       date   => '1999'
  ) }
  1;
%
% cat > t.pl
  #!/usr/local/bin/perl -w
  use strict;
  require 't.cfg';
  my %cfgs = &init;
  print $cfgs{author};
%
% perl t.pl
% Vernor Vinge
%

Simple enuf?  The only thing that strict cost you was a single "my";

-- 
Jeff


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

Date: Wed, 26 Apr 2000 21:36:22 -0700
From: Anonymous <nobody@newsfeeds.com>
Subject: Re: Put Variable Initializations In Other File
Message-Id: <3907C3C6.ED01726F@noname.nospam>

Jeff Zucker wrote:

> That said, since the troll is telling you to drop strict, here is one of
> several simple ways to do what you want and preserve strict:
> 
> % cat > t.cfg
>   sub init { (
>        author => 'Vernor Vinge',
>        title  => 'A Deepness in the Sky',
>        date   => '1999'
>   ) }
>   1;
> %
> % cat > t.pl
>   #!/usr/local/bin/perl -w
>   use strict;
>   require 't.cfg';
>   my %cfgs = &init;
>   print $cfgs{author};
> %
> % perl t.pl
> % Vernor Vinge
> %
> 
> Simple enuf?  The only thing that strict cost you was a single "my";
> 
> --
> Jeff


18 lines of code, a subroutine, module calls...

 ...to do what Godzilla does in half a dozen
lines of straight code, no modules, no subroutines.


Anonymoose


  --------== Posted Anonymously via Newsfeeds.Com ==-------
     Featuring the worlds only Anonymous Usenet Server
    -----------== http://www.newsfeeds.com ==----------


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

Date: Thu, 27 Apr 2000 04:44:57 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Put Variable Initializations In Other File
Message-Id: <x7r9bs2lvb.fsf@home.sysarch.com>

>>>>> "A" == Anonymous  <nobody@newsfeeds.com> writes:

  A> 18 lines of code, a subroutine, module calls...

  A> ...to do what Godzilla does in half a dozen
  A> lines of straight code, no modules, no subroutines.

and what i did in one line. BFD. go marry purlmoron and stay away
from here.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 26 Apr 2000 22:08:20 -0700
From: Anonymous <nobody@newsfeeds.com>
Subject: Re: Put Variable Initializations In Other File
Message-Id: <3907CB44.59C56708@noname.nospam>

Uri Guttman wrote:
> 
> >>>>> "A" == Anonymous  <nobody@newsfeeds.com> writes:
> 
>   A> 18 lines of code, a subroutine, module calls...
> 
>   A> ...to do what Godzilla does in half a dozen
>   A> lines of straight code, no modules, no subroutines.
> 
> and what i did in one line. BFD. go marry purlmoron and stay away
> from here.
> 
> uri
> 
> --
> Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
> SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
> The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
> The Best Search Engine on the Net  ----------  http://www.northernlight.com



You accomplished nothing in one line

Anonymoose

  --------== Posted Anonymously via Newsfeeds.Com ==-------
     Featuring the worlds only Anonymous Usenet Server
    -----------== http://www.newsfeeds.com ==----------


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

Date: Wed, 26 Apr 2000 23:46:17 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Put Variable Initializations In Other File
Message-Id: <3907C619.A7BE3E0A@home.com>

Jim Monty wrote:
> 
> All I want to do is move several lengthy hash initializations
> out of my script into a separate file. How can I do this simply,
> easily, and quickly?
> 
> I'm using 'use strict;' in my script. I've read about use, require,
> package, do, etc. in both Programming Perl and Perl Cookbook.

I think do is probably the "right" way for this.

> I still don't understand why my script won't compile while I have
> 'use strict' in effect, and I don't really care.

But if we're going to help you, we do care. The error diagnostics are
invaluable.

Assuming that "do 'inifile'" didn't work for you, you can try something
like this:

open(INI, 'inifile') or die "Couldn't open 'inifile': $!\n";
my @src = <INI>;
eval("@src");
close(INI);

It's a little ugly and kludgy, but it's what I had to resort to in one
of my scripts when I couldn't get do to play nice. Might have been
because of the version or perl I'm using, or maybe I just didn't try
hard enough; but it worked and I happily went on my way.

-mjc


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

Date: Thu, 27 Apr 2000 08:17:24 +0200
From: Frederic Aussedat <Frederic.Aussedat@Alcatel.fr>
Subject: Question on overload module
Message-Id: <3907DB74.568545AA@Alcatel.fr>

Is there here anybody who have experiment overload module?

I'm using Perl 5.004_04 on Solaris.
And get a few problem using this overload module.

The access to @_ variable cause the overload routine to stop (in fact
not stop but continue aditam eternam). I don't get the prompt again.

Following an extract of the code causing the pb.
Thanks to glance at it.

The problem exist also if in the first line I do
my @x = @_;

---------

package dotNumber;      # eg: 1.10.004.12

#-- Overload comparison operators
use overload    '=='    => \&ge_
           ,    '""'    => \&string
           ;

sub ge_ {

        #-- Get dot fields
print STDERR __LINE__."\n";
        my @a = split /\./, $_[$_[2]?0:1];
print STDERR __LINE__."\n";
        my @b = split /\./, $_[$_[2]?1:0];
print STDERR __LINE__."\n";

        #-- Do comparison on each dot field
        my $i=0;
        while (defined $a[$i] && defined $b[$i] && $a[$i] == $b[$i]) {
                $i++;
        };
        return ($a[$i] >= $b[$i]);
}

1;


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

Date: Thu, 27 Apr 2000 02:31:38 GMT
From: Medi Montaseri <medi@cybershell.com>
Subject: RFD: comp.lang.perl.oop
Message-Id: <956802698.22469@isc.org>

                     REQUEST FOR DISCUSSION (RFD)
                 unmoderated group comp.lang.perl.oop

This is formal Request For Discussion (RFD) for the creation of a
world-wide unmoderated Usenet newsgroup comp.lang.perl.oop. This is not a
Call for Votes (CFV); you cannot vote at this time. Procedural details are
below.

Newsgroup line:
comp.lang.perl.oop	Object Oriented Programming in Perl.

RATIONALE: comp.lang.perl.oop

While comp.lang.perl.modules provides a similar forum, its charter is
mostly around the procedural (or function driven) programming.
comp.lang.perl.oop dedicates itself to Object Oriented Programming in
Perl. How are encapsulation, inheritance, polymorphism, virtual
functions, private vs public and other attributes of OO orientation
are implemented with Perl.

CHARTER: comp.lang.perl.oop

Facilitates Object Orientation Design and Programming in Perl by
providing tips, exchange of ideas and techniques.

END CHARTER.

PROCEDURE:

This is a request for discussion, not a call for votes.  In this phase
of the process, any potential problems with the proposed newsgroups
should be raised and resolved.  The discussion period will continue
for a minimum of 21 days (starting from when the first RFD for this
proposal is posted to news.announce.newgroups), after which a Call For
Votes (CFV) may be posted by a neutral vote taker if the discussion
warrants it.  Please do not attempt to vote until this happens.

All discussion of this proposal should be posted to news.groups.

This RFD attempts to comply fully with the Usenet newsgroup creation
guidelines outlined in "How to Create a New Usenet Newsgroup" and "How
to Format and Submit a New Group Proposal".  Please refer to these
documents (available in news.announce.newgroups) if you have any
questions about the process.

DISTRIBUTION:

This RFD has been posted to the following groups:
news.announce.newgroups
news.groups
comp.lang.perl.modules
comp.lang.perl.misc

Proponent: Medi Montaseri <medi@cybershell.com>


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

Date: Wed, 26 Apr 2000 21:08:11 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: searching database fields
Message-Id: <3907AC80.FBCCC68C@mrnoitall.com>

Hello,
I'm using the routine below to match line in a database, and it
automatically defaults to the "else" (not finding the match). If I comment
out the "else" it finds the right match.
Is perl just lazy or am I missing something?
Thanks in advance.

sub get_package{

open (DATABASE, "$data") || &file_open_error
        ("$data", "get_package",  __FILE__, __LINE__);

  while (<DATABASE>)
    {
    $line = $_;
    chop $line;
    @fields = split (/\|/, $line);


if (($form_data{'db_id'} eq "$fields[1]" )  &&
($form_data{'crypt'} eq "$fields[2]") &&
($form_data{'password'} eq "$fields[3]")){

   $right_shit = "$line\n";



if($right_shit ne ""){


&display_package;



}#if right_shit ne


}#if match

else{
close (DATABASE);

&order_error("Sorry! There are no packages in $program_name for you.");

}

}# End of while (<DATABASE>)
    close (DATABASE);



 }#get_package



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

Date: Wed, 26 Apr 2000 23:53:28 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: searching database fields
Message-Id: <3907C7C8.5CF8A1F@home.com>

Todd Anderson wrote:
> 
> I'm using the routine below to match line in a database, and it
> automatically defaults to the "else" (not finding the match). If 
> I comment out the "else" it finds the right match.
> Is perl just lazy or am I missing something?

[code snipped.]

At a glance, I'd say that the first line from <DATABASE> doesn't match
your criteria, so you're closing it and aborting. When you delete the
else, you let it loop long enough to find something. You probably want
to set a flag when you do find a match, and then check the flag when you
finish your loop to see if you should report failure.

BTW, chomp() is better than chop() for removing newlines. chop() removes
the last char regardless of what it is, chomp() only removes it if it
matches $/

-mjc


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

Date: Thu, 27 Apr 2000 02:22:51 GMT
From: borg <csis@geocities.com>
Subject: substitution question
Message-Id: <3907A499.4C609706@geocities.com>

I am looking for a way to rename all the text files in a dir to html. ie
I want to change their extensions. Normally when I want to replace
something in a file I use:

perl -pe 's/old/new/g' filename > newfilename

How can I rename all the extensions using somethng similar?

thanks,
Peter



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

Date: Wed, 26 Apr 2000 23:35:13 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: substitution question
Message-Id: <3907C381.C8CB3D3D@home.com>

borg wrote:
> 
> I am looking for a way to rename all the text files in a dir to 
> html. ie I want to change their extensions.

I forget where I found this -- might have been the cookbook. Stick this
in rename.pl:

#!/usr/local/bin/perl5 -w
# rename - Larry's filename fixer
$op = shift or die "Usage: rename 'expr' [files]\n";
chomp (@ARGV = <STDIN>) unless @ARGV;
for (@ARGV) {
	$was = $_;
	eval $op;
	die $@ if $@;
	rename ($was, $_) unless $was eq $_;
}


then run

rename.pl "s/\.txt$/\.html/" *.*

-mjc


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 2875
**************************************


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