[15597] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3010 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 10 21:05:38 2000

Date: Wed, 10 May 2000 18:05:12 -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: <958007112-v9-i3010@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 10 May 2000     Volume: 9 Number: 3010

Today's topics:
    Re: after the whatever.cgi?  question? <jeff@vpservices.com>
        Best Mail module? <crossbach@atgi.net>
    Re: CGI and Upload/Download <jim_tyler@eli.net>
    Re: CGI and Upload/Download <lr@hpl.hp.com>
        COBOL subroutines in Perl? <drdoc@mail.utexas.edu>
    Re: Commifying <lr@hpl.hp.com>
    Re: Commifying (Abigail)
    Re: Commifying (Bart Lateur)
    Re: Commifying (Andrew Johnson)
    Re: Commifying <kristor@NOcuchulainSPAM.com>
        Correction: fork does not work properly on NT! <robert.ioffe@intel.com>
        fork does not work properly on NT! <robert.ioffe@intel.com>
        how do I redirect output/filehandles? jlamport@calarts.edu
    Re: how do I redirect output/filehandles? (Bart Lateur)
    Re: HOW:  I want to set the time... <andrew.mcguire@walgreens.com>
    Re: HOW:  I want to set the time... (David Efflandt)
        Iteration <andy@u2me3.com>
    Re: Iteration <makarand_kulkarni@My-Deja.com>
    Re: Net::Telnet question (David Efflandt)
    Re: Object Question <aqumsieh@hyperchip.com>
    Re: Printing Arrays <uri@sysarch.com>
    Re: Proper use of resources (was Re: more regexp madnes (Eric Bohlman)
    Re: Quality of perl implementations aradia@aracnet.com
        Question !!! (Beginner question !) (!)
    Re: Question !!! (Beginner question !) (Mark Badolato)
    Re: removing carriage returns from a form entry <mj.stevenson@auckland.ac.nz>
        Still having problems with cgi under IIS <Hamza.Sadiq@bridge.bellsouth.com>
    Re: Still having problems with cgi under IIS (Paul J. Bosselaers)
    Re: taint workin <mjmatt@qsun.att.com>
    Re: Two Perl Syntax Question <raju_kotha@yahoo.com>
    Re: Two Perl Syntax Question <raju_kotha@yahoo.com>
    Re: Two Perl Syntax Question (Bart Lateur)
    Re: Where's the FAQ? <rootbeer@redcat.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 10 May 2000 15:06:26 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: after the whatever.cgi?  question?
Message-Id: <3919DD62.9FCB56A1@vpservices.com>

Jeff Winner wrote:
> 
> Whats this CGI.pm do i download and put it on my server or what?

CGI.pm is a module that does just about everything you need to do with
CGI in Perl.  If your server has a version of perl that is anywhere near
recent, it will already have CGI.pm installed.  To test it out to see if
it is installed, write this simple script (change the first line to be
whatever the first line of your scripts usually is).

#!/usr/local/bin/perl -Tw
use strict;
use CGI qw(:all);
use CGI::Carp qw(fatalsToBrowser);
print header, "It works!";

If you don't see the words "It works!", then you've either made a typo,
or your first line is wrong, or you don't have CGI.pm on your server. 
If it turns out you don't have it on your server, look for information
on downloading and installing modules (www.activestate.com for windoze
or www.cpan.org for anything else).

-- 
Jeff (the other one)


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

Date: Wed, 10 May 2000 17:00:56 -0700
From: Cynthia Rossbach <crossbach@atgi.net>
Subject: Best Mail module?
Message-Id: <3919F838.657F8231@atgi.net>

Hi All,

Im working on a program that will need to send mail as well has read the
body of mail messages. The server has "mail", "sendmail", "Qmail".
Solaris 8, Perl 5.6.

I would appreciate any and all suggestions on the best module for my
needs.

TIA, Cynthia



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

Date: Wed, 10 May 2000 22:56:08 GMT
From: Jim_Tyler <jim_tyler@eli.net>
Subject: Re: CGI and Upload/Download
Message-Id: <3919E91C.7C1B2138@eli.net>

I would just print to standard out a content type header and two newlines, then
open the file and send to standard out.  Then the browser can handle how to deal
with the file based on the content type (which you could define for yourself).

JT

Callum wrote:

> I have a simple problem but do not know how to fix it.  I can easily upload
> a file from the client to the server using standard multi-part forms, but
> how do I get a file from the server to the client ?
> I have been looking for a solution to this for ages, it must be simple but I
> just can't find a Perl example anywhere.
>
> If any of you enlightend Perl users out there know the answer I would really
> like to know !
>
> I would appreciate any response e-mailed to : cmacalli@fsmail.net
>
> Many thanks for all your help.
>
>                                                         Kind Regards
>
>                                                         Callum

--
Jim Tyler
Sr. UNIX Systems Administrator
Electric Lightwave, Inc.




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

Date: Wed, 10 May 2000 15:59:29 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: CGI and Upload/Download
Message-Id: <MPG.138389ae4279784198aa53@nntp.hpl.hp.com>

In article <8fcf7t$666$1@news6.svr.pol.co.uk> on Wed, 10 May 2000 
20:58:17 +0100, Callum <callum@online-home.freeserve.co.uk> says...
> I have a simple problem but do not know how to fix it.  I can easily upload
> a file from the client to the server using standard multi-part forms, but
> how do I get a file from the server to the client ?
> I have been looking for a solution to this for ages, it must be simple but I
> just can't find a Perl example anywhere.
> 
> If any of you enlightend Perl users out there know the answer I would really
> like to know !

Is there less here than meets the eye?

To get a file from the server to the client, you use the Perl print() 
function to send: first, an appropriate header that tells the client 
what data to expect; then two sequential empty lines to signify the end 
of the header information; then the data stream.  You have no direct 
control over what the client does with what it receives.

> I would appreciate any response e-mailed to : cmacalli@fsmail.net

Unfortunately, that's not the From: address, and you didn't supply a 
Reply-to: address.

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


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

Date: 10 May 2000 18:23:17 -0500
From: Doc Shipley <drdoc@mail.utexas.edu>
Subject: COBOL subroutines in Perl?
Message-Id: <3919F13E.C44D2AC8@mail.utexas.edu>

I'm posting this for a friend stranded in VPN-Land, and I'm not familiar
with perl, si please forgive the crosspost....

> Is it possible to call a COBOL subroutine in a perl
> script? I know I can call a compiled COBOL program,
> but what about an interpreted subroutine? 

-- 
 Doc Shipley
 Network Support
 TARL Labs, UT
 Austin, Texas


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

Date: Wed, 10 May 2000 15:10:57 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Commifying
Message-Id: <MPG.13837e516116f6c798aa52@nntp.hpl.hp.com>

In article <zFiS4.2188$gl2.87839@typhoon1.ba-dsg.net> on Wed, 10 May 
2000 19:22:07 GMT, Chris Williams <kristor@NOcuchulainSPAM.com> says...
> I'm trying to put commas in the output of larger numbers and I came across
> the following subroutine in the Cookbook that is fine except it places a
> leading comma even if there is no number in front of it. ie;
> $,123,456.78... looks dumb... right? Any thoughts would help.
> 
> Thanks
> 
> sub commify {
>      my $text = reverse $_[0];
>      $text =~ s/(\d\d\d)(?!\d*\.)/$1,/g;
>      return scalar reverse $text;
> }

The version in my copy of the Cookback (p. 64 bottom) and in perlfaq5 
has a look'ahead' for another digit:

       $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;

Did you simply overlook that when typing the code in?

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


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

Date: 10 May 2000 22:43:06 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Commifying
Message-Id: <slrn8hjpfo.h6o.abigail@ucan.foad.org>

On Wed, 10 May 2000 21:42:43 GMT, Andrew Johnson <andrew-johnson@home.com> wrote
++ In article <zFiS4.2188$gl2.87839@typhoon1.ba-dsg.net>,
++  Chris Williams <kristor@NOcuchulainSPAM.com> wrote:
++ > I'm trying to put commas in the output of larger numbers and I came across
++ > the following subroutine in the Cookbook that is fine except it places a
++ > leading comma even if there is no number in front of it. ie;
++ > $,123,456.78... looks dumb... right? Any thoughts would help.
++ > 
++ > Thanks
++ > 
++ > sub commify {
++ >      my $text = reverse $_[0];
++ >      $text =~ s/(\d\d\d)(?!\d*\.)/$1,/g;
++ >      return scalar reverse $text;
++ > }
++ 
++ My copy of the cookbook shows the commify routine with the
++ same regex as is in the FAQ:
++ 
++     s<(\d\d\d)(?=\d)(?!\d*\.)><$1,>g;
++               ^^^^^^


The disadvantage of that is that the (?!\d*.) makes it quadratic in
the lenght of the string - as it has to scan the rest of the string
foreach inserted comma. (Also, the above regex prevents "1000.0" 
from being commified as "1,000.0" - it will commify "1000.0001"
as "1000.000,1" though. Is that really what one wants?)

Here's another way of doing it:

     substr ($string, (length ($string) % 3) || 3) =~ s/(\d\d\d)/,$1/;

(Although that doesn't take care of the existance of a .).



Abigail


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

Date: Wed, 10 May 2000 23:37:55 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Commifying
Message-Id: <391bf203.4232959@news.skynet.be>

Abigail wrote:

>++     s<(\d\d\d)(?=\d)(?!\d*\.)><$1,>g;
>++               ^^^^^^
>
>
>The disadvantage of that is that the (?!\d*.) makes it quadratic in
>the lenght of the string - as it has to scan the rest of the string
>foreach inserted comma.

Quadratic -- so what. We're not talking about millions of charatcer
here. We talking about strings of, say, at most 15 digits.. Granted,
it's not ideal, but it doesn't really hurt, as it doesn't neeed to scale
up.

>(Also, the above regex prevents "1000.0" 
>from being commified as "1,000.0" - it will commify "1000.0001"
>as "1000.000,1" though. Is that really what one wants?)

You must have overlooked the fact that the string is reversed before and
after the commify. I had. It's not in the part you quoted. So
"1000.000,1" is really "1,000.0001".

-- 
	Bart.


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

Date: Thu, 11 May 2000 00:36:48 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Commifying
Message-Id: <AgnS4.11780$95.151691@news1.rdc1.mb.home.com>

In article <slrn8hjpfo.h6o.abigail@ucan.foad.org>,
 Abigail <abigail@foad.org> wrote:
> On Wed, 10 May 2000 21:42:43 GMT, Andrew Johnson <andrew-johnson@home.com> wrote
[snip]
> ++     s<(\d\d\d)(?=\d)(?!\d*\.)><$1,>g;
> ++               ^^^^^^
> 
> 
> The disadvantage of that is that the (?!\d*.) makes it quadratic in
> the lenght of the string - as it has to scan the rest of the string
> foreach inserted comma. (Also, the above regex prevents "1000.0" 
> from being commified as "1,000.0" - it will commify "1000.0001"
> as "1000.000,1" though. Is that really what one wants?)

in the context of the commify routine (as in the cookbook or
the FAQ) in which my reply was intended, the regex works fine:

#!/usr/bin/perl -w
use strict;

$_ = '1000.0 and 1000.0001 and 3.14159 and $123456789.987654321';
print commify($_);

sub commify {
    my $input = shift;
    $input = reverse $input;
    $input =~ s<(\d\d\d)(?=\d)(?!\d*\.)><$1,>g;
    return scalar reverse $input;
}
__END__

output:
1,000.0 and 1,000.0001 and 3.14159 and $123,456,789.987654321

regards
andrew

-- 
Andrew L. Johnson   http://members.home.net/andrew-johnson/epwp.html
      Reality is that which, when you stop believing in 
      it, doesn't go away.
          -- Philip K. Dick
      


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

Date: Thu, 11 May 2000 00:48:51 GMT
From: "Chris Williams" <kristor@NOcuchulainSPAM.com>
Subject: Re: Commifying
Message-Id: <TrnS4.2405$gl2.101468@typhoon1.ba-dsg.net>


> The version in my copy of the Cookback (p. 64 bottom) and in perlfaq5
> has a look'ahead' for another digit:
>
>        $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
>
> Did you simply overlook that when typing the code in?

Hmm... so what you might be saying is omissions brought about by a severe
case of dyslexia aren't going to help my cause.

I now see the error of my ways.

Thanks to everyone for your help!




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

Date: Wed, 10 May 2000 16:07:52 -0700
From: "Ioffe, Robert" <robert.ioffe@intel.com>
Subject: Correction: fork does not work properly on NT!
Message-Id: <3919EBC8.626105B7@intel.com>


--------------A0FE7487FBA63969B6EE95AE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Folks,

The code in the previous message had a typo. Below is corrected code,
but it still has a problem described.

Robert

"Ioffe, Robert" wrote:

> Folks,
>
> I just installed ActiveState Perl 5.6.0 build 613 and want to try
> running my testcases in parallel by forking them. Each testcase is
> relatively heavy on resourses and I have 40 of them. That means that
> after several forks I expect fork to fail, which it prompty does after
> 12 testcases producing the following line:
>
> panic: pseudo fork() failed at regtestout.pl line 25.
>
> The 'right' fork behavior is to return either 0 (child), pid (parent),
> or undefined (fork failed), so I expect third value in my case and I
> never get it! Something happens to parent process (it dies? but then
> it should kill all its offspring according to documentation), so I
> never hear from it again, but all 12 spawned children finish properly.
>
> See part of my code below. Please help or let me know how to get
> around this problem properly (right now I just sleep for a minute
> after I spawn 10 testcases).
>
> Robert Ioffe (Robert.Ioffe@intel.com)
>
> foreach $hash_ref (@hash_refs) {
>         while (!defined($pid = fork())) { # Here is line 25
>                print "$$: Well, it seems we are out of system
> resourses: $!";
>                print "$$: No problem, we will sleep for a while!\n";
>                sleep(30);
>                print "$$: I am awake now - lets do more forking\n";
>         }
>         if ($pid == 0) {
>                 print "$$: ", $hash_ref->{'testcase_line'};
>                 print "$$: Running ", $hash_ref->{'command_line'};
>                 system($hash_ref->{'command_line'});
>                 print "$$: Done. ", $hash_ref->{'testcase_line'};
>                 exit;
>         }
>         print "$$: Just spawned $pid\n";
> }
> print "$$: Regression test complete!\n";
> print "$$: Well not really - we have to wait for all the kids to
> die!\n";

--------------A0FE7487FBA63969B6EE95AE
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Folks,
<p>The code in the previous message had a typo. Below is corrected code,
but it still has a problem described.
<p>Robert
<p>"Ioffe, Robert" wrote:
<blockquote TYPE=CITE>Folks,
<p>I just installed ActiveState Perl 5.6.0 build 613 and want to try running
my testcases in parallel by forking them. Each testcase is relatively heavy
on resourses and I have 40 of them. That means that after several forks
I expect fork to fail, which it prompty does after 12 testcases producing
the following line:
<p>panic: pseudo fork() failed at regtestout.pl line 25.
<p>The 'right' fork behavior is to return either 0 (child), pid (parent),
or undefined (fork failed), so I expect third value in my case and I never
get it! Something happens to parent process (it dies? but then it should
kill all its offspring according to documentation), so I never hear from
it again, but all 12 spawned children finish properly.
<p>See part of my code below. Please help or let me know how to get around
this problem properly (right now I just sleep for a minute after I spawn
10 testcases).
<p>Robert Ioffe (Robert.Ioffe@intel.com)
<p><font face="Courier New,Courier"><font size=-2>foreach $hash_ref (@hash_refs)
{</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
while (!defined($pid = fork())) { # Here is line 25</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: Well, it seems we are out of system resourses: $!";</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: No problem, we will sleep for a while!\n";</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
sleep(30);</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: I am awake now - lets do more forking\n";</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if ($pid == 0) {</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: ", $hash_ref->{'testcase_line'};</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: Running ", $hash_ref->{'command_line'};</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
system($hash_ref->{'command_line'});</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: Done. ", $hash_ref->{'testcase_line'};</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
exit;</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: Just spawned $pid\n";</font></font>
<br><font face="Courier New,Courier"><font size=-2>}</font></font>
<br><font face="Courier New,Courier"><font size=-2>print "$$: Regression
test complete!\n";</font></font>
<br><font face="Courier New,Courier"><font size=-2>print "$$: Well not
really - we have to wait for all the kids to die!\n";</font></font></blockquote>
</html>

--------------A0FE7487FBA63969B6EE95AE--



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

Date: Wed, 10 May 2000 16:03:30 -0700
From: "Ioffe, Robert" <robert.ioffe@intel.com>
To: Robert.Ioffe@intel.com
Subject: fork does not work properly on NT!
Message-Id: <3919EAC2.DCEB51E7@intel.com>


--------------349A00BA978FA15EF2CFE6E6
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Folks,

I just installed ActiveState Perl 5.6.0 build 613 and want to try
running my testcases in parallel by forking them. Each testcase is
relatively heavy on resourses and I have 40 of them. That means that
after several forks I expect fork to fail, which it prompty does after
12 testcases producing the following line:

panic: pseudo fork() failed at regtestout.pl line 25.

The 'right' fork behavior is to return either 0 (child), pid (parent),
or undefined (fork failed), so I expect third value in my case and I
never get it! Something happens to parent process (it dies? but then it
should kill all its offspring according to documentation), so I never
hear from it again, but all 12 spawned children finish properly.

See part of my code below. Please help or let me know how to get around
this problem properly (right now I just sleep for a minute after I spawn
10 testcases).

Robert Ioffe (Robert.Ioffe@intel.com)

foreach $hash_ref (@hash_refs) {
        my $pid = fork();
        while (!defined($pid = fork())) { # Here is line 25
               print "$$: Well, it seems we are out of system resourses:
$!";
               print "$$: No problem, we will sleep for a while!\n";
               sleep(30);
               print "$$: I am awake now - lets do more forking\n";
        }
        if ($pid == 0) {
                print "$$: ", $hash_ref->{'testcase_line'};
                print "$$: Running ", $hash_ref->{'command_line'};
                system($hash_ref->{'command_line'});
                print "$$: Done. ", $hash_ref->{'testcase_line'};
                exit;
        }
        print "$$: Just spawned $pid\n";
}
print "$$: Regression test complete!\n";
print "$$: Well not really - we have to wait for all the kids to
die!\n";

--------------349A00BA978FA15EF2CFE6E6
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Folks,
<p>I just installed ActiveState Perl 5.6.0 build 613 and want to try running
my testcases in parallel by forking them. Each testcase is relatively heavy
on resourses and I have 40 of them. That means that after several forks
I expect fork to fail, which it prompty does after 12 testcases producing
the following line:
<p>panic: pseudo fork() failed at regtestout.pl line 25.
<p>The 'right' fork behavior is to return either 0 (child), pid (parent),
or undefined (fork failed), so I expect third value in my case and I never
get it! Something happens to parent process (it dies? but then it should
kill all its offspring according to documentation), so I never hear from
it again, but all 12 spawned children finish properly.
<p>See part of my code below. Please help or let me know how to get around
this problem properly (right now I just sleep for a minute after I spawn
10 testcases).
<p>Robert Ioffe (Robert.Ioffe@intel.com)
<p><font face="Courier New,Courier"><font size=-2>foreach $hash_ref (@hash_refs)
{</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
my $pid = fork();</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
while (!defined($pid = fork())) { # Here is line 25</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: Well, it seems we are out of system resourses: $!";</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: No problem, we will sleep for a while!\n";</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
sleep(30);</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: I am awake now - lets do more forking\n";</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if ($pid == 0) {</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: ", $hash_ref->{'testcase_line'};</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: Running ", $hash_ref->{'command_line'};</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
system($hash_ref->{'command_line'});</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: Done. ", $hash_ref->{'testcase_line'};</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
exit;</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</font></font>
<br><font face="Courier New,Courier"><font size=-2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
print "$$: Just spawned $pid\n";</font></font>
<br><font face="Courier New,Courier"><font size=-2>}</font></font>
<br><font face="Courier New,Courier"><font size=-2>print "$$: Regression
test complete!\n";</font></font>
<br><font face="Courier New,Courier"><font size=-2>print "$$: Well not
really - we have to wait for all the kids to die!\n";</font></font></html>

--------------349A00BA978FA15EF2CFE6E6--



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

Date: Wed, 10 May 2000 22:16:05 GMT
From: jlamport@calarts.edu
Subject: how do I redirect output/filehandles?
Message-Id: <8fcn2p$4fs$1@nnrp1.deja.com>

What's the best way of redirecting output from one filehandle to another?
E.g. if I wanted STDERR to be redirected to STDOUT, or to go to a log
file instead of to the screen, or if I wanted a filehandle called DEBUG
which I could reassign to STDOUT, STDERR, or a log file depending... ?

Would pipe() do what I want?  The perldocs don't say much except that it
works just like the system call, and "man pipe" on my system doesn't tell
me anything useful.

Now, I know this is a case where TMTOWTDI, but knowing me, if left to my
own devices, I'm sure I would come up with the most utterly hackish,
difficult, crack-headed way of doing it, and miss some much better,
simpler solution.  That's why I'm asking here first.  :)

-jason


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


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

Date: Wed, 10 May 2000 22:40:06 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: how do I redirect output/filehandles?
Message-Id: <3919e4a4.809539@news.skynet.be>

jlamport@calarts.edu wrote:

>What's the best way of redirecting output from one filehandle to another?
>E.g. if I wanted STDERR to be redirected to STDOUT, or to go to a log
>file instead of to the screen, or if I wanted a filehandle called DEBUG
>which I could reassign to STDOUT, STDERR, or a log file depending... ?

	open STDERR, ">&STDOUT";

This will not work in external called programs.

As for a log file:

	open STDERR, ">logfile.log";


Spice up with error checking at will.

-- 
	Bart.


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

Date: Wed, 10 May 2000 17:06:01 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: HOW:  I want to set the time...
Message-Id: <3919DD49.C064D3F8@walgreens.com>

Lou Moran wrote:
> 
> ---I would like to set the time on my system to a timeserver like the
> one in boulder colorado...

OK.

> ---I have a win9x app that does this called atomtime, but I'd like to
> write my own in Perl for my Linux machines...

Don't reinvent the wheel.

> ---I need to know two things (stares at feet, shoves hands in pockets)
> what is the URL of a timeserver?

Don't think you need a URL, just an IP, or FQDN.
 
> ---to set time in linux do I need to give the script root access?
> that would be bad right?

Why not just use xntpd?  NTP = Network Time Protocol.
 
> clue free...

Apparently. :-)  There really is no Perl question here.
I would look in comp.os.linux, after reading the NTP documentation
that came with your distribution.  I beleive xntpd is what
you are looking for, and it is relatively easy to configure.

Cheers,

anm
-- 
Andrew N. McGuire
andrew.mcguire@walgreens.com


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

Date: 11 May 2000 00:57:39 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: HOW:  I want to set the time...
Message-Id: <slrn8hk1c3.3pr.efflandt@efflandt.xnet.com>

On Wed, 10 May 2000, Andrew N. McGuire <andrew.mcguire@walgreens.com> wrote:
>Lou Moran wrote:
>> 
>> ---I would like to set the time on my system to a timeserver like the
>> one in boulder colorado...
>
>Apparently. :-)  There really is no Perl question here.
>I would look in comp.os.linux, after reading the NTP documentation
>that came with your distribution.  I beleive xntpd is what
>you are looking for, and it is relatively easy to configure.

Actually ntpdate is all he needs from the xntp package.  The html docs
link to a list of statum 2 time servers.

-- 
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: Wed, 10 May 2000 23:17:45 +0100
From: "Andy Chantrill" <andy@u2me3.com>
Subject: Iteration
Message-Id: <8fcn5b$nfv$1@uranium.btinternet.com>

Hey,

Is it possible for me to iterate through the following hash structure in a
"while", or even better; maybe a "for" loop? For example, I want to do
something like the following:

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

${$hash{'key1'}}[0] = "value1";
${$hash{'key1'}}[1] = "value2";
${$hash{'key2'}}[0] = "value3";
${$hash{'key2'}}[1] = "value4";

while (($key, @values) = each %hash) {
    $values = join(',', @values);
    print "$key : $values\n";
}
--

Possible? If so how?  :o)


