[9543] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3137 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 13 00:07:17 1998

Date: Sun, 12 Jul 98 21:00:20 -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           Sun, 12 Jul 1998     Volume: 8 Number: 3137

Today's topics:
        Code for deciding week number? <thomas@provideo.dk>
    Re: Directory Names with Perl for NT scott@softbase.com
        First meeting of Dallas.pm (Brand and Karina Hilton)
    Re: forking on win32 scott@softbase.com
    Re: Getting Yesterday's Date <tchrist@mox.perl.com>
    Re: hash's and a foreach - Can't do it? graemeaustin@my-dejanews.com
    Re: Having STDERR go to STDOUT in a system call eslevitt@mediaone.net
        Help with cgi-lib.pl and input text boxes (Emmett McLean)
    Re: How to use 'system ("...")' on WIN32. scott@softbase.com
    Re: HTTP connections WITHOUT the libwww module? scott@softbase.com
        hypertext links to files in ls output (Emmett McLean)
    Re: mkdir with NT - question scott@softbase.com
    Re: Need a more efficient sort subroutine. (Ronald J Kimball)
    Re: number of days between two given dates using perl <spamsux-tex@habit.com>
    Re: Perl Beautifier Home Page <tchrist@mox.perl.com>
    Re: Perl Beautifier Home Page (Ilya Zakharevich)
    Re: PING / Traceroute Perl Script (Marc Spitzer)
    Re: Putting CPAN on a CD:  good or not good? <kperrier@blkbox.com>
    Re: Running cgi executables in Windows http server scott@softbase.com
        Silly question about IO::SOCKET <domainsource@usa.net>
    Re: Splitting a difficult CSV file scott@softbase.com
    Re: Weirdness in trying to extract year from localtime (I R A Aggie)
        What's the substitute for #! /usr/bin/perl in Win32 Per (James Moore)
        Where can I find GD.pm <GeoffW@wordsmith.demon.co.uk>
        Why is Dave operating here? (was Re: REPOST: Re: ) (John Stanley)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Sun, 12 Jul 1998 05:35:04 -0700
From: Thomas Albech <thomas@provideo.dk>
Subject: Code for deciding week number?
Message-Id: <35A8AD78.46F90580@provideo.dk>

This is a multi-part message in MIME format.
--------------2812F5F774B8B380071EE732
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi everyone,

How do you mathematically decide, which week number we are currently in?
Is there any expression for it
in combination with the Time module?


Thanks,
Thomas

--------------2812F5F774B8B380071EE732
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Thomas Albech
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Thomas Albech
n:              Albech;Thomas
org:            Crystal Graphics
adr;dom:        Guldborgvej 3;;DK-4990 Sakskxbing;;;;
email;internet: thomas@provideo.dk
tel;work:       +54 54 70 71 10
tel;fax:        +45 54 70 03 10
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------2812F5F774B8B380071EE732--



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

Date: 8 Jul 1998 12:21:38 GMT
From: scott@softbase.com
Subject: Re: Directory Names with Perl for NT
Message-Id: <6nvo8i$k2a$1@mainsrv.main.nc.us>

Jeff Lockard (jLockard@rwd.com) wrote:

>  Long names are fine, but a space causes the DOS commands to fail.

When passing filenames with spaces to the command interpreter,
put them in quotes.

