[7853] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1478 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 15 18:07:26 1997

Date: Mon, 15 Dec 97 15:00:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 15 Dec 1997     Volume: 8 Number: 1478

Today's topics:
     Re: 'inportb' and 'outportb' missing from Perl? scott@softbase.com
     Re: 001 + 1 = 002; 002 - 1 = 1 ARGH (Martien Verbruggen)
     Re: @a = m// bug in 5.004_04? (Martien Verbruggen)
     Advice on References to Class Functions ? <mbennett@ideaeng.com>
     Re: DATABASE HELP!! <rootbeer@teleport.com>
     Re: delete files in perl (Tad McClellan)
     Re: Dynamically Sending an Adobe Acrobat PDF File to th (Martien Verbruggen)
     Re: Embedding Perl In A C++ Program <rootbeer@teleport.com>
     find and replace (Andreas Kraska)
     Re: German characters (Martien Verbruggen)
     Re: Hex, Oct, and Bin convertor? (Jason Gloudon)
     Re: Hex, Oct, and Bin convertor? <reibert@mystech.com>
     Re: HTTP/1.0 500 Server Error (/cgi-bin/multiple_forms. (Poul Kornmod)
     Re: HTTP/1.0 500 Server Error (/cgi-bin/multiple_forms. <rootbeer@teleport.com>
     Looking for Perl Spreadsheet <tory1@IDT.NET>
     Re: NEED:  Fast, Fast string trim() <reibert@mystech.com>
     Pass variables to Unix command? (Paul Heindselman)
     Re: Perl 5.004_04 install error - can't find compiler? (Honza Pazdziora)
     Re: Perl script works when initiated from the unix shel <rootbeer@teleport.com>
     Re: Perl script works when initiated from the unix shel (Martien Verbruggen)
     Re: Perl url redirect (Martien Verbruggen)
     Re: PIng a Port (Martien Verbruggen)
     post your dynamic IP address to a web page-cant be done <dana@medical-info.com>
     Re: post your dynamic IP address to a web page-cant be  (Brian Wheeler)
     Re: Problem with getc? (Martien Verbruggen)
     Re: Problem with ODBC.pm (on WinNT) (Raul Nohea Goodness)
     Q on fcntl (Chan Pui Nang)
     Re: Which language pays most 17457 -- C++ vs. Java? (Seymour J.)
     Re: Which language pays most 17457 -- C++ vs. Java? (Giacomo Delre)
     Re: Workaround for FLOCK? (Martien Verbruggen)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 15 Dec 1997 20:41:16 GMT
From: scott@softbase.com
Subject: Re: 'inportb' and 'outportb' missing from Perl?
Message-Id: <6744lc$14v$1@mainsrv.main.nc.us>

greg aiken wrote:

> 'inportb' and 'outportb' missing from Perl?
> How does one do this in Perl?   I really like Perl, and I use it for most
> all tasks that I need to do, however, I now find that I need to write
> programs to access installed hardware on my PC (specifically an Intel
> 8255A programmable peripheral interface chip), and I can't figure out how
> to specifically read and/or write to a SPECIFIC address location in
> memory.  Certainly, a Perl guru out there must know how this can be done.

Perl would be a very bad choice for a hardware programming language.
I'm not sure why you'd want to use it as such. It isn't designed for
operating-system level stuff at all. You certainly couldn't
write device drivers in it.

> PS - ALL languages for the PC allow this functionality; C (inport,
> inportb, outport, outportb), Pascal (Port, Portw), even Basic can do this
> (although I can't immediately find the mneumonics for the command).  I
> can't believe Perl can't handle this task.

Funny, I've *never* used a language that had this on the PC. Delphi
doesn't.  None of the C++ versions I use have had it. Visual Basic
doesn't have it.

Some ancient DOS compilers had macros that allowed direct hardware
access, but they'd be of no use on modern PC operating systems.

Scott


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

Date: 15 Dec 1997 21:03:43 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: 001 + 1 = 002; 002 - 1 = 1 ARGH
Message-Id: <6745vf$mbh$2@comdyn.comdyn.com.au>

In article <349553D4.3806@groton.pfizer.com>,
	"Jack H. Ostroff" <jack_h_ostroff@groton.pfizer.com> writes:

>> >Ok. So what comes after "a999"?
>> 
>> That's an easy one. It is "b000".
> 
> Why not "a99a"?

Because it was defined in the following way:

perldoc perlop
/Auto-increment

The auto-increment operator has a little extra built-in magic to it.
If you increment a variable that is numeric, or that has ever been
used in a numeric context, you get a normal increment. If, however,
the variable has been used in only string contexts since it was set,
and has a value that is not null and matches the pattern
/^[a-zA-Z]*[0-9]*$/, the increment is done as a string, preserving
each character within its range, with carry:

It could have been defined in another way, possibly, but the choice
was made to leave characters as characters, and digits as digits. 

How this is all going to work for multibyte characters, and different
character sets is a different issue. For now it only works on the
character set given above. How meaningful it is, may be another
question.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.       | you come to the end; then stop.
NSW, Australia                      | 


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

Date: 15 Dec 1997 21:21:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: @a = m// bug in 5.004_04?
Message-Id: <674700$mbh$5@comdyn.comdyn.com.au>

In article <s3pyb1n5s5z.fsf@sandpiper.lcs.mit.edu>,
	dmjones@theory.lcs.mit.edu (David M. Jones) writes:

> And, sure enough, I just checked that after
> 
>     @a = "a" =~ /a/
> 
> we have
> 
>     @a = (1)

Well, this is documented behaviour, so I don't think you can take that
as proof of perl evaluating it in a scalar context. You can always
force it in a list context to see what happens, but I suspect it will
be the same.

I think you might want to report a bug, and see what the answer to
that is :)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd.       | excuse - Lazarus Long
NSW, Australia                      | 


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

Date: Mon, 15 Dec 1997 14:25:09 -0800
From: "Mark L. Bennett" <mbennett@ideaeng.com>
Subject: Advice on References to Class Functions ?
Message-Id: <3495AE45.2697@ideaeng.com>

I'm trying to model a logical tree of information.

I have a base class Node.
I also have a derived class, NamedNode; named nodes
have a formal "name".

There are many cases in which I want to traverse the entire
tree structure and do something to each node.
Instead of hard coding all the logic in each routine, I decide
to write a "Traverse" routine (part of class Node).

I will call Traverse, and pass it a reference to a function.
I will call the Traverse fuction with a Node (or NamedNode)
reference, and a reference to a small fucntion to process
each node.

For example, to print the entire tree I would have a small
function that prints out just one node.  For this example,
PrintShort prints a compact description of a node.
Then I'll call Traverse with a reference to the PrintShort
function.

The issue is the "function" to process each node is dependant
on the class, and how to pass it correctly.

For example, I have a function Node::PrintShort which will
print out some info about a generic node.
I have overriden this in the NamedNode class so that it will
also print the name of the node.

When Traverse is processing a plain node it should call
Node::PrintShort.  If it happens to be processing a NamedNode
I want it to call NamedNode::PrintShort.

If I call traverse with something like \&NamedNode I will
always get Node::PrintShort, even for named nodes.

I'm still messing with this.  Maybe I've got some other errors.
What I _think_ I want to do is something like
\&$Self->PrintShort or some variation, but right now it's
not working.

I'd appreciate any comments, or references to better doc.
I have the O'Reilly "Advanced Perl Programming" book but it
doesn't really address this specific issue (that I've found).

Thanks,
Mark


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

Date: Mon, 15 Dec 1997 13:36:51 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Justin Markle <mystery@nb.net>
Subject: Re: DATABASE HELP!!
Message-Id: <Pine.GSO.3.96.971215133356.12424T-100000@user1.teleport.com>

On Mon, 15 Dec 1997, Justin Markle wrote:

> My main question here is how can I get an area code search to only
> search for matching places in a particular area code?

You could use a database indexed by area code, and retrieve only the
entries with the code you wish. Or, if you retrieve an entry with the
wrong code, simply skip it and go on to the next.

> Is there an easier way to do this database search without putting
> the area code in its own field?

I'd think it would be easier without putting the area code in its own
field. :-)  But it would probably be slower.

