[12891] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 301 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 29 17:07:23 1999

Date: Thu, 29 Jul 1999 14:05:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 29 Jul 1999     Volume: 9 Number: 301

Today's topics:
        Calling C from Perl <smeka@nsf.gov>
    Re: CGI to verify the SSN (llornkcor@earthlink.net)
    Re: Don't want to make file that owner is "NOBODY" <vlad@doom.net>
    Re: Easy way to emulate Unix's "sort" command? <d-edwards@uchicago.edu>
    Re: Extracting plain text from email <rexcell@btinternet.com>
    Re: File maintenance algorithm required (Roger Musson)
    Re: Getting Height and Width of GIF/JPEG in PERL? (Benjamin Franz)
    Re: help running Perl Scripts in win95 (llornkcor@earthlink.net)
    Re: help w/command line argument sn0brdr@my-deja.com
    Re: help w/command line argument sn0brdr@my-deja.com
        How to copy a file to another name  in same directory   <factory@factory.co.kr>
    Re: How to determine a date in the past <sariq@texas.net>
    Re: How to trim a String <uri@sysarch.com>
    Re: How to trim a String <sariq@texas.net>
        HTML 2 text??? <bob.freedman@eis.noaa.gov>
    Re: Newbie sort and references question. (Rory C-L)
    Re: NEWSFLASH: Supremes rule anti-advert-ware illegal (1)
        One File to Handle all the Variations of a Form  <tomatocans@erols.com>
    Re: Online Job Fair w/ chance to WIN a FREE Trip <emschwar@rmi.net>
    Re: OOP question. (Damian Conway)
    Re: OOP question. <uri@sysarch.com>
    Re: Perl 5.005_58 ... a bug. <dgris@moiraine.dimensional.com>
    Re: Perl Anonymity Question (gulp!) (Malcolm Ray)
        Perl with oracle questions ... <praveenm@cisco.com>
        POSIX win NT <eugene@iescrow.com>
    Re: programming problem (Paul Rahe)
    Re: two forms interact with one script? (Garth Sainio)
        Use of uninitialized value at ...... warning with hash  <jong@ebi.ac.uk>
    Re: Using a timer on flock (Benjamin Franz)
    Re: variation on  /^=/ .. /^=cut/ (Randal L. Schwartz)
    Re: variation on  /^=/ .. /^=cut/ (John Borwick)
    Re: variation on  /^=/ .. /^=cut/ <uri@sysarch.com>
        Warrning with Variable <anonymous@web.remarq.com>
    Re: Warrning with Variable <mattk@cybersurf.net>
    Re: What is "variable suicide"? <macintsh@cs.bu.edu>
    Re: Why this not work HELP! (Bart Lateur)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Thu, 29 Jul 1999 16:48:58 -0400
From: "S. Rao MEKA" <smeka@nsf.gov>
Subject: Calling C from Perl
Message-Id: <37A0BE38.52ECF2BD@nsf.gov>

Hi,
I need to call C function(s) from Perl.
Can you folks please tell me, what is the way to call C from Perl. Do I
need to hack some assembly code OR any quicker way to handle this task.
Our environment is Solaris.

Thanks
M



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

Date: 29 Jul 1999 14:43:04 -0600
From: llornkcor@earthlink.net (llornkcor@earthlink.net)
Subject: Re: CGI to verify the SSN
Message-Id: <wkk8rjrxuv.fsf@earthlink.net>

As from experience, and being off topic here, the only way to verify
SSN, is to run a credit check, and see if the name matches the number,
and if any other name has been used with the number. The SSA does not
give out this info. To no one... 


abigail@delanet.com (Abigail) writes:


>wmichaeln@my-deja.com (wmichaeln@my-deja.com) wrote on MMCLVII September
>MCMXCIII in <URL:news:7nnma1$bq3$1@nnrp1.deja.com>:
>== Hello,
>== I need to write the CGI script to verify
>== the SSN ( Social Security Number ).
>== Does anyone know how to do that ?
>
>
>I would suggest people send in a copy of their SSN card, that
>makes verifying easier.
>
>
>
>Abigail
>-- 
>package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
>                                      print } sub __PACKAGE__ { &
>                                      print (     __PACKAGE__)} &
>                                                  __PACKAGE__
>                                            (                )
>
>
>  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
>   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
>------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----

-- 
llornkcor rocknroll
SpiritShip MultiMedia Recording Studio
www.llornkcor.com
			        (0 0)
+=======================----oOO--(_)--OOo----=========================+
   __   _
  / /  (_)__  __ ____  __    
 / /__/ / _ \/ // /\ \/ /  
/____/_/_//_/\_,_/ /_/\_\    The choice of a GNU generation...



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

Date: 29 Jul 1999 15:14:41 GMT
From: <vlad@doom.net>
Subject: Re: Don't want to make file that owner is "NOBODY"
Message-Id: <7npr51$inb$1@news.servint.com>

I.J. Garlick <ijg@connect.org.uk> wrote:


> Ok I will give you that, but it's not clear what the poster actually wants.

Yes, very true.  I was just assuming worst case scenario.


> And nobody is an invalid user on your system? (or whatever the server runs
> a connection as anyway) All right you can't login into it but that's for
> security.

Well what I meant by valid, is a user who can login to the system. and that user is
the only one that can spawn process under that user id.

User nobody is used for all sorts of mundane system tasks. and if the web server runs
as nobody, then anybody can spawn a nobody :)


