[12794] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 204 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 20 18:07:16 1999

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

Perl-Users Digest           Tue, 20 Jul 1999     Volume: 9 Number: 204

Today's topics:
        about the function "validate" bing-du@tamu.edu
        Appeasing the Java and Perl naming gods <wohler@gbr.newt.com>
    Re: basename regexp? (Randal L. Schwartz)
    Re: basename regexp? <jcreed@cyclone.jprc.com>
    Re: basename regexp? <jcreed@cyclone.jprc.com>
    Re: basename regexp? (Larry Rosler)
    Re: basename regexp? <gellyfish@gellyfish.com>
    Re: basename regexp? (Anno Siegel)
    Re: beginner needs some help <wmooney@voicenet.com>
    Re: Check if 2 dates are in the same week shawnporter@my-deja.com
    Re: Check if 2 dates are in the same week skyfaye@my-deja.com
        Checking File Version <kkuebler@iwaynet.net>
        Execute file association in Win32 (Andy Davidson)
    Re: getting the decimal portion of a floating point num <bivey@teamdev.com>
    Re: getting the decimal portion of a floating point num <paul.glidden@unisys.com>
    Re: getting the decimal portion of a floating point num (I R A Darth Aggie)
    Re: How to open database just once? <paul.glidden@unisys.com>
    Re: How to open database just once? (Tad McClellan)
    Re: HTTP PUT method rlw_ctx@my-deja.com
        Information about major ecommerce sites using perl <decon2@dont_writeme.com>
    Re: Listing Files <gellyfish@gellyfish.com>
    Re: Listing Files <tchrist@mox.perl.com>
        need to redirect STDOUT and STDERR <jkart@leland.Stanford.EDU>
        newbie question about fork <josh@titan.byu.edu>
    Re: Perl and Personal Web Server (Win98) <marshalc@americasm01.nt.com>
    Re: Perl and Personal Web Server (Win98) <gellyfish@gellyfish.com>
    Re: PGP and Mail <upsetter@ziplink.net>
    Re: Problem with forking (Anno Siegel)
        Q: getting the decimal portion of a floating point numb anna@water.ca.gov
    Re: Reading password via Socket Connection (Anno Siegel)
    Re: reading sections of a file by markers (Tad McClellan)
    Re: regular Expression (I R A Darth Aggie)
        Unique IP Address Extraction wired2000@my-deja.com
    Re: Unique IP Address Extraction <paul.glidden@unisys.com>
    Re: Unique IP Address Extraction (John Stanley)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Tue, 20 Jul 1999 21:01:09 GMT
From: bing-du@tamu.edu
Subject: about the function "validate"
Message-Id: <7n2o2b$8ca$1@nnrp1.deja.com>

Greetings all...

Basically, the following code snippet showed what I wanted to do.
But seemed to me that the function 'validate' does not like variable.

#!/usr/local/bin/perl
use File::CheckTree;
$basedir = "/tmp";
$warnings += validate( q{$basedir/file -e});

if (!$warnings)
{
print "file exists\n";
} else {
         print "not exists\n";
       }

The outcome of the above code was "/$basedir/file does not exist".
Obviously it was not correct.

If I changed to:
 $warnings += validate( q{/tmp/file -e});

The outcome was "file exists" which was correct.

So my question is how to let 'validate' accept variable?

Any idea?

Bing


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


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

Date: 20 Jul 1999 13:55:39 -0700
From: Bill Wohler <wohler@gbr.newt.com>
Subject: Appeasing the Java and Perl naming gods
Message-Id: <vplncb82ic.fsf@gbr.newt.com>

  If you develop both Java and Perl classes/modules, what sort of
  naming conventions do you use?

  For example, the Java conventions tell us to put the code for the
  com.newt.foo.Bar in com/newt/foo/Bar.java. However, the Perl
  conventions (I think) call for Com::Newt::Foo::Bar in
  Com/Newt/Foo/Bar.pm.

  I'd like to be able to put Bar.pm and Bar.java in the same
  directory. How do you resolve this dilemma? My thoughts would be to
  follow the Java conventions and use lowercase package names. How
  "bad" would it be to put Bar.pm in com/newt/foo and invoke it with
  com::newt::foo?

-- 
Bill Wohler <wohler@newt.com>
Say it with MIME.  Maintainer of comp.mail.mh and news.software.nn FAQs.
If you're passed on the right, you're in the wrong lane.


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

