[8037] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1662 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 17 19:07:07 1998

Date: Sat, 17 Jan 98 16:00:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 17 Jan 1998     Volume: 8 Number: 1662

Today's topics:
     Re: Backspacing in output ? <bowlin@sirius.com>
     Re: Backspacing in output ? <maxwell@natasha.jpl.nasa.gov>
     Re: Book review wanted - GET IT FOR FREE <gedavis3@vt.edu>
     Re: converting file names down a directory tree <joseph@5sigma.com>
     Re: Create file <gedavis3@vt.edu>
     Re: Create file <gedavis3@vt.edu>
     Re: Create file <gedavis3@vt.edu>
     Re: EMTY FILE? (Tad McClellan)
     Re: EMTY FILE? <rjk@coos.dartmouth.edu>
     Re: get machine name from IP? (Juergen Heinzl)
     Re: get machine name from IP? <maxwell@natasha.jpl.nasa.gov>
     Re: get machine name from IP? (Tad McClellan)
     HELP: Efficient *Wait*ing for file to appear. <david@telekinesys.co.uk>
     Re: HELP: Efficient *Wait*ing for file to appear. (Juergen Heinzl)
     Re: How to do random pornography in Perl. (Nathan V. Patwardhan)
     Re: How to do random pornography in Perl. (Nathan V. Patwardhan)
     How to modify files? <balder@tavosf.iso.dec.com>
     Re: How to modify files? (Tad McClellan)
     Re: Logical 'and' in regex? (Martin Vorlaender)
     Newbie question: exact time <vit@unforgettable.com>
     Re: Newbie question: exact time (I R A Aggie)
     Re: Newbie question: exact time (Clay Irving)
     Re: Perl 5.0040x and FreeBSD-2.2.x (Nathan V. Patwardhan)
     Re: Perl for Engineering purposes <fgiorg@atl.com>
     Re: Please Help <gedavis3@vt.edu>
     Programmers everywhere! <loren..baker@worldnet.att.net>
     Re: Puzzling behavior of c.l.p.* readers (Erik Y. Adams)
     Re: Puzzling behavior of c.l.p.* readers (Nathan V. Patwardhan)
     Re: Puzzling behavior of c.l.p.* readers (Nathan V. Patwardhan)
     Q: Regional Sort by ZIP code? <fgiorg@atl.com>
     Re: Q: Regional Sort by ZIP code? (brian d foy)
     returning values out of a recursed sub (William Byrd)
     Re: returning values out of a recursed sub (Tad McClellan)
     Re: sending emails with perl ? (DIAL-MB-Edward Finch)
     Sort question <andrew.spiers@virgin.net>
     Re: Sort question (Nathan V. Patwardhan)
     Re: Style Q for modules:  best syntax for "hash" argume <eryq@zeegee.com>
     UserAgent Post/Get, Print, Here, etc. (SasEz! Publications and Design)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 17 Jan 1998 10:46:35 -0800
From: Jim Bowlin <bowlin@sirius.com>
To: Surinder Singh <ssingh1@xws379.sc.intel.com>
Subject: Re: Backspacing in output ?
Message-Id: <34C0FC8B.2D8040FC@sirius.com>

Once you've printed \n to stdout, you're out of luck
so don't do that.  Instead use \r which will allow
you to overwrite the previous output.  For example:

print "first\r";
print "second\r";

Will end up with just the word "second".

One thing to keep in mind, there is no automatic way to
erase a line so you need to pad the end of each line with
spaces in order to erase the previous output.  For example:

sub oneline {
    my $s = shift;
    $s = substr($s, 0, 70);
    print $s, ' ' x (70 - length($s)), "\r";
};

HTH - Jim Bowlin

Surinder Singh wrote:
> 
> How can I print to STDOUT something and then
> have it backspaced or deleted.
> In a program that is slow to run I could, for
> instance, print the loop index of the current loop,
> then deleted and the new index printed
> when the loop index changes. This saves from having
> screen cluttered.
> 
> Thanks a lot.
> 
> --
> Surinder
> 
> -------------------------------------------------------------------
> I speak only for myself, not for my employer
> -------------------------------------------------------------------


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

Date: 17 Jan 1998 14:47:54 -0800
From: Scott Maxwell <maxwell@natasha.jpl.nasa.gov>
Subject: Re: Backspacing in output ?
Message-Id: <m390sebtut.fsf@localhost.localdomain>

Jim Bowlin <bowlin@sirius.com> writes:

> Surinder Singh wrote:

> > How can I print to STDOUT something and then
> > have it backspaced or deleted.
> > In a program that is slow to run I could, for
> > instance, print the loop index of the current loop,
> > then deleted and the new index printed
> > when the loop index changes. This saves from having
> > screen cluttered.

> One thing to keep in mind, there is no automatic way to
> erase a line so you need to pad the end of each line with
> spaces in order to erase the previous output.  For example:

The original poster was talking about printing loop indices -- so if
he's counting up, he'll never print anything shorter than before.  But
anyway ....

> sub oneline {
>     my $s = shift;
>     $s = substr($s, 0, 70);
>     print $s, ' ' x (70 - length($s)), "\r";
> };

