[10008] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3601 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 31 23:04:31 1998

Date: Mon, 31 Aug 98 20:00:22 -0700
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, 31 Aug 1998     Volume: 8 Number: 3601

Today's topics:
    Re: Carrage Returns in a Array Removal <rootbeer@teleport.com>
    Re: Carrage Returns in a Array Removal (Andre L.)
    Re: comp.lang.perl.windows.misc (Andrew M. Langmead)
    Re: Copy Problems??? (Tad McClellan)
        Currency Formatting in Perl (s//) <ar@webcanada.com>
    Re: Currency Formatting in Perl (s//) <rootbeer@teleport.com>
    Re: DeCrypt ? <sneaker@sneex.fccj.org>
        Defining constant values in Perl using #DEFINE <david.mohorn@sourcebbs.com>
    Re: Defining constant values in Perl using #DEFINE <rootbeer@teleport.com>
    Re: Determining strlen <dave@nic.com>
        Formatting money jeanmar@my-dejanews.com
    Re: Formatting money <nguyend7@msu.edu>
    Re: Formatting money <sneaker@sneex.fccj.org>
    Re: Formatting money (Andre L.)
        Funny, that:  $#myarray (C. Abney)
    Re: Funny, that:  $#myarray <rootbeer@teleport.com>
    Re: GD.pm (Larry Rosler)
    Re: HELP!!! pls (Andre L.)
        How to timeout on Win32 without alarm()? (Larry Rosler)
    Re: mod_perl configuration (Randy Kobes)
        My Perl Window Keeps Closing <jt@eatel.net>
        Non-Blocking Socket in NT <wkchiu@yahoo.com>
        Redirect problems! <qmwclka@emw.ericsson.se>
    Re: Redirect problems! <rootbeer@teleport.com>
        substitution problems <ilowe@ibm.net>
    Re: substitution problems <rootbeer@teleport.com>
        Which error return test? <sneaker@sneex.fccj.org>
    Re: Which error return test? <rick.delaney@shaw.wave.ca>
    Re: Win32 Local Path Info <sneaker@sneex.fccj.org>
    Re: Win32 Local Path Info (Larry Rosler)
    Re: Win32 Local Path Info <sneaker@sneex.fccj.org>
    Re: Win32::Console For Password Entry (Matthew Bafford)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 01 Sep 1998 00:04:19 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Carrage Returns in a Array Removal
Message-Id: <Pine.GSO.4.02A.9808311703010.24074-100000@user2.teleport.com>

On Mon, 31 Aug 1998, Robert Saunders wrote:

> Subject: Carrage Returns in a Array Removal

I suspect that you want to remove newlines rather than carriage returns.
Removing newlines is done most often in Perl with chomp. Does that do what
you need? Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 31 Aug 1998 21:17:27 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Carrage Returns in a Array Removal
Message-Id: <alecler-3108982117270001@dialup-550.hip.cam.org>

In article <Pine.GSO.4.02A.9808311703010.24074-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:

> On Mon, 31 Aug 1998, Robert Saunders wrote:
> 
> > Subject: Carrage Returns in a Array Removal
> 
> I suspect that you want to remove newlines rather than carriage returns.
> Removing newlines is done most often in Perl with chomp. Does that do what
> you need? Hope this helps!


I'm afraid that might not cut it with the problem at hand -- that is, if
the poster has the data from each of his HTML form inputs in a scalar.
Then, it becomes a matter of eliminating end-of-line sequences inside a
string, not in an array, as the subject line misleadingly states.

The HTML specs tell us that the ends-of-lines in textareas are \015\012
(carriage return and linefeed). So, to remove the ends-of-lines, a
substitution like this would be used:

   $textarea =~ s/\015\012/ /g;
   #                       ^this is a space

Remember to append a newline to the modified textarea string when writing
it to the file.

Andre


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

Date: Tue, 1 Sep 1998 00:43:56 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: comp.lang.perl.windows.misc
Message-Id: <EyKy19.2Hx@world.std.com>

fl_aggie@thepentagon.com (I R A Aggie) writes:

>In article <EyDJG1.EKD@world.std.com>, aml@world.std.com (Andrew M.
>Langmead) wrote:

>+ Its the VMS 

>How so? yes, I have sullied my hands and used that system. Thought it was
>great. Then I got unix.

Did you think this was a knock against VMS systems in general or
sepcifically against Perl for VMS. I'm not sure whether I meant it as
either. VMS is even less "unix-ish" than the microcomputer platforms
that I was discussing. I'd guess this is partly due age (the
microcomputer OS designers had a lot more exposure to Unix), and
partly due to design criteria (Digital's products were small
mainframes, and carried a lot of their baggage.) Its not the machines
I'm surprised at, its just to see a "portable distillation of Unix" on them.

-- 
Andrew Langmead


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

Date: Mon, 31 Aug 1998 19:29:56 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Copy Problems???
Message-Id: <46ffs6.vn6.ln@metronet.com>

kena4078@my-dejanews.com wrote:
: I'm having a problem copying any file size greater than 1mb from one directory
: to another. Is there a limit on the file size that can be copied from one
: directory to another?


   The Operating System is responsible for filesystem operations.

   Please ask in a newsgroup appropriate for whatever OS you
   are using.


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


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

Date: 31 Aug 1998 23:59:17 GMT
From: "Internet Guy" <ar@webcanada.com>
Subject: Currency Formatting in Perl (s//)
Message-Id: <01bdd53b$6b7d4340$f50870d1@webcan>

Can anyone tell me how I can create an expression to format currency values
in Perl?

I imagine it's something complicated involving s// but I can't get the
parameters right.

I would input a number such as 200000 and would want 200,000 as the result

Replies by e-mail (ar@webcanada.com) are appreciated.

Thanks.



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

Date: Tue, 01 Sep 1998 00:20:41 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Currency Formatting in Perl (s//)
Message-Id: <Pine.GSO.4.02A.9808311716340.24074-100000@user2.teleport.com>

On 31 Aug 1998, Internet Guy wrote:

> Newsgroups: comp.lang.perl, comp.lang.perl.misc, comp.lang.perl.modules,
>     comp.lang.perl.tk

That's excessive. When comp.lang.perl was a valid newsgroup, Phil Hartman
was still a regular on Saturday Night Live. And does this question really
belong in both .tk and .modules as well? 

> I would input a number such as 200000 and would want 200,000

The FAQ talks about putting commas into a number. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 31 Aug 1998 20:52:17 -0400
From: Bill 'Sneex' Jones <sneaker@sneex.fccj.org>
Subject: Re: DeCrypt ?
Message-Id: <35EB4541.612DAC72@sneex.fccj.org>

Abigail wrote:
> 
<snip infinite passwd cracker>
> 
> Abigail
> --
> perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")\n-> define ("foldoc", "perl")) [0] -> print'


Thx for the FOLDOC reference, I was looking for that!

-Sneex- 
__________________________________________________________________
Bill Jones | FCCJ Webmaster | Murphy's Law of Research:
           Enough research will tend to support your theory.


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

Date: Mon, 31 Aug 1998 20:39:26 -0400
From: "David Mohorn" <david.mohorn@sourcebbs.com>
Subject: Defining constant values in Perl using #DEFINE
Message-Id: <01bdd541$34d35ea0$0e5c5499@user.ncr.com>

Does anyone know the best way of defining constant "preprocessor" type
definitions in Perl similar to C?  For example:

#define RTS = 1
#define CTS = 2
#define DTR = 3

Obviously, this won't work in Perl, but having to define:

$RTS=1;
$CTS=2;
$DTR=3;

means I could inadvertantly modify these values somewhere else in the
program.  Does Perl have a "const" modifier or similar??? 

david.mohorn@norfolkva.ncr.com
CNE, MCSE




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

Date: Tue, 01 Sep 1998 01:08:23 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Defining constant values in Perl using #DEFINE
Message-Id: <Pine.GSO.4.02A.9808311807580.24074-100000@user2.teleport.com>

On Mon, 31 Aug 1998, David Mohorn wrote:

> Does Perl have a "const" modifier or similar??? 

The command 'perldoc constant' should inform you. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 31 Aug 1998 20:54:22 -0400
From: Dave Wreski <dave@nic.com>
Subject: Re: Determining strlen
Message-Id: <35EB45BE.FEA3CEDA@nic.com>

> /<A HREF=http:.*>/i
>
> But notice that this is a naive approach. Asterisks are greedy
> matchers by default .. so you might end up matching something like:
>
> <A HREF="http://www.bla.com/>Click <bold>here</bold>

Well, that's exactly what's happened, and I can't figure it out.  Given the following
string:

<TD><A HREF=http://www.mywebsite.com/url/goes/here>http://www.mywebsite.com/url/goes/here</A></TD>

How can I just grab the data between the anchors, and not the actual URL itself?  I figure
I need to do something like find the '>http://' pattern, using index()?  Then use strstr()
to move to that point, but even once I do that, I can't figure out how to stop grabbing
characters...

Once I've done that, I then need to adjust the length of the text to 80 characters or
less..

Thanks much for any ideas.  I've been pushed into this, and just don't have the time to get
up to speed before this project is due...

Dave



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

Date: Tue, 01 Sep 1998 00:20:46 GMT
From: jeanmar@my-dejanews.com
Subject: Formatting money
Message-Id: <6sfeku$qm2$1@nnrp1.dejanews.com>

Hi,
Is there a simple way to format a number to a money format?
e.g. 12345.65 -> $12,345.65
Thanks in advance,
JeanMarie

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 1 Sep 1998 00:45:51 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: Formatting money
Message-Id: <6sfg3v$kdh$1@msunews.cl.msu.edu>

jeanmar@my-dejanews.com wrote:
: Is there a simple way to format a number to a money format?
: e.g. 12345.65 -> $12,345.65

I just finish reading the thread on "Currency Formatting in Perl
(s//)"  It was posted about 20 minutes earlier.  Please read that
thread and reduce redundant post.

-dan

-- 
           Dan Nguyen            | There is only one happiness in
        nguyend7@msu.edu         |   life, to love and be loved.
http://www.cse.msu.edu/~nguyend7 |                   -George Sand



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

Date: Mon, 31 Aug 1998 21:15:50 -0400
From: Bill 'Sneex' Jones <sneaker@sneex.fccj.org>
Subject: Re: Formatting money
Message-Id: <35EB4AC6.ADA70EFE@sneex.fccj.org>

jeanmar@my-dejanews.com wrote:
> 
> Hi,
> Is there a simple way to format a number to a money format?
> e.g. 12345.65 -> $12,345.65
> Thanks in advance,
> JeanMarie
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


You should really see this:
http://www.plover.com/perl/Interpolation/index.html

HTH,
-Sneex- 
__________________________________________________________________
Bill Jones | FCCJ Webmaster | Murphy's Law of Research:
           Enough research will tend to support your theory.


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

Date: Mon, 31 Aug 1998 21:43:57 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Formatting money
Message-Id: <alecler-3108982143570001@dialup-550.hip.cam.org>

In article <6sfg3v$kdh$1@msunews.cl.msu.edu>, Dan Nguyen
<nguyend7@msu.edu> wrote:

> jeanmar@my-dejanews.com wrote:
> : Is there a simple way to format a number to a money format?
> : e.g. 12345.65 -> $12,345.65
> 
> I just finish reading the thread on "Currency Formatting in Perl
> (s//)"  It was posted about 20 minutes earlier.  Please read that
> thread and reduce redundant post.

It is possible that that thread had not reached the poster when he sent
his own question. 20 minutes is not a long time in terms of news
propagation...

Andre


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

Date: 1 Sep 1998 01:45:10 GMT
From: cabney@cyberpass.net (C. Abney)
Subject: Funny, that:  $#myarray
Message-Id: <6sfjj6$h49$1@news.infonex.net>

The Camel tells me:

	...the following is always true:

		scalar(@whatever) == $#whatever + 1;

but my recent experience tells me $#myarray gives me something more
like the length of the first element in @myarray than the size of the
entire array itself.

I did:
	...
	# $line looks something like "field 5 is 1. e4 e5 2. Nf3 Nc6 3. ..."
	# populate @movelist:
	if ($line =~ /^field\s5\sis/) {
        $line =~ s/^field\s\d+\sis\s(.*)\.$/$1/;
        $line =~ s/\s(\d+\.\s)/|$1/g;
        @movelist = split /\|/, $line;
    }
    ...
	use integer;
	$height = $#movelist / 4 + 1;
	# ^^^^^^^^^^^^^^^^^^^^^^^^^^^
	# instead of the following, which works:
	# $height = @movelist / 4 + 1;
	...
	# process array here

Can some monger riddle me this?

-C
-- 
Internet Service Providers:  MAKE MONEY FAST!!!!!!! Totally legal!
Collect UCE/UBE from your users, and $50 per incidence!
Offer only good in California, Nevada, and Washington.       -C. Abney



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

Date: Tue, 01 Sep 1998 02:09:41 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Funny, that:  $#myarray
Message-Id: <Pine.GSO.4.02A.9808311859500.24074-100000@user2.teleport.com>

On 1 Sep 1998, C. Abney wrote:

> 	...the following is always true:
> 
> 		scalar(@whatever) == $#whatever + 1;

Yes, so long as you haven't been tampering with the special $[ variable.
But you shouldn't be doing that in any case.

> but my recent experience tells me $#myarray gives me something more
> like the length of the first element in @myarray than the size of the
> entire array itself.

The length of an element? Not in a million years. :-)

> 	use integer;

Uh oh. Do you know what you're doing with this? 

> 	$height = $#movelist / 4 + 1;
> 	# ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 	# instead of the following, which works:
> 	# $height = @movelist / 4 + 1;

Suppose there are 100 elements in @movelist. Your first expression would
return int(99/4)+1 => 25, but the second should return int(100/4)+1 => 26.
Which one do you want? My suspicion is that you need to know the number of
elements in the array, rather than the last array index, but maybe your
formula is defective. In any case, I see no sign of the length of an
element having any relevance. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 31 Aug 1998 17:37:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: GD.pm
Message-Id: <MPG.1054e1afa770816a989780@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <35EB2096.CB0416BD@bbnplanet.com> on Mon, 31 Aug 1998 22:25:45 
GMT, Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> says...
> > zactly But you gotta have a compiler. dont ya.
> 
> one would hope that if one has perl on ones system that one also has gcc
> or somesuch to go with it. why ask a rhetorical question.

Huh???  As compilers have to be acquired and installed, and as no 
compiler is required to install perl binaries, there is zero correlation 
between these two capabilities, except by some programmer's conscious 
choice.  Hardly a rhetorical question!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 31 Aug 1998 21:38:36 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: HELP!!! pls
Message-Id: <alecler-3108982138360001@dialup-550.hip.cam.org>

In article
<Pine.OSF.3.96.980831163128.28086B-100000@hilbert1.ms.washington.edu>,
Meenu <meenu@ms.washington.edu> wrote:

> hey guys I wrote a script to grab the data from some search engine.. now
> here comes the silly question, I'm not being able to open a file & PASTE
> that data in there. Can anyone tell me how to do it
> 
> I was tryin' to do something as
>   open (file, ">$data");
>   print file $data;
>   close (file)
> 
> 
> ..I know its wrong.. I just switched from good old C to perl.. so a bit
> confused.. your help will be appreciated ;o)


As Tom P. always says, check the return value of open() (which you'll find
in the global variable $!):

   my $filename = '/root/this/that/thefile.xox';
   open (FILE, ">$filename") 
      or die "Gasp! $filename was not opened: $!\n";

You are using the value in $data as the second argument to open() -- is
$data really the name of the file you want to open?

Also, using lowercase barewords for filehandles is risky, as they could
clash with eventual reserved words in a future version of Perl. (Using the
-w switch would warn you about this.) The convention is to use
all-uppercase filehandles to prevent this.

HTH,
Andre


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

Date: Mon, 31 Aug 1998 19:16:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: How to timeout on Win32 without alarm()?
Message-Id: <MPG.1054f8c2ed48df52989782@nntp.hpl.hp.com>

I just downloaded the ActiveState 5.005_02 binary and discovered to my 
dismay that it *still* doesn't support the alarm() function.  This 
function is supported in the MKS perl 5.003 (an existence proof that 
alarm() can be implemented on Win32), but the MKS perl doesn't support 
the socket() functions.

Will someone please suggest how I can timeout on a socket call using 
Win32 Perl?

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 1 Sep 1998 02:28:41 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: mod_perl configuration
Message-Id: <slrn6umne3.5ft.randy@theory.uwinnipeg.ca>

On Mon, 31 Aug 1998 14:00:42 GMT, marad@usa.net <marad@usa.net> wrote:
>Yes, yes. Just for fun, I tried commenting out the .cgi line in my srm.conf
>(and then restarting the server, of course), but no cigar. Other ideas,
>anyone?
>
>In article <comdog-ya02408000R2808982119520001@news.panix.com>,
>  comdog@computerdog.com (brian d foy) wrote:
>> In article <6s72au$7gi$1@nnrp1.dejanews.com>, marad@usa.net posted:
>>
>> >After many hassles, I successfully complied Apache 1.3.1 for Linux with
>> >mod_perl, but I still can't seem to get it to actually run scripts. Instead,
>> >it just displays the script. I have searched the newsgroups and FAQs over and
>> >over, but nothing seems to work. My srm.conf looks like this:
>>
>> >AddHandler cgi-script .cgi  #Do I need this line? Is it in the way?
>>
>> i have this commented out in my config, but that doesn't mean anything.
>> my servers don't allow executable content outside of designated
>> directories.
>>
>> >Alias /perl/ /usr/apache/share/perl/
>> ><Location /perl>
>> >SetHandler perl-script
>> >PerlHandler Apache::Registry
>> >Options ExecCGI
>> ></Location>
>>
>> my configuration looks very similar to yours (Stronghold is a little
>> different than Apache for configuration).  i know this is a stupid
>> question, but have you reloaded the server so that the new
>> configuration takes affect?  that bites me a couple times a week :)
>>
>> good luck :)
>>
>> --
>> brian d foy                                  <comdog@computerdog.com>

Hi,
   The parts of the configuration files you posted also look similar
to mine, so there's nothing obviously wrong there. Does the rest of
your server function OK - static pages, etc.? Are you using the
latest mod_perl, and CGI.pm if that's being used in your scripts?
There were such problems in particular combinations of some earlier
versions of these that have since been resolved.
   There may be something else in one of the *.conf files that's 
causing this problem - for example, do you have a ScriptAlias 
definition pointing to the same directory? Or the variable 
PerlSendHeader set for this directory in another part of 
the configuration files? Or perhaps the real /perl directory
is contained in another set of directives that is causing a conflict?
   Another possibility that I encountered is that many of the
default locations changed in Apache 1.3.x, particularly the
location of the configuration files. What might happen is that
if you compile mod_perl the "simple" way, as opposed to using
the new APACI interface, then manually copy httpd to the relevant
location, it may be using a different, older set of configuration 
files than the ones you're editing. Do you start httpd using the -f 
switch telling it what configuration file to use?
   Other than that, you might want to search the information on
	http://perl.apache.org/
particularly for the links there to archives of the (pretty active)
mailing list - this problem is not rare, for a variety of reasons,
and maybe something there might help.

-- 
		Best regards,
		Randy Kobes

Physics Department		Phone: 	   (204) 786-9399
University of Winnipeg		Fax: 	   (204) 774-4134
Winnipeg, Manitoba R3B 2E9	e-mail:	   randy@theory.uwinnipeg.ca
Canada				http://theory.uwinnipeg.ca/


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

Date: Mon, 31 Aug 1998 21:52:30 -0500
From: "Jonathan Tapp" <jt@eatel.net>
Subject: My Perl Window Keeps Closing
Message-Id: <35eb6247.0@news.eatel.net>

    Hi.  I'm using ActivePerl for Windows.  Actually, I'm using Windows 98.
If I type

"perl counter.pl" at the prompt, it tells me "This file cannot be run in
MS-DOS mode".  If I type it in a DOS windows in Windows, it says "This file
cannot be run in Windows".  The only way I can run my Perl scripts is to
double-click them in Windows.  This runs the program in a DOS window that
promptly closes.  How do I keep the window open to see my output?  The
association for running Perl on my computer is

C:\Perl\5.005\bin\MSWin32-x86-object\Perl.exe "%1" %*

Please send your answer via e-mail.  Thanks in advance!!!

Jonathan Tapp
jonathan_tapp@hotmail.com
Go ahead.  Spam me.  I dare ya.




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

Date: 1 Sep 1998 02:46:04 GMT
From: "wkchiu" <wkchiu@yahoo.com>
Subject: Non-Blocking Socket in NT
Message-Id: <01bdd553$f2a2cf80$de93fccd@pct3>

I am a newbie in perl programming and just encountered a problem which I
don't know how to solve.

I have written a client socket program in Windows NT using ActiveState Perl
(5.004) and connect to a socket server. The socket is blocking by default.
How can I set the socket to non-blocking ? I have checked the Perl
reference and find that fcntl() and ioctl() may be help, but it is
UNSUPPORTED in AS Perl !!

Can anyone share with your experience.

wkchiu.


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

Date: Wed, 26 Aug 1998 11:47:38 +0200
From: Clas <qmwclka@emw.ericsson.se>
Subject: Redirect problems!
Message-Id: <35E3D9B9.4B27AFCD@emw.ericsson.se>

Hello

I have a problem like this:

First in my program I have to write some things to a HTML-page.
After that I want to redirect a the person...

How could I make the redirect to work after the line print header();

Here is an example of what I mean (My problem is not exactly this
simple...so you can't just make an if-statemet to come aruond the
problem).

#!/opt/free/bin/perl5.003

use CGI qw(:standard);

$query = new CGI;

print header();  #Here is the problem...this makes so everything comes
up in the HTML-page
print "Hello Everybody";
print $query->redirect("/any/new/address");

The address "/any/new/address" shows up in the HTML-page and this is not

what I want :(

Please help me to solve this problem
//Clas




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

Date: Tue, 01 Sep 1998 01:43:30 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Redirect problems!
Message-Id: <Pine.GSO.4.02A.9808311842130.24074-100000@user2.teleport.com>

On Wed, 26 Aug 1998, Clas wrote:

> Subject: Redirect problems!

It sounds as if your problem is that you're trying to get a browser to do
something. The docs, FAQs, and newsgroups about browsers should be useful.
Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 31 Aug 1998 20:47:29 -0400
From: "Ian A. Lowe" <ilowe@ibm.net>
Subject: substitution problems
Message-Id: <35EB4421.AAC6D188@ibm.net>

I am try a fairly simple substitution, but am having problems.  Can
anyone tell me what I'm doing wrong?  Here is the scenario:

$daemon =~ s(\<in.routed>\>) (/usr/sbin/in.routed);

What I am doing is building a process table for a daemon monitor.  On
our HA servers, the in.routed process is just 'in.routed -q'.  On our
regular servers, it is the full path as you see it above
(/usr/sbin/in.routed).

I could have sworn that this was working for me a couple of weeks ago,
but today I started to run into problems with it not substituting.  Am I
crazy, or does this syntax look right?

Thanks for the help on a very small, but frustrating problem.

Ian



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

Date: Tue, 01 Sep 1998 01:04:09 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: substitution problems
Message-Id: <Pine.GSO.4.02A.9808311800590.24074-100000@user2.teleport.com>

On Mon, 31 Aug 1998, Ian A. Lowe wrote:

> Can anyone tell me what I'm doing wrong?  

> $daemon =~ s(\<in.routed>\>) (/usr/sbin/in.routed);

That's valid Perl code, dispite the misleading backslashes. Isn't it doing
what you want? It should find a string in $daemon beginning with '<in',
followed by any character but newline, then finishing up with 'routed>>',
and when it finds that string it should replace it with
'/usr/sbin/in.routed'. Is that not what you want? Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 31 Aug 1998 20:48:29 -0400
From: Bill 'Sneex' Jones <sneaker@sneex.fccj.org>
Subject: Which error return test?
Message-Id: <35EB445D.1BB70570@sneex.fccj.org>

Should 

$erc = system("echo Hi") / 256 unless $erc;

be used.  Or should

$erc = system("echo Hi") % 256 unless $erc;

be used???


Hmmm, or maybe

$erc = system("echo Hi") & 256 unless $erc;


Thx,
-Sneex- 
__________________________________________________________________
Bill Jones | FCCJ Webmaster | Murphy's Law of Research:
           Enough research will tend to support your theory.


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

Date: Tue, 01 Sep 1998 01:37:18 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Which error return test?
Message-Id: <35EB514D.3B724B8D@shaw.wave.ca>

[posted & mailed]
I'm sure that you've read the perlfunc entry for system which goes into
great detail in examining the return value from system.  Perhaps the
entry for $? in perlvar will simplify things.

The main point is that the exit value is returned in the high-order
byte, hence divide by 256.  The low-order byte tells you which signal
killed the process.  To get the exit value:

    $exit_value = system(...) >> 8;

Bill 'Sneex' Jones wrote:
> 
> Should
> 
> $erc = system("echo Hi") / 256 unless $erc;
>

$erc = exit_value # with decimal part indicating signal/core dump
 
> be used.  Or should
> 
> $erc = system("echo Hi") % 256 unless $erc;
> 

$erc is true if signal/core dump.

> be used???
> 
> Hmmm, or maybe
> 
> $erc = system("echo Hi") & 256 unless $erc;
> 

If you had 255 there, then $erc would contain the signal/core dump info.

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Mon, 31 Aug 1998 20:59:58 -0400
From: Bill 'Sneex' Jones <sneaker@sneex.fccj.org>
Subject: Re: Win32 Local Path Info
Message-Id: <35EB470E.92EB55D9@sneex.fccj.org>

Bob Anderson wrote:
> 
> I'm trying to determine if there is a way to retrieve the local path to
> an HTML file, i.e.
> 
> c:\inetpub\wwwroot\mypage.html
> 
> as opposed to
> 
> http://www.mydomain.com/mypage.html
> 
> The scripts and HTML files will all reside on the same machine.
> 
> Thanks
> 
> Bob A.


This may be of interest - or at least point you in the
right direction.

http://www.stonehenge.com/merlyn/UnixReview/col16.html


HTH,
-Sneex- 
__________________________________________________________________
Bill Jones | FCCJ Webmaster | Murphy's Law of Research:
           Enough research will tend to support your theory.


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

Date: Mon, 31 Aug 1998 19:05:16 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Win32 Local Path Info
Message-Id: <MPG.1054f6359c3a7814989781@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <35EB470E.92EB55D9@sneex.fccj.org> on Mon, 31 Aug 1998 
20:59:58 -0400, Bill 'Sneex' Jones <sneaker@sneex.fccj.org> says...
> Bob Anderson wrote:
> > I'm trying to determine if there is a way to retrieve the local path to
> > an HTML file, i.e.
> > 
> > c:\inetpub\wwwroot\mypage.html
> > 
> > as opposed to
> > 
> > http://www.mydomain.com/mypage.html
 ...
> This may be of interest - or at least point you in the
> right direction.
> 
> http://www.stonehenge.com/merlyn/UnixReview/col16.html

Nothing to do with this problem, unfortunately.  What he needs to do is 
compare $ENV{PATH_TRANSLATED} with $ENV{PATH_INFO} to determine the web 
root.  If the server isn't setting these variables, he has to come back 
around with a slash at the end of the URL of the CGI program.  Briefly 
(without adequate checking for undefined variables; the :PORT part is 
superfluous if it is 80):

unless ($ENV{PATH_INFO}) {
  print
    "Location: $ENV{SERVER_NAME}:$ENV{SERVER_PORT}$ENV{SCRIPT_NAME}/\n\n"
  exit;
}

I don't know how this is done using CGI.pm, as I haven't used it yet.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 31 Aug 1998 22:23:11 -0400
From: Bill 'Sneex' Jones <sneaker@sneex.fccj.org>
To: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Win32 Local Path Info
Message-Id: <35EB5A8F.8B9CD30D@sneex.fccj.org>

[Posted to comp.lang.perl.misc and a copy mailed.]

Larry Rosler wrote:
> 
> [Posted to comp.lang.perl.misc and a copy mailed.]
> > http://www.stonehenge.com/merlyn/UnixReview/col16.html
> 
> Nothing to do with this problem, unfortunately.  What he needs to do is
> compare $ENV{PATH_TRANSLATED} with $ENV{PATH_INFO} to determine the web
> root.  If the server isn't setting these variables, he has to come back
> around with a slash at the end of the URL of the CGI program.  Briefly
> (without adequate checking for undefined variables; the :PORT part is
> superfluous if it is 80):
> 
> unless ($ENV{PATH_INFO}) {
>   print
>     "Location: $ENV{SERVER_NAME}:$ENV{SERVER_PORT}$ENV{SCRIPT_NAME}/\n\n"
>   exit;
> }
> 
> I don't know how this is done using CGI.pm, as I haven't used it yet.
> 

You're right :]  Re:  CGI -

Something like:
# Uncomment the following during DEBUGGING Only...
#print "Content-type: text/plain\n\n'<PRE>CGI Diagnostics' -
Initialized!\n\n";
#if (accept())          { print "Browser MIME List:\t",
accept()            }
#if (auth_type())       { print "\nAuthentication Type:\t\t",
auth_type()   }
#if (raw_cookie())      { print "\nRaw Cookie:\t\t",
raw_cookie()           }
#if (path_info())       { print "\nPath Info:\t\t",
path_info()             }
#if (path_translated()) { print "\nPath Translated:\t\t",
path_translated() }
#if (query_string())    { print "\nQuery String:\t\t",
query_string()       }
#if (referer())         { print "\nReferrer:\t\t",
referer()                }
#if (remote_addr())     { print "\nRemote Addr:\t\t",
remote_addr()         }
#if (remote_ident())    { print "\nRemote Ident:\t\t",
remote_ident()       }
#if (remote_host())     { print "\nRemote Host:\t\t",
remote_host()         }
#if (remote_user())     { print "\nRemote User:\t\t",
remote_user()         }
#if (request_method())  { print "\nRequest Method:\t\t",
request_method()   }
#if (script_name())     { print "\nScript Name:\t\t",
script_name()         }
#if (server_name())     { print "\nServer Name:\t\t",
server_name()         }
#if (server_software()) { print "\nServer Software:\t",
server_software()   }
#if (virtual_host())    { print "\nVirtual Host:\t\t",
virtual_host()       }
#if (server_port())     { print "\nServer Port:\t\t",
server_port()         }
#if (user_agent())      { print "\nUser Agent:\t\t",
user_agent()           }
#if (user_name())       { print "\nUser Name:\t\t",
user_name()             }