Thanks, Andy.
andy@u2me3.com




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

Date: Wed, 10 May 2000 15:49:11 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Iteration
Message-Id: <3919E767.111CEA92@My-Deja.com>

> Is it possible for me to iterate through the following hash structure in a
> "while", or even better; maybe a "for" loop? For example, I want to do
> something like the following:

essentially you have a HoL
check
perldoc perldsc

eg
my %hash;
${$hash{'key1'}}[0] = "value1";
${$hash{'key1'}}[1] = "value2";
${$hash{'key2'}}[0] = "value3";
${$hash{'key2'}}[1] = "value4";

foreach ( keys %hash )
        {
        print join '|', @{$hash{$_}};
        print "\n";
        }
--



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

Date: 11 May 2000 01:01:15 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Net::Telnet question
Message-Id: <slrn8hk1ir.3pr.efflandt@efflandt.xnet.com>

On Wed, 10 May 2000 18:25:07 GMT, Aran Meuser <aran@mapcruzin.com> wrote:
>Go to your command prompt (dos shell) and type "ppm".  This will start the
>Perl Package Manager for ActivePerl.  Then, you can do several things like
>search, install, uninstal, etc, but they provide a good help for it all.
>You'll see what I mean when you run it.
>
>Aran
>
><bahram22@my-deja.com> wrote in message news:8fc8km$j7h$1@nnrp1.deja.com...
>> I want to do something simple, I want to telnet
>> automatically from my NT PC to another remote
>> host, run some commands and parse the output on
>> my local PC.  After some investigation I found
>> out that the NET/telnet.pm module can help me
>> with this.  I even found some examples.
>>
>> However, I cannot find the NET::telnet.pm module
>> on my PC.  I have installed ActivePerl5.6 on my
>> WIN NT machine.  Is there a site that I can
>> download this particular module?  Any other
>> pointers will be greatly appreciated!