Ex: system("xcopy \"foo bar.txt\" v:\");

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 


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

Date: Sun, 12 Jul 1998 19:29:50 GMT
From: bkhilton@netcom.com (Brand and Karina Hilton)
Subject: First meeting of Dallas.pm
Message-Id: <bkhiltonEvzy5q.Kpy@netcom.com>

The first meeting of the Dallas Perl Mongers is on:

  Date:  Wednesday, July 15
  Time:  7:00pm
  Place: Juan's Cantina, southwest corner of Central
         Espressway and Belt Line Rd, Richardson.

When you get there, tell 'em you're with "The Perl Group".
(I really don't want to try to explain to the management
what a "Perl Monger" is.)

Agenda:    7:00  Get there.
           7:10  Order refreshments.
           7:30  Throw security badges into the basket
                 for the drawing.  Whose ever badge you
                 draw, you have to pretend to be that person
                 for the rest of the year.  First one to get
                 promoted wins a free subscription to TPJ.

See ya there.


	Brand


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

Date: 10 Jul 1998 22:02:50 GMT
From: scott@softbase.com
Subject: Re: forking on win32
Message-Id: <6o632a$vfi$2@mainsrv.main.nc.us>

Ted (kolovos_ted@prc.com) wrote:
> I noticed that fork is unimplemented on win32, is there
> a way around this, perhaps through a call to the windows createthread
> api
> in kernerl32.dll??

Absolutely not. Forking is *impossible* in Win32 because of
differences in the process model. Think VMS when you think Win32.

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 


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

Date: 12 Jul 1998 19:11:32 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Getting Yesterday's Date
Message-Id: <6ob1p4$i4g$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    cadams@ro.com (Chris Adams) writes:
:According to Tom Christiansen  <tchrist@mox.perl.com>:
:>                                            It turns out that POSIX
:>requires that time() not include leap seconds
:
:Out of curiousity, where is this said?  Is it still true in the Unix98
:spec?  I just looked at the Unix98 spec and it says:
:
:    APPLICATION USAGE
:
:     The range [0,61] for tm_sec allows for the occasional leap second
:     or double leap second.

>From reading various manpages, it is remarkable how many programmers
think this can happen, but I believe it is a myth that a double leap
second can exist.  I can find no reference supporting it, and several
disputing it.  In particular:

http://sohowww.nascom.nasa.gov/operations/prelaunch/integration/EOFintegration/clock.txt

Leads one to believe that since whether there's a leap second is stored
as a single bit, you *cannot* have two in one minute!

Here are some other references:

http://www.its.bldrdoc.gov/fs-1037/dir-021/_3005.htm

    leap second: An occasional adjustment of one second, added to,
    or subtracted from, Coordinated Universal Time (UTC) to bring it
    into approximate synchronism with UT-1, which is the time scale
    based on the rotation of the Earth. (188) Note 1: Adjustments, when
    required, are made at the end of June 30, or preferably, December
    31, Universal Time, so that UTC never deviates from UT-1 by more
    than 0.9 second. Note 2: The last minute of the day on which an
    adjustment is made has 61 or 59 seconds.

Notice we have nothing about a 62-second minute.

http://www.boulder.nist.gov/timefreq/faq/q6.htm

    Why do we need leap seconds? 

    Occasional leap seconds are introduced into the UTC time system by
    international agreement for keeping the atomic-based time scale
    in approximate agreement with the astronomical time scale, UT1,
    which is based on the rotation of the earth. Even though the
    atomic UTC time scale is much more uniform than the UT1 scale,
    some users must work with earth-based time. For example, boaters
    navigating by using celestial navigation, need to know the UT1 time
    of their observations. Since only UTC time is normally broadcast
    by time-and-frequency radio stations such as WWV, the broadcasters
    agreed to occasionally adjust UTC time in steps of exactly 1 second
    so that the difference between UTC and UT1 would never exceed 0.9
    seconds. Thus, celestial navigators could then use the received UTC
    signals and know that any errors with respect to UT1 would be less
    than 1 second. Leap seconds have been inserted as needed into the
    UTC time scale since 1972 at average intervals slightly longer than
    one year.

http://astrosun.tn.cornell.edu/students/lazio/sci.astro.3.FAQ

    UTC is a time defined not by the movement of the earth, but by a
    large collection of atomic clocks located all over the world, the
    atomic time scale TAI. When UTC and UT1 are about to drift apart
    more than 0.9 s, a leap second will be inserted (or deleted, but
    this never has happened) into UTC to correct this. When necessary,
    leap seconds are inserted as the 61th second of the last UTC minute
    of June or December. During a leap second, a UTC clock (e.g., a GPS
    receiver) shows:

        1995-12-31 23:59:59
        1995-12-31 23:59:60
        1996-01-01 00:00:00

    ....

    For the latest status concerning leap seconds in UTC, send
    email to <adsmail@tycho.usno.navy.mil> with a Subject: line of
    'leap' and no text. You will receive in reply a list of past
    and provisional future leap seconds.  Additional information
    about the world time standard UTC (e.g., when will the next leap
    second be inserted in time, etc.)  is available from the US Naval
    Observatory on the Web <URL:http://tycho.usno.navy.mil/time.html>
    and from the International Earth Rotation Service (IERS) with
    anonymous ftp from <URL:ftp://mesiom.obspm.fr/iers/>. Also
    <URL:http://www.eecis.udel.edu/~ntp/> is a good start if you want
    to learn more about time standards.


Those should lead you to similar places.

If you can show me something from an astronomer or something
like NIST, then I'll believe you.  Manpages written by confused
programmers.

--tom
-- 
    I think I'm likely to be certified before Perl is...  :-) 
	--Larry Wall in <1995Feb12.061604.6008@netlabs.com>


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

Date: Sun, 12 Jul 1998 13:47:35 GMT
From: graemeaustin@my-dejanews.com
Subject: Re: hash's and a foreach - Can't do it?
Message-Id: <6oaepn$bdm$1@nnrp1.dejanews.com>

In article <6o7ueo$1qb$1@nnrp1.dejanews.com>,
  jevon@my-dejanews.com wrote:
> I would like to get some opinnions on how to append to a hash within a
> foreach..
>
> eg.
>
> I would like to do this:
>
> %items = (
>         $name => $value{$name}
> );
>
> but $value and $name are arrays. And I need to sort through them.. What I can
> do in a foreach..
>
> eg.
>
> This is what I would think would work.
>
> foreach $name (@name) {
>        %items = ($name => $value{$name})
> }
>
> I tried a push but I can't push a hash..
>
> Any suggestions?

How about...

foreach $name (@name) {
	$items{$name} = $name;
}

 ... but this will only generate a hash whose keys and values are the same -
you didn't give any indication of where the values are held.

If, suppose, you had two arrays, @names and @values, and they are related in
that eg $name[5] points to $values[5] then do something like this...

foreach $counter (0 .. $#names) {
	$items{$names[$counter]} = $values[$counter];
}

Of course, if @names and @values are not the same length, this doesn't work.

hope that helps you some

Graeme

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


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

Date: Sun, 12 Jul 1998 19:23:08 GMT
From: eslevitt@mediaone.net
To: Brett Denner <Brett.W.Denner@lmco.com>
Subject: Re: Having STDERR go to STDOUT in a system call
Message-Id: <6ob2es$ih2$1@nnrp1.dejanews.com>

In article <3586A04A.A8C09387@lmco.com>,
  Brett Denner <Brett.W.Denner@lmco.com> wrote:

> I have tried this approach:
>
>     open (STDOUT, "> file.txt") or die;
>     open (STDERR, "> file.txt") or die;
>     $ret = system "my_program";
>
> but I don't know how to "undo" the two open statements so that future writes
> or prints go to the original STDOUT and STDERR instead of file.txt.  If I
> close STDOUT and STDERR, any writes or prints later in the script do not work.

I don't know why no one answered your question directly.  You have probably
solved this by now, but just in case, the O'Reilly "Camel" book recommends
"saving, redirecting, and restoring" STDOUT and STDERR, like the following:

open SAVEOUT, ">&STDOUT";  #save
open STDOUT, ">foo.out";   #redirect
print STDOUT "something here\n"; #print
close STDOUT;
open STDOUT, ">&SAVEOUT"; #restore
print STDOUT "goes back where you want\n"; #print

To handle standard error, you duplicate everything above (line by line),
except you open STDERR as:

open STDERR, ">&STDOUT";

Their example unbuffers the output using a select before printing, in case
that's important.

Hope that helps!


Eliot Sabath-Levitt

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


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

Date: 12 Jul 1998 20:56:29 -0700
From: emclean@slip.net (Emmett McLean)
Subject: Help with cgi-lib.pl and input text boxes
Message-Id: <6oc0hd$orp@slip.net>

Hi,

I'd like to use cgi-lib.pl which comes with the 
Apache distribution. It works great except that
in an input text control all text after the
first blank gets annilated. Is there work around,
without using JavaScript which allows you to
extract all data in an input text control?

Thanks,

Emmett



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

Date: 9 Jul 1998 12:26:16 GMT
From: scott@softbase.com
Subject: Re: How to use 'system ("...")' on WIN32.
Message-Id: <6o2ct8$20f$3@mainsrv.main.nc.us>

Michael Pham <mpham@cts.com> wrote:
> I have a script that calls another script using 'system()' function.
> It works fine on Unix.  I tried to port it to WIN32 and find that it
> does not work as expected.  Any WIN32 gurus?

I would *EXPECT* this. Why *would* you expect a system() invocation
created for UNIX to work on Win32? They are very different operating
systems.

If Perl has a golden rule, it's "always look for ways to do things
using the functionality Perl provides rather than by calling the OS" --
particularly if you want to port your scripts! If you're calling
another Perl script, you should use some of the built-in Perl
mechanisms for doing so and not rely on the system() function. Use
eval, or wrap it as a package and require it. When you use system()
you're creating a new process, which is about the worst thing you can
do performancewise.

If it's a script in another language, you're likely going to have
to really work to get it to port to Win32. You'll have to get a
shell interpreter for that language, as well as any shell
utilities you need within the script.

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 


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

Date: 9 Jul 1998 12:30:47 GMT
From: scott@softbase.com
Subject: Re: HTTP connections WITHOUT the libwww module?
Message-Id: <6o2d5n$20f$4@mainsrv.main.nc.us>

David Thompson (domainsource@usa.net) wrote:
> Is it possible to retrieve a URL (and store for later parsing) WITHOUT
> using the LibWWW module?

Sure! In fact, it's such a simple matter that the LibWWW module seems
like overkill in all but the most advanced cases. I posted a geturl
function very recently that should still be accessible via DejaNews (I
no longer have it online anywhere I can get to it easily, or I'd attach
it to this post). It's a function that reads a URL into an array.
Basically take the canned socket code out of the Camel book and add
a HTTP transaction to it.

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 




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

Date: 12 Jul 1998 12:59:18 -0700
From: emclean@slip.net (Emmett McLean)
Subject: hypertext links to files in ls output
Message-Id: <6ob4im$dmc@slip.net>

Hi,

Does anyone have an example of a Perl script
which lists the files in a directory on a UNIX 
machine and adds the text so the filenames
appear as hypertext links in a html document?

Thanks,

Emmett



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

Date: 9 Jul 1998 12:35:48 GMT
From: scott@softbase.com
Subject: Re: mkdir with NT - question
Message-Id: <6o2df4$20f$5@mainsrv.main.nc.us>

Stephen Ghelerter (shortys@shortysplace.com) wrote:
> I want to create a new subdirectory from a web page on an NT server. My
> book on Perl only shows the permissions for Unix. I want execute
> permission only (to run Perl and VBscript scripts). Can anyone tell me
> how to do this. Thanks.

Even if you do it (does mkdir not work as-is on Win32? I have never had
any reason to use it, but I imagine the permissions stuff is translated
by the Perl interpreter from the UNIX octal code into something the NT
API can handle), but ...

Whether a directory is "executable" on the web servers I've used (which
are IIS and PWS) is doesn't seem to be controlled by the directory
permissions, but by the server's administration screens. The server
keeps track of which directories are allowed to execute scripts, and
the file system permissions aren't used. I could be totally wrong, but
it looks like the web server itself has a list of directories
from which you can execute programs. You'd have to find some way
to tell the web server you wanted the directory to be executable.

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 


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