> Dismissal! I think modifying some one elses files on your companies system
> is definitely grounds for not having your feet touch the floor on the way
> out of the door. Especially ones that have to be openly group modifiable,
> at least with out permission.

I agree, but worst case scenario, the poster is on a public server that has other
users with web pages and are allowed to run cgi's, In that case, not a whole lot you
can do.  Thats the nature of shared web servers though, 


> If you must have a system where you can't trust people, say in an academic
> environment then I would suggest a cgi wrapper would be more appropriate.
> Agreed suExec seams to be something like that but sounds much more dangerous.

>> Thats one reason suexec exists...

> Ok. Lets check out what it says in the quoted HTML page.

> 	Used properly, this feature can reduce considerably the security risks
> 	involved with allowing users to develop and run private CGI or SSI
> 	programs.  However, if suEXEC is improperly configured, it can cause any
> 	number of problems and possibly create new holes in your computer's
> 	security. If you aren't familiar with managing setuid root programs and
> 	the security issues they present, we highly recommend that you not
> 	consider using suEXEC


> Hmmmm.... Not something a begginer should even contemplate with a warning
> like that. Best left to a very savvy webmaster.

No kidding.... suexec + newbie = hmm....

But suexec is very useful if configured properly.  I don't use it for anything
important. IMO if your data files are that important and security is an issue, then 
you should have a dedicated server for your proggies and data files.

Again my answer to his origanl post.

Worst case. You're on a shared web server The web server must run as nobody.  You
have data files that must be modifiable via the web, and can't be owned by nobody.
must be owned by the posters userid and can only be modified by proggies owned by his
userid.

suexec is the way to go... Not the only solution, but one nonetheless

-v


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

Date: Thu, 29 Jul 1999 19:26:08 GMT
From: Darrin Edwards <d-edwards@uchicago.edu>
Subject: Re: Easy way to emulate Unix's "sort" command?
Message-Id: <tghfmnxnov.fsf@noise.bsd.uchicago.edu>

jimhutchison@metronet.ca (Jim Hutchison) writes:

> On 28 Jul 1999 20:04:13 -0000, Jonathan Stowe
> <gellyfish@gellyfish.com> wrote:
> 
> >I would read the article entitled :
> >
> >  =head2 How do I sort an array by (anything)?
> >
> >in perlfaq4.  Of course after you have read that and possibly still
> >have difficulties please feel free to ask again.
> 
> Thanks Jonathan.   As I'm still digesting the basics, the FAQ wasn't
> clear on how to do a simple numeric sort on, say, the 3rd column of a
> multi-column table.  
> 
> Their example was for "the first word after the first number"...  I
> don't know perl enough yet to be creative, so it's not clear to me how
> to change the script to sort on another column.

If you take a look at the Schwartzian Transform example:

              @sorted = map  { $_->[0] }
                        sort { $a->[1] cmp $b->[1] }
                        map  { [ $_, uc((/\d+\s*(\S+)/ )[0] ] } @data;

notice that the "sort" is sorting here effectively on the "second column"
of a "two-column table".  If your "table" is a simple 2d array, then
you might not even need an ST, just modify that sort statement accordingly.

Darrin


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

Date: Thu, 29 Jul 1999 21:26:20 +0100
From: "Roger" <rexcell@btinternet.com>
Subject: Re: Extracting plain text from email
Message-Id: <7nqdcm$bol$1@uranium.btinternet.com>

maybe  this should be be a new msg
but all i did was ask question

no need to get alll over excited how i did it :))

thanks problem solved thanks to you guys


Roger

Roger <rexcell@btinternet.com> wrote in message
news:7ncqe4$237$1@uranium.btinternet.com...
>
> Hi all
>
> A question with no simple answer i guess
>
> How can you get the plain text version of an email out of all the headers
> and if it been sent in html format loose all the formating below the main
> body of the message.
>
> Hope that makes sense ?
>
> Also i hope someone has a simple soloution
>
> Thanks for reading and hopefuly helping
>
> Roger
>
> --
>  www.btinternet.com/~rexcell
>
>
>
>
>
>




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

Date: Thu, 29 Jul 1999 20:05:35 GMT
From: roger@wheelpro.co.uk (Roger Musson)
Subject: Re: File maintenance algorithm required
Message-Id: <37a0882b.4876306@nntp.netcomuk.co.uk>

bart.lateur@skynet.be (Bart Lateur) wrote:

>Roger Musson wrote:

>>I need to add a line of data to the front of a file (i.e. not
>>appending). The file is several thousand lines long and about 5mb file
>>size.

>Why do you need that? To create a log file, latest events at the front?
>Maybe you should try appending anyway, but in parallel creating an index
>file, with the seek/tell value of each line.

[...]

Appending is really what I would like to do for efficiency, but 90% of
the time the file is used for displaying the recent additions, so
appending to the front makes the display transaction faster. An index
would be fine but for the fact that lines can also be deleted from the
file.

I'm sure there must be a good reason why Perl does not have a
<lineInput> command that works in reverse, i.e starting at the end of
the file. This would make things real easy and fast.


Roger Musson


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

Date: Thu, 29 Jul 1999 20:39:00 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: Getting Height and Width of GIF/JPEG in PERL?
Message-Id: <EZ2o3.99$y82.15394@typhoon01.swbell.net>