Not sure if Win version is case sensitive, but look for "Net::Telnet",
not "NET::telnet".

>> Warmest Regards,
>>
>> Bahram

-- 
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: Wed, 10 May 2000 23:04:15 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Object Question
Message-Id: <7abt2e80sv.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>


"spurcell" <skpurcell@hotmail.com> writes:

> use Tk;
> my $mw = MainWindow->new; # is this a constructor or what is this?

Yes. It calls the method new() in the Tk class. The method
returns a new MainWindow object (just a blessed hash, really).

> my $t = $mw->Scrolled('Text');  # likewise, what kind of data structure is
> this?

It calls the method Scrolled().
The main thing to keep in mind is that, in Perl, a method (in OO jargon)
is simply a subroutine. By default, the first variable passes to the
subroutine is the object (or class) that is used to invoke it. Ie:

	MainWindow->new();

is another way of saying:

	new('MainWindow');

> Anyway, if someone out there has time to explain or point me somewhere to
> get an explanation, I would be very happy,

There are several good pods on OOPerl:

	perlobj
	perltoot
	perlbot
	perlboot

Also, there is a very good book out there called "Object Oriented Perl"
by Damian Conway (a clpmisc lurker). I recommend that you buy it.

--Ala


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

Date: Wed, 10 May 2000 23:36:09 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Printing Arrays
Message-Id: <x73dnqt1uh.fsf@home.sysarch.com>