Date: Sun, 12 Jul 1998 23:07:08 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Need a more efficient sort subroutine.
Message-Id: <1dc2t4g.1n7s3af19arglcN@bay1-529.quincy.ziplink.net>

[posted and mailed]

Meeko <meeko@meeko.org> wrote:

> I am writing a program which will let a user sort the contents of a
> csv file according to as many columns as he/she wishes to, however
> the sort routine I am using is taking extremely long, and since I am
> not an expert on writing efficient sort routines, I figured someone
> could come up with a much better one.  Here is what I am doing right
> now:
> 
> First of all, I'm using the Text::CSV module:
> 
> require Text::CSV;
> 
> Then I read in my file (passed as a command line argument) into one
> array, called @oldlines.  Now, what I want to do is sort those lines
> by the columns specified, which are also command line arguments, and
> are held in the array @col_num, and the scalar $count contains the
> number of columns to sort.  Before beginning the sort, I create 2 new
> CSV objects for the sort routine to use:
> 
> $aline=Text::CSV->new;
> $bline=Text::CSV->new;
> 
> Then I sort the lines, reversing the order in which I get them back,
> with this:
> 
> @newlines = reverse sort by_values @oldlines;

If you sorted in the opposite order to begin with, you wouldn't have to
reverse the result.

> Here is my inefficient by_values routine:
> 
> sub by_values {
>     $aline->parse($a);
>     $bline->parse($b);
> 
>     @alist=$aline->fields();
>     @blist=$bline->fields();
> 
>     for ($count=0; $count<$columns; $count++) {

I thought $count held the number of columns to sort.  I guess you meant
to say $columns did that.  But couldn't you just use scalar(@col_num)?
In fact, you should be able to use a foreach loop instead of a for loop.

>        $comp_a="\L$alist[$col_num[$count]]\E";  # Case insensitve
>        $comp_b="\L$blist[$col_num[$count]]\E";  # comparing

The lc() function would be more appropriate here.

>        $compare=($comp_a cmp $comp_b);
>        if ($compare!=0) { last; }
>     }
>     return $compare;
> }

