[15833] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3246 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 4 03:05:29 2000

Date: Sun, 4 Jun 2000 00:05:14 -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: <960102314-v9-i3246@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 4 Jun 2000     Volume: 9 Number: 3246

Today's topics:
    Re: Anyone use win32::IPROC  - help <pmudundi@sunny.zp>
    Re: Anyone use win32::IPROC  - help (jason)
    Re: Can't seem to find the Form post data <vvacme@worldonline.nl>
        default behavior of <ejwhite1@facstaff.wisc.edu>
    Re: default behavior of <tina@streetmail.com>
    Re: Execute perl code in a variable <eidheim@hivolda.no>
    Re: Execute perl code in a variable (Tad McClellan)
    Re: floating point algorithm bug in perl 5.6.0? <vvacme@worldonline.nl>
    Re: floating point algorithm bug in perl 5.6.0? (Eric Bohlman)
    Re: How do I update records in a file?  (cgi & perl) (Tad McClellan)
    Re: How do I update records in a file?  (cgi & perl) <nayler@SPAMOFFses.curtin.edu.au>
    Re: How do you pass a hash reference in Perl 4? (Tad McClellan)
        newsgroup help <danjones@crosswinds.net>
    Re: newsgroup help <tina@streetmail.com>
    Re: newsgroup help <danjones@crosswinds.net>
        perl editor for linux <dgrogan@virginia.edu>
    Re: perl editor for linux <tina@streetmail.com>
    Re: perl editor for linux <dgrogan@virginia.edu>
    Re: Perl to write to a text file (Tad McClellan)
        please help in checking the referer site and giving pag <joydip_chaklader@my-deja.com>
    Re: please help in checking the referer site and giving (jason)
    Re: please help in checking the referer site and giving (David Efflandt)
    Re: Problem using command line arguments <wellhaven@worldnet.att.net>
    Re: Problem using command line arguments (Eric Bohlman)
    Re: Problem using command line arguments <red_orc@my-deja.com>
    Re: Problem using command line arguments (Tad McClellan)
    Re: Require statement kills script <nayler@SPAMOFFses.curtin.edu.au>
        Setup Local Server CGI Form W/MacPerl (DEDSRD)
        Testing hello.pl in a browser? surens@attglobal.net
    Re: Testing hello.pl in a browser? (jason)
    Re: Testing hello.pl in a browser? (David Efflandt)
        That should be the default behavior of radio_group() in <ejwhite1@facstaff.wisc.edu>
        The most basic perl/ web browser question <psimdars@lisco.com>
    Re: The most basic perl/ web browser question <tina@streetmail.com>
    Re: The most basic perl/ web browser question <psimdars@lisco.com>
    Re: The most basic perl/ web browser question <tina@streetmail.com>
    Re: The most basic perl/ web browser question (David Efflandt)
    Re: using 'exists' in a program to test for keys in a h <phill@modulus.com.au>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 04 Jun 2000 00:35:35 -0400
From: prasanth <pmudundi@sunny.zp>
Subject: Re: Anyone use win32::IPROC  - help
Message-Id: <3939DC97.E1D6E62D@sunny.zp>

I went thru the Code again

trying to figure out what is wrong ...

the following is a piece of code from the author

http://www.generation.net/~aminer/Perl/scripts/pstat.txt

use Win32::IProc;

my($obj)=new Win32::IProc || die "IProc object can not be created";
$obj->EnumProcesses(\@EnumInfo);
my($nbr)=scalar(@EnumInfo);
print "\nThe total running Processes is: [$nbr]\n\n";
printf("%15.14s%19.18s%19.18s%15.14s%7.6s\n\n","[Name]","[UserTime]",
       "[KernTime]","[StartTime]","[Pid]");
$size=scalar(@EnumInfo);


for($i=0;$i<$size;$i++)


{ # $obj->Open($EnumInfo[$i]->{ProcessId},PROCESS_QUERY_INFORMATION |
  #            PROCESS_VM_READ,INHERITED,\$Hnd);

 $obj->Open($EnumInfo[$i]->{ProcessId},PROCESS_ALL_ACCESS,INHERITED,\$Hnd);

  # I put this statement for seeing the result of the above line
  $obj->LastError;
#__________________________________________

# The above code returned "Access Denied"
#Are there any  special permissions to to get this info or any other
modules
# __________________________________________


  $obj->GetStatus($Hnd,\$TimeInfo,DIGITAL);

printf("%15.14s%19.18s%19.18s%15.14s%7.6s\n",$EnumInfo[$i]->{ProcessName},


$TimeInfo->{UserTime},$TimeInfo->{KernelTime},$TimeInfo->{CreationTime},

  $EnumInfo[$i]->{ProcessId});
  $obj->CloseHandle($Hnd);
}


prasanth wrote:

> Below is the code from win32::IProc documentation from the author
>
> use win32::IProc;
> my($obj)=new Win32::IProc || die;
> $obj->EnumProcesses(\@EnumInfo,NOPATH);
> my($size)=scalar(@EnumInfo);
> for($i=0;$i<$size1;$i++)
>  {
>
>   print "\n Name  : $EnumInfo[$i]->{ProcessName}
>                      Id    : $EnumInfo[$i]->{ProcessId}
>                 Handle: $EnumInfo[$i]->{ProcessHandle} \n" ;
>
> }
>
> i was never able to get the $EnumInfo[$i]->{ProcessHandle} to have a
> value.
>
> the handle never is printed. Is there some thing i am missing.
> I intend to use a $obj->getstatus
> ($EnumInfo[$i]->{ProcessHandle},\$Info,DIGITAL)
> using the above handle for CPU Times.
>
> is there any other module for process control like iproc
>
> thanks
> prasanth mudundi
>
> p m u d u n d i @ g i s . n e t



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

Date: Sun, 04 Jun 2000 05:48:07 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Anyone use win32::IPROC  - help
Message-Id: <MPG.13a48ac15681a41698970b@news>

prasanth writes ..
>the following is a piece of code from the author

to be honest - the author's code doesn't inspire confidence .. I 
especially loved this line

>my($nbr)=scalar(@EnumInfo);

clearly not a Perl Golf player ;)

try mailing Amine directly with your problem .. especially seeing as you 
can't get the provided example to work

  aminer@generation.net

> $obj->Open($EnumInfo[$i]->{ProcessId},PROCESS_ALL_ACCESS,INHERITED,\$Hnd);
>
>  # I put this statement for seeing the result of the above line
>  $obj->LastError;
>#__________________________________________
>
># The above code returned "Access Denied"
>#Are there any  special permissions to to get this info or any other
>modules

yes .. there almost certainly are .. I would imagine that on NT your 
code would need to be run under either the Administrator or System 
security context

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sun, 04 Jun 2000 03:20:14 +0200
From: Vincent Voois <vvacme@worldonline.nl>
Subject: Re: Can't seem to find the Form post data
Message-Id: <3939AECE.22E89409@worldonline.nl>



mcnuttj@missouri.edu wrote:
> 
> Personally, I just rewrote these functions myself, mostly because for
> something this (relatively) simple, I wanted to know exactly what was
> going on, and the perl code I saw to do this seemed obfuscated to me.
> 
> Anyway, here's what I did.  Works only for POST.  GET will fail:
> 
> #### BEGIN CODE SNIPPET ####
> for ( my $x=0 ; $x < $ENV{CONTENT_LENGTH} ; $x++ ) ;
> 
>         # Get the input from STDIN, which is how POST works.
>         $char = getc;

Why reading this stuff like that?

my $buffer = '';
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
my @args = split(/&/, $buffer);

# and all your arguments are stored inside args.
# Now only needing to put the values into a hash:

foreach $pair (@args)	{
  ($name, $value) = split(/=/, $pair);

  # Unescape the argument value 
  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

  # Save the name=value pair for use below.
  $ArgHash{$name} = $value;
}

> #### END CODE SNIPPET ####
> 
> Now all your input variables, whatever they are can be accessed as 'keys
> %input'.  They're values are 'values %input' or just $input{$key}.  All
> metacharacters (that I know about) have been converted to what the user
> actually typed.
> 
> If anybody can see anything obviously ugly about this code, let me know.
> I'm using this exact stuff in production on one of my servers.  It seems
> to work for the different types of input I use, but I may have missed
> something.

Well, i also only stole the solution i used above from a commonly used example but i do see that your code
looks quite cpu-eating.

Vv.


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

Date: Sat, 03 Jun 2000 22:10:30 -0500
From: "Eric J. White" <ejwhite1@facstaff.wisc.edu>
Subject: default behavior of
Message-Id: <3939C8A6.EEBE1CD2@facstaff.wisc.edu>

Hello,

I'm wondering if there's a way to change the default behavior of the
radio_group() function in CGI.pm - in particular its desire to mark the
first button.

I can do the following to make neither of the buttons checked by
default, but is there a way to do this without having to specify this at
every radio_group()?

the following:

radio_group(-default=>'unchecked', -name=>'B1A', -linebreak=>1,
-values=>['1', '2'], -labels=>{'1'=>'Yes, Present', '2'=>'No, Not
Present'})

Thanks a lot, and my apologies if the formatting of this messages is
munged by netscape's little ol' editor.

Eric




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

Date: 4 Jun 2000 04:31:18 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: default behavior of
Message-Id: <8hcm2m$2pr9m$2@fu-berlin.de>

hi,

Eric J. White <ejwhite1@facstaff.wisc.edu> wrote:

> I'm wondering if there's a way to change the default behavior of the
> radio_group() function in CGI.pm - in particular its desire to mark the
> first button.

i don't think you can change its default behavior
(without changing CGI.pm)
but why not write a sub in your program:
sub radio_group {
 return $cgi->radio_group(-default=>'unchecked',@_);
}

tina

-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: Sun, 04 Jun 2000 03:40:56 +0200
From: Ole Christian Eidheim <eidheim@hivolda.no>
Subject: Re: Execute perl code in a variable
Message-Id: <3939B3A8.53301258@hivolda.no>

Michael Roper wrote:

> > I want to execute code that resides in a variable. The code is fetched
> > into the variable from a database. How do I execute this code and still
> > have access to the resources in my script(the script that runs the code
> > in the variable).
> >
> > So far I have used `perl -e $code_from_database`. But doing this don't
> > give the code in $code_from_database access to variables declared in my
> > script that runs the command listed above. Also using this command
> > starts another instance of perl which takes time and resources.
>
>     eval $code_from_database;
>
> > Another question:
> > In C you have #define statements. Is there a similiar data type in perl?
> Perl doesn't have a separate pre-processor. What did you want to do with a
> #define statement?

For instance, I would like the following code to return 2:
#define SUM $a+$b;                  #Of course this isn't perl code
$a=1;
$b=1;
return SUM;                                #Neither is this

I know I could achive the same thing with functions, but the #define
statement has its uses sometimes. One use could be instead of writing the
same code many times, one could use a defined statement to ease the
reading/writing of the code.

Thank you for the response,
Ole Christian Eidheim



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

Date: Sat, 3 Jun 2000 21:09:23 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Execute perl code in a variable
Message-Id: <slrn8jjeij.ut.tadmc@maxim.metronet.com>

On Sun, 4 Jun 2000 04:36:34 +1000, Michael Roper 
   <michael_roper@hotmail.com> wrote:

>> Another question:


A separate question should go in a separate post (with a different
Subject).


People that know about #define statements might not read
an article about executing code in a variable.

You could miss an answer.

People that want to know about #define statements might not read
an article about executing code in a variable.

They could miss an answer.


If you change the subject, then you should change the Subject.


>> In C you have #define statements. Is there a similiar data type in perl?

>Perl doesn't have a separate pre-processor.


Yes it does.

In fact it has the very same pre-processor that you are talking
about!


   perldoc perlrun


check out the -P switch...



-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 04 Jun 2000 03:06:51 +0200
From: Vincent Voois <vvacme@worldonline.nl>
Subject: Re: floating point algorithm bug in perl 5.6.0?
Message-Id: <3939ABAB.5C31D281@worldonline.nl>



Eric Bohlman wrote:
> 
> Vincent Voois (vvacme@worldonline.nl) wrote:
> : As i want to make notice that this is for financial purposes which do need a quite precise output and
> : processing so i guess this bug propbably did not went unnoticed.

> Others have told you why you're getting the results you are, but haven't
> pointed out that when doing financial calculations it's strongly advisable
> to do all your actual computations in whole numbers of the smallest
> currency units you deal with (e.g. cents for US currency where no prices
> involve fractions of a cent) and convert to larger units (e.g. dollars)
> only when doing output.  That prevents roundoff losses from accumulating.

Yes multiplying by 1000 but i found out what i did wrong which was simply that i should not subtract the
decimals from it at all but just us substr() to cover it.

Though this is very tricky if you loose your head with your concentration but it works.

Vv.


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

Date: 4 Jun 2000 01:57:53 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: floating point algorithm bug in perl 5.6.0?
Message-Id: <8hcd31$fcg$3@slb6.atl.mindspring.net>

Vincent Voois (vvacme@worldonline.nl) wrote:
: "Peter J. Acklam" wrote:
: > Doing maths with floating point arithmetic is not the same as doing
: > maths in theory.  The number 0.02 can't be represented exact with (the
: > most common types of) floating point arithmetic.
: 
: I noticed, but as a bridge engineer i would not place my bets on such fpu arithmics or you want to have my
: constructions end up on your head one day or fall down with it.

People who design programs for doing engineering calculations are well 
aware of the inherent problems with finite-precision floating-point 
arithmetic, and there's a whole branch of mathematics (numerical 
analysis) that deals with designing algorithms that are robust to 
roundoff error (for example, the usual textbook formula for computing the 
standard deviation of a set of data in one pass is *not* numerically 
stable, but there are one-pass formulas that are specially arranged so 
that the rounding errors will cancel each other out).

: It reminds me of the P75 FPU bug that acted similar back in 1994 and we were not happy with it either.

No, that's something entirely different.  Intel's buggy FPU introduced 
inaccuracies of a completely different nature from the ones numerical 
analysts are used to dealing with.  They were completely avoidable errors.

: Though, not that i'm going to desing a bridge-construction in Perl :)

Once again, finite-precision floating-point arithmetic is inexact in 
*every* language.  It's the nature of the beast.


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

Date: Sat, 3 Jun 2000 21:23:02 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How do I update records in a file?  (cgi & perl)
Message-Id: <slrn8jjfc6.ut.tadmc@maxim.metronet.com>

On Sun, 4 Jun 2000 00:20:03 +0800, Thaddeus 
   <nayler@SPAMOFFses.curtin.edu.au> wrote:


[ you should include an attribution when you quote someone... ]


>> -------------------------------
>> #!/usr/bin/perl -w
>> use strict;
>>
>> while (<DATA>) {
>>    print "before: $_";
>>    my @fields = split /\|/;
>>
>>    $fields[1] = 'a new value';
>>
>>    print ' after: ', join('|', @fields), "\n";
>> }
>
>
>Ok, great,  how do i actually update this file when it is open for reading?


You cannot write to a file that was opened for reading.