>>>>> "TW" == The WebDragon <nospam@devnull.com> writes:

  TW>  | dataList
  TW>  | filesList
  TW>  | grabFile
  TW>  | inputDir
  TW>  | 
  TW>  | No offense, but I hate that naming convention with a passion bordering 
  TW>  | on
  TW>  | obsession.  ("Let's see now, which letter was uppercase?")  :{D

  TW> as for the naming thing, TMTOWTDI, right? (: 

  TW> I use the same thing while mucking around in Tcl too, and it seems to 
  TW> work fine there as well =) 

defending anything by saying tcl does it is a lost cause. how about
making EACH of their functions into its onw man page installed with the
rest of the manuals. man of any common name gets me the useless tcl
command man page. brilliant organization in that group.

  TW> *flee*

you can't flee if you keep coming back for more questions.

yes, studly caps works in perl as it would in any normal language with
cased identifiers. but it still sicks in any language. separating words
is why ${DEITY} gave us the underscore char. and in the perl culture
(the only true one), underscore is used and studly caps are rightfully
reviled.

uri

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


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

Date: 11 May 2000 00:11:53 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Proper use of resources (was Re: more regexp madness extracting data from files.)
Message-Id: <8fcts9$4k1$1@nntp9.atl.mindspring.net>

The WebDragon (nospam@devnull.com) wrote:
: here's the final script: fileGrab2.pl
: #!perl -w
: use strict;
: use diagnostics -verbose;
: use LWP::UserAgent;
: use File::Spec;
: 
: my $inputDir = File::Spec->catfile( File::Spec->curdir(), 'input_files', 
: '');
: my $baseURL = "http://www.planetunreal.com/nalicity/";
: 
: #fixed fileslist
: #my @filesList = qw(
: #    ut_assault_maps.htm
: #    ut_capturetheflag_maps.htm
: #    ut_dm_maps.htm
: #    ut_dm_maps_b.htm
: #    ut_domination_maps.htm
: #    ut_other_maps.htm
: #);
: 
: #active fileslist
: opendir(DIR, $inputDir) || die ("Cannot opendir $inputDir : $!");
:     my @filesList = readdir(DIR);
: closedir DIR;

It does seem as if your program is building up an awful lot of 
"in-process inventory" at several different stages.  Here you build up a 
complete list of files...

: for (@filesList) {
:     my $ua = new LWP::UserAgent;
:     my $request = new HTTP::Request 'GET' => $baseURL . $_;
:     my $response = $ua->request($request);
:     die "$baseURL $_ failed: ",$response->error_as_HTML 
:         unless $response->is_success;
: 
:     open(OUT, ">$inputDir$_") or die ('Aieeeeee');
:     print OUT $response->content;
:     close OUT;
: };

And here you loop over the whole list grabbing the new versions.  You 
could have done everything one at a time, reading each directory entry 
and immediately grabbing it rather than building inventory in @fileslist.

Just about everything in this loop *could* be done with a call to 
LWP::Simple's getstore() method; the only difference I can see is that 
the diagnostics wouldn't be quite as good.  But read on.

: my @dataList;
: for (@filesList) {
:     my $grabFile = $inputDir . $_;
:     open(GRAB, "<$grabFile") or die ("Cannot open file $grabFile : $!");
: #   print "Successful open of $grabFile\n";
:     push @dataList, "-- $_\n";
:     while(<GRAB>) {
:         tr/\r//d;
:         next unless /^\Qmaps[i++] = new Map(\E([^)]+)/;
:         push @dataList, "$1\n" ;
: #       print "$1\n";
:     }
:     close (GRAB);
: };

Here you could save a lot of time if you were processing each file
completely in sequence, because you'd already have the complete text of
each file from the previous step and therefore wouldn't need to reread it. 

: 
: open(OUT, ">maps_list.txt") or die ("DOH! can't create the maps list : 
: $!");
: #   for (@dataList) { print OUT "$_\n" }
:     print OUT @dataList;
: close (OUT);
: __END__

Again, you could keep OUT open for the entire duration and just write to 
it as you generate entries rather than squirreling them all away in 
@dataList.



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

Date: Wed, 10 May 2000 19:48:37 GMT
From: aradia@aracnet.com
Subject: Re: Quality of perl implementations
Message-Id: <p2jS4.699$NX3.15623@typhoon.aracnet.com>

In comp.lang.perl.moderated Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:

>> 	I have managed to produce a program that is fairly large, is in
>> 	fairly wide use, and is entirely (or almost) in Perl.

> Which still does not make Perl a programming language.

Hmmm. People have written programs. They've used Perl to write said
programs. Yeah, that makes it a programming language. Unless your
definition of "programming language" does not include "a language used to
program a computer". Don't people get tired of the programming language
v. scripting language argument?

Alas, I just started another game of chess. Gotta run.


-- Sean...

#!/usr/bin/perl
$j=\$j;{$_=unpack(P24,pack(L,$j));/Just Another Perl Hacker/?print:$j++&&redo}


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

Date: Wed, 10 May 2000 23:07:22 GMT
From: Roberto^&(!) <tjuana@my-deja.com>
Subject: Question !!! (Beginner question !)
Message-Id: <8fcq30$7nl$1@nnrp1.deja.com>

Hi guys !  (I need some help) Does anyone know where can I get some good
information and how can I install perl to my computer ! I'm using windows 98
and I would like to start learning cgi programming Any help around here ..
!!! Thanks


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


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

Date: 10 May 2000 23:22:24 GMT
From: mbadolato@quepasa.com (Mark Badolato)
Subject: Re: Question !!! (Beginner question !)
Message-Id: <8F30AAC2Ambadolatoquepasacom@206.165.3.80>

On 10 May 2000, tjuana@my-deja.com (Roberto^&(!)) wrote in
<8fcq30$7nl$1@nnrp1.deja.com>: 

>Hi guys !  (I need some help) Does anyone know where can I get
>some good information and how can I install perl to my computer !
>I'm using windows 98 and I would like to start learning cgi
>programming Any help around here .. !!! Thanks

You managed to find your way onto Usenet and into comp.lang.perl.misc 
but didn't bother to even try looking for http://www.perl.com/ on the 
web?

--mark


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

Date: Thu, 11 May 2000 10:31:44 +1200
From: Matthew Stevenson <mj.stevenson@auckland.ac.nz>
Subject: Re: removing carriage returns from a form entry
Message-Id: <3919E350.6B57CFC1@auckland.ac.nz>

chris wrote:
> 
> unfortunately, when i enter carriage returns into the form they still
> show up in the data file and it screws the whole database up.
> 
> i think the problem might lie in the somewhere else--the form input does
> not come in as an array, although the input fields do correspond to
> @db_user_definable_field_order.
> 
> i get form data in like this:
> 
> $form_data{'field_name_goes_here'}
> 
> so maybe the beginning of those lines is wrong.  i have tried the
> following variations:
> 
> ######################################################
> foreach $field (@db_user_definable_field_order)
>   {
>    $form_data{$field} =~ s/\|//mg; # removes pipes
>    $form_data{$field} =~ s/\n//mg; # removes returns
>   }

try

foreach $field (@db_user_definable_field_order)
   {
    # remove newlines and carrage returns
    $form_data{$field} =~ tr/\015\012//d; 
   }

Matthew
-- 

Matthew Stevenson
University of Auckland
mj.stevenson@auckland.ac.nz


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

Date: Wed, 10 May 2000 18:59:10 -0400
From: Hamza Sadiq <Hamza.Sadiq@bridge.bellsouth.com>
Subject: Still having problems with cgi under IIS
Message-Id: <3919E9BE.BBB1574E@bridge.bellsouth.com>

Hi everyone,

I am still having problems running perl/cgi scripts through my browser.
It works find from the command prompt but shows up as text in my
browser.  I've tried following the previous info giving in this
newsgroup but to no avail.  my code is as follows:

#!C:\Perl\bin\perl


use lib ("C:/perl/lib/");

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

print "Hello";

Any help is gladly appreciated.  Thanks.

Cedron



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

Date: Thu, 11 May 2000 00:40:16 GMT
From: paulboss@erols.com (Paul J. Bosselaers)
Subject: Re: Still having problems with cgi under IIS
Message-Id: <8fcvgl$doc$1@bob.news.rcn.net>

In article <3919E9BE.BBB1574E@bridge.bellsouth.com>, Hamza Sadiq <Hamza.Sadiq@bridge.bellsouth.com> wrote:
>Hi everyone,
>
>I am still having problems running perl/cgi scripts through my browser.
>It works find from the command prompt but shows up as text in my
>browser.  I've tried following the previous info giving in this
>newsgroup but to no avail.  my code is as follows:
>
>#!C:\Perl\bin\perl
>
>
>use lib ("C:/perl/lib/");
>
>print "Content-type: text/html\n\n";
>
>print "Hello";
>
Make sure the file extension of your perl cgi scripts is .pl, not .cgi.


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

Date: Wed, 10 May 2000 18:17:48 -0400
From: "Michael Matthews" <mjmatt@qsun.att.com>
Subject: Re: taint workin
Message-Id: <8fcmua$7mb15@kcweb01.netnews.att.com>

Thanks for asking. I found the problem in the Text::Wrapper module. I also
found a simple work around.
DONT USE $_[0] as buffer arg!

DISTILLED:
#!/usr/local/bin/perl -T
sub wrap {
    for (;;) {
        if ($_[0] =~ m/\G[ \t]*(\n+)/gc) {
print "line $1\n";
        } else {
            $_[0] =~ m/\G(\s*(?:[^-\s]+-*|\S+))/g or last;
print "word $1\n";
        }
    } # end forever
}
$str="this is a line.
Another line.
and finally.";
open(MR,">ff") or die "abort";
syswrite( MR, $str );
open(MR,"<ff") or die "abort";
sysread( MR , $str, 5000 );
wrap($str);

###########################################################

- Without the -T works fine, with loops infinitely.
- regex's must be in a function.
- Input to function must come from file, if I pass $str directly it works
ok.
- $_[0] must be used, not assigned to a var which is why a function.

How is that for a mind melter ! 8-}


Tom Phoenix <rootbeer@redcat.com> wrote in message
news:Pine.GSO.4.10.10005101255430.16364-100000@user2.teleport.com...
> On Wed, 10 May 2000, change wrote:
>
> > works fine unless I use taint, and then susequent regex calls do NOT
> > advance the buffer and the routine goes into a infinite loop.
>
> Could you please create a small, self-containted program to demonstrate
> this behavior? Ideally, it should produce different output depending upon
> whether -T is used. Having that program would make it much more likely
> that the bug can be found and squashed quickly.
>
> > Are there any fixes in later perl releases?
>
> With that sample program, it would be easy to find out. :-)
>
> Thanks!
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>




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