I think the main problem is that you're parsing each line over and over
again.  You could save a lot of time by either caching the results of
the parse, or just parsing all the lines ahead of time, as in a
Schwartzian transform:

[Is it just me, or is the Text::CSV syntax kind of annoying?  It doesn't
support an expression such as 'Text::CSV->parse($_)->fields()'.]

# *** Almost entirely untested ***

$csv = new Text::CSV;

@newlines = map {$_->[0]}
            sort by_values
            map {[$_, [do{$csv->parse($_); $csv->fields()}]]} 
            @oldlines;

sub by_values {
  my $count;
  foreach my $col_num (@col_num) {
    return $cmp
      if ($cmp = lc($b->[1][$col_num]) cmp
                 lc($a->[1][$col_num]));
  }
  return 0;
}

# note $a and $b swapped to reverse sort order


You could also build your sort routine on the fly and eval the
definition, so that you don't have the overhead of a for loop for each
comparison.  This might not give you a big speed bonus.

# *** Partly tested ***

$sortsubdef = "sub by_values {\n  return\n";

foreach $col_num (@col_num) {
  push @cmp, '    ' .
    'lc($b->[1][' . $col_num . ']) cmp ' .
    'lc($a->[1][' . $col_num . '])';
}

$sortsubdef .= join(" ||\n", @cmp) . "\n  ;\n}\n1;\n";