(So don't open it for reading then)


>eg:
>
>open (DATA, "<$filename");
>while (<DATA>)
>{
>@record=split/\|/;
>
>$record[1]++;
>join('|', @record);   **gives a warning - pointless use of join **


You should heed the warning.

You joined them up with vertbars, and then discarded the 
resulting string.


>*the file is open and i want to update the record*


You cannot write the file because you opened it for reading.


>I also need to sort the record by the value of the second field (highest ->
>lowest) as you can see I was trying to do.


   perldoc -f sort

   perldoc -q sort


We are not here to read the manual for you.

Check the stuff already on your hard disk *before* you ask here.

If you don't understand something in the docs, ask about it here,
but don't expect us to repeat things that are already done.



>Feel free to point out syntax errors, but i didnt copy/paste so its not
>exact.


If I had known that it was not your real code I would not have
read your article.

I'm gonna put you in my killfile for a few months for that.

copy/paste is not hard to do.


>Sorry if its simple, but its not clear to me just now how to do it.


It is not clear how to do it to LOTS of people.

There have been 10s of thousands of people before you who
have learned Perl.

It is rather presumptuous of you to think that you are the
first person to want to update a file.

If you thought others might have wanted to do that before, then
you would have checked the Perl FAQ before posting to the Perl
newsgroup, as netiquette requires.


   Perl FAQ, part 5:

      "How do I change one line in a file/
       delete a line in a file/
       insert a line in the middle of a file/
       append to the beginning of a file?"



Check out    news.announce.newusers     your "net manners" are 
lacking in several respects...



-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 4 Jun 2000 13:24:03 +0800
From: "Thaddeus" <nayler@SPAMOFFses.curtin.edu.au>
Subject: Re: How do I update records in a file?  (cgi & perl)
Message-Id: <8hcp69$a69$1@ftp.curtin.edu.au>


"Tad McClellan" said:

all sorts of nasty stuff....  see the preceeding post (its pretty obvious
what I am replying to if you do this)

bit shirty aint we Tad??

I think you should check your net manners....  some people just happen to
have trouble finding things at 3am and resort to a possible quick fix.  If
you do take personal offense at this, my inclusion in your killfile is quite
welcome.  However, thank you at least for taking the time to read my
message, even though it must have wasted your obviously valuable time.

There are actually several reason why I couldn't research what I required:

1. I am remotely logged onto the development server
2. Which has no perldocs installed (seemingly)
3. My connection is very slow - meaing i cant access http sites.
4. I have a telnet window as a development environment (cut/paste difficult
to impossible).
5. I have two days to complete this project which I was given on the side.

Excuses?  Absolutely.  Its up to you whether or not to think they were
worthy of pissing off the great Tad McClellan.

Otherwise, I sincerely apologise.

Thad




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

Date: Sat, 3 Jun 2000 21:38:37 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How do you pass a hash reference in Perl 4?
Message-Id: <slrn8jjg9d.ut.tadmc@maxim.metronet.com>

On Sat, 3 Jun 2000 19:29:05 -0500, Duke Banerjee 
   <sfighter@cs.utexas.edu> wrote:

> Subject: Re: How do you pass a hash reference in Perl 4?


Nobody cares about how to do _anything_ in Perl 4 ( what you
want to do is impossible to do in Perl 4).

Perl 4 went away several years ago.

When Perl 4 was used, PCs all had Windows 3.1 on them...


There are CERT security warnings about perl4 too.


There *is no* perl 4!

It is merely a historical artifact.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 04 Jun 2000 16:40:09 +1000
From: Daniel Jones <danjones@crosswinds.net>
Subject: newsgroup help
Message-Id: <3939F9C8.3BDAB8CC@crosswinds.net>

Does any one know how to create a perl script that gets any new messages
posted by a news group and converts them into a html web page for
archiving?

Any scripts similar created by some one before?

Any code snippets?

Any thing at all?

thanks
Daniel
nikoomba@mbox.com.au



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

Date: 4 Jun 2000 06:43:16 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: newsgroup help
Message-Id: <8hctq3$2pr9m$4@fu-berlin.de>

hi,

Daniel Jones <danjones@crosswinds.net> wrote:
> Does any one know how to create a perl script that gets any new messages
> posted by a news group and converts them into a html web page for
> archiving?

> Any thing at all?

$ perldoc -q news

[...]

How do I fetch a news article or the active newsgroups?

Use the Net::NNTP or News::NNTPClient modules, both available from CPAN.
This can make tasks like fetching the newsgroup list as simple as:

    perl -MNews::NNTPClient
      -e 'print News::NNTPClient->new->list("newsgroups")'




-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: Sun, 04 Jun 2000 17:00:30 +1000
From: Daniel Jones <danjones@crosswinds.net>
Subject: Re: newsgroup help
Message-Id: <3939FE8E.5DF2CC4E@crosswinds.net>

hi daniel here again
i ment how to fetch a newsgroup article and put it on a webpage using a cgi
script

Daniel Jones wrote:

> Does any one know how to create a perl script that gets any new messages
> posted by a news group and converts them into a html web page for
> archiving?
>
> Any scripts similar created by some one before?
>
> Any code snippets?
>
> Any thing at all?
>
> thanks
> Daniel
> nikoomba@mbox.com.au



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

Date: Sat, 03 Jun 2000 23:27:27 -0400
From: David Grogan <dgrogan@virginia.edu>
Subject: perl editor for linux
Message-Id: <3939CC9F.98B011F1@virginia.edu>

Does anyone know of a perl editor for linux or freebsd?  I'm looking for
one that just has some color coding and maybe autoindentation or
something.  Let me know....

Thanks,
David



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

Date: 4 Jun 2000 04:08:18 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: perl editor for linux
Message-Id: <8hckni$2pr9m$1@fu-berlin.de>

hi,

David Grogan <dgrogan@virginia.edu> wrote:
> Does anyone know of a perl editor for linux or freebsd?  I'm looking for
> one that just has some color coding and maybe autoindentation or
> something.  Let me know....

if you're working on linux, you have lots of
possibilities.
first, i'd recommend vi. the newer versions (Vim) have
syntax highlighting.
or try out emacs / Xemacs. syntax higlighting and many
other features for programming. you can even read mail
and news with it :-)

tina

-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: Sun, 04 Jun 2000 00:30:25 -0400
From: David Grogan <dgrogan@virginia.edu>
Subject: Re: perl editor for linux
Message-Id: <3939DB61.9C55772C@virginia.edu>

I didn't know emacs did syntax highlighting.  Exactly what I was looking for.

Thank you very much,
David.


Tina Mueller wrote:

> hi,
>
> David Grogan <dgrogan@virginia.edu> wrote:
> > Does anyone know of a perl editor for linux or freebsd?  I'm looking for
> > one that just has some color coding and maybe autoindentation or
> > something.  Let me know....
>
> if you're working on linux, you have lots of
> possibilities.
> first, i'd recommend vi. the newer versions (Vim) have
> syntax highlighting.
> or try out emacs / Xemacs. syntax higlighting and many
> other features for programming. you can even read mail
> and news with it :-)
>
> tina
>
> --
> http://www.tinita.de \  enter__| |__the___ _ _ ___
> tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
> search & add comments  \    \ _,_\ __/\ __/_| /__/ perception



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