Date: Wed, 10 May 2000 16:42:08 -0700
From: Nagaraju Kotha <raju_kotha@yahoo.com>
Subject: Re: Two Perl Syntax Question
Message-Id: <3919F3D0.F6F66325@yahoo.com>



Iali0719 wrote:

> I am a comparatively newbie to Perl and could not find the syntax to the do the
> following two things in my Perl Reference Books:
>
> 1) How to separate characters in a string..i.e.
> $myString = 1234;
>
> Now how can I read individual characters within this string i.e. if I want to
> break it into two characters each i.e. have one variable contain 12 and the
> other 34.  There are no special characters in between to use the split function
>

@myString = grep(/../,split( /(..)/,$myString) );

Now you have (12,34) in @my String.


>
> 2)
> For the following code
>
> $myHexVal = 0x12AC;
> $myString = "This is a hex number $HexVal";
>
> How can I have $myString show the hex value of $HexVal instead of decimal such
> that it shows "This is a hex number 12AC"
>

print "This is Hex Number: ",sprintf("%X",$HexVal),"\n";

From
Nagaraju Kotha.

>
> Any help would be greatly appreciated



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

Date: Wed, 10 May 2000 16:44:22 -0700
From: Nagaraju Kotha <raju_kotha@yahoo.com>
Subject: Re: Two Perl Syntax Question
Message-Id: <3919F456.EA7FA078@yahoo.com>