Date: 20 Jul 1999 13:17:08 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: basename regexp?
Message-Id: <m1673fxeij.fsf@halfdome.holdit.com>

>>>>> "Lauren" == Lauren Smith <laurens@bsqaure.com> writes:

Lauren> instead of the above...
Lauren> /([^\\]+)$/; #

Lauren> $scriptname = $1;

No.  Never use $1 unless you've also checked the success or failure of
the match that you think is matching. $1 is set and reset only on a
*successful* match, so if your filename in $_ is "/foo/bar/", you've
just sent the user on a debugging trip trying to figure out why $1 is
some random string.

>> If you're unwilling to learn Perl, then all hope is lost...

Lauren> and if I'm unwilling to check my own code, then I am lost too.

Better doublecheck next time. :)

print "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 20 Jul 1999 16:22:10 -0400
From: Jason Reed <jcreed@cyclone.jprc.com>
Subject: Re: basename regexp?
Message-Id: <a1iu7fgjgt.fsf@cyclone.jprc.com>


> Jona Andersen wrote:
 ...
> > I need to know the name of my script.
> > $0 you'd say right? I know, but I just want the name, not the full
> > pathname.

Marshall Culpepper <marshalc@americasm01.nt.com> writes:
> Larry Rosler wrote:
> 
> > > $script=$0;
> > > $script=~ s/\/+\w+\///;
> > > print $script
> 
> wrong, wrong, wrong? I tested it pretty rigorously on my HPUX 10.20 and it
> seems to work just perfect with the 10 or more examples I've put it
> through...

bash$ echo > /homes/jcreed/sb/clpm/foo.pl
#!/usr/bin/perl -w
$script=$0;
$script=~ s/\/+\w+\///;
print "$script\n"
$ perl /homes/jcreed/sb/clpm/foo.pl 
jcreed/sb/clpm/foo.pl
bash$

Is that 'just perfect'?

(not to mention the possibility of directory
names with \W characters in them)

---Jason
do{my$y,$z;$y=sub{!!@_&&((pop).&$y)};$z=sub{print$y->(split//,$
_[0]);$z}}->(" tsuJ")->(" rehtona")->(" lreP")->("\n...rekcah")


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

Date: 20 Jul 1999 16:25:37 -0400
From: Jason Reed <jcreed@cyclone.jprc.com>
Subject: Re: basename regexp?
Message-Id: <a1hfmzgjb2.fsf@cyclone.jprc.com>

Jason Reed <jcreed@cyclone.jprc.com> writes:

> bash$ echo > /homes/jcreed/sb/clpm/foo.pl
        ^^^^
er, cat.

Stupid irony of criticizing unchecked
code showing up in the one line that
I forgot to check.

---Jason


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

Date: Tue, 20 Jul 1999 14:14:36 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: basename regexp?
Message-Id: <MPG.11fe86958c73f392989d06@nntp.hpl.hp.com>

In article <3794CA1E.7B13BCEA@americasm01.nt.com> on Tue, 20 Jul 1999 
14:12:30 -0500, Marshall Culpepper <marshalc@americasm01.nt.com> says...
> Larry Rosler wrote:

Where are the other attributions?  I certainly didn't write what comes 
next -- you did!

> > > $script=$0;
> > > $script=~ s/\/+\w+\///;
> > > print $script
> 
> oops forgot the semicolon :)

But that's not an error, because it was the last line in your source 
file.  ;-)
 
> >
> > > #$script is now the name of your script
> > >
> > > :)
> >
> > Is the smiley to show that the code is wrong, wrong, wrong???
> 
> wrong, wrong, wrong? I tested it pretty rigorously on my HPUX 10.20 and it
> seems to work just perfect with the 10 or more examples I've put it
> through...

Jason Reed responded with several classes of failures.

 ...

> didn't mean to offend you if I did...but I am still to find an example that
> doesn't work with the code I've posted....(unless of course it's a windows
> platform...)

I'm not offended, just astounded to find such stuff posted as if to 
answer a question.  By the way, your regex doesn't work with Windows/DOS 
either, because of a possible drive letter followed by a colon:  

  C:/perl/bin/perl

You'd better let this one go, Marshall, and really test before your next 
post.

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


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

Date: 20 Jul 1999 20:25:05 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: basename regexp?
Message-Id: <7n2lv1$1mb$1@gellyfish.btinternet.com>