In article <7ZRn3.3034$nB.451730@news.itd.umich.edu>,
Sean McAfee <mcafee@waits.facilities.med.umich.edu> wrote:
>In article <slrn7pv624.4oo.abigail@alexandra.delanet.com>,
>Abigail <abigail@delanet.com> wrote:
>>Sean McAfee (mcafee@waits.facilities.med.umich.edu) wrote on MMCLVII
>>September MCMXCIII in <URL:news:jFEn3.2866$nB.428994@news.itd.umich.edu>:
>>!! In article <slrn7psv3n.3hu.abigail@alexandra.delanet.com>,
>>!! Abigail <abigail@delanet.com> wrote:
>>!! >Don't forget, when it comes to the web, the evil character is Netscape,
>>!! >way more than MS.
>
>>!! *blink*
>>!! You don't say.
>
>>Oh yes, I do. Let me say it again: the evilness of Jim Clark and Mark
>>Andreessen far outweights the evilness of Bill Gates.
>
>Erp... I had a feeling the joke was too well-disguised even as I posted it.
>Maybe I should have written "<blink>" instead.  But you're right; now that
>I think about it, it's hard to imagine that even Microsoft could be evil
>enough to create that monstrosity of a tag.

Nope. They settled for breaking all standard advanced HTML constructs
such as OBJECT in ways that rendered them impossible to _ever_ use in a
mixed browser environment and inventing ActiveX, IFRAME and BGSOUND. And 
don't forget 'JScript' and MS-Java. 

The MS execs who decided that they had to 'market differentiate' their
HTML, XML, XSL, CSS, PNG, scripting, document model and Java support from
the standards the rest of the world agreed upon *will* be first against
the wall. 

-- 
Benjamin Franz


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

Date: 29 Jul 1999 14:32:32 -0600
From: llornkcor@earthlink.net (llornkcor@earthlink.net)
Subject: Re: help running Perl Scripts in win95
Message-Id: <wkn1wfrycf.fsf@earthlink.net>

hehehe- funny answer... God module, I like that.... :o)

to the original poster-you also might see if Front Page extensions are
installed on your server, if thats what the sfript is using.

"Lauren Smith" <laurens@bsquare.com> writes:

>I've been working on a God module for myself for some time now, and this
>would be good place to try some functionality.
>
>use God::Omniscience;
>&FindProblem($no_information_given);
>
>output:
>There is a problem in your script.  Look for 'system()' commands or
>backticked commands.  The source of your woes comes from such lines.
>
>Well, that's what my God module is saying, I have to take it at face value.
>
>>I have even tried running the example script "Excel1.pl".
>>It executes, starts Excel, loads, displays and terminates.
>
>Let me try again.
>
>use God::Omniscience;
>&WhatIsGoingOn($no_clue_as_to_what_is_supposed_to_happen);
>
>output:
>I have no idea.
>
>*sigh*  Not all problems can be solved, it seems.
>
>Lauren
>
>

-- 
llornkcor rocknroll
SpiritShip MultiMedia Recording Studio
www.llornkcor.com
			        (0 0)
+=======================----oOO--(_)--OOo----=========================+
   __   _
  / /  (_)__  __ ____  __    
 / /__/ / _ \/ // /\ \/ /  
/____/_/_//_/\_,_/ /_/\_\    The choice of a GNU generation...



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

Date: Thu, 29 Jul 1999 20:03:57 GMT
From: sn0brdr@my-deja.com
Subject: Re: help w/command line argument
Message-Id: <7nqc36$41a$1@nnrp1.deja.com>


> Then I would write my program such that it doesn't take switches!
how? got samples?


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


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

Date: Thu, 29 Jul 1999 20:26:56 GMT
From: sn0brdr@my-deja.com
Subject: Re: help w/command line argument
Message-Id: <7nqde2$517$1@nnrp1.deja.com>


> Use one of the Getopt option parsers or write your own.  It's not that
> hard.  We might offer code, but you don't say what you want.

which getopt parser are you referring to?
i want to pass an arg to a script within my proggie.

> : the ability to see output and error would be great.
>
> Maybe you should elaborate on this so we can get a better idea of what
> you want.

to see stderr and stdout

nu B


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


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

Date: Thu, 29 Jul 1999 08:34:07 +0900
From: "Yeong Mo/Director Hana co." <factory@factory.co.kr>
Subject: How to copy a file to another name  in same directory  and more ?
Message-Id: <7no3hu$hrb$1@news1.kornet.net>

Hi,

There is a file named aaa.txt

Let's think there are directories information in aaa.txt file as following;
01 | directory-a |.................
02 | directory-b |.................
This directory fields are changed when I load other script.

Before aaa.txt file is changed, I want to have a backup file.

Finally, I want to compare two files of new aaa.txt and backup file, and
delete the old directory from my server which is not still there in new
aaa.txt file.

If someone has a solution for this, please let me know.

Thanks in advance.




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

Date: Thu, 29 Jul 1999 15:25:27 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: How to determine a date in the past
Message-Id: <37A0B8B7.6AC13E64@texas.net>

Steve Walker wrote:
> 
> Does anyone know of a way of determining a date in the past, by counting
> back a specified number of days?  Ideally the date would be returned as
> an integer, i.e. YYYYMMDD.
> 
> Are there any Perl libraries which provide such a function?

Have you bothered to look?  You might try a module from CPAN that starts
with, say, 'Date'...

- Tom


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