> What can I change here to only search the first 3 numbers for the areacode?

I think you'd want substr.

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Mon, 15 Dec 1997 14:54:21 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: delete files in perl
Message-Id: <td5476.j53.ln@localhost>

Kelly Horstmann (kelly_horst@hotmail.com) wrote:
: I want to write a perl program to delete a specific kind of file, (for
: example *.o
:  file)in the current directory (say, /usr/bin/perl) and also delete all
: the *.o
: files in all the subdirectories (eg. /usr/bin/perl/dir1,
: /usr/bin/perl/dir2, /usr/perl/dir3 
: etc). I have been working on that for couple hours, and I just don't
: know how to call perl
: to search all the *.o files in all the subdirectories. Just let me know,
: if you can
: code up this problem.



You may want to use the File::Find module for that.


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


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

Date: 15 Dec 1997 21:52:44 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
To: "Daniel F. Van Der Werken, Jr." <danvdw@microsoft.com>
Subject: Re: Dynamically Sending an Adobe Acrobat PDF File to the Browser using PERL in a CGI Script
Message-Id: <6748rc$mip$1@comdyn.comdyn.com.au>

[Posted and Mailed]

Since this has not much to do with perl anymore, maybe we should keep
any followups off the newsgroup, and in private email.

In article <672l4c$1u8@news.microsoft.com>,
	"Daniel F. Van Der Werken, Jr." <danvdw@microsoft.com> writes:

Try it this way:

(leaving the use strict, and using pathnames delimited with / instead
of \\ is not a bad idea, especially, since the PATH_INFO variable that
you will get back from the server has a leading /, not a leading \\.
So, there is a reason for using /:)

#!/usr/local/bin/perl5 -w
 
# script: getpdf.pl

use strict;
my $buffer = "";

my $PDF_DIR = "c:/ntreskit/perl";
my $filename = $ENV{PATH_INFO} or cgi_error("No file name supplied");
$filename = $PDF_DIR . $filename;

open(PDF, $filename) or cgi_error("Error opening $filename: $!");
binmode(PDF);

my $filesize = (stat(PDF))[7] or cgi_error("Cannot stat $filename: $!");

print "Content-Type: application/pdf\n";
print "Content-Length: $filesize\n\n";

while(read(PDF,$buffer,4096))
{
	print $buffer;
}

close(PDF);

sub cgi_error
{
	my $error = shift;

	print "Content-type: text/plain\n\n";
	print "Some error occurred:\n\n";

	print $error . "\n" if (defined($error));
	exit;
}


And call it like:

http://shadowrunner/perl/sendpdf.pl/samples.pdf


I wrote that script in such a way that you can use the same script for
different files, instead of writing a script specifically for one
file.

Also, try running it from the command line. I am not entirely sure how
ENV variables are handled on Win32, but this might work:

DOS> set PATH_INFO=/samples.pdf
DOS> perl getpdf.pl

Just to test if this works. Since the script write to STDOUT, this
will dump a lot of garbage in your dos box.

> In all cases, your $filename scheme gave me a "/path-to-file/sendpdf.pl".
> The file I needed is "/path-to-file/samples.pdf".  Rather than try to figure

Well, that might be an implementation quirk of your server, but what I
wrote, up there, should work on any server that implements CGI the
right way. getpdf.pl should be the script (in the ENV variable
SCRIPT_NAME) and anything after and including a / following the
scriptname should end up in the ENV variable PATH_INFO

> Regardless, the browser returns "An error has occurred while tryign to use
> this document" in all cases.  I do have Adobe Acrobat Reader loading, just
> nothing in the browser.  Likewise, if I will often get a dialog box asking
> for the password to the file.  <Huh?>

Hmmm, this sounds more like a setup problem than a perl problem to
me.. Maybe you should try some other small perl scripts, just to test
if the setup works at all? And run the script from the command line..

> Of course, I'm running this on a Windows NT 4.0 server with IIS 3.0
> installed and the Perl from the NT Resource Kit.

Well, I don't know too much about IIS, except that it's Microsoft's :)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | That's not a lie, it's a terminological
Commercial Dynamics Pty. Ltd.       | inexactitude.
NSW, Australia                      | 


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

Date: Mon, 15 Dec 1997 13:10:01 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: teetshd@ucbeh.san.uc.edu
Subject: Re: Embedding Perl In A C++ Program
Message-Id: <Pine.GSO.3.96.971215130438.12424O-100000@user1.teleport.com>

On Mon, 15 Dec 1997, Greg Teets wrote:

> The entire information on the referenced page:

[ Nine lines of text snipped. ]

Hmmm... perlembed.pod is 33225 bytes long on my machine. Maybe you have an
out-of-date version of it? You should be able to get a reasonably-recent
version from this URL. Cheers!

    http://www.perl.com/CPAN/doc/manual/html/pod/perlembed.html

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!




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

Date: 15 Dec 97 21:28:40 GMT
From: jimknopf@Lummerland.halberstadt.netsurf.de (Andreas Kraska)
Subject: find and replace
Message-Id: <3495a108.0@news.regiocom.net>


Hello !

I need a script to find a paricular word or phrase in files of a given directory, then replace all at once by another word or phrase.
Its to get a word referenced by an explanation in  another file (html).
Is there such a script (perl) or easy to make?
Any suggestions are wellcomed.

Smile (Breit grinsend, kopfkratzend) AK
-- 
* Dr. Andreas Kraska,
* Clinical pharmacist
* Noeschenroeder Str.77, D-38855 Wernigerode, Germany
* email :    jimknopf@halberstadt.netsurf.de
* Micha 4,3 : " Dann schmieden sie aus ihren Schwertern
* Pflugscharen und aus den Spitzen ihrer Speere Winzermesser"


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

Date: 15 Dec 1997 21:14:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: German characters
Message-Id: <6746jo$mbh$4@comdyn.comdyn.com.au>

In article <adelton.882176710@aisa.fi.muni.cz>,
	adelton@fi.muni.cz (Honza Pazdziora) writes:
>> > I am using PERL ($]=5.00390) with NT 4.0 in Germany. I have noticed,
> 
> [...]
> 
>> Read the perllocale man page and see if that clears up your confusion.  By
>> default, Perl assumes the "C" locale, which is essentially equivalent to
>> an American English locale.
> 
> I wanted to give the same answer but then I thought: they might not
> have man pages on Windoze and they might not have locales on Windoze ;-)

perldoc perllocale should work.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd.       | cynical. It's perfectly easy  to be
NSW, Australia                      | cynical.


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

Date: Mon, 15 Dec 1997 21:27:13 GMT
From: jgloudon@bbn.subtleantispam.com (Jason Gloudon)
Subject: Re: Hex, Oct, and Bin convertor?
Message-Id: <Rghl.139$ea2.6465032@cam-news-reader1.bbnplanet.com>

Heng-Chih Lin (hclin@PROBLEM_WITH_INEWS_GATEWAY_FILE.spdc.ti.com) wrote:
: Hi,

: I am wondering if there is any routine in perl which can convert number back
: and forth among Dec, Hex, Oct, and Bin formats.

man perl.

Look for oct, binary.

Jason Gloudon


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

Date: Mon, 15 Dec 1997 14:38:12 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: Hex, Oct, and Bin convertor?
Message-Id: <3495A343.32A20D8D@mystech.com>

Heng-Chih Lin wrote:

> Hi,
>
> I am wondering if there is any routine in perl which can convert number back
> and forth among Dec, Hex, Oct, and Bin formats.
>
> For example, if I have a number 3476 (in decimal) or 10100 (in binary), how can
> I convert it to other formats?
>
> Any suggestion is highly appreciated!

Standard Perl has the hex() and oct() functions to convert hexadecimal and octal
numbers (actually, strings) to decimal. Use sprintf() to go the other direction.
For example:

$dec = hex( "ff" );
$hexString = sprintf( "%lx", $dec );

Similar examples can be constructed for decimal-octal conversions. See page 179,
190, and 222 in "Programming Perl" for more details.

I don't know if Perl has any functions for binary numbers - check CPAN for a
module. Otherwise, it is not too difficult to write yourself!

Mark Reibert
-----------------------------
   Mark S. Reibert, Ph.D.

  Mystech Associates, Inc.
  3233 East Brookwood Court
   Phoenix, Arizona 85044

    Tel: (602) 732-3752
    Fax: (602) 706-5120
 E-mail: reibert@mystech.com
-----------------------------




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

Date: Mon, 15 Dec 1997 21:10:47 GMT
From: pbk@sasintern.com (Poul Kornmod)
Subject: Re: HTTP/1.0 500 Server Error (/cgi-bin/multiple_forms.cgi is not a valid Windows NTapplication. )
Message-Id: <34959b83.379015@news.dknet.dk>

Dear All,

Thanks for your reply's, both private and on this group. Sorry for
being ignorant and not aware of that great search ability on both
DejaNews and Altavista. It solved my problem immediately.

Brgds

Poul Kornmod


On Mon, 15 Dec 1997 14:42:13 -0500, comdog@computerdog.com (brian d
foy) wrote:

>In article <3495490e.25383727@news.dknet.dk>, pbk@sasintern.com (Poul Kornmod) wrote:
>
>>I know that this has been posted before - but I didn't read the
>>thread. Could somebody please forward me some of the reply's?
>
>Dejanews and Altavista archive usenet.  you can find old thread at
>either service.
>
>good luck :)
>
>-- 
>brian d foy                                  <comdog@computerdog.com>
>NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
>CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>



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

Date: Mon, 15 Dec 1997 13:24:08 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Poul Kornmod <pbk@sasintern.com>
Subject: Re: HTTP/1.0 500 Server Error (/cgi-bin/multiple_forms.cgi is not a valid Windows NTapplication. )
Message-Id: <Pine.GSO.3.96.971215132216.12424R-100000@user1.teleport.com>

On Mon, 15 Dec 1997, Poul Kornmod wrote:

> I know that this has been posted before - but I didn't read the
> thread. Could somebody please forward me some of the reply's?

No, that's what Usenet archiving services, such as AltaVista and Deja
News, are good for.

> Subject: HTTP/1.0 500 Server Error (/cgi-bin/multiple_forms.cgi is not a valid Windows NTapplication. )

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN. Hope this helps!

   http://www.perl.com/CPAN/
   http://www.perl.org/CPAN/
   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
   http://www.perl.org/CPAN/doc/manual/html/pod/

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 15 Dec 1997 20:43:33 GMT
From: James Frogel <tory1@IDT.NET>
Subject: Looking for Perl Spreadsheet
Message-Id: <6744pl$cic@nnrp4.farm.idt.net>

Does anybody know of a Perl spreadsheet. I am trying to take some thousands
of prices and perform multiple transformations on each of the prices.
Of course I could just Map this but I need the spreadsheet display to move
around thru the values...