In the spirit of TMTOWTDI, how about this:

BEGIN {
    my $erase = '';		# How to erase previous OneLine() output.

    sub OneLine {
	my $s = shift(@_);

	printf '%s', "$erase$s";
	$erase = "\r" . (' ' x length($s)) . "\r";
    }
}

(I use printf instead of print because I normally have $\ set to "\n".)

This keeps the cursor at the end of the line until you print the next
line (which I think looks a little nicer).  Also, it isn't limited to
70 columns (or whatever number you choose), although on my system it
doesn't work properly when a line exceeds the terminal width.  To
really solve this, you may have to use tset and tput (under Unix), or
there may be a CPAN module that abstracts such stuff.

-- 
-------------------------+-----------------------------------------------------
R H L U  Scott Maxwell:  | perl -e '$\=".\n";Just();sub another{Perl()}sub Just
E A I X      s-max@      | {another()}sub Perl{hacker()}sub hacker{$,=" ";print
D T N !    pacbell.net   | reverse map{$_=(caller($_))[3];s/.*:://;$_}(0..3)}'


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

Date: Sat, 17 Jan 1998 16:09:43 -0500
From: "Jerry Davis" <gedavis3@vt.edu>
Subject: Re: Book review wanted - GET IT FOR FREE
Message-Id: <69r6ok$re3$1@solaris.cc.vt.edu>

http://www.mcp.com/personal/

go to the above URL and register (for free) for personal bookshelf.
Then you can log in and "check out" htmled versions of 100's of computer
related books.
They have that exact book their.  I didn't like it that much.  I found it
easier to use a seperate book for perl (teach yourself perl in 21 days) and
then a book that explains just cgi.

REGARDLESS YOU OWE IT TO YOURSELF TO CHECK THIS SITE OUT!

Jerry


Brad McFarlane wrote in message ...
>A local remaindered book sale has:
>
>Teach Yourself CGI Programming with Perl 5 in a week, 2nd Ed.
>
>by Eric Herrmann (publisher SAMS) for CDN$20, with a CD-ROM included. I
know
>a bit of Perl, and have used the CGI module to do some CGI programming;
>with my appetite whetted, I want to get a bit futher into it, and this
>looks like a good book to help me. I checked various Perl web pages, and
>couldn't find a review of it. Has anybody got it or read it? If so, how is
>it? I figure for $20 it won't be a big loss, but if it's as bad as some of
>the books mentioned in the "Camel Critiques", I want to steer clear.
>
>Any info would be appreciated.
>Thanks,
>Brad
>
>--
>Brad McFarlane
>Newbridge Networks Corp.
>Kanata, Ont. CANADA




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

Date: Sat, 17 Jan 1998 12:26:40 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: converting file names down a directory tree
Message-Id: <34C105CF.2F1C2037@5sigma.com>

Actually this is one of the more stupid posts I've generated
in a while.  I completely spaced on File::Find, and besides
this example will chase symlinks.  Bad Joseph!  Bad Joseph!

	-joseph
	 http://www.effectiveperl.com

Joseph N. Hall wrote:
> 
> This program executes quickly, although it's not necessarily
> quick to write from scratch:
> 
> sub recurse {
>   local *DH;
>   my $dir = shift;
  [blah blah blah]


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

Date: Sat, 17 Jan 1998 14:03:00 -0500
From: "Jerry Davis" <gedavis3@vt.edu>
Subject: Re: Create file
Message-Id: <69qvdo$kn3$1@solaris.cc.vt.edu>

first of all make sure that you can open a file the simple way before
involving variables.
Try
open(FILE, "file.txt");
and
open(FILE, ">file.txt");

if you can't get the second one to work most likely your directory does not
have write permision.  set it or ask your sysadmin.

Now if they both work.  Then try it with variables

$filename = 'file.txt';
open(FILE, ">$filename");

Solve one problem at a time.
Jerry



Kitse / Phoenix Bird Coders wrote in message ...
>Hiya,
>
>I didn't find out, how could one create file in perl.
>Ok, one way is open(SomeHandle,">SomeFile"); --- that's not working (and
>man says that) when filename is in some variable, say,
>open(SomeHandle,">$FileNameVariable"); # <- not OK
>
>So, how could i create file?





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

Date: Sat, 17 Jan 1998 14:03:00 -0500
From: "Jerry Davis" <gedavis3@vt.edu>
Subject: Re: Create file
Message-Id: <69qvi8$l7u$1@solaris.cc.vt.edu>

first of all make sure that you can open a file the simple way before
involving variables.
Try
open(FILE, "file.txt");
and
open(FILE, ">file.txt");

if you can't get the second one to work most likely your directory does not
have write permision.  set it or ask your sysadmin.

Now if they both work.  Then try it with variables

$filename = 'file.txt';
open(FILE, ">$filename");

Solve one problem at a time.
Jerry



Kitse / Phoenix Bird Coders wrote in message ...
>Hiya,
>
>I didn't find out, how could one create file in perl.
>Ok, one way is open(SomeHandle,">SomeFile"); --- that's not working (and
>man says that) when filename is in some variable, say,
>open(SomeHandle,">$FileNameVariable"); # <- not OK
>
>So, how could i create file?





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

Date: Sat, 17 Jan 1998 14:03:00 -0500
From: "Jerry Davis" <gedavis3@vt.edu>
Subject: Re: Create file
Message-Id: <69qvkh$lkk$1@solaris.cc.vt.edu>

first of all make sure that you can open a file the simple way before
involving variables.
Try
open(FILE, "file.txt");
and
open(FILE, ">file.txt");

if you can't get the second one to work most likely your directory does not
have write permision.  set it or ask your sysadmin.

Now if they both work.  Then try it with variables

$filename = 'file.txt';
open(FILE, ">$filename");

Solve one problem at a time.
Jerry



Kitse / Phoenix Bird Coders wrote in message ...
>Hiya,
>
>I didn't find out, how could one create file in perl.
>Ok, one way is open(SomeHandle,">SomeFile"); --- that's not working (and
>man says that) when filename is in some variable, say,
>open(SomeHandle,">$FileNameVariable"); # <- not OK
>
>So, how could i create file?





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