eval $sortsubdef
  or die "Could not compile sortsub: $@\n\n$sortsubdef\n";

@newlines = map {$_->[0]}
            sort by_values
            map {[$_, [do{$csv->parse($_); $csv->fields()}]]} 
            @oldlines;


> The good news is, this routine does indeed work.  The bad news is, it
> took a good 30-40 minutes to execute on a Pentium 233, when sorting on
> a 3.5 MB .csv file with about 10 or 12 columns.  I know there has got
> to be a better way to sort these lines, I just don't know how.  I read
> lots about the Schwartzian Transform thing, but I'm not sure how I
> would implement that in this case.

Ah, you did think of it, cool.  I did have some difficulty figuring out
how to put it together with Text:CSV.  Especially since I've never used
that module.  So I might not have the syntax right.  :-)

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 12 Jul 1998 11:43:22 +0800
From: Austin Schutz <spamsux-tex@habit.com>
Subject: Re: number of days between two given dates using perl
Message-Id: <35A830DA.244B@habit.com>

santhi@my-dejanews.com wrote:
> 
> I have to calculate the number of days in between two given dates in certain
> format.( 07/10/98, 05/30/98 ) Is there any Perl module written for that, or I
> have to write my own function? Please help me.
> 

	A cursory examination of CPAN (http://www.cpan.org/) shows that
there are a couple modules that will help you accomplish this.
	Try reading the READMEs for those modules, you will more than
likely find a function or two to accomplish what you want. 


	Austin


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

Date: 12 Jul 1998 19:44:11 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl Beautifier Home Page
Message-Id: <6ob3mb$kml$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Rick Delaney <rick.delaney@shaw.wave.ca> writes:
:    %hash=(a=>'A',ab=>'AB',abc=>'ABC',);
:    $var=10;
:    $longvar=10;
:
:Beautified?:
:
::   %hash = (a => 'A', ab => 'AB', abc => 'ABC',);
::   $var = 10;
::   $longvar = 10;
:
:No syntax errors, but still not very pretty.

That should be:

    %hash   	= (a => 'A', ab => 'AB', abc => 'ABC',);
    $var     	= 10;
    $longvar 	= 10;

or probably even:

    %hash   	= (
		    a 	    => 'A', 
		    ab 	    => 'AB', 
		    abc     => 'ABC',
		);
    $var     	= 10;
    $longvar 	= 10;

or somesuch.

The day a beautifier can even PARSE all my code will be a miracle.
I can't possibly expect it to ever do 10% as good a job as I -- or any
other programmer with aesethetics -- could at make code look right.
Note that the examples I gave above are *not* amongst the things I
wouldn't expect it to be able do.

--tom
-- 
    "You're flame-proof in the same sense that certain plastics are fluorine-proof."
    	--Larry Wall


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

Date: 12 Jul 1998 19:54:36 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl Beautifier Home Page
Message-Id: <6ob49s$47u$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Rick Delaney 
<rick.delaney@shaw.wave.ca>],
who wrote in article <35A90407.7A686BB8@shaw.wave.ca>:
>     %hash=(a=>'A',ab=>'AB',abc=>'ABC',);
>     $var=10;
>     $longvar=10;
> 
> Beautified?:
> 
> :   %hash = (a => 'A', ab => 'AB', abc => 'ABC',);
> :   $var = 10;
> :   $longvar = 10;