Date: 29 Jul 1999 16:19:04 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How to trim a String
Message-Id: <x7lnbzp5tz.fsf@home.sysarch.com>

>>>>> "FN" == Faisal Nasim <swiftkid@bigfoot.com> writes:

  FN> :   ( local $_ = shift ) =~ s/\s+|\s+$//gs;
  FN> Oops, I meant

  FN> ( local $_ = shift ) =~ s/^\s+|\s+$//gs;

even that is extra. why not s/// the arg itself?

	$_[0] =~ s/^\s+|\s+$//g;

and no need for the /s as there is no . in the regex.

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Thu, 29 Jul 1999 15:17:03 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: How to trim a String
Message-Id: <37A0B6BF.67D8B8D9@texas.net>

Faisal Nasim wrote:
> 
> : : sub trim
> : : {
> : :   ( local $_ = shift ) =~ s/\s+|\s+$//gs;
> : :   $_
> : : }
> :
> : I don't think that does what you think it does (unless you have a
> : different definition of what it means to trim a string).
> 
> I thought trim means removing space from left and right...

That's what it means to me,too.  Did you test your code above to see if
that's what it does?

- Tom


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

Date: Thu, 29 Jul 1999 14:31:58 -0400
From: Bob Freedman <bob.freedman@eis.noaa.gov>
Subject: HTML 2 text???
Message-Id: <37A09E1E.840A33DD@eis.noaa.gov>

Can someone show me a quick example of how to extrapolate the text from
a HTML file.

I tried:
$text = new HTML::Parser;

$text->parse_file($document);

if I print $document I get 'HTML::Parser=HASH(0xba23c)'

Help Please!!!


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

Date: Thu, 29 Jul 1999 21:12:46 +0100
From: campbell-lange@easynet.co.uk (Rory C-L)
Subject: Re: Newbie sort and references question.
Message-Id: <campbell-lange-2907992112460001@campbell-lange.easynet.co.uk>

In article <7nnf7o$mn5$1@news.mch.sbs.de>, michel.dalle@usa.net (Michel
Dalle) wrote:>
>Something like this might work :
>
>@sortedkeys = map { $_->[0] }
>        sort { $a->[1] <=> $b->[1] }
>        map { [ $_, split('/',$hash{$_}[0][0]) ] } keys %hash;
>
>Again, you might re-think your data structure before going any further...
>Have a look at perldsc, perllol and perlref for some pointers :-)
>
>Have fun,
>
>Michel.

Thanks for the pointers, Michel

I got to this with help from Anno:

In article <7np33c$pa$1@lublin.zrz.tu-berlin.de>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

> Obviously you need help.  But you won't get it unless you state
> clearly what you want to do.  Don't use Perl parlance if you don't
> understand it clearly, it will only confuse your readers.  
> 
> Anno

My sincere apologies for wasting your time. I failed
to read your previous posting properly. All my questions
about constructing the array referenced by the hash value
were answered by your excellent help. Thank you for spending
time trying to interpret my confusion.

I now understand:
Inserting : takes the form of:
         push @{$hash{'key'}}, [qw!one two three!];
         push @{$hash{'key'}}, [qw!three four five!];
Accessing : takes the form of:
         print @{@{$hash{'key'}}[0]}; # gives "one two three"
         print ${@{@{$hash{'hasher'}}[0]}}[2]; # gives "three"

Sorting: 
I realise I have to sort the hash by keys or values, or the hash value
ref'd array by values in the arrays in the ref'd array.

Thank you again
Rory
   

This is the final code, which works
------------
#!perl -w
use strict;

my (@issues, %hash);

while (<>)
{
   chomp;
   my ($plot, $no, $rev, $title, $iss, $date) = "";
   my ($rest) = [];
   ($plot, $no, $rev, $title, $iss, $date) = split /\t/;
   $date = "none" if (! $date);  
   $rest = [$no, $rev, $date, $iss];
   push @{ $hash{$iss} }, $rest; # from Anno Siegel 
}

### adapted from help by Anno Siegel

for my $issue ( sort keys %hash ) 
{
  print "$issue: \n";
  for my $aref ( @{ $hash{ $issue}} ) 
  {
    print "\t@$aref\n";
  }
  print "\n";
}

# (sample data)
# __END__
# 4   A/LB/10/00/249 C  Utility Building  780/1999 21/4/99
# 1   A/LB/10/01/003 R  First Floor Plan  874/1999 1/6/99
# 1   A/LB/10/02/028 C  Second Floor   542/1999 14/1/99
# 1   A/LB/10/04/021 J  Utility Building Central   487/1998 4/12/98
# 1   A/LB/10/05/032 K  Roof Plan   897/1999 8/6/99

-- 
Rory Campbell-Lange
The Campbell-Lange Workshop

-- 
--
Rory Campbell-Lange
The Campbell-Lange Workshop, London


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

Date: Thu, 29 Jul 1999 12:50:49 -0700
From: "REBUS" <rebus@acces(1).com>
Subject: Re: NEWSFLASH: Supremes rule anti-advert-ware illegal
Message-Id: <rq1c02$0$37nspbj$3e@corp.supernews.com>


Tom Christiansen wrote in message <379f67d1@cs.colorado.edu>...
> March 32, 2002
>
>Washington DC - After more than two years in and out of the courts,
>The Supreme Court today upheld the lower courts' ruling that the viewing
>of a website in any layout and format other than the one set-up by that
>site's authors was illegal.