Date: Sat, 3 Jun 2000 21:50:35 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl to write to a text file
Message-Id: <slrn8jjgvr.ut.tadmc@maxim.metronet.com>

On Sat, 03 Jun 2000 18:32:04 GMT, Bob Walton <bwalton@rochester.rr.com> wrote:
>Rodney Engdahl wrote:
>> 
>> In article <8hb325$d26$1@newssvr03-int.news.prodigy.com>,
>>   "Navneet Behal" <navneetbehal@bigfoot.com> wrote:
>...
>> open (FH, "/full/path/to/file/text.txt") || die "Cannot open text file\n";

>You need a > in front of the filename to open it for writing.


 ... and you need to include $! in the diagnostic message.

 ... and you need to leave the newline out of the diagnostic message.

 ... and you need to mention the name of the file in the diagnostic message.


:-)


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 04 Jun 2000 02:53:04 GMT
From: Joydip Chakladar <joydip_chaklader@my-deja.com>
Subject: please help in checking the referer site and giving page view authorisation
Message-Id: <8hcgac$ee0$1@nnrp1.deja.com>



I am trying to make a referer check to a certain page where i give a
service of search engine submission programme which is free.Now I want
person to come from my server rather than from an bookmark or from the
copy of the html file which somebody has made into thier server.I am
trying this checksitereferer subroutine and it is showing the page
blank or showing documents contains no data . Things are working superb
if I get ride of this subroutine.



sub Checksitereferer()

{

my($sClientID)=@_;

$HitOStatdotcom="http://www.hitostat.com";

if (lc(substr($ENV{'HTTP_REFERER'}, 0, length($HitOStatdotcom))) eq
$HitOStatdotcom)
{
		## search engine submission code
}
else
{

             print "location: $HitOStatdotcom \n\n";
             exit;

}

}


--
Joydip Chakladar
http://www.allindialive.com
From India to world
A meeting place of surfers and webmasters


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


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

Date: Sun, 04 Jun 2000 05:37:46 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: please help in checking the referer site and giving page view authorisation
Message-Id: <MPG.13a48852d8f58d7d98970a@news>

Joydip Chakladar writes ..
>I am trying to make a referer check to a certain page where i give a
>service of search engine submission programme which is free.Now I want
>person to come from my server rather than from an bookmark or from the
>copy of the html file which somebody has made into thier server.I am
>trying this checksitereferer subroutine and it is showing the page
>blank or showing documents contains no data . Things are working superb
>if I get ride of this subroutine.

while this is an unreliable method of securing a service (the 
HTTP_REFERER header is easily faked) there appears to be nothing wrong 
with your code

have you tried just putting something really simple in the true clause 
of your condition ? .. maybe it's your "search engine submission code" 
that is faulty

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 4 Jun 2000 06:05:57 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: please help in checking the referer site and giving page view authorisation
Message-Id: <slrn8jjse5.42b.efflandt@efflandt.xnet.com>

On Sun, 04 Jun 2000, Joydip Chakladar <joydip_chaklader@my-deja.com> wrote:
>
>I am trying to make a referer check to a certain page where i give a
>service of search engine submission programme which is free.Now I want
>person to come from my server rather than from an bookmark or from the
>copy of the html file which somebody has made into thier server.I am
>trying this checksitereferer subroutine and it is showing the page
>blank or showing documents contains no data . Things are working superb
>if I get ride of this subroutine.