On 20 Jul 1999 16:29:36 GMT Walter Tice USG wrote:
> In article <37948E1E.28C77299@ds10.hobby.nl> jona@ds10.hobby.nl writes:
>>Hi,
> 
>>I need to know the name of my script.
>>$0 you'd say right? I know, but I just want the name, not the full
>>pathname.
> 
> How bout' this?
> 
> $len = length($0);
> 
> for ($i=0; $i<$len; $i++) {
>     $char = substr($0,$i,1);
>     if ($char =~ /\//) { $k = $i }  ## make it /\\/ for DO$
> }
> 
> $name = substr($0,$k);
> print "$name\n";
> 

Of course if one wants to avoid using a regex and use substr instead you
could do away with the loop and let a builtin do that for you:

  print substr $0, rindex($0,'/') + 1;

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 20 Jul 1999 21:55:04 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: basename regexp?
Message-Id: <7n2r7o$qm2$1@lublin.zrz.tu-berlin.de>

Marshall Culpepper  <marshalc@americasm01.nt.com> wrote in comp.lang.perl.misc:
>>
>> How bout' this?
>>
>> $len = length($0);
>>
>> for ($i=0; $i<$len; $i++) {
>>     $char = substr($0,$i,1);
>>     if ($char =~ /\//) { $k = $i }  ## make it /\\/ for DO$
>> }
>
>eww...you used a for loop for something that is easily done with regexp :)
>chant with me.."regexp is your friend.."

I refuse to join that chant.  A more immediate fix is

  substr( $0, rindex( $0, '/') + 1);

Anno


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

Date: Tue, 20 Jul 1999 16:56:12 -0400
From: Bill Mooney <wmooney@voicenet.com>
Subject: Re: beginner needs some help
Message-Id: <Pine.SOL.4.04.9907201630530.13946-100000@unix01>


 
>    I understand the majority of this script except for the line:
> $howmany= $ENV{CONTENT_LENGTH};
> and
> cntnu: @pairs= split(/&/, $buffer);
>  

HTML forms can be submitted to the web server with a GET or POST method.
If the script is a CGI script (it looks like one to me) and the
REQUEST_METHOD=POST then the parameters in the form are read from STDIN. 
$ENV{CONTENT_LENGTH} tells you how many characters you should read in from
the input stream.

When html forms are submitted, the variables are usually passed as
name-value pairs separated by the amperstand. The split function in your
example separates a string into its component name-value pairs. If you
wan't to learn more about CGI scripts, O'Reilly has a decent book for
beginners called CGI Programming.

 HTH
-Bill




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

Date: Tue, 20 Jul 1999 20:19:15 GMT
From: shawnporter@my-deja.com
Subject: Re: Check if 2 dates are in the same week
Message-Id: <7n2ljk$771$1@nnrp1.deja.com>

Check the FAQ...

-> http://language.perl.com/newdocs/pod/perlfaq4.html#Data_Dates

--
Shawn Porter

--
In article <7n2fjs$4f0$1@nnrp1.deja.com>,
  skyfaye@my-deja.com wrote:
> $old_mon=11; $old_day=27; $old_year=1998; #Dec 27, 1998
> $new_mon=0; $new_day=8; $new_year=1999;   #Jan 8,  1999
>
> I need to find out if 2 dates are in the same week, one week apart, 2
> weeks apart, and s
> o on.  For me, Monday is the beginning of the week.
> I know how to find the number of days between 2 dates but that doesn't
> help this problem.
>
> Thanks,
> Hung
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>


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


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

Date: Tue, 20 Jul 1999 21:29:17 GMT
From: skyfaye@my-deja.com
Subject: Re: Check if 2 dates are in the same week
Message-Id: <7n2pms$90n$1@nnrp1.deja.com>

I did check the FAQ before posting but no help.

- Hung

In article <7n2ljk$771$1@nnrp1.deja.com>,
  shawnporter@my-deja.com wrote:
> Check the FAQ...
>
> -> http://language.perl.com/newdocs/pod/perlfaq4.html#Data_Dates
>
> --
> Shawn Porter
>
> --
> In article <7n2fjs$4f0$1@nnrp1.deja.com>,
>   skyfaye@my-deja.com wrote:
> > $old_mon=11; $old_day=27; $old_year=1998; #Dec 27, 1998
> > $new_mon=0; $new_day=8; $new_year=1999;   #Jan 8,  1999
> >
> > I need to find out if 2 dates are in the same week, one week apart,
2
> > weeks apart, and s
> > o on.  For me, Monday is the beginning of the week.
> > I know how to find the number of days between 2 dates but that
doesn't
> > help this problem.
> >
> > Thanks,
> > Hung
> >
> > Sent via Deja.com http://www.deja.com/
> > Share what you know. Learn what you don't.
> >
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>


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


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

Date: Tue, 20 Jul 1999 16:15:13 -0400
From: "Kevin Kuebler" <kkuebler@iwaynet.net>
Subject: Checking File Version
Message-Id: <7n2ldf$vqs$1@news.iwaynet.net>

HI,
I'm using ActivePerl Build 518 on an NT 4 machine. I recently wrote a script
to check the NT Service Pack version on all of the machines in my domain.
This was easy to do using the Win32::TieRegistry module to connect to the
registry of each machine and read the apropriate key. Now I need to modify
the script to check the Office97 service release version (we're deploying
SR2). Unfortunately there doesn't seem to be a registry key anywhere that we
can check. If anyone knows of a key with this info please let me know.

Assuming that we can't use the registry, we thought we would just check the
file version of one of the core files (like excel.exe). I know I can
probably do this easily on the local machine, but how to you check the file
attributes of a file on a remote machine? Any help would be appreciated.

Thanks,

Kevin Kuebler




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

Date: Mon, 19 Jul 1999 21:23:15 GMT
From: pheon@hevanet.com (Andy Davidson)
Subject: Execute file association in Win32
Message-Id: <37939653.29037268@news.hevanet.com>

No, I don't want to make perl run when I doubleclick a .pl file.  What
I want is a way to cause a browser to be launched by 'running' a .html
file.  In other words, from a perl script I want to cause the same
action that occurs when I use the Start Menu 'Run' command and enter
'index.html' without my having to know which browser they have
installed.

If I can't do that, I will have to search the registry, I suppose, for
the registered browser program and call it myself.  Anybody got some
extant code to do that?  Or is there an alternative I've missed?

andy



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

Date: 20 Jul 1999 21:29:52 GMT
From: "William" <bivey@teamdev.com>
Subject: Re: getting the decimal portion of a floating point number
Message-Id: <01bed2f7$1a2d8b20$583c08cf@bill.jump.net>

anna@water.ca.gov wrote in article <7n2n1s$7t0$1@nnrp1.deja.com>...
> Hi,
> 
> Is there a way in Perl or in a module of getting the decimal portion of
> a floating point number?  I have already tried using the format_picture
> method of Number::Format, but that doesn't work.
> 
> For example, if I have a number, 12345.6789 and I want to be able to
> return the portion .6789, how do I go about that?
> 
> Thanks in advance for your reply,
> Anna

Try
	$YerNumber =~ m/(\.\d+)/;
	return $1;
-Wm


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

Date: Tue, 20 Jul 1999 16:27:28 -0500
From: "Paul Glidden" <paul.glidden@unisys.com>
Subject: Re: getting the decimal portion of a floating point number
Message-Id: <7n2pk8$5qe$1@bbnews1.unisys.com>


anna@water.ca.gov wrote in message <7n2n1s$7t0$1@nnrp1.deja.com>...
>Hi,
>
>Is there a way in Perl or in a module of getting the decimal portion of
>a floating point number?  I have already tried using the format_picture

$int_var = 123456.789;
@new_var = split /\./,$int_var;
$new_var= pop(@new_var); # will now = 789




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

Date: 20 Jul 1999 21:49:12 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: getting the decimal portion of a floating point number
Message-Id: <slrn7p9rr0.mhr.fl_aggie@thepentagon.com>

On Tue, 20 Jul 1999 16:27:28 -0500, Paul Glidden <paul.glidden@unisys.com>, in
<7n2pk8$5qe$1@bbnews1.unisys.com> wrote:

+ $int_var = 123456.789;
+ @new_var = split /\./,$int_var;
+ $new_var= pop(@new_var); # will now = 789

Too much work and a temp variable!

$int_var = 123456.789;
(undef,$decimal)=split /\./,$int_var; # more obvious to me what's happening

or for the more adventurous

$decimal=(split /\./,$int_var)[1]; # presuming you don't have more than 1 "."

James


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

Date: Tue, 20 Jul 1999 16:02:58 -0500
From: "Paul Glidden" <paul.glidden@unisys.com>
Subject: Re: How to open database just once?
Message-Id: <7n2o68$51u$1@bbnews1.unisys.com>

What kind of database are you talking about?

Will the DBI module do the trick for you?





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

Date: Tue, 20 Jul 1999 12:25:42 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How to open database just once?
Message-Id: <6u72n7.rk6.ln@magna.metronet.com>

Larry Rosler (lr@hpl.hp.com) wrote:

: 'Close enough' is good enough only in horseshoes or thermonuclear war.
                                        ^^^^^^^^^^    ^^^^^^^^^^^^^^^^^

   and dancing.


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


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

Date: Tue, 20 Jul 1999 21:43:47 GMT
From: rlw_ctx@my-deja.com
Subject: Re: HTTP PUT method
Message-Id: <7n2qif$9cg$1@nnrp1.deja.com>

In article <7n281i$on$1@nnrp1.deja.com>,
  keydet89@yahoo.com wrote:
> Does anyone have a working example of using the HTTP PUT method
> in Perl?

Look at module HTTP::Request

It has been a while (and I've lost what I did), but....

Basically, your query will be "PUT /path/to/filename.ext" with
the content of the request being the desired content of the
file.

With Apache, you can either install mod_put (a 3rd party module)
or use mod_action to assign a script to the PUT method. The
environment passed to the script be similar to what a CGI would
see, but the content (stdin) will be the (I think) URL encoded
content to save to the location specified in the query string.

Depending on exactly what you want to do, it might be easier
(for the intended users) for you to use an HTML form with a
INPUT type=file field. The method would be POST and you would
use ENCODING=multipart/x-url-encoded-form (I think - as I said,
it has been a while).

You then can use CGI.pm in the CGI script. The intended content
of the file will be available (and decoded) as the value of the
field variable. I think the POD for CGI.pm tells some of this.
There is an official RFC describing this.

--
Ron Wilson
Connectex, LLC


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


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

Date: Tue, 20 Jul 1999 17:05:28 -0400
From: "Sreenivas Kothapalli" <decon2@dont_writeme.com>
Subject: Information about major ecommerce sites using perl
Message-Id: <7n2oaq$bi7@nntpa.cb.lucent.com>

Yesterday I was trying to persuade some of my friends to use
linux/apache/perl/mysql for an ecommerce venture.

The project on which I am employed has a web frontend and we get at least 3
prodn support calls per week for it; whereas the three calls we received for
the unix backend (for the entire year) were related to programmer-errors.
So I have been firmly in favor of a non-NT/IIS solution.

I could wax eloquent on the advantages--stability, speed, flexibility, etc.
But I was stumped when I was challenged to name some major ecommerce sites
using perl.  I tried to educate myself and I got some names from
http://perl.apache.org/stories/.  But these success stories are confined to
the usage of mod_perl and anyway they are too few.  But, adult ad servers
and singles sites are not exactly clinching arguments for business!

So I am here seeking help in finding information about ecommerce sites using
perl, not just mod_perl.

PS: And where can I find information on the comparision between perl/apache
(on linux) and ASP/IIS in terms of development effort, stability, etc?  Any
success stories, articles, etc.

Thank you.

--
S Kothapalli
----------------------------------------------------------------------
To reply, please remove the "dont_" from my email address.





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

Date: 20 Jul 1999 20:41:24 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Listing Files
Message-Id: <7n2mtk$1nh$1@gellyfish.btinternet.com>

On Mon, 19 Jul 1999 21:04:14 -0700 Kevin M. Sproule wrote:
> 
> Ashish Kadakia wrote in message <932424514.5244@www.remarq.com>...
>>Hi, I would like to list all the files starting with the
>>root directory..
>>Can anyone point me how to do that?
>>
> 
> What the previous examples lack in functionality they make up for in
> brevity. ;)  The request was to list "all" the files starting with the root
> directory.  Here a a working WIN32 solution.
> 

<snip over blown example>

> To iterate is human, to recurse devine.
> 

Quite so, quite so ...

Of course as others have pointed out File::Find is by far the best way
to go but if you must do it yourself - you neednt waste so many keystrokes:


#!/usr/bin/perl -w

use strict;

my $input_dir = $ARGV[0] || '.' ;

my $item;

&dodir ($input_dir);

sub dodir 
{
   my $thedir = shift ;

    opendir DIR, $thedir || die "Couldnt open $thedir - $!\n";

    my @entries = map { $thedir . '/' . $_ } grep !/^\.{1,2}$/, readdir(DIR);

    closedir (DIR);

    foreach $item (@entries) 
      {
        if ( -d $item ) 
          {
            dodir ( $item);
          } 
        else 
          {
            print $item,"\n";
          }
      }
}

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 20 Jul 1999 15:46:14 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Listing Files
Message-Id: <3794ee26@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, Ashish Kadakia <anonymous@web.remarq.com> writes:
:that's on UNIX system.
:I want to on NT system, with Perl and put the list into an
:array.

That's your problem, not ours.  Just because the Lord Thy Bill has
withheld from you the basic tools that every programmer needs doesn't
mean that you're permanently banished to a place of torture and suffering.
Empower yourself!

    http://language.perl.com/ppt/

--tom
-- 
If the code and the comments disagree, then both are probably wrong.
                --Norm Schryer


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

Date: Tue, 20 Jul 1999 13:12:56 -0700
From: Jonathan Kart <jkart@leland.Stanford.EDU>
Subject: need to redirect STDOUT and STDERR
Message-Id: <Pine.GSO.3.96.990720130852.3412A-100000@myth1.Stanford.EDU>


is there any way on WinNT to redirect STDOUT and/or STDERR to a log file?

I can't just select a different filehandle for output I need to actually
redirect STDOUT and STDERR so that when someone says: 
"print 'hello world';" it goes to one log file but 
"die 'hello world';"  goes to another

any help would be greatly appreciated,
Thanks
jk



//*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*//
     	Jonathan Kart         jkart@leland.stanford.edu	
	Po Box 5291
	Stanford, CA   94309
	(650) 497-6695	    
 //*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*//



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

Date: Tue, 20 Jul 1999 09:08:19 -0600
From: Joshua Harr <josh@titan.byu.edu>
Subject: newbie question about fork
Message-Id: <379490E3.6AC6AF36@titan.byu.edu>

I need to spawn another program from with my script and wait for
it to complete before continuing.  system() returns success/failure etc.

of the spawned process but I need the PID also - and I need it before
the child process terminates.  How do I get the PID after spawning a
process (w/o losing the system call return value)?  Do I need a need to
use wait or waitpid somehow?  Is system the wrong way to go... should
I be using fork...wait?  I'm confused as to how this all fits together.
Thanks for your help.






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

Date: Tue, 20 Jul 1999 14:23:50 -0500
From: Marshall Culpepper <marshalc@americasm01.nt.com>
Subject: Re: Perl and Personal Web Server (Win98)
Message-Id: <3794CCC6.C77A9D55@americasm01.nt.com>

Eric The Read wrote:

> "Hi, my name is Alex, and my girlfriend spends too much time writing Perl
> scripts.  She calls them `programs', but I know better-- programs have
> dialog boxes and stuff, and these just read in stuff and print it out
> again.  What should I do?"
>

Glorify your girlfriend! :)


--
perl -wlne 'print $.."\t$_";' file #idea was kinda stolen from Abigail..does the same thing as `nl file` :)





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

Date: 20 Jul 1999 20:03:23 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl and Personal Web Server (Win98)
Message-Id: <7n2kmb$1ki$1@gellyfish.btinternet.com>

On Tue, 20 Jul 1999 18:31:15 GMT Tzadik Vanderhoof wrote:
> In article <37709A4A.E79125AD@dave.org.uk>,
>   Dave Cross <dave@dave.org.uk> wrote:
>> chitown34@my-deja.com wrote:
>> >
>> > I'm trying to configure ActivePerl for use with
>> > Microsoft's Personal Web Server on a Windows98.
>> >
> 
>> Presumably the people a Windows web server newsgroup will be able to
>> help you.
>>
> 
> Well, *presumably* there are people on the perl ng who have experience
> with this, 

This is very possible, yes but I have experience of carpentry as well
are you suggesting we should answer *any* questions here ..

>            and *presumably* this *is* a perl-related question since it
> involves getting perl set up properly on the guy's system.  

No the question is about the configuration of a web server, this has
*nothing* to do with Perl - the answer would be the same if he was using
Perl,Python,Tcl,Rexx ... This group isnt the place to be asking questions
about Web Server configuration.  In this instance the appropriate group
would be comp.infosystems.www.servers.ms-windows, if the question wasnt
answered in a FAQ.

>                                                             And
> *presumably* if we had as much people posting useful info as posting ng-
> police stuff, we'd be in much better shape here!
> 

I dont see you contributing to this 'solution' with this post - perhaps
if people like you didnt make posts like this complaining about other
peoples posts without _actually_offering_any_help_yourself_ then perhaps
then things might be in better shape too.

The answer to the original posters question is discussed in a whole section
of the Win32 specific FAQ that comes with the Activestate distribution.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Tue, 20 Jul 1999 22:00:49 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: PGP and Mail
Message-Id: <lk6l3.663$ui4.212722@news.shore.net>

brian d foy <brian@pm.org> wrote:
:>         $ret_val = open (PGP, "|$pgpprog -fea +VERBOSE=0 \"tony
:> <tony\@tony.co.uk>\" > $pgptmp");

: i recommend using IPC::Open3.  i recently posted an example in either
: this forum or comp.infosystems.www.authoring.cgi.

Could someone explain in a nutshell what the advantages are to using
IPC::Open3 rather than open?

Has anyone had any experience with PGP::PGP5::MessageProcessor? Does that
offer any additional advantages beyond convenience?

Thanks,

--Art

-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: 20 Jul 1999 20:46:35 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Problem with forking
Message-Id: <7n2n7b$qfl$1@lublin.zrz.tu-berlin.de>

 <smnayeem7346@my-deja.com> wrote in comp.lang.perl.misc:
>In article <7mv0cj$h8l$1@server1.powernet.net>,
>  lwp@mail.msen.com wrote:

>> It seems to me you have an infinite loop in your &REAPER
>> :       while ($child = waitpid(-1, WNOHANG)) {
>> What condition do you think would ever terminate this while() ?
>>
>> On Sat, 17 Jul 1999 08:19:36 GMT, smnayeem7346@my-deja.com wrote:
>> : I am having some difficulties doing forking, when I try to connect
>to my
>> : server program for the 2nd time it hangs up.

>Actually I quoted it off from the Camel directly. If you still think
>this is the problem, any suggestion as to what I should replace it with?

How snotty can you get?

The reply was posted above the quoted text.  I put it where it
belongs.

Lou has pointed out an obvious error in your code.  Instead of
looking up what waitpid() does and fixing your code accordingly,
all you say is, "It's in the Camel".  Even if it were (it isn't,
not in my copy), do you think that gives you the right to challenge
a helpful poster to correct it for you?

Gah.

Anno


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

Date: Tue, 20 Jul 1999 20:43:44 GMT
From: anna@water.ca.gov
Subject: Q: getting the decimal portion of a floating point number
Message-Id: <7n2n1s$7t0$1@nnrp1.deja.com>

Hi,

Is there a way in Perl or in a module of getting the decimal portion of
a floating point number?  I have already tried using the format_picture
method of Number::Format, but that doesn't work.

For example, if I have a number, 12345.6789 and I want to be able to
return the portion .6789, how do I go about that?

Thanks in advance for your reply,
Anna


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


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

Date: 20 Jul 1999 21:08:49 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Reading password via Socket Connection
Message-Id: <7n2oh1$qjj$1@lublin.zrz.tu-berlin.de>

 <stuckenbrock@my-deja.com> wrote in comp.lang.perl.misc:
>Hi there
>
>I have the problem, that I want to read a password over a Socket without
>writing it on the screen at the (Telnet-)Clientside. For normal
>Terminalinput this works with the Term::ReadKey Module but this
>doesn't seem to work with a socket.
>I also tried system("stty -echo")... same effect.

From a cursory glance at perldoc Net:Telnet, that module seems
to deal with switching the remote echo on or off.

Anno


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

Date: Tue, 20 Jul 1999 10:38:01 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: reading sections of a file by markers
Message-Id: <9k12n7.sa6.ln@magna.metronet.com>

Steve . (syarbrou@nospam.enteract.com) wrote:


: How would I basically say something like take everything starting
: after <- start -> and before <- e1 -> and put it in variable $start,
: and take everything after <- start e2 -> and before <- end e2 -> and
: put it in variable $end ?  Thanks.

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

{ local $/;      # set slurp mode
  $_ = <DATA>;   # slurp whole file into a scalar
}

my $start = $1 if /<- start ->\n(.*?)<- e1 ->\n/s;
print "start '$start'\n";

my $end = $1 if /<- start e2 ->\n(.*?)<- end e2 ->\n/s;
print "end '$end'\n";


__DATA__
<- start ->
bla bla
bla bla bla
bla bla
bla

<- e1 ->

<- start e2 ->
bla bls a sfd
sfd

ddfsf
df
<- end e2 ->
---------------------------------


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


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

Date: 20 Jul 1999 20:19:01 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: regular Expression
Message-Id: <slrn7p9mht.m03.fl_aggie@thepentagon.com>

On 20 Jul 1999 12:49:43 -0600, Daniel Grisinger
<dgris@moiraine.dimensional.com>, in
<m3u2qz40mw.fsf@moiraine.dimensional.com> wrote:

+ I just don't think you'd be interested in my perlfaq patches.  *shrug*

Submit the patches. If they're used, great, if they aren't, publish
them here, or submit them to the cookbook repository.

Perl's about sharing, even when you don't think there's any interest.

James


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

Date: Tue, 20 Jul 1999 21:01:17 GMT
From: wired2000@my-deja.com
Subject: Unique IP Address Extraction
Message-Id: <7n2o2k$8cc$1@nnrp1.deja.com>

Hello,

I have a flat text db file with the following info:
date/time;;;pageURL;;;IPaddress

I'd like to be able to scan the entire file (about 4-10 megs) for the
number of unique IP addresses and optionally report them to me (listing
each IP address).

The actual looping and splitting is easy, my only problem, is what's
the most efficient way of extracting only UNIQUE IP address' from this
file without crashing or impacting the server?

My idea would be to use a hash table and store each IP inside, but I
don't believe this would be the most efficient way.

As well, what's the most efficient way of reading line by line from the
text file (remember, file is 4-10 megs)? open the whole thing and put
it in memory or read line by line? If reading line-by-line, how can I
do that?

Please help

If anyone knows a better way to do this with grep/egrep/any other linux
command, your input is definitely appreciated.

Thank you all!
Charles


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


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

Date: Tue, 20 Jul 1999 16:43:33 -0500
From: "Paul Glidden" <paul.glidden@unisys.com>
Subject: Re: Unique IP Address Extraction
Message-Id: <7n2qia$6n0$1@bbnews1.unisys.com>

Are you going to use the information in the file for something else later?
If so it is going to be more efficient to read in the entire file.
If it is only going to be used one time, it is probably more efficient to
read it in line by line.

why, processing time for the rest of the code is negligable, and if the info
from the file is not going to be used any more, there is no need to store
the entire file in an array which will become about the same size as the
file

@unique_ip="";
open (INFILE,"filename");
while ($line=<INFILE>)
{
    chomp $line;
    @array= split /;/,$line;
    $ip = pop @array;
    foreach $unique (@unique_ip)
    {
        code to test each ip for uniqueness
    }
}

wired2000@my-deja.com wrote in message <7n2o2k$8cc$1@nnrp1.deja.com>...
>Hello,
>
>I have a flat text db file with the following info:
>date/time;;;pageURL;;;IPaddress
>
>I'd like to be able to scan the entire file (about 4-10 megs) for the
>number of unique IP addresses and optionally report them to me (listing
>each IP address).
>
>The actual looping and splitting is easy, my only problem, is what's
>the most efficient way of extracting only UNIQUE IP address' from this
>file without crashing or impacting the server?
>
>My idea would be to use a hash table and store each IP inside, but I
>don't believe this would be the most efficient way.
>
>As well, what's the most efficient way of reading line by line from the
>text file (remember, file is 4-10 megs)? open the whole thing and put
>it in memory or read line by line? If reading line-by-line, how can I
>do that?
>
>Please help
>
>If anyone knows a better way to do this with grep/egrep/any other linux
>command, your input is definitely appreciated.
>
>Thank you all!
>Charles
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.




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

Date: 20 Jul 1999 21:54:21 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Unique IP Address Extraction
Message-Id: <7n2r6d$83k$1@news.NERO.NET>

In article <7n2o2k$8cc$1@nnrp1.deja.com>,  <wired2000@my-deja.com> wrote:
>If anyone knows a better way to do this with grep/egrep/any other linux
>command, your input is definitely appreciated.

cat file | cut -f7 -d\; | sort | uniq



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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


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


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