Well, I guess this flash from the future also means that M$ as succeeded in
taking over the entire Web--infrastructure and all--so that users of
Netscape or any other browser that wasn't the version of IE the author used,
wouldn't be accidentally performing a criminal act. (I also guess that this
means the "Don't Show Images" option is also history, along with:
scroll-bars, the color control on your monitor, and font settings. Oh, also
you'll be required by law to have a 19-inch monitor set to 1024x780 at 16M+
colors.)






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

Date: 29 Jul 1999 15:34:43 -0500
From: "Thomas McLaughlin" <tomatocans@erols.com>
Subject: One File to Handle all the Variations of a Form 
Message-Id: <37a0acd3@discussions>


I am currently working on my first PERL assignment and I need to
develop an object which contains variations of a particular form.
Currently, this form is coded individually in each page and each 
page displays its particular fields from the form.  The objective
is to have one file contain the form and have each individual 
page file reference this file for the form. The idea is to allow
changes to this form to be made in one file instead of going into
the individual files for each page and changing any new 
requirements.  If anyone knows some sample code or has 
suggestions on resolving the problem, I would appreciate the 
guidance as a newbie to PERL. Thanks in advance. 


--Posted from EarthWeb Discussions. http://discussions.earthweb.com



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

Date: 29 Jul 1999 13:07:04 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Online Job Fair w/ chance to WIN a FREE Trip
Message-Id: <xkfoggvi8br.fsf@valdemar.col.hp.com>

Apex <arc@flash.net> writes:
> [1  <text/plain; us-ascii (7bit)>]
> 
> 
> [2 Part Letter.html <text/html; us-ascii (7bit)>]

What?

-=Eric


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

Date: 29 Jul 1999 20:28:38 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: OOP question.
Message-Id: <7nqdhm$l5n$1@towncrier.cc.monash.edu.au>

pijll@phys.uu.nl (Eugene van der Pijll) writes:

   > In <7nools$sv5$1@towncrier.cc.monash.edu.au> damian@cs.monash.edu.au (Damian Conway) writes:

   > >	my $c1 = C->new(name=>'bar', rank=>'foo', serialnum=>00001);
   > >	my $c2 = C->new(name=>'blah', rank=>'floo', serialnum=>00002);


   > >Now $c1 is a C, whilst $c2 is an AntiC.

   > But you're using two classes, that looks like cheating to me.

"Rules?! In a bar fight?" :-)

I didn't see anything about not using other classes as well.
Besides, genius consists of knowing when to draw outside the lines ;-)


   > Besides, it's not a correct solution, IMHO:

   > what if the name of an object is changed?
   > $c1->set_name('blah') should rebless $c1 into the package AntiC, no?

Sure, but that wasn't part of the original spec.


   > My solution would be to have 1 class only, but with an @ISA which is
   > only determinated when a method is called:

It also assumes that C is accessed *only* through its inherited methods -
that's C's methods do nothing of their own. In my experience, that
never happens.

If you *really* needed all C objects to be actually blessed into class C,
that wouldn't be hard to achieve (and without jiggling @ISA on the fly):


	package C;

	sub new
	{
		my ($class, %args) = @_;
		my $realself = ($args{name} eq 'blah')
					?  EvilRobotC->new(%args)
					:  GoodRobotC->new(%args);
		bless \$realself, $class;
	}

	sub AUTOLOAD
	{
		my ($self, @args) = @_;
		$AUTOLOAD =~ s/.*:://;
		${$self}->$AUTOLOAD(@args);
	}


	package GoodRobotC;
	@ISA = qw( A B );

	sub new
	{
		my ($class, %args) = @_;
		return bless(\%args, $class);
	}

	package EvilRobotC;
	@ISA = qw( B A );

	sub new
	{
		my ($class, %args) = @_;
		return bless(\%args, $class);
	}


	package main;

	my $c1 = C->new(name=>'bar', rank=>'foo', serialnum=>00001);
	my $c2 = C->new(name=>'blah', rank=>'floo', serialnum=>00002);


Now both $c1 and $c2 are C's, but all method requests are
forwarded to the appropriate helper class, which takes care of
the desired inheritance order. Note that methods can be added to
either helper class, as is usually required.

This version is a more traditional implementation of the
envelope/letter idiom, but gains us very little in Perl, apart from the
satisfaction of having ref return 'C' on both objects. And the cost of
that satisfaction, in terms of method call overhead, is substantial.

And, of course, it carries the heavy karmic burden of having "cheated".

;-)

Damian


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

Date: 29 Jul 1999 16:47:08 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: OOP question.
Message-Id: <x7aesfp4j7.fsf@home.sysarch.com>

>>>>> "DC" == Damian Conway <damian@cs.monash.edu.au> writes:

  DC> pijll@phys.uu.nl (Eugene van der Pijll) writes:
  >> In <7nools$sv5$1@towncrier.cc.monash.edu.au> damian@cs.monash.edu.au (Damian Conway) writes:

  >> But you're using two classes, that looks like cheating to me.

  DC> "Rules?! In a bar fight?" :-)

hey damian, he probably doesn't know you're an aussie! 

  DC> 		my $realself = ($args{name} eq 'blah')
  DC> 					?  EvilRobotC->new(%args)
  DC> 					:  GoodRobotC->new(%args);
  DC> 		bless \$realself, $class;