Anybody got something like this?

Thanks in Advance,

Jim


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

Date: Mon, 15 Dec 1997 13:57:06 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: NEED:  Fast, Fast string trim()
Message-Id: <349599A2.920A2C88@mystech.com>

>     Benchmark: timing 1000 iterations of OneExp, TwoExp...
>         OneExp:  4 secs ( 3.76 usr  0.00 sys =  3.76 cpu)
>         TwoExp:  1 secs ( 0.99 usr  0.00 sys =  0.99 cpu)
>
> So, your version executes almost 4 times slower than the other.

Nice work! It looks like I'll be using the two-op version from now on!

Mark Reibert
-----------------------------
   Mark S. Reibert, Ph.D.

  Mystech Associates, Inc.
  3233 East Brookwood Court
   Phoenix, Arizona 85044

    Tel: (602) 732-3752
    Fax: (602) 706-5120
 E-mail: reibert@mystech.com
-----------------------------




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

Date: Mon, 15 Dec 1997 14:20:13 GMT
From: webmaster@realvision-inc.com (Paul Heindselman)
Subject: Pass variables to Unix command?
Message-Id: <34953a57.210745045@news.dx.net>

Hello, 

Heres a script I have so far:
---------------------------------------------------
#!/usr/bin/perl -w

print "Content-type:text/html\n\n";

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

     foreach $pair (@pairs)
     {
         ($name, $value) = split(/=/, $pair);
         $value =~ tr/+/ /;
         $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
         $value =~ s/~!/ ~!/g;
         $FORM{$name} = $value;
     }

$logintext = $FORM{'loginText'};
$testvar = `egrep $logintext callsign.txt`;

print "This should be Helmet $testvar\n";
----------------------------------------------------------------------------------------------

What I'm trying to do here is search a text file for a name that comes
from a web page form. 
It will search the file fine when I specify a name instead of
$logintext, but it wont pass the value of the $logintext variable to
the command line. Is there some special syntax to pass the variable?
Thanks in advance

Paul Heindselman
Webmaster - RealVision Inc.
webmaster@realvision-inc.com


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

Date: Mon, 15 Dec 1997 18:40:56 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Perl 5.004_04 install error - can't find compiler?
Message-Id: <adelton.882211256@aisa.fi.muni.cz>

nathan_loyer@vapower.com writes:

> While trying to make the Configure file (i.e. "sh Configure") for Perl
> 5.004_04, it cannot find my gcc compiler.  When I type "gcc" on the
> command line, it works fine.  What gives?  I am using pgcc, but it is
> refered to as gcc when used.  Is this a problem?

What does the Configure say?

It might be because you have the gcc defined as alias in your shell
and it will not get inherited to Configure. You might want to make a
soft link from gcc to your compiler, so that the gcc realy exests in
your system.

[CC'ed and posted]

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Mon, 15 Dec 1997 13:15:53 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Wayne <wcl@netrox.net>
Subject: Re: Perl script works when initiated from the unix shell, but not from web server.
Message-Id: <Pine.GSO.3.96.971215131447.12424P-100000@user1.teleport.com>

On Sun, 14 Dec 1997, Wayne wrote:

> #!/usr/bin/perl

What, no -w? :-)

> open (USER_INFO, ">" . "/home/pico/john/DATA/data.txt");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

> But when I run the script from a web browser,

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN. Hope this helps!

   http://www.perl.com/CPAN/
   http://www.perl.org/CPAN/
   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
   http://www.perl.org/CPAN/doc/manual/html/pod/

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 15 Dec 1997 22:27:13 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl script works when initiated from the unix shell, but not from web server.
Message-Id: <674as1$mlu$3@comdyn.comdyn.com.au>

In article <672aeu$kdm$1@usenet88.supernews.com>,
	"Wayne" <wcl@netrox.net> writes:
> Consider the following perl script used in a cgi setting.
> 
> #!/usr/bin/perl
> open (USER_INFO, ">" . "/home/pico/john/DATA/data.txt");

Always, Always check the return value of an open.

> print USER_INFO "Have a nice day\n";
> print "Content-type: text/plain\n\n";
> print "Done\n";

> When I run this script from my Unix account, which is where my perl script
> and the data.txt file reside, the script works fine, and the data.txt file
> ends up with the string "Have a nice day".  But when I run the script from a
> web browser, i.e., the web server is involved, this same script writes the
> empty string to data.txt thus leaving it empty.  Now I know that it is
> writing to it because what I did was have data.txt initialized to have some
> data in it.  Then after running the script via a web browser, data.txt was

Checking the return value of open is better and safer.

> left empty.  Any ideas as to what is going on??  Thanks.  If you could
> e-mail your responses to me that would be great.  Wayne.