CPerl will do it.

Hope this helps,
Ilya


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

Date: Sun, 12 Jul 1998 16:43:52 GMT
From: mspitzer@stones.com (Marc Spitzer)
Subject: Re: PING / Traceroute Perl Script
Message-Id: <35a8e61a.10522019@s1.optonline.net>

On Sat, 11 Jul 1998 18:02:16 -0700, Jesse Rosenberger
<jesse@savalas.com> wrote:

>I am trying to get a Ping and a Traceroute Perl Script  to work so that
>they will output the information as they are recieved (ie nph-file.pl).
>Has anyone done this?  So far this is what I have, and this is only for
>the Ping Script:
>
>$fqdn = $ENV{'QUERY_STRING'};
>$ping_cmd = "/sbin/ping";
>$num_times = 4;
>@result = `$ping_cmd -c$num_times $fqdn`;
>
>print "Content-type: text/html\n\n";
>print "Ping Results For <b>$fqdn</b>:<br>";
>print "<br>\n";
>print "@result";
>exit;
>
>but it prints it all out in one block instead of line-by-line, like the
>normal ping output looks, and it also waits till all the pinging is done
>before it outputs.   Can anyone help me with this?
>

This is kind of ugly and unsafe but you can do this:

open( PING, "$ping_cmd -c$num_times $fqdn |" ) or die " message here";
while (<PING>)
{ 
  print ;
}