that IS sneaky. it took me a couple of minutes to see the ref of ref.

  DC> 		${$self}->$AUTOLOAD(@args);

that is even sneakier. and as you said a real pig. you must love bar
fights and i bet you win them with the old "your shoelaces are untied"
trick.

  DC> And, of course, it carries the heavy karmic burden of having
  DC> "cheated".

i don't think you feel any guilt after all the foster's you must have
drunk.

:-)

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 29 Jul 1999 13:35:43 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Perl 5.005_58 ... a bug.
Message-Id: <m3pv1b1c6o.fsf@moiraine.dimensional.com>

"Faisal Nasim" <swiftkid@bigfoot.com> writes:

> perl -V is broken!

You shouldn't be using _58 unless you are planning on hacking,
debugging, or testing the perl core.

You shouldn't be directing problems with _58 to clpm, it isn't
the appropriate forum.  p5p is.

You shouldn't be running _58 unless you are subscribed to p5p 
and are competent to understand the discussion that takes 
place there.

You can't run _58 properly without first applying the tiny
patch Ilya posted[0] to p5p shortly after _58 was released.

dgris
0- in message <19990727174200.A12775@monk.mps.ohio-state.edu>
-- 
You'll feel much better once you've given up hope.


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

Date: 29 Jul 1999 20:44:27 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Perl Anonymity Question (gulp!)
Message-Id: <slrn7q1f9b.cp0.M.Ray@carlova.ulcc.ac.uk>

On Thu, 29 Jul 1999 17:36:40 +0100, Simmo <SimsiREMOVETHISBIT@hotmail.com>
wrote:
>Ok thanks anyway Martien....topic closed here i think :-)

Well, not necessarily!  You're assuming that you need to use different
IP addresses to represent different clients.  But think about proxies.
If the server's logs show a large number of accesses from an address
which resolves to, say, 'proxy.example.com', and the contents of
the client's 'User-Agent' header (if this is being logged) varies
convincingly from access to access, the administrator may be fooled.
Not that I approve of trying to fool system administrators, of course:
we don't like it, and we have ways of making you suffer.

The LWP::UserAgent module allows you to set the User-Agent header.

-- 
Malcolm Ray                           University of London Computer Centre


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

Date: Thu, 29 Jul 1999 12:07:28 -0700
From: Praveen Mohan <praveenm@cisco.com>
Subject: Perl with oracle questions ...
Message-Id: <Pine.GSO.3.96.990729120657.17252F-100000@jlequang-ss20.cisco.com>




Hi,

I am a newbie with perl and I have a couple of questions ...

1> Which Oracle 8.0 libraries must be available for a perl script to work?

2> Are they already linked into the oraperl module or are they shared?

Thanx in advance,

Praveen





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

Date: Thu, 29 Jul 1999 13:30:08 -0700
From: "news.tngi.com" <eugene@iescrow.com>
Subject: POSIX win NT
Message-Id: <933280327.58180@storm.tngi.com>

IF anybody knows where to gete POSIX perl module for WinNT, and how to use
it, please email me at eugene@iescrow.com , or site@bastion.net .




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

Date: Thu, 29 Jul 1999 19:31:50 GMT
From: paul_rahe@cissc.canon.com (Paul Rahe)
Subject: Re: programming problem
Message-Id: <37a0abff.433052@news.cis.canon.com>

On Thu, 29 Jul 1999 11:19:54 -0700, David Cassell
<cassell@mail.cor.epa.gov> wrote:

>paul_rahe@cissc.canon.com wrote:
>> 
>> You might want to try putting your DOS commands in a BAT file and then
>> executing them from within your Perl script with the SYSTEM command.
>
>He shouldn't even need to go that far.  He should be able to
>execute them directly using the system() command [I know you
>meant that rather than SYSTEM but many newbies don't know
>Perl is case-sensitive, so I try to be careful about this]
>or qx//, or even a pipe open() depending on what he needs
>done.
>
>BTW Paul, would you do me a small favor?  In this ng we try to
>put our responses after the text to which we're responding, in
>old-fashioned Usenet style.  Could you do that in future?  I'd
>appreciate it, and then you won't have newsgroup nabobs 
>nattering on about your style.
>
>David
>-- 
>David Cassell, OAO                     cassell@mail.cor.epa.gov
>Senior computing specialist
>mathematical statistician

David,

Thanks for the correction regarding system() and for the advice
concerning proper Usenet posting.

Paul



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

Date: Thu, 29 Jul 1999 16:18:46 -0400
From: modred@shore.net (Garth Sainio)
Subject: Re: two forms interact with one script?
Message-Id: <modred-2907991618460001@pm4-2-191.port.shore.net>

In article <37A09F7D.3BC6516A@dds.nl>, Niek Slatius <nslatius@dds.nl> wrote:

!!  Garth Sainio wrote:
!!  
!!  > you could try naming the submit buttons differently and seeing which one
!!  > comes back with a defined value. Are you using CGI.pm to do this? If not,
!!  > you probably should be. Without the actual code it is pretty difficult to
!!  > give you much more direction on what is going wrong.
!!  
!!  Hey Garth,
!!  
!!  Thanx for your reply.
!!  
!!  The problem is, I don't have submit buttons, but buttons which call for a
!!  javascript function. This javascript function checks whether the data
is correct
!!  and if so it submits the appropriate form.
!!  
!!  This is the perl code:
!!  ----------------------------------------------------------------------
!!  #!/usr/bin/perl