If your script runs fine from the command line, but doesn't as a CGI,
then there is no problem with perl. There could be a problem with
permissions, web server implementations, and all sorts of stuff like
that. Check out section 9 of the perl faq (comes with perl, perldoc
perlfaq9), and the (don't be offended) idiot's guide to solving CGI
problems at 

http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html

and other documents at 

http://www.perl.com/CPAN/doc/FAQs/cgi/

You could also ask if this behaviour is something that is known on a
newsgroup dedicated to web servers (don't forget to mention the type
and version you're on, include OS information as well)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd.       | things get worse.
NSW, Australia                      | 


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

Date: 15 Dec 1997 22:39:15 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl url redirect
Message-Id: <674bij$mlu$4@comdyn.comdyn.com.au>

In article <3495606B.49AD60B5@wwgv.com>,
	Shawn Tolivar <shawn@wwgv.com> writes:
> This is a multi-part message in MIME format.
> --------------253824B1DA16D988E9453CE1
> Content-Type: multipart/alternative; boundary="------------BD03C9957DC322A0A257178B"

Please post in plain text. Don't 'attach' things, include them as
text. A lot of people won't be able to read, or can't be bothered to
read multipart MIME messages with encoded scripts attached to them.

Martien
-- 
Martien Verbruggen                  | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au    | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd.       | I can ask him what he meant - Steven
NSW, Australia                      | Wright


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

Date: 15 Dec 1997 21:09:41 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: PIng a Port
Message-Id: <6746al$mbh$3@comdyn.comdyn.com.au>

In article <34956672.9EFB82DF@arco.com>,
	Kevin Hawley <cchkxh@ARCO.com> writes:
> You can't ping a port,  ... But I'll bet you can port a ping ... or  not.

not :)

Not all socket libraries support the raw sockets that you need to
create a ping packet and send it off. Traceroute is another one of
those. The one socket library that comes to mind right now is
Microsoft's winsock implementation. Doesn't have raw sockets, so no
direct ICMP. But.. They do include an ICMP.DLL with some half
functional API, which is what you need to use on that platform.

I ran into this about two years ago, when I needed to write a
ping/traceroute component for Delphi. Maybe they do allow raw sockets
to be opened in the new versions of Winsock.. I dunno. 

I bet the perl porters also found out some things about MS Winsock
while working with it.. :)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.       | enough features yet.
NSW, Australia                      | 


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

Date: Mon, 15 Dec 1997 13:16:40 -0800
From: Dana Ludwig <dana@medical-info.com>
Subject: post your dynamic IP address to a web page-cant be done, right?
Message-Id: <34959E38.93CBB2A@medical-info.com>

I'm trying to use my permanent (static IP) web site as a sort-of
personal ICQ server, to let other web browser users find out whether I'm
on-line and what my current dynamic IP address is.

My idea is that I would have a small program on my personal PC that
would automatically post a message to my web site, saying that I am on
line and what my dynamic IP address is.

Next, I'd have to have a process on my host that would check,
periodically (say every 5 minutes), and query my dynamic IP address to
see that I am still online.  If it discovers that I am no longer online,
it would post this information to the web page.

Does anyone know whether/how this might be done?

Thank you,
--
Dana Ludwig
President
Medical Information Associates
535 Starboard Drive
San Mateo, CA  94404
voice - 650-572-9873
fax - 650-286-9534




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

Date: 15 Dec 1997 21:35:43 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: post your dynamic IP address to a web page-cant be done, right?
Message-Id: <6747rf$hvv$1@dismay.ucs.indiana.edu>

In article <34959E38.93CBB2A@medical-info.com>,
	Dana Ludwig <dana@medical-info.com> writes:
> I'm trying to use my permanent (static IP) web site as a sort-of
> personal ICQ server, to let other web browser users find out whether I'm
> on-line and what my current dynamic IP address is.
> 
> My idea is that I would have a small program on my personal PC that
> would automatically post a message to my web site, saying that I am on
> line and what my dynamic IP address is.
> 
> Next, I'd have to have a process on my host that would check,
> periodically (say every 5 minutes), and query my dynamic IP address to
> see that I am still online.  If it discovers that I am no longer online,
> it would post this information to the web page.
> 
> Does anyone know whether/how this might be done?
> 
> Thank you,


Pretty easy really, if you're using unix. (but then, all things are easier when
using unix).  I haven't tested this, but it should be close (I hope!).  Sorry
about the sheer ugliness of it.

portable side:

add the name of the perl script to the start up of your PPP session.

-- perl script --
#!/usr/bin/perl
# This is on linux, your mileage may vary!
use Net::FTP;

#configuration
$IFCONFIG="/sbin/ifconfig";
$INTERFACE="ppp0";
$USERNAME="foo";
$PASSWORD="bar";
$HOST="rabbit.foo.bar.com";