Date: Sat, 17 Jan 1998 16:30:29 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: EMTY FILE?
Message-Id: <5ebr96.4p9.ln@localhost>

William Byrd (wcb4@erols.com) wrote:

: There are many of us using perl on Macs or Win systems, thus no
: perlfunc manpage. 


"manpage" is a colloquial usage, it does not really mean "accessed
via the 'man' program". It means "check the docs that came with
your perl distribution".

You likely have a "perlfunc HTML page" instead (which makes it
harder to just word search in. I use the raw *.pod files for that).


The canonical format (ie. the official versions from which all the
other formats are derived) is a POD (Plain Old Documentation) file,
with .pod filename extension.


I don't have any experience with MS or Apple perl distributions.


******************************

Would folks that know of any distribution that does not include
the docs in one form or another please chime in here?

If there are broken distributions around, then folks should know
the names of those distributions...

******************************



: a URL would be appreciated


   http://language.perl.com/info/documentation.html#online


has several formats:  HTML, Postscript, PDF, ASCII text...


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


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

Date: Sat, 17 Jan 1998 18:47:25 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: wcb4@erols.com
Subject: Re: EMTY FILE?
Message-Id: <34C1430D.5C7C1316@coos.dartmouth.edu>

[posted and mailed]

William Byrd wrote:
> 
> There are many of us using perl on Macs or Win systems, thus no
> perlfunc manpage. I do have the camel book and can look it up (the
> book never leaves my computer desk), but is there a winhelp file or
> one of those nifty apple help files or hypercard stacks or something
> that us non unix users can keep on our desktops for quick reference?

Both MacPerl and the Win32 ports come with all the manpages.  It just
happens you don't access them with the 'man' command.

In MacPerl, the documentation is under the Help menu, as you'd expect.
The perlfunc manpage is the menu item named 'Builtin Functions'.

I believe that Win32 ports have the documentation in HTML format, so
you can read them with your web browser.

Additionally, all the manpages are available at <http://www.perl.com/>

Chipmunk


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

Date: 17 Jan 1998 22:20:33 GMT
From: juergen@unicorn.noris.de (Juergen Heinzl)
Subject: Re: get machine name from IP?
Message-Id: <slrn6c2c0u.4n.juergen@unicorn.noris.de>

In article <69qtb7$69n$1@solaris.cc.vt.edu>, Jerry Davis wrote:
>one can track the IP of the user who activates a perl script with the
>$ENV('REMOTE_ADDR') variable.

see gethostbyaddr( $ipaddress, AF_INET )

Bye, Juergen

-- 
\ Real name     : Juergen Heinzl     \       no flames      /
 \ EMail Private : unicorn@noris.de   \ send money instead /
  \ Phone Private : +49 911-4501186    \                  /


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

Date: 17 Jan 1998 15:00:22 -0800
From: Scott Maxwell <maxwell@natasha.jpl.nasa.gov>
Subject: Re: get machine name from IP?
Message-Id: <m37m7ybta1.fsf@localhost.localdomain>

"Jerry Davis" <gedavis3@vt.edu> writes:

> $ENV('REMOTE_ADDR') variable.  Is there a perl command to either get or
> convert that to the machine name.

Hmm ... I thought gethostbyaddr() would do it, though it doesn't seem
to be working in the quick test I just tried.  Maybe it'll work for
you anyway.