You probably want the -w flag here to help you catch any typos or the
like. The -w flag turns on all the warnings the interpreter can give you.

!!  
!!  # insert code for parsing incoming formcode to be handled in perl
!!  require "formparse.pl";
!!  
!!  $lid="leden.txt";
!!  $bel="belang.txt";
!!  
!!  # if the hidden field with NAME="name1" is being send open LID file etc.
!!  if($FORM{'name1'})

What is $FORM? Is it in formparse.pl? What is formparse.pl? Are you trying
to parse out the environment variables yourself? 

$FORM{'name1'} is an element of a hash, if want to test whether it is
there you want to use the built in function exists (for more information
perldoc -f exists). So, maybe you want if(exists($FORM{'name1'}) instead.
Or if are giving it a default value in formparse.pl you may want to try
if($FORM{'name1'} eq 'your_value_here').

!!  {
!!      open(LID,">>$lid") || die "can't open file\n";

You want to say || die "Can't open file: $!\n" here. $! contains the error
message indicating the reason the file could not be opened. 

!!      print LID $FORM{'lid'}, " ", $FORM{'emailLid'}, "\n";
!!      close LID;
!!      chmod 0777,"$lid";

You want to check the return value of chmod. Everything I said above also
applies to the elsif code.

!!  }
!!  
!!  # else if hidden field with NAME="name2" is being send open BEL file etc.
!!  elseif($FORM{'name2'})
!!  {
!!      open(BEL,">>$bel") || die "can't open file\n";
!!      print BEL $FORM{'belang'}, " ", $FORM{'emailBelang'}, "\n";
!!      close BEL;
!!      chmod 0777,"$bel";
!!  }

Where's your else? Putting in an else clause will allow to you to do some
checking to see what is going wrong.

something like

else
{
   # Print the HTML header (I assume you are going to output something back
   # to the browser...
   print "Content-type:text/html\n\n"; # Or if you use the CGI.pm module
                                       # just print header() will suffice.
   
   print "<H1>Error!</H1>\n";
   print "<PRE>"; # Or in table format if like
   # Print out all the values that are in $FORM to see if they are the values
   # that are expected
   foreach $key (keys %FORM)
   {
      print "$key\t$FORM{$key}\n";
   }
   print "</PRE>";
}


!!  ----------------------------------------------------------------------
!!  
!!  Hope this is more vivid for you to analyse. Thanx!!
!!  
!!  BTW... what's CGI.pm? Some debugging tool? (I'm a newbie, forgive me)

Try perldoc CGI for more information. It is a module that takes care of
parsing the input from forms for you so you do not have to re-invent the
wheel. Take a look around www.perl.com for more information about Perl in
general and at http://stein.cshl.org/WWW/software/CGI/cgi_docs.html for
more information about CGI.pm. It is part of the standard perl
distribution so it should be available for your use already.

Garth

-- 
Garth Sainio               "Finishing second just means you were the 
modred@shore.net            first to lose" - anonymous


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

Date: Thu, 29 Jul 1999 21:37:48 +0100
From: "J.H.P" <jong@ebi.ac.uk>
Subject: Use of uninitialized value at ...... warning with hash of hash
Message-Id: <37A0BB9C.7987BC1B@ebi.ac.uk>

Hi,

When I assign a value to a hash of a hash, I get the
above warning.


I use


$hash{first}{second}='xxxx';



I 'my' %hash in the subroutine.

My guess is that -w sign thinks that I use
an undefined hash (multi-level hash) even
though I my %hash.

Is this true?

If so, can anybody tell me how to avoid the warning?

Cheers,

Jong



-- Jong Park : a Biology student --  Tel work: +44 1223 49-4613

 BioPerl Conference with ISMB 99 in Heidelberg ==>

         http://bio.perl.org/bioperl-99/


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

Date: Thu, 29 Jul 1999 20:58:50 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: Using a timer on flock
Message-Id: <eg3o3.103$y82.16839@typhoon01.swbell.net>

wgd@adelaide.on.net wrote in comp.lang.perl.misc:
>
>So as a newbie, I ask how can you tell if a file is locked without
>using the -e indicator?

Use non-blocking locks:

    my $timeout =100;
    while (not flock (DB_FH, &LOCK_EX | &LOCK_NB)) {
        $timeout--;
        if ($timeout == 0) {
            die ("Failed to get exclusive lock on the file: $!\n");
        }
        select undef,undef,undef,0.1; # Sleep a tenth of a second
    }

-- 
Benjamin Franz


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

Date: 29 Jul 1999 12:15:34 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: variation on  /^=/ .. /^=cut/
Message-Id: <m1907z2rop.fsf@halfdome.holdit.com>

>>>>> "Keith" == Keith A Arner <karner@andrew.cmu.edu> writes:

Keith> I know I could do something like:

Keith>  while(<>) {
Keith>   if (/^=/   ) {$flag=1; next}
Keith>   if (/^=cut/) {$flag=0; next}
Keith>   print if $flag;
Keith>  }

The final match of a flipflop has "E0" appended, which doesn't change
the numeric value but can be tested-for.  Try this:

    while (<>) {
      $inside = /^=/ .. /^=cut/;
      print if $inside and $inside > 1 and $inside !~ /E/;
    }

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Thu, 29 Jul 1999 19:45:04 GMT
From: John.Borwick@sas.com (John Borwick)
Subject: Re: variation on  /^=/ .. /^=cut/
Message-Id: <37a0af2e.286271566@newshost.unx.sas.com>