this opens a pipe for reading and prints the output 1 line at a time.

if you mail me at work marc@nassau.cv.net I will send you a small
perl/cgi that lets you set some ping options and also has a traceroute
button in it.  

happy coding
marc 
>Thanks in advance,
>Jesse Rosenberger
>



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

Date: 12 Jul 1998 15:17:37 -0500
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: Putting CPAN on a CD:  good or not good?
Message-Id: <ysin2aej02m.fsf@blkbox.com>

Randal Schwartz <merlyn@stonehenge.com> writes:

> 
> Not free.  Just sensibly priced.
> 
> :-)
> 
> Seriously though, "not going to jail" is a long way from "no longer a
> felon".  That's another two years in the making <sigh, crossing
> fingers>.
> 

This is a new developement (at least to me).  What happened?
(Email or a URL to check out is fine for an answer.)

Kent


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

Date: 8 Jul 1998 12:25:47 GMT
From: scott@softbase.com
Subject: Re: Running cgi executables in Windows http server
Message-Id: <6nvogb$k2a$2@mainsrv.main.nc.us>

Harinder Pal Singh Takhar (htakhar@hotmail.com) wrote:
> ... seems to keep waiting till forever.
> The web server i am using is frontpage web server.

This is normal, and here's what's happening:

You're likely using the perl.exe command line version of Perl, which
doesn't work. You need the ISAPI DLL version of Perl. You should be
able to get it where you got the original Perl interpreter.

Once you install the ISAPI version, you should have no more problems
like this. You'll probably have *other* problems, but you 
should be able to run basic Perl CGI programs.

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 


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

Date: Sun, 12 Jul 1998 23:44:14 -0400
From: "David Thompson" <domainsource@usa.net>
Subject: Silly question about IO::SOCKET
Message-Id: <6obvjf$il5$1@winter.news.erols.com>

I'm just getting into a simple webget client and I have the following
code fragmet that seems to work:

$remote = IO::Socket::INET->new ( proto => "tcp",
PeerAddr => $host,
PeerPort => "http(80)",
);
unless ($remote) {die "error"}
$remote->autoflush(1);
printe $remote "GET $document HTTP/1.0\n\n";
while (<$remote>) {print}
-close $remote;


Now, my silly questions is if I want to save the results into a string
instead of printing it, what do I put after the while?  Would
$somestring .= $remote work?  Thanks!!!

David






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

Date: 9 Jul 1998 12:44:33 GMT
From: scott@softbase.com
Subject: Re: Splitting a difficult CSV file
Message-Id: <6o2dvh$20f$6@mainsrv.main.nc.us>

Matthew Giles (mgiles@mindspring.com) wrote:

> I am totally stumped on how to split this Excel exported CSV file that is
> being delivered to me each day.  I'm trying to read the file in and spit
> out an HTML document with the three nicely formatted tables.

Since you're exporting the data from Excel anyway...

Why not use the Excel HTML generation capabilities to generate HTML?
Write a little VBA macro to arrange the data the way you want it, and
export the data as HTML? (If you can't change the export format,
re-import it into Excel and do it yourself :)).