Subject:
            Re: Two Perl Syntax Question
       Date:
            Wed, 10 May 2000 16:42:08 -0700
       From:
            Nagaraju Kotha <raju_kotha@yahoo.com>
 Newsgroups:
            comp.lang.perl.misc
  References:
            1





Iali0719 wrote:

> I am a comparatively newbie to Perl and could not find the syntax to the do the
> following two things in my Perl Reference Books:
>
> 1) How to separate characters in a string..i.e.
> $myString = 1234;
>
> Now how can I read individual characters within this string i.e. if I want to
> break it into two characters each i.e. have one variable contain 12 and the
> other 34.  There are no special characters in between to use the split function
>

@myString = grep(/../,split( /(..)/,$myString) );

Now you have (12,34) in @my String.


>
> 2)
> For the following code
>
> $myHexVal = 0x12AC;
> $myString = "This is a hex number $HexVal";
>
> How can I have $myString show the hex value of $HexVal instead of decimal such
> that it shows "This is a hex number 12AC"
>

print "This is Hex Number: ",sprintf("%X",$HexVal),"\n";

From
Nagaraju Kotha.

>
> Any help would be greatly appreciated






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

Date: Wed, 10 May 2000 23:51:17 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Two Perl Syntax Question
Message-Id: <391cf3af.4660825@news.skynet.be>