On Thu, 29 Jul 1999 13:14:55 -0400, Keith A Arner
<karner@andrew.cmu.edu> wrote:

>I know I could do something like:
>
> while(<>) {
>  if (/^=/   ) {$flag=1; next}
>  if (/^=cut/) {$flag=0; next}
>  print if $flag;
> }
>

this probably would not work, as =cut matches the first case.

-- 
John Borwick


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

Date: 29 Jul 1999 16:24:06 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: variation on  /^=/ .. /^=cut/
Message-Id: <x7iu73p5lk.fsf@home.sysarch.com>

>>>>> "KAA" == Keith A Arner <karner@andrew.cmu.edu> writes:

  KAA> Say I have the following file (line numbers added for discussion
  KAA> purposes): 

  KAA> 1:  #!/usr/local/bin/perl
  KAA> 2:  =head1 Foo
  KAA> 3:
  KAA> 4:  Bar
  KAA> 5:
  KAA> 6:  =cut
  KAA> 7:
  KAA> 8:  use strict;

  KAA>  while(<>) {
  KAA>   if (/^=/   ) {$flag=1; next}
  KAA>   if (/^=cut/) {$flag=0; next}
  KAA>   print if $flag;
  KAA>  }


my version (you got at least 2 others so far):

	while( <> ) {

		next unless $range = /^=/ .. /^=cut/ ;
		next if $range == 1 ;
		next if $range =~ /E/ ;
		print ;
	}

very few folks know about or make use of the value of the .. operator.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Thu, 29 Jul 1999 11:04:07 -0800
From: Samay <anonymous@web.remarq.com>
Subject: Warrning with Variable
Message-Id: <933275051.24882@www.remarq.com>

Hi, I am running a big perl program which operates on
serveral files. I generate various warning for some files.
I have to parse this files for various formats.
If it's not identifiable it generates warning indicating
that line number. Note that this doesn't happen for all the
files for a perticular line.

Example:
 Argument "Lee" isn't numeric in lt at subs line 127

Now, I would like to know which file generated this warning
message, so I can check that file to see what's wrong.

Code:

while $file (@files){
  process $file;
}
sub process{
   some code..
}

I want to see warning as

Argument "Lee" isn't numeric in lt at subs line 127 while
processing "xyz.txt"


Any ideas will be useful.
Thank You
Samay.






* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!


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

Date: Thu, 29 Jul 1999 14:08:03 -0700
From: Matt <mattk@cybersurf.net>
Subject: Re: Warrning with Variable
Message-Id: <37A0C2B3.2757FA6A@cybersurf.net>

Isn't $file passed to process()? Just include $file in print.

Matt

Samay wrote:
> 
> Hi, I am running a big perl program which operates on
> serveral files. I generate various warning for some files.
> I have to parse this files for various formats.
> If it's not identifiable it generates warning indicating
> that line number. Note that this doesn't happen for all the
> files for a perticular line.
> 
> Example:
>  Argument "Lee" isn't numeric in lt at subs line 127
> 
> Now, I would like to know which file generated this warning
> message, so I can check that file to see what's wrong.
> 
> Code:
> 
> while $file (@files){
>   process $file;
> }
> sub process{
>    some code..
> }
> 
> I want to see warning as
> 
> Argument "Lee" isn't numeric in lt at subs line 127 while
> processing "xyz.txt"
> 
> Any ideas will be useful.
> Thank You
> Samay.
> 
> * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
> The fastest and easiest way to search and participate in Usenet - Free!


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

Date: 29 Jul 1999 19:36:17 GMT
From: John Siracusa <macintsh@cs.bu.edu>
Subject: Re: What is "variable suicide"?
Message-Id: <7nqafh$4dk$1@news1.bu.edu>

Doh!  FAQed.  I guess it's been a while since I read it...

Anyway, more questions:

    my $f = "foo";
    sub T {
      while ($i++ < 3) { my $f = $f; $f .= "bar"; print $f, "\n" }
    }
    T;
    print "Finally $f\n";

    The $f that has ``bar'' added to it three times should be a new $f
    (my $f should create a new local variable each time through the
    loop). It isn't, however. This is a bug, and will be fixed.

What *should* be printed (i.e. if the bug was fixed)?  I expect to see
"foobar" three times, followed by "Finally foo."  I do see this in
5.005_03.

The example in perltrap makes sense and does demonstrate a bug, but
I'm not sure how it relates to the FAQ example.

-----------------+----------------------------------------
  John Siracusa  | If you only have a hammer, you tend to
 macintsh@bu.edu | see every problem as a nail. -- Maslow



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

Date: Thu, 29 Jul 1999 15:36:47 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Why this not work HELP!
Message-Id: <37a07441.27139486@news.skynet.be>

Ryan Ngi wrote:

>give:
>
>%HASH = ( "k" => [1,2,3] );
>
>$x = $HASH{ "k" }-> [1]++;
>
>print $x;
>
>...... the result is "2" but i expect "3";...... why this not work !?

Because you're reading the value of the second item (2) into $x before
incrementing it?

Try either:

	print $HASH{"k"}->[1];

instead of "print $x;", or just

	$x = ++$HASH{"k"}->[1];
	print $x;

	Bart.


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

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

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

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

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

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

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


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


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