-- 
-------------------------+-----------------------------------------------------
R H L U  Scott Maxwell:  | perl -e '$\=".\n";Just();sub another{Perl()}sub Just
E A I X      s-max@      | {another()}sub Perl{hacker()}sub hacker{$,=" ";print
D T N !    pacbell.net   | reverse map{$_=(caller($_))[3];s/.*:://;$_}(0..3)}'


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

Date: Sat, 17 Jan 1998 16:46:57 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: get machine name from IP?
Message-Id: <1dcr96.nr9.ln@localhost>

Jerry Davis (gedavis3@vt.edu) wrote:
: one can track the IP of the user who activates a perl script with the
: $ENV('REMOTE_ADDR') variable.  Is there a perl command to either get or
: convert that to the machine name.
: i.e gedavis3.campus.vt.edu.  Mainly I want to be able to track the domain
: the user is comming from.


Net::Whois module:

   http://www.perl.org/CPAN/modules/by-module/Net/CHIPS/


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


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

Date: Sat, 17 Jan 1998 20:23:56 +0000
From: David Greaves <david@telekinesys.co.uk>
Subject: HELP: Efficient *Wait*ing for file to appear.
Message-Id: <34C1135C.37586EF@telekinesys.no.co.spam.uk>

Hi
I'm writing a script that needs to wait for a file to appear.

Any ideas how I can do this efficiently and responsively?

Ideally not:
  while !(-e $file) {sleep $for_a_bit} ;

preferably
  sleep_until($file)

David
--
David Greaves




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

Date: 17 Jan 1998 22:27:53 GMT
From: juergen@unicorn.noris.de (Juergen Heinzl)
Subject: Re: HELP: Efficient *Wait*ing for file to appear.
Message-Id: <slrn6c2cem.4n.juergen@unicorn.noris.de>

In article <34C1135C.37586EF@telekinesys.no.co.spam.uk>, David Greaves wrote:
>Hi
>I'm writing a script that needs to wait for a file to appear.
>
>Any ideas how I can do this efficiently and responsively?

Just an idea though it may not be what you need ...

* create a named pipe (mkfifo fifo for instance)
* open( FIFO, "<fifo" ) || die "oops";
  while (<FIFO>) {
         print THEREALFILE $_;
  }

 ... but it may be a nice work around.

Bye, Juergen

-- 
\ Real name     : Juergen Heinzl     \       no flames      /
 \ EMail Private : unicorn@noris.de   \ send money instead /
  \ Phone Private : +49 911-4501186    \                  /


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

Date: 17 Jan 1998 20:23:53 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: How to do random pornography in Perl.
Message-Id: <69r40p$bm4@fridge.shore.net>

Fred Tunalu (tunalu@geocities.com) wrote:
: Need random pornography in Perl?

Seems to me that all pronography is kind of random.  :-)

--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov


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

Date: 17 Jan 1998 21:05:04 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: How to do random pornography in Perl.
Message-Id: <69r6e0$bm4@fridge.shore.net>

Nathan V. Patwardhan (nvp@shore.net) wrote:
: Fred Tunalu (tunalu@geocities.com) wrote:
: : Need random pornography in Perl?

: Seems to me that all pronography is kind of random.  :-)

As is my spelling of pornography.  Blargh!

--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov


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

Date: Sat, 17 Jan 1998 23:18:30 +0200
From: Daniel Balderman <balder@tavosf.iso.dec.com>
Subject: How to modify files?
Message-Id: <34C12026.338A@tavosf.iso.dec.com>

Hi,

This is a beginner question, What I wish to do seems to me something
simple.
I'd like to open a text file, where each line is read into a variable
(string). then change one of the strings (line) and write it back
instead of the old one.

I would appreciate any code example...

Thanks,
Danny.
Daniel.Balderman@digital.com


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

Date: Sat, 17 Jan 1998 16:52:22 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to modify files?
Message-Id: <6ncr96.nr9.ln@localhost>

Daniel Balderman (balder@tavosf.iso.dec.com) wrote:

: This is a beginner question, 


No problem.


: What I wish to do seems to me something
: simple.

When you find yourself saying that, you should think
"Frequently Asked Question" (FAQ).


: I'd like to open a text file, where each line is read into a variable
: (string). then change one of the strings (line) and write it back
: instead of the old one.

Perl FAQ, part 5:

   "How do I change one line in a file/delete a line in a file/
    insert a line in the middle of a file/append to the beginning of a file?"


: I would appreciate any code example...


There's code there too.


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


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

Date: Sat, 17 Jan 1998 19:22:50 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Logical 'and' in regex?
Message-Id: <34c0f6fa.524144494f47414741@radiogaga.harz.de>

Frank (FHeasley@chemistry.com) wrote:
: In the meantime, I found the
: following will also do it, although inelegantly:

Why "inelegantly"? I think Perl's concept of "it" allows extremely elegant
constructs.

: $_  = $menu;