Nagaraju Kotha wrote:

>> Now how can I read individual characters within this string i.e. if I want to
>> break it into two characters each i.e. have one variable contain 12 and the
>> other 34.  There are no special characters in between to use the split function
>>
>
>@myString = grep(/../,split( /(..)/,$myString) );
>
>Now you have (12,34) in @my String.

This puzzled me a bit. The grep serves to remove the actual split items,
which have no length, right? And then, there's the question of what you
want to do with an odd number of characters.

	$text = '123456789';
	($\, $,) = ("\n", "|");
	print 'oops:';
	print split /(..)/, $text;
	print 'yours:';
	print grep /../, split /(..)/, $text;
	print 'variation:';
	print grep length, split /(..)/, $text;
	print 'alternative:';
	print $text =~ /.{1,2}/g;

-->
	oops:
	|12||34||56||78|9
	yours:
	12|34|56|78
	variation:
	12|34|56|78|9
	alternative:
	12|34|56|78|9

-- 
	Bart.


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

Date: Wed, 10 May 2000 17:22:44 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Where's the FAQ?
Message-Id: <Pine.GSO.4.10.10005101720510.16364-100000@user2.teleport.com>

On Wed, 10 May 2000, Bagsy wrote:

>     Just got here and was looking for the FAQ but I don't see it anywhere in
> the last 400 headers. Can somebody post me a URL for the FAQ please?

My frequent posting of "How to find the Perl FAQ" shows up every week.
Would it do any more good if it appeared more often than that?

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



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

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


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