> I could read
> the entire document in an array and pick out each element..

Why not read each line into an array? I'm not sure from this post
exactly what you're trying to do. You know the headers will always be
the same, so read the file until you get to a header, then read each
line and process it. Programs that process CSV files are loop-oriented.

> I also need the date and day of week fields which change
> from the data file.  But these fields are identical for each of the three
> tables so I can not use them as a key to being reading in the data.

I guess I just can't follow what the problem is. Your post is very
vague and has nonsense expressions like "being reading" in it that
makes it difficult to figure out what you're really asking for help
with. Try explaining what the goal of your program is, and the
pseudo-code algorithm you want to use. Normally, once you have that,
a Perl program will write itself because Perl is so expressive.
I highly recommend a book called Code Complete if you're having
trouble turning what the program should do into code. It's a great
book that has many useful techniques for crafting code.

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 


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

Date: Sun, 12 Jul 1998 15:00:09 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Weirdness in trying to extract year from localtime
Message-Id: <fl_aggie-1207981500090001@aggie.coaps.fsu.edu>

In article <6o6dlk$md6@Xenon.Stanford.EDU>, hirano@Xenon.Stanford.EDU
(Kelly Hirano) wrote:

+ In article <35A6B033.A2BA3BDF@us.oracle.com>,
+ Allen Choy  <achoy@us.oracle.com> wrote:
+ >Don't I get into a Y2K problem if I add 1900?
+ 
+ someone just posted this a few days ago. rtfm.

You'll be seeing this every couple of days/hours/minutes until about
0000 GMT 01 Jan 2000. I threw together the attached script for the
groups amusement...

James

#!/usr/bin/perl -w
#-- -*-perl-*-
use Date::Manip;
my $err;

$date1=&ParseDate("now");
$date2=&ParseDate("Dec 31, 1999  12:00:00 GMT");
$delta=&DateCalc($date1,$date2,$err);
$str=&Delta_Format($delta,0,"%hh");
print "Only $str hours till the Year 2000 bug hits!\n";


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

Date: Mon, 13 Jul 1998 03:03:21 GMT
From: jim@bokler.com (James Moore)
Subject: What's the substitute for #! /usr/bin/perl in Win32 Perl?
Message-Id: <35aa75d7.2257729152@newstoo.hiwaay.net>

Newby needs an answer to the following question:

I'm using the ActiveState Win32 Perl on an NT 4.0 system... what do I
use in place of the first line (#! /usr/bin/perl) in Unix versions of
the script ?

Thank you,
Jim Moore


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

Date: Sun, 12 Jul 1998 13:11:49 +0100
From: Geoff Wilkins <GeoffW@wordsmith.demon.co.uk>
Subject: Where can I find GD.pm
Message-Id: <JmIyANAFgKq1EwfF@wordsmith.demon.co.uk>

I'm looking urgently for Lincoln Stein's Perl graphics module, GD.pm.
All the links I've come across are to

        www-genome.wi.mit.edu/ftp/pub/software/WWW/GD.html

but this gives the message

        "File Not Found: Our server is in the middle of maintenance..."

Does anyone know where else I might find it?  (Or anything similar?)


Geoff Wilkins

34 Farnham Road, Handsworth, Birmingham B21 8EG, UK, 
        telephone: 0121-554 8264

email GeoffW@wordsmith.demon.co.uk
Web-site at http://www.wordsmith.demon.co.uk/


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

Date: 13 Jul 1998 03:53:22 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Why is Dave operating here? (was Re: REPOST: Re: )
Message-Id: <6oc0bi$3cd$1@news.NERO.NET>

X-Reposted-By: dave@ferret.ocunix.on.ca

When was the charter for this newsgroup changed to invite Dave? I don't
recall any discussion asking for Dave's "help", and do not appreciate
losing the ability to cancel my own articles.



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

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

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