Or a better example:

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

use CGI qw(:all);
use strict;
#use diagnostics;
#print header;

my $basedir = '/drv2/usr/ns-home/cgi-src'; # Enter Directory Pathing...
my ($hr_link, $hr_tlink) = '';
my $flag = 1; # Set the trip wire...

# Location & Name of Log file...
my($reportLog) = '/drv2/usr/ns-home/docs/Referrers.html';

if (referer()) {
    open (inpFile, "$basedir/Targets") || die("Can't open $! <BR>");
	while (<inpFile>) {
	    chomp;
	    ($hr_link, $hr_tlink) = split /\|/;
	    next unless $hr_link eq referer();

	    $flag = 0; # We have a match!
	    last;  # We are out of here...
	}
}

# Write out log...
    open(outFile, "+>>$reportLog") or die("Cannot open $reportLog:
$!\n");
#............................................................................
print outFile "<HR NOSHADE>Referrer from ";

#(remote_host()) ? print outFile "Host: ", remote_host()
#                : print outFile "Address: ", remote_addr();
# if (accept()) { print "<BR>Browser MIME List: &nbsp;", accept() }
# if (auth_type()) { print outFile "<BR>Authentication Type: &nbsp;",
auth_type() }
# if (raw_cookie()) { print outFile "<BR>Raw Cookie: &nbsp;",
raw_cookie() }
# if (query_string()) { print outFile "<BR>Query String: &nbsp;",
query_string() }