@output=`$IFCONFIG $INTERFACE`;
$ip_line=$output[1];
m/inet addr:([\d\.]+)/;
$IP=$1;

open(OUT,">/tmp/$$");
print OUT "<HTML><HEAD><TITLE>here I am!</TITLE></HEAD><BODY>\n";
print OUT "I am at $IP!\n";
print OUT "</BODY></HTML>\n";
close(OUT);

open(OUT,">$$.ip");
print OUT "$IP\n";
close(OUT);

$ftp=new Net::FTP($HOST);
$ftp->login($USERNAME,$PASSWORD)
$ftp->put("/tmp/$$","www/where.html");
$ftp->put("/tmp/$$.ip","mobile.ip");
$ftp->close;

unlink("/tmp/$$");
unlink("/tmp/$$.ip");
---------

Stationary side:

-- crontab --

*/5 * * * * /path/to/perl/script


----------

-- perl script --
#!/usr/bin/perl
use Net::Ping;

open(HANDLE,"mobile.ip");
chop($ip=<HANDLE>);
close(HANDLE);

$p=new Net::Ping;
if(!$p->ping($ip)) {
	open(OUT,"www/where.html");
	print OUT "<HTML><HEAD><TITLE>here I am</TITLE></HEAD><BODY>\n";
	print OUT "I'm gone!\n";
	print OUT "</BODY></HTML>\n";
	close(OUT);
}



Hope this helps.  Fixing bugs is an exercise left to the reader!
Brian Wheeler
bdwheele@indiana.edu



> --
> Dana Ludwig
> President
> Medical Information Associates
> 535 Starboard Drive
> San Mateo, CA  94404
> voice - 650-572-9873
> fax - 650-286-9534
> 
> 


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

Date: 15 Dec 1997 22:16:00 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Problem with getc?
Message-Id: <674a70$mlu$1@comdyn.comdyn.com.au>

In article <ybbtyj3171.fsf@hector.ultimatech.com>,
	Ivan Kourtev <ivan@ultimatech.com> writes:

> #!/usr/local/bin/perl -w

-w, good

no strict? hmmm.

> print "Name of file to read from > "; # prompt user
> $InFile = <STDIN>;                    # get a filename
> print "Name of file to write to > ";  # prompt user
> $OutFile = <STDIN>;                   # get a filename

$inFile and $OutFile both have a trailing newline. This will be
stripped by open, but I just wondered if you were aware of it.

> open (INFILE, $InFile) or die "Can't read $InFile\n";
> open (OUTFILE, ">$OutFile") or die "Can't write $OutFile\n";

checking the return values, good

> $line_no = 0;                         # initialize line counter
> $char_no = 0;                         # initialize character counter
> 
> printf(OUTFILE "%5d: ", ++$line_no);      # print $line_no
> while ($Char = getc INFILE) {

What happens, you think, when $char == '0' ?

Instead, you want to check if $Char is defined, see below.

>     ++$char_no;
>     if ($Char eq "\n") {
> 	printf(OUTFILE "\n%5d: %s", ++$line_no, $Line);

$Line is never initialised, and not used for anything useful. You
don't need it.

>     else {
> 	printf(OUTFILE $Char);

This printf can get screwed up if $Char is a % sign, because $Char
will be interpreted as a format. Just use print.

>     }
> }
> printf("Read %d lines and %d characters\n", $line_no, $char_no);

The whole if - then - else loop can be more efficient, and less
obscure.

-----------
printf(OUTFILE "%5d: ", ++$line_no);      # print $line_no

while (defined($Char = getc INFILE)) 
{
    ++$char_no;

	print OUTFILE $Char;

    if ($Char eq "\n") 
	{
         printf(OUTFILE "%5d: ", ++$line_no);
    }
}
-----------

If you want to use a $Line as buffer, which might be more efficient:

-----------
$Line = "";

while (defined($Char = getc INFILE)) 
{
    ++$char_no;

	$Line .= $Char;

    if ($Char eq "\n") 
	{
         printf(OUTFILE "%5d: %s", ++$line_no, $Line);
		 $Line = "";
    }
}

printf(OUTFILE "%5d: %s", ++$line_no, $Line) unless ($Line eq "");
-----------


There might be still one or two problems with files that don't end
with a newline, but I don't think so. You'll be able to test it and
work it out :)

HTH,

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.       | Gates?
NSW, Australia                      | 


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

Date: Mon, 15 Dec 1997 20:49:11 GMT
From: raul@homeontheweb.net (Raul Nohea Goodness)
Subject: Re: Problem with ODBC.pm (on WinNT)
Message-Id: <34959771.18803999@news.spacelab.net>

I use ODBC.pm a lot, but not with -w. 
Try to get the error string from ODBC. It's usually pretty
informative. I use something similar to this: 