: if (/bacon/ && /eggs/ && /waffles/ && /juice/) { 

: # oddly, if ($_ =~  (/bacon/ && /eggs/ && /waffles/ && /juice/)) fails

Does not surprise me. You'll have to write it like

if ($_ =~ /bacon/ && $_ =~ /eggs/ && $_ =~ /waffles/ && $_ =~ /juice/)

But then, I think you chose to assign $menu to $_ to avoid just that.

cu,
  Martin
--
                          | Martin Vorlaender | VMS & WNT programmer
 Ceterum censeo           | work: mv@pdv-systeme.de
 Redmondem delendam esse. |       http://www.pdv-systeme.de/users/martinv/
                          | home: martin@radiogaga.harz.de


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

Date: Sat, 17 Jan 1998 14:31:13 -0800
From: Vitalik <vit@unforgettable.com>
Subject: Newbie question: exact time
Message-Id: <34C13131.6DD6095@unforgettable.com>

Hi,
 I need  some function like 'time', but more exact.
  time returns something like 885076162 , but i need something like
885076162.123456

 Can you help me, please?
Thank you in advance.

				Vitaly


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

Date: Sat, 17 Jan 1998 16:26:34 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Newbie question: exact time
Message-Id: <fl_aggie-1701981626350001@aggie.coaps.fsu.edu>

In article <34C13131.6DD6095@unforgettable.com>, Vitalik
<vit@unforgettable.com> wrote:

+ Hi,
+  I need  some function like 'time', but more exact.

Does this help?

          The Time::HiRes module implements a Perl interface to the
          usleep, ualarm, and gettimeofday system calls. See the
          EXAMPLES section below and the test scripts for usage; see
          your system documentation for the description of the
          underlying gettimeofday, usleep, and ualarm calls.

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: 17 Jan 1998 18:28:25 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Newbie question: exact time
Message-Id: <69reqp$1k6@panix.com>

In <34C13131.6DD6095@unforgettable.com> Vitalik <vit@unforgettable.com> writes:

> I need  some function like 'time', but more exact.
>  time returns something like 885076162 , but i need something like
>885076162.123456

Perl Modules are your friend.

Something like Time::HiRes might do the trick for you:

  gettimeofday ()
  In array context it returns a 2 element array with the seconds and
  microseconds since the epoch.  In scalar context it returns floating
  seconds like Time::HiRes::time() 

Example:

  use Time::HiRes qw(gettimeofday);

  # get seconds and microseconds since the epoch
  ($s, $usec) = gettimeofday;

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: 17 Jan 1998 20:55:38 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Perl 5.0040x and FreeBSD-2.2.x
Message-Id: <69r5sa$bm4@fridge.shore.net>

Soulsmith (soulsmit@vader.deepsky.com) wrote:
: I'm having some difficulties with Perl on the FreeBSD platform and I'm
: wondering if anybody else has come across the same problems?

I've never had any problems with Perl under any FreeBSD (1.x - 2.2.x);
I've always built it myself and made sure to make test before
installing it.  I've also blown away any pre-packaged versions of Perl
before installing my own.

Were you sure to enable 003 compatibility when you built 004_0x?

Did you check the mailing list archives at freebsd.org about the
problems you're having with Perl?

--
Nathan V. Patwardhan


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

Date: 15 Jan 1998 23:37:15 GMT
From: Fred Giorgi <fgiorg@atl.com>
Subject: Re: Perl for Engineering purposes
Message-Id: <69m6jb$n291@sunshine.atl.com>

Well the world is not so different as you may think. I for one would
greatly 
benefit from your works both in engineering lab automation(production
testing)
and remote web control of embedded controllers (robotics hobby). Perl is
not
recognized at my work place outside the SW tools and IS departments. If I
were
consulting I too would be wary of the changes in compilers and scientific
analysis packages. Not every company and sometimes department within 
updates their tools at the same time. Knowing how an getting the job done
quickly in perl has termendous career potential. I'm just getting started
in perl but I see there is an interface to mathematica and other
scientific
libraries available. It must be widely used in engineering.
THis group is rather rich. Maybe whats neede is a news thread prefix like
 [ENG] of [SCI] to focus interest a bit.
--fred
In article <696gdh$ob2$1@news.fm.intel.com> Terry Michael Fletcher - PCD
~, tfletche@pcocd2.intel.com writes:
>at home, i am using perl to communicate with an HC11 processor EVBU board's
>RS-232 serial port from WindowsNT (is this closer to your particular use?).  it
>is used to remotely monitor and control a house via a web page.
>
>i think that when you get down to those low-levels, the particular use of perl
>becomes way too specific to be released as a public module.  it will probably be
>difficult to find enough of us geeks using perl for the exact same thing to even
>warrant a mailing list!
>


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

Date: Sat, 17 Jan 1998 14:08:56 -0500
From: "Jerry Davis" <gedavis3@vt.edu>
Subject: Re: Please Help
Message-Id: <69qvmd$ohn$1@solaris.cc.vt.edu>

don't use split, instead read the lines in one at a time and store in
@Balance.

$linenumber=0;
while (!EOF)
{
    $line = <FILE>;
    $Balance[$linenumber]=$line;
    $linenumber++;
}
then use split to break up each element in @Balance

Jerry

Jeff Marsh wrote in message <69hd40$edp@sjx-ixn4.ix.netcom.com>...
>I would appreciate any help that anyone can give me here...
>
>I have a script that reads a text file where the information is delimited
by
>carriage return. How do I tell the script to look for the return and split
>values accross it???
>
>Here is the code fragment so far...
>
>open ($file,"test.txt");
>@Balance = split( ##Put carriage return here!!##, <$file>);
>foreach $pair (@Balance) {
> ($name, $value) = split('=', $pair);
> @first[$count] = $name;
> @second[$count] = $value;
> $count = $count+1;





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

Date: Sat, 17 Jan 1998 12:54:46 -0600
From: Paul Baker <loren..baker@worldnet.att.net>
Subject: Programmers everywhere!
Message-Id: <69qunh$miq@bgtnsc02.worldnet.att.net>

Hello everyone. I was wondering if you would like to take part in
Ulitmate Chat. I am looking for a couple of programmers to help me in
UChat (Ultimate Chat). I have no clue how to program in perl, all i know
is HTML & JavaScript. So if you are interested, just send an email!

Paul Baker



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

Date: Sat, 17 Jan 1998 11:16:09 -0800
From: erik@earthlink.net (Erik Y. Adams)
Subject: Re: Puzzling behavior of c.l.p.* readers
Message-Id: <erik-1701981116090001@pool005-max15.mpop2-ca-us.dialup.earthlink.net>

Two things I wanted to respond to.  First, 

<snip>
>* People who automatically think that something besides their code is
>broken: "Subject: CGI.pm broken????!?!?"

This problem is not at all unique to c.l.p.* groups.  It happens all the
time in many groups; it's just more common in programming groups.  Lately
I've been reading the Microsoft ASP groups, and it's exactly the same
thing you describe:  everyone assumes ASP, NT, or IIS is broken or has
some kind of bug before they try and really debug their own scripts.  Now,
as it happens, they're right about ASP, NT, and IIS, but that's a
different issue ;-)

<snip>
>* People who try to fit Perl into their BASIC/C/whatever paradigms, and
>have apparently looked at NO code besides their own, anywhere.  
>"I want to see if the first character of a string is a Y.  Here's what I
>have so far:
>  $string = "Yes";
>  $firstchar = substr( $string, 1, 1 );
>  if ( $firstchar == "Y" ) || ( $firstchar == "y" ) { ...
>but it doesn't work!  Why?"
>
>Sooner or later, you have to learn to use the tool you're using, no?

Just because someone doesn't use a feature of Perl doesn't mean that
they're doing it wrong.  All together now: there's more than one way to do
it.  Now, not using regexps is particularly stunning, but if the code does
what it's supposed to, who cares how it was written?

Erik

-- 
----------------------------------------------------------
Erik Y. Adams                           erik@earthlink.net
Information Systems Consultant                626/795-2701
Internet and Intranet Specialist


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

Date: 17 Jan 1998 21:02:27 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Puzzling behavior of c.l.p.* readers
Message-Id: <69r693$bm4@fridge.shore.net>

Erik Y. Adams (erik@earthlink.net) wrote:

: it.  Now, not using regexps is particularly stunning, but if the code does
: what it's supposed to, who cares how it was written?

(1) your clients [did they get something well-written for their $?]
(2) programmers who might inherit the code from you at a later date

--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov


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

Date: 17 Jan 1998 20:58:58 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Puzzling behavior of c.l.p.* readers
Message-Id: <69r62i$bm4@fridge.shore.net>

Randal Schwartz (merlyn@stonehenge.com) wrote:

: There's always some looney in the crowd that says "hey, this shouldn't
: be discussed here... please take to to rec.aquaria!"

Well, at least nobody's mentioned Hitler or Mussolini yet.  ;-)

--
Nathan V. Patwardhan
please don't send spam to president@whitehouse.gov


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

Date: 16 Jan 1998 19:49:47 GMT
From: Fred Giorgi <fgiorg@atl.com>
Subject: Q: Regional Sort by ZIP code?
Message-Id: <69odkr$n4r1@sunshine.atl.com>

I need to sort database records by region (group of states) or state. But
the only guarenteed field I can use is ZIP code. Does anyone have a table
that can be used to cross refrence zip to state? Are the first few digits
a state code possibly? A perl module would be nice if one already exists.
--fred


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

Date: Sat, 17 Jan 1998 18:52:16 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Q: Regional Sort by ZIP code?
Message-Id: <comdog-ya02408000R1701981852160001@news.panix.com>
Keywords: from just another new york perl hacker

In article <69odkr$n4r1@sunshine.atl.com>, Fred Giorgi <fgiorg@atl.com> posted:

>I need to sort database records by region (group of states) or state. But
>the only guarenteed field I can use is ZIP code. Does anyone have a table
>that can be used to cross refrence zip to state? Are the first few digits
>a state code possibly? A perl module would be nice if one already exists.

the US Postal Service has such a thing on CD.  ask them about it.

if you have problems with the implememtation in Perl, ask here, but
otherwise there is probably a more appropriate forum in which to 
discuss this.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Sun, 18 Jan 1998 00:03:05 GMT
From: wcb4@erols.com (William Byrd)
Subject: returning values out of a recursed sub
Message-Id: <69r69p$mrf$1@winter.news.erols.com>

IF this is answered elsewhere, please forgive, but I need a little
general purpose routine to collapse a variable changing all
occourances of multiple spaces, regardless of how many into a single
space. same goes for tabs.

I have written this:


$stringtocollapse="This	is    only    a                         test";
print $stringtocollapse;
&collapse($stringtocollapse);
print $stringtocollapse;


sub collapse {
	local ($line) = @_ if @_;
	print $line."\n";		#here for debugging only 
	$line =~ s/\t/ /gi;	#substitute spaces for tabs in line
	if ($line =~ m/  /i){					
		$line =~ s/  / /gi;	#substitute 1 space for 2
		&collapse($line);            #recurse this routine
	}	
	return($line);
}


I added the print routine so I could see what it is doing to $line,
and it indeed does collapse it just as I had hoped, but the value does
not return in the calling variable. Again, Please forgive if I am
trying to do something that can be done much easier in perl, I still
think in other computer langauges and try to make perl do what I am
thinking, not always successfully.



Thanks in advance, 
Bill
-----------------------------------------------------
Please always check the syntax before applying any fix 
anyone gives you on a newsgroup, no one is perfect. 
Not everyone reads the newgroups every day, but most 
check their e-mail. A private e-mail with the answer
as well as the NG posting is often appreciated. 
Just my 2 cents worth.



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

Date: Sat, 17 Jan 1998 17:08:47 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: returning values out of a recursed sub
Message-Id: <vldr96.n0a.ln@localhost>

William Byrd (wcb4@erols.com) wrote:
: IF this is answered elsewhere, please forgive, but I need a little
: general purpose routine to collapse a variable changing all
                             ^^^^^^^^^^^^^^^^^^^

I'm sure you really mean the *contents* of a variable there.

I'm not sure how to "collapse a variable"  ;-)


: occourances of multiple spaces, regardless of how many into a single
: space. 


   $stringtocollapse =~ tr/ //s; 


tr/// is documented in the 'perlop' man^H^H^H uhhh... HTML page   ;-)


: same goes for tabs.

Now I'm not sure how "same" you mean.

Change all occurrences of one or more tabs into a single tab?

into a single space?


This should approximate what you might maybe be asking for:

  $stringtocollapse =~ tr/ \011//s; # 011 (octal) is 9 (decimal), the tab char


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


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

Date: 17 Jan 1998 19:32:30 GMT
From: efinch@sun.vais.net (DIAL-MB-Edward Finch)
Subject: Re: sending emails with perl ?
Message-Id: <69r10e$nv1@netaxs.com>

I should have known - not only is TMTOWTDI, TMTOMTDIW (there's more
than one module to do it with) ;-) Would someone be kind enough to      
compare/contrast Net::SMTP, MailTools, Mail::Mailer, etc.?
 
Thanks!
Ed
--
Ed Finch
UNIX & ClearCase Administrator
NASA's Earth Observation System, "Mission To Planet Earth"
 
   Linux. Because using the Windows 95 interface is like living
   in "Who Framed Roger Rabbit?".
 
                       - me



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

Date: Sat, 17 Jan 1998 20:00:11 +0000
From: Andrew Spiers <andrew.spiers@virgin.net>
Subject: Sort question
Message-Id: <34C10DCB.3E8FFC72@virgin.net>

PLEASE HELP ME. I AM GOING MAD !!!!

I have two fields : one contains a URL and the other contains the number
of hits on this URL. I want to sort them so that the most visited
appears at the top. Sounds simple but I cant get it to work. I have
tried looking in the usual places, FAQs etc, but I just cant seem to get
it to work.

Many thanks,

Andrew Spiers

P.s. If you ever come to West London I will buy you a beer ! Promise !!



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

Date: 17 Jan 1998 20:44:10 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Sort question
Message-Id: <69r56q$bm4@fridge.shore.net>

Andrew Spiers (andrew.spiers@virgin.net) wrote:
: PLEASE HELP ME. I AM GOING MAD !!!!

And your madness is causing you to yell at us!  :-)

: I have two fields : one contains a URL and the other contains the number
: of hits on this URL. I want to sort them so that the most visited
: appears at the top. Sounds simple but I cant get it to work. I have

What have you done so far?  I didn't see any code attached to this
posting.

: tried looking in the usual places, FAQs etc, but I just cant seem to get
: it to work.

perlfaq4 is the place to find the answer.

Well, you didn't tell us how your file was delimited, so this solution
is only a guess.  Let's say your file contains:

http://www.perl.com/MYSTERY_DELIM1000
http://www.foo.com/index/homepage.htmlMYSTERY_DELIM1
http://www.pottery.com/pottery/crafted.htmlMYSTERY_DELIM23
http://www.random-sex.com/random/quite/srand.htmlMYSTERY_DELIM50000
http://www.lost-dog.com/rover/come/home/now.htmlMYSTERY_DELIM300
http://www.princess-di.com/stop/writing/ridiculous/books.htmlMYSTERY_DELIM4000
http://www.boring.com/yawn/goodnight.htmlMYSTERY_DELIM0

where MYSTERY_DELIM is your delimiter.

Something like this might work out for you:

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

use strict;
my(@data, @sorted);

@data = <>;

@sorted = map  { $_->[0] }
sort { $b->[1] <=> $a->[1] }
map  { [ $_, (split(/::/, $_))[1] ] } @data;

for(@sorted) { print; }

--
Nathan V. Patwardhan


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

Date: Sat, 17 Jan 1998 16:20:11 -0500
From: Eryq <eryq@zeegee.com>
To: sac@genome.stanford.edu
Subject: Re: Style Q for modules:  best syntax for "hash" arguments?
Message-Id: <34C1208B.11B23F97@zeegee.com>

Steve A. Chervitz wrote:

> When a function can accept either named or unnamed parameters, it would
> be nice to have a standard mechanism for discriminating these cases. For
> example, it's convenient to allow the following:
> 
>      new->Foo("MyFoo");                # Gets default settings.
>      new->Foo(-name   => "MyFoo",      # Custom settings.
>               -flavor => "vanilla");
> 
> If named parameters always start with a "-" then it is easy to
> distinguish these situations, regardless what case is used for the tags.

I have to disagree.  What about:

	Foo->new($fooname);

where $fooname just happens to be "-bar"?  A string is a string;
there's no way to distinguish the intent of the caller.
I have toyed with doing cute things like "if the number of
arguments is even, then assume it's a hash", but even that
give me the willies -- you can get into severe trouble with
typos like:

	@flavors = qw(chocolate vanilla);

	Foo->new(-flavors => @flavors);		# spot the problem? :-)


-- 
  ___  _ _ _   _  ___ _   Eryq (eryq@zeegee.com)
 / _ \| '_| | | |/ _ ' /  President, Zero G Inc: http://www.zeegee.com/
|  __/| | | |_| | |_| |   
 \___||_|  \__, |\__, |___/\  Visit STREETWISE, Chicago's newspaper by/
           |___/    |______/ of the homeless: http://www.streetwise.org


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

Date: Sat, 17 Jan 1998 23:36:08 GMT
From: sase@sasezdesyn.com (SasEz! Publications and Design)
Subject: UserAgent Post/Get, Print, Here, etc.
Message-Id: <34c13da7.26865038@news.theriver.com>

Hi again all.

Ok, I'm trying to create an automated submission engine. I've been
working on it for a while now and I've almost worked all of the bugs
out.  I worked out my code by writing a piece then testing it with
-w from the command line, once something worked as it should I then
added another piece and so on. Then when I added the read/parse
routine it seemed to fall apart.  I need to read the input from a
web form and get it into key/value pairs for processing (if this is
more cgi please tell me so). Now, when I run this from the command
line it appears to work perfectly, no errors/dies/etc. But running
from the browser (chmod'ed to 777 to rule that out) it returns a 500
internal server error.

If anyone has a clue I'd really appreciate it! Here's the main parts
of the code:

#!/usr/lib/perl


#Read the input data
#


local($in, %in) ;
    local($name, $value) ;

    
    # Resolve and unencode name/value pairs into %in
    foreach (split('&', $in)) {
        s/\+/ /g ;
        ($name, $value)= split('=', $_, 2) ;
        $name=~ s/%(..)/chr(hex($1))/ge ;
        $value=~ s/%(..)/chr(hex($1))/ge ;
        $in{$name}.= "\0" if defined($in{$name}) ;  # concatenate
multiple vars
        $in{$name}.= $value ;
    }

##Create Here document for informing the user of what's happening
print "Content-type: text/html\n\n";
   print "<html><head><title>Submission Status</title></head>\n";
   print "<body bgcolor=#FFFFFF text=#000000><center>";
   print "<h1><B>Now Submitting $IN{'url'}...\n";
   print "Please Wait</h1></B></center>\n";

use LWP::UserAgent;
  $ua = new LWP::UserAgent;
  $ua->agent("SasBot/0.1 " . $ua->agent);

#1
my $req = new HTTP::Request POST =>
'http://www.excite.com/cgi/add_url.cgi';
  $req->content_type('application/x-www-form-urlencoded');
  $req->content(look => 'excite', 
              url => $IN{'url'},
              email => $IN{'email'});

  # Pass request to the user agent and get a response back
  my $res = $ua->request($req);

  if ($res->is_success) {
      print "$IN{'title'} successfully posted to Excite\n";
  }


#2
my $req = new HTTP::Request (GET =>
"http://www.infoseek.com/AddURL/addurl?sv=IS&lk=noframes&nh=10&url=$IN{'url'}&CAT=Add/Update
URL&pg=URL.html");

  # Pass request to the user agent and get a response back
  my $res = $ua->request($req);

  if ($res->is_success) {
      print "$IN{'title'} successfully posted to Infoseek\n";
  }

##more snipped...

##Finish it off...
print "<HR>\n";
print "Thank You so much for using our new Submission Program!\n";
print "This service is brand new, we are adding more submission";
print "sites each day. If you would like to recommend a site";
print "for us to add, please mail the URL to our";
print "<a
href=\"mailto:webmaster\@sasezdesyn.com\">Webmaster</a>.\n\n";
print "<HR>\n";
print "<i>copyright 1998, <a
href=\"http://www.sasezdesyn.com>SasEz!";
print "Publications and Design</a>. All rights reserved.\n";
print "</body></html>\n";

_END_

I hardcoded the variables at one point in the testing stage to be
sure my GET and POST were formatted correctly, then I did a 
print $res->content to be sure the site returned a successful
submission, that part worked fine.
Thanks again,
Kathy

-
SasEz! Publications and Design ~ Kathy Burns
Professional Web Design, Hosting, and Maintenance
Is your business set up to make money 24 hours a day, 7 days a week?
http://www.sasezdesyn.com  mailto:sase@sasezdesyn.com
ICQ #828499 ~Check out our Free web design planning guide!~
-


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


------------------------------
End of Perl-Users Digest V8 Issue 1662
**************************************

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