if (referer()) { 
   print outFile "<a href=", referer();
   print outFile ">", referer();
   print "</a>";
} else {
   print outFile "NONE.  Client hit Script $0 directly.";
}

# if (remote_addr()) { print outFile "<BR>Remote Addr: &nbsp;",
remote_addr() }
# if (remote_ident()) { print outFile "<BR>Remote Ident: &nbsp;",
remote_ident() }
# if (remote_host()) { print outFile "<BR>Remote Host: &nbsp;",
remote_host() }
# if (remote_user()) { print outFile "<BR>Remote User: &nbsp;",
remote_user() }
# if (request_method())  { print outFile "<BR>Request Method: &nbsp;",
request_method() }
# if (virtual_host()) { print outFile "<BR>Virtual Host: &nbsp;",
virtual_host() }
# if (server_port()) { print outFile "<BR>Server Port: &nbsp;",
server_port() }
# if (user_agent()) { print outFile "<BR>User Agent: &nbsp;",
user_agent() }
# if (user_name()) { print outFile "<BR>User Name: &nbsp;", user_name()
}
        
print outFile " &nbsp;logged: ", scalar localtime;
#............................................................................
    close(outFile) or die("Cannot close $reportLog: $!\n");
# Done writing log...

if ($flag)  {
	$hr_link  = '';

	$hr_tlink = "http://webmaster.fccj.org/Webmaster";
}