$stmt = "insert into WesPRESSAccessInfo (UserID, AccessTime, DocType,
DocName, DocCount, Query, ProposalID) values ('$username', $logintime,
'$doctype', '$docname', 1, '$queryzip', '$propid') ; ";
$rc = $db->Sql($stmt); 
($ErrNum, $ErrText, $ErrConn) = $db->Error();	# in case of error
condition, get debug info.
print "SQL failed $stmt :  $ErrNum, $ErrText, $ErrConn " if $rc; 

Also, you can try to make sure your date format is correct. 
Use {ts '1997-04-06 03:55:23'} or {d '1997-04-06'} . Forget about
newer version, I don't think there is one.

-Raul Goodness


On Mon, 15 Dec 1997 11:33:24 -0500, Henry Hartley <henry@DotRose.com>
wrote:

>I have a Perl script that, among other things, writes a record to a MS
>Access table.  The line that sets up the SQL statement is as follows:
>
>$sql = qq(insert into WesPRESSAccessInfo (UserID, AccessTime, DocType,
>DocName, DocCount, Query, ProposalID) values ('$username', $logintime,
>'$doctype', '$docname', 1, '$queryzip', '$propid'));
>
[snip]
>Where document-log.pl line 231 is the one listed above.  If I remove the
>-w I get no error message but the record is not added to the table
>either.  Is there really something wrong with ODBC.pm or is this likely

>
>Henry



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

Date: 15 Dec 1997 14:28:46 GMT
From: ronald@cs.ust.hk (Chan Pui Nang)
Subject: Q on fcntl
Message-Id: <673equ$h1o@ustsu10.ust.hk>

Dear all,

	Would you tell me how to get the flag of file descriptor?

	I have tried the following in Solaris, but not work.

	$temp=0;
	$temp2=0;
	open(THELOCK, "temp.lock");
	fcntl(THELOCK, F_SETFL, O_RDWR);
	$temp=fcntl(THELOCK, F_GETFL, $temp2);
	print $temp;
	print $temp2;

	Neither $temp nor $temp2 can have O_RDWR. What is wrong?

	Thanks in advance.

Ronald


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

Date: Mon, 15 Dec 1997 12:03:34 -0800
From: "Shmuel (Seymour J.) Metz" <nospam@gsg.eds.com>
Subject: Re: Which language pays most 17457 -- C++ vs. Java?
Message-Id: <34958D16.190C@gsg.eds.com>

Alicia Carla Longstreet wrote:

> > >6. The syntax must be simple. The semantics must be well defined.
> 
> > > C is ok with 1, 2 and 3, but not with 4, 5 and 6.
>
> You got this wrong:
> As for number 6, C has one of the smallest sets of keywords (excluding
> the library) of any language available. 

The complexity of the syntax involves a lot more than the number of
keywords. The degree to which the d\semantics are well defined has
nothing whatsoever to do with the number of keywords. If he's wrong you
haven't shown it.

> C provides the needed primitives to do anything you need.  

You got this wrong; C does not have the needed primitives to handle
sets, do string matching, do record-oriented I/O, etc., except in the
trivial sense that anything can be simultated on anything else.

-- 

                        Shmuel (Seymour J.) Metz
                        Senior Software SE

The values in from and reply-to are for the benefit of spammers:
reply to domain eds.com, user msustys1.smetz or to domain gsg.eds.com,
user smetz. Do not reply to spamtrap@library.lspace.org


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

Date: Mon, 15 Dec 1997 19:59:10 GMT
From: giader@eostel.it (Giacomo Delre)
Subject: Re: Which language pays most 17457 -- C++ vs. Java?
Message-Id: <3494f3f7.555311@news.teseo.it>

On 12 Dec 1997 21:16:34 GMT, tholen@ifa.hawaii.edu wrote:

>Mix writes:
>
>> I will graduate from a college very soon with a Computer Science
>> degree under my belt
>
>How did you manage that, if something as easy as Fortran was
>incomprehensible to you?
>

Right!

gi@der


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

Date: 15 Dec 1997 22:20:50 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Workaround for FLOCK?
Message-Id: <674ag2$mlu$2@comdyn.comdyn.com.au>

In article <3494582E.D135E94D@aol.com>,
	Vik Rubenfeld <VikR@aol.com> writes:
> I've got a machine that doesn't support FLOCK. (Error message "# The flock()
> function is unimplemented.") I'd rather not tell my client to update his PERL

An upgrade of perl might not help. It might be the OS perl is running
on. If that, by any chance is Win32, check the win32 FAQ, section 5.1
I believe, just to check if WIn32 does indeed support flock-ing.

http://www.perl.com/CPAN/doc/FAQs/win32/Perl_for_Win32_FAQ.html

Martien

-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd.       | negative.
NSW, Australia                      | 


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 1478
**************************************

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