Seems like you could use a simple pattern search for that.  However,
requiring an optional variable that is NOT required by any standards is
generally a bad idea.  So something like this would be better:

    if (!$ENV{HTTP_REFERER}
      || $ENV{HTTP_REFERER} =~ m|^\Q$HitOStatdotcom\E|) {

        ## search engine submission code

    } else {
        print "Location: $HitOStatdotcom\n\n";  
        exit;
    }


One other note is that your redirect is invalid because it uses an
incomplete URL (trailing slash required if not referencing a file) and the
extra space in your location header makes it "http://www.hitostat.com "
which with the trailing space would really be invalid.  The newlines
should immediately follow the variable like I have it above.

>sub Checksitereferer()
>
>{
>
>my($sClientID)=@_;
>
>$HitOStatdotcom="http://www.hitostat.com";
>
>if (lc(substr($ENV{'HTTP_REFERER'}, 0, length($HitOStatdotcom))) eq
>$HitOStatdotcom)
>{
>		## search engine submission code
>}
>else
>{
>
>             print "location: $HitOStatdotcom \n\n";
>             exit;
>
>}
>
>}
>
>
>--
>Joydip Chakladar
>http://www.allindialive.com
>From India to world
>A meeting place of surfers and webmasters


-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Sun, 04 Jun 2000 01:53:02 GMT
From: "William Cardwell" <wellhaven@worldnet.att.net>
Subject: Re: Problem using command line arguments
Message-Id: <2Ei_4.2256$2b4.145964@bgtnsc06-news.ops.worldnet.att.net>


Vincent Voois <vvacme@worldonline.nl> wrote in message
news:3939AAF8.1B1835D2@worldonline.nl...
>
>
> William Cardwell wrote:
> >
> > I'm trying to read from the first file and write to the second file on
the
> > command line, and supply a default file name when a command line file is
> > absent. I can't get it to work right for the output file. My latest test
is
> > below. I'm thinking I shouldn't have to open the output file as I did
below,
> > but how do I specify the file I am writing to? Can anyone help?
> >
> > # -----This doesn't work
> > right-----------------------------------------------------
> > $ARGV[0] = 'infile.txt' unless $ARGV[0];
> > $ARGV[1] = '>outfile.txt' unless $ARGV[1];
> > open OUTFILE, "$ARGV[1]" or die "Can't open file $ARGV[1] for output:
$!\n";
> > while(<>) {
> >   $i++;
> >   print OUTFILE "$i $_";
> >   if ($i >= 2000) {last;}
> > }
> > close OUTFILE;
> >
# --------------------------------------------------------------------------
> > --------
>
> Did you tried below instead of your upper one?:
> $ARGV[1] = 'outfile.txt' unless $ARGV[1];
> open OUTFILE, ">$ARGV[1]" or die "Can't open file $ARGV[1] for output:
$!\n";
>
> Vv.

Yep, it reads the 1st file, then the 2nd file it created, then the new 2nd
file etc in endless loop, hence the quit at 2000 lines statement. FYI, I'm
using Win32...possibly this is platform sensitive.
Will




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

Date: 4 Jun 2000 02:22:30 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Problem using command line arguments
Message-Id: <8hceh6$fcg$4@slb6.atl.mindspring.net>

William Cardwell (wellhaven@worldnet.att.net) wrote:
: $ARGV[0] = 'infile.txt' unless $ARGV[0];
: $ARGV[1] = '>outfile.txt' unless $ARGV[1];
: open OUTFILE, "$ARGV[1]" or die "Can't open file $ARGV[1] for output: $!\n";

At this point, you've still got your output file name sitting in 
$ARGV[1], which means that it's on the list of files that the <> operator 
will try to open in sequence.  You could use splice() to remove it, but 
the way I'd do it would be:

my $infile=shift || 'infile.txt';
my $outfile=shift || 'outfile.txt';
unshift @ARGV,$infile;
open OUTFILE, ">$outfile" or die "Can't open file $outfile for output: $!\n";

This assumes that you want any filenames listed after the second one to 
be treated as additional input files.

: while(<>) {
:   $i++;
:   print OUTFILE "$i $_";
:   if ($i >= 2000) {last;}
: }
: close OUTFILE;

perl keeps track of line numbers automatically; see the '$.' variable 
documented in perlvar.



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

Date: Sun, 04 Jun 2000 03:09:22 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Problem using command line arguments
Message-Id: <8hch8s$f42$1@nnrp1.deja.com>

In article <_Ah_4.2180$2b4.140735@bgtnsc06-news.ops.worldnet.att.net>,
  "William Cardwell" <wellhaven@worldnet.att.net> wrote:
> I'm trying to read from the first file and write to the second file on the
> command line, and supply a default file name when a command line file is
> absent. I can't get it to work right for the output file. My latest test is
> below. I'm thinking I shouldn't have to open the output file as I did below,
> but how do I specify the file I am writing to? Can anyone help?
>
> # -----This doesn't work
> right-----------------------------------------------------
> $ARGV[0] = 'infile.txt' unless $ARGV[0];
> $ARGV[1] = '>outfile.txt' unless $ARGV[1];
> open OUTFILE, "$ARGV[1]" or die "Can't open file $ARGV[1] for output: $!\n";
> while(<>) {

where did you open your input file, what is its filehandle (INFILE ?)?
you may want:

while (<INFILE>) {

>   $i++;
>   print OUTFILE "$i $_";
>   if ($i >= 2000) {last;}
> }
> close OUTFILE;
> # --------------------------------------------------------------------------
> --------
>
> Thanks so much.
>
> Will Cardwell
>
>


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


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

Date: Sat, 3 Jun 2000 22:00:26 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Problem using command line arguments
Message-Id: <slrn8jjhia.ut.tadmc@maxim.metronet.com>

On Sun, 04 Jun 2000 00:41:30 GMT, William Cardwell 
   <wellhaven@worldnet.att.net> wrote:

>$ARGV[1] = '>outfile.txt' unless $ARGV[1];
>open OUTFILE, "$ARGV[1]" or die "Can't open file $ARGV[1] for output: $!\n";
               ^        ^
               ^        ^ those quotes have no effect. so why are they there?

>while(<>) {


<> reads from files named in @ARGV.

It will try to read from a file named '>outfile.txt'.

But you probably don't have a file with that name, so it
doesn't really matter (but you ought to *remove* it from
@ARGV before you let <> execute anyway).


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sun, 4 Jun 2000 13:31:35 +0800
From: "Thaddeus" <nayler@SPAMOFFses.curtin.edu.au>
Subject: Re: Require statement kills script
Message-Id: <8hcpkd$ach$1@ftp.curtin.edu.au>


"Rodney Engdahl" <red_orc@my-deja.com> wrote in message
news:8hbnnk$u6r$1@nnrp1.deja.com...
> chances are that your required file does not have a
> 1;

it sure does.

it also has correct file permissions, and its accessible from the other
scripts, and the procedures are exactly the same as when i place them
directly in the scripts.

and more info?




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

Date: 04 Jun 2000 03:36:49 GMT
From: dedsrd@aol.com (DEDSRD)
Subject: Setup Local Server CGI Form W/MacPerl
Message-Id: <20000603233649.21257.00001446@ng-ft1.aol.com>

I think I have all the software I need on my Mac
OS 8.6
Netprezenz
MacPerl
IF {I could get some help with
	TCP/IP setting to run my server locally as a test
I have a web site/host but don't want to test there
And I think I might be able to get going writing the actual script My first
SCRIPT that is
Could someone give me a HTML file that is a form that allows for two entry
fields(0 thru 9) and the Perl/CGi script that would add those two entries
together
ELSE a web soucre that may have such a thing
}
Darrell
	


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

Date: Sat, 03 Jun 2000 23:21:11 +0200
From: surens@attglobal.net
Subject: Testing hello.pl in a browser?
Message-Id: <393976C7.7C4788F1@attglobal.net>

Hi,

I am trying to test a perl script, hello.pl in netscape browser, but it
is not showing "Hello, World!" in the browser, the code is executed
(showing a warning message for execution, click ok). I also change it
hello.cgi, did't help. The sample code is below. Both files are in the
same directory. 
How can I make it work?
Thanks.

---hello.pl ---permission:0755-----------
#!/usr/bin/perl -w
use CGI qw(:standard);
use strict;

print header;
#print "Content-type: text/html\n\n"; # didn't help
print "<B>Hello, World!</B>";

---test.html-----------------------------
<FORM action="hello.pl" method="get">
<INPUT type="submit" value="Send">
</FORM>
-----------------------------------------


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

Date: Sun, 04 Jun 2000 05:15:44 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Testing hello.pl in a browser?
Message-Id: <MPG.13a48327539f540f989709@news>

surens@attglobal.net writes ..
>I am trying to test a perl script, hello.pl in netscape browser, but it
>is not showing "Hello, World!" in the browser, the code is executed
>(showing a warning message for execution, click ok). I also change it
>hello.cgi, did't help. The sample code is below. Both files are in the
>same directory. 
>How can I make it work?

run it through a web server ? .. you can't expect this to run unless 
you're running a web server locally on your machine

  perldoc -q CGI

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 4 Jun 2000 06:13:27 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Testing hello.pl in a browser?
Message-Id: <slrn8jjss8.42b.efflandt@efflandt.xnet.com>

On Sat, 03 Jun 2000, surens@attglobal.net <surens@attglobal.net> wrote:
>
>I am trying to test a perl script, hello.pl in netscape browser, but it
>is not showing "Hello, World!" in the browser, the code is executed
>(showing a warning message for execution, click ok). I also change it
>hello.cgi, did't help. The sample code is below. Both files are in the
>same directory. 
>How can I make it work?

CGI requires a web server.  If your web host uses apache you might want to
download and install the Win32 version:  http://www.apache.org/

Otherwise if you use a IIS server, a simplified PWS version of that is on
the Win98 CD or the NT Option Pack 4 version can be installed in Win95.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Sat, 03 Jun 2000 22:12:54 -0500
From: "Eric J. White" <ejwhite1@facstaff.wisc.edu>
Subject: That should be the default behavior of radio_group() in CGI.pm
Message-Id: <3939C936.92FE50D@facstaff.wisc.edu>

I was so worried about the editor I munged the subject line...




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

Date: Sat, 03 Jun 2000 21:35:45 -0500
From: paul simdars <psimdars@lisco.com>
Subject: The most basic perl/ web browser question
Message-Id: <3939C081.181236F@lisco.com>

I think I am missing something simple and obvious.  I have looked at
tutorials and just bought a good book but . .. . They all start with a
simple perl script which you run from the prompt.
perl filename.pl

Then you create a .cgi file for a browser.  Then I go to the browser and
open the file and it just prints out the contents of the .cgi file.  ( I
am using netscape on Linux).

If you know what I am doing wrong, please enlighten me.
Thank you



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: 4 Jun 2000 02:39:40 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: The most basic perl/ web browser question
Message-Id: <8hcfhc$2m6fq$4@fu-berlin.de>

hi,

paul simdars <psimdars@lisco.com> wrote:
> I think I am missing something simple and obvious.  I have looked at
> tutorials and just bought a good book but . .. . They all start with a
> simple perl script which you run from the prompt.
> perl filename.pl

> Then you create a .cgi file for a browser.  Then I go to the browser and
> open the file and it just prints out the contents of the .cgi file.  ( I
> am using netscape on Linux).

which webserver are you using?


-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: Sat, 03 Jun 2000 21:47:16 -0500
From: paul simdars <psimdars@lisco.com>
Subject: Re: The most basic perl/ web browser question
Message-Id: <3939C334.A7B5E64E@lisco.com>

Apache.  That is another question.  I was just opening it up in the browser on
my machine.  I have set up Apache and there is the default page
(http://localhost).  The book I have says nothing about how to actually run
the .cgi program.

Tina Mueller wrote:

> hi,
>
> paul simdars <psimdars@lisco.com> wrote:
> > I think I am missing something simple and obvious.  I have looked at
> > tutorials and just bought a good book but . .. . They all start with a
> > simple perl script which you run from the prompt.
> > perl filename.pl
>
> > Then you create a .cgi file for a browser.  Then I go to the browser and
> > open the file and it just prints out the contents of the .cgi file.  ( I
> > am using netscape on Linux).
>
> which webserver are you using?
>
> --
> http://www.tinita.de \  enter__| |__the___ _ _ ___
> tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
> search & add comments  \    \ _,_\ __/\ __/_| /__/ perception



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: 4 Jun 2000 04:39:06 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: The most basic perl/ web browser question
Message-Id: <8hcmha$2pr9m$3@fu-berlin.de>

hi,

paul simdars <psimdars@lisco.com> wrote:
> Apache.  That is another question.  I was just opening it up in the browser on
> my machine.  I have set up Apache and there is the default page
> (http://localhost).  The book I have says nothing about how to actually run
> the .cgi program.

then the apache documentation should help you.
but this is OT in this newsgroup.
at least, did you made the file executable, is it in the
cgi-bin directory, and did you to call it
with http://localhost/whatever/cgi-bin/program.cgi ?

tina

> Tina Mueller wrote:

>>[removed fullquote] 


-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception


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

Date: 4 Jun 2000 06:28:43 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: The most basic perl/ web browser question
Message-Id: <slrn8jjtos.42b.efflandt@efflandt.xnet.com>

On Sat, 03 Jun 2000 21:47:16 -0500, paul simdars <psimdars@lisco.com> wrote:
>Apache.  That is another question.  I was just opening it up in the browser on
>my machine.  I have set up Apache and there is the default page
>(http://localhost).  The book I have says nothing about how to actually run
>the .cgi program.

If you don't have the apache docs on your Linux box somewhere (they should
be), see http://www.apache.org/

See if you have a directory like /usr/home/httpd/cgi-bin, try putting the
script there and access it as http://localhost/cgi-bin/scriptname

For further questions see:

comp.infosystems.www.authoring.cgi	for CGI
comp.infosystems.www.servers.unix	for apache

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Sun, 04 Jun 2000 11:09:53 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: using 'exists' in a program to test for keys in a hash
Message-Id: <3939AC61.72A@modulus.com.au>

RGW303 wrote:
> 
> Ok, I copied and pasted the Perl program the uses DB and compiled and I get
> the same error. I get the error that DB_File module could be found in @INC
> (c:\perl\lib) and low and behold it's not there. I've repaired and
> reinstalled ActivePerl Build 613 several times. I've even uninstalled it and
> reinstalled it but it won't show up. However, I do have the file
> SDBM_File.pm in C:\perl\lib and when I use that program example that you
> posted here (copied and pasted exactly as shown). I still the error:
> "SDBM_File doesn't define an EXISTS method at myprog.pl line xx". (I 

[snip]

Read perlfaq4 - What's the difference between "delete" and
"undef" with hashes? - paying particular attention to the truth tables.

'exists' is unlikely to be what you want.

Instead of: 
while(exists $hash{"$key_$num"}) { <code...> }
you probably want;
while($hash{$key_$num}) { <code...> }
or;
while(defined $hash{$key_$num}) { <code...> }

The choice will depend on what you are storing in your hash.
-- 
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/


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

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


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