print "Location: $hr_tlink\n\n";  # They are sent here immediately...
exit;

-Sneex-  :]
__________________________________________________________________
Bill Jones | FCCJ Webmaster | Murphy's Law of Research:
           Enough research will tend to support your theory.


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

Date: Mon, 31 Aug 1998 21:23:50 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Win32::Console For Password Entry
Message-Id: <MPG.105516a4135a3348989683@news.south-carolina.net>

In article <6ra9cp$p41$1@nnrp1.dejanews.com> on Sat, 29 Aug 1998 
14:42:01 GMT, shawn_campbell@my-dejanews.com (shawn_campbell@my-
dejanews.com) pounded in the following text:
=> I went to the archives for this solution.  It is exactly what I need.  One
=> problem however; if the user
=> enters a zero, the line-
=>    $key = $Console->InputChar(1) || die "Error reading character";
=> fails.  What if my user has a zero in their username or password?
=> Note- I have tried every other character on the keyboard, and only the zero
=> fails.

It's doing exactly what it's supposed to do.  If the above 
statement is written like this:

unless ( $key = $Console->InputChar(1) )
{
	die "Error reading character";
}

do you see what's happening?

Basically <GUESS> InputChar returns the key typed </GUESS> and if 
that key happens to be 0, the unless is successful, and so the 
die is called.

=> 
=> Thanks,

No problem, hope it helped... :)

--Matthew


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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