[6392] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 17 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 26 13:38:06 1997

Date: Wed, 26 Feb 97 10:01:48 -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           Wed, 26 Feb 1997     Volume: 8 Number: 17

Today's topics:
     Re: Passing command line parameters <rra@cs.stanford.edu>
     Perl & Ingress ? <gilh@sysdep.elex.co.il>
     Re: Perl and NT (Jarle Aasland)
     Perl and Server Side Include on WIN32 <vidar5@tott.hibu.no>
     Re: Perl and Server Side Include on WIN32 (Nathan V. Patwardhan)
     Re: Perl as a systems programming language (Tad McClellan)
     Re: PERL for NT & Netscape Enterprise Server <nmljn@wombat.staff.ichange.com>
     Re: PERL for NT & Netscape Enterprise Server <strad@mondenet.com>
     Re: perl forking problem <rra@cs.stanford.edu>
     Perl History Help skindig@coe.edu
     Re: Perl Script for DNS? (Kermit Tensmeyer)
     Re: Perl5/Tk for Win95/NT (Charles K. Kincaid)
     Re: Perl5/Tk for Win95/NT (Nathan V. Patwardhan)
     Re: PerlWin32-95:Yes-NT4:No (Ingemar Hansson)
     QUESTION about multilpe filehandles (-intern)
     Re: QUESTION about multilpe filehandles (Tad McClellan)
     Re: QUESTION about multilpe filehandles (Andrew M. Langmead)
     Re: Reading formatted (13.6E) data <anders@ix.netcom.com>
     Re: Searching for Perl-supported Linux database (Johan R Sundstr|m)
     Re: Socket problem: sometimes getting garbage back on S (Nathan V. Patwardhan)
     Sorting in perl <charlies@ctn.independent.co.za>
     Standalone environment (Paco Hope)
     sv_setref_pvn VS sv_setref_pv? <pvh@leftside.uwc.ac.za>
     Tap, tap, anyone here ? <doug@3dlabs.com>
     Re: Tap, tap, anyone here ? <dcordero@giss.nasa.gov>
     Re: Trying to understand regex's (Jeffrey)
     Re: Trying to understand regex's (Tad McClellan)
     Re: Use "use" when and where <domi@marlis.grenoble.hp.com>
     Re: Variable interpolation with s/// operator <rra@cs.stanford.edu>
     vi & color coding <ol@twics.com>
     Re: vi & color coding (Mike Stok)
     Re: Win32::NetAdmin <karp@hpl.hp.com>
     Re: Yet another desirable pack format: (was re: Strange (Will Morse)
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 26 Feb 1997 07:44:52 -0800
From: Russ Allbery <rra@cs.stanford.edu>
Subject: Re: Passing command line parameters
Message-Id: <qumene3zi4r.fsf@cyclone.stanford.edu>

Clay Irving <clay@panix.com> writes:
> jvenu@ctp.com (Jagadeesh Venugopal) writes:

>> Maybe your Camel is missing Page 445, Getopt::Long?

> Yeah, but some folks are intimidated|can't install modules -- Sad, but
> true.

The module comes with Perl.  It's already installed.  Although I usually
use Getopt::Std instead for most scripts because all of the additional
features of Getopt::Long are basically worthless for the short 100-200
line ones.

Getopt::Std is totally trivial to use.  Getopt::Long is a great deal more
complex to figure out, although it's a lot more flexible.

For really short scripts, I usually do something more like this:

die "Usage: $0 [-hvm] [<channel>] [<file> ...]\n" if ($ARGV[0] =~ /^-.*h/);
die "$0 " . (split (' ', $version))[2] . "\n" if ($ARGV[0] =~ /^-.*v/);
my $message = shift if ($ARGV[0] =~ /^-.*m/);

(from a log cleaning script I have sitting around).

-- 
Russ Allbery (rra@cs.stanford.edu)      <URL:http://www.eyrie.org/~eagle/>


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

Date: Wed, 26 Feb 1997 14:17:41 GMT
From: SHILUV Gil Hirsch 5810 <gilh@sysdep.elex.co.il>
Subject: Perl & Ingress ?
Message-Id: <33144605.56BA@sysdep.elex.co.il>

Hi,
I'm currently working on an interface to the local Ingress DataBase, and
I thought it would be much easier to accomplish using perl in
conjunction with an SQL/Ingress module. A colleague of mine remembers
something called ingperl, which he claims is the answer to what I'm
looking for, but unfortunately, I wasn't able to locate it, or any other
SQL/Ingress module, in the CPAN list of modules.

To make a long story short - I NEED an SQL/INGRESS MODULE (or anything
else that would provide me with an easy interface to Ingress).

Thanx in advance, 
	Gil Hirsch, aka gilh@sysdep.elex.co.il.


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

Date: Wed, 26 Feb 1997 09:15:32 GMT
From: sajaa@sn.no (Jarle Aasland)
Subject: Re: Perl and NT
Message-Id: <3313fd1d.10007575@news.eunet.no>

>1- First, I had the following: #!/usr/bin/perl 
>that pointed I think to a file. I did not see such a file on the NT
>system, can I only have it point to the Perl program?

I'm no expert, but here is what I know:
This line points to the location of your Perl directory. This is not
neccessary under NT, as this variable is defined in the registry.

>
>2- Then there are a few variables that are use in the CGI:
>
>$backurl = "http://college-granby-hy.qc.ca/";
>$backname = "College de Granby Haute-Yamaska";
>$mailprog = '/bin/mail';
>$youmail = 'dd@mic.qc.ca';
>$yourname = "Denis Dumouchel";
>$get_date = "/bin/date";

The backurl, backname, youmail and yourname are just user-defined
variables, and are of course valid under any system.

The mailprog-parameter points to the Linux mail program. Under NT you
have to install a small freeware mail-program called "Blat". 

In general, I'm very satisfied with Perl running on NT. However, be
sure to get the version found at http://www.activeware.com

Good luck!

Jarle Aasland
NORWAY






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

Date: Wed, 26 Feb 1997 11:56:58 +0100
From: Vidar Markussen d2b <vidar5@tott.hibu.no>
Subject: Perl and Server Side Include on WIN32
Message-Id: <331416F9.262E@tott.hibu.no>

How do you use SSI with Perl5
Can you do something with Content-type: text/.........

Please help me.

-- 
Vennlig hilsen / Best regards:

Vidar Markussen		E-mail: vidar5@tott.hibu.no
Skolegata 17		Phone:	+47-327363333
3600 KONGSBERG
NORWAY


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

Date: 26 Feb 1997 14:34:46 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Perl and Server Side Include on WIN32
Message-Id: <5f1hm6$bf0@fridge-nf0.shore.net>

Vidar Markussen d2b (vidar5@tott.hibu.no) wrote:
: How do you use SSI with Perl5
: Can you do something with Content-type: text/.........

Your question has been answered on comp.infosystems.www.authoring.cgi.
Perl != CGI.  Perusing the comp.infosystems.www.authoring.cgi archives
at http://www.dejanews.com would be an excellent idea.

--
Nathan V. Patwardhan
nvp@shore.net
"What is the wind speed of a sparrow?"


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

Date: Wed, 26 Feb 1997 07:27:34 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Perl as a systems programming language
Message-Id: <6od1f5.9q.ln@localhost>

Tim_Howe (Trhowe@cris.com) wrote:
: Granted that perl is a wonderful language, I have a few reservations and
: questions about using it as a systems programming language, especially if we
: want it to be OS-independent (on Unix and on NT).

: My questions are:

: Has anyone found a good way to make perl code accessible from both perl and
: from the command line?

: Is anyone really using perl as a complete substitute for shell languages?

: Here are the problems I've run into in trying to substitute perl for the Korn
: shell:


: 1. If I write a Korn shell script to perform a task, that script becomes a
: command that is automatically available both from the command line and from
: other scripts. But that's not how it works for perl, because the command line
: processor is not the same as the perl interpreter. Even on Unix.

: So I end up writing a .p and a .pl for many tasks that I implement in perl. I
: can call a subroutine in the .pl from any perl program, and I can invoke the .p
: from the command line (it processes the command line arguments and then invokes
: the subroutine in the .pl file).


You can write the perl script to do this (If I'm understanding the
problem here). Perl can process command line arguments via the @ARGV array.


: 2. Perl has no copy command. This is not a large problem; I just write a
              ^^^^^^^^^^^^^^^

But it does!  see File::Copy perl module...


: subroutine to do the copying. The subroutine finds out what the operating
: system is and then invokes cp on Unix, copy on NT.


: 3. Similarly for rm, ls, etc. Perl has mkdir() but if I want the equivalent of
                   ^^

unlink()


: "mkdir -p", I have to write my own. So now I'm having to write a sort of
: compatibility library.

: 4. To emulate the Korn shell's

: 	for file in *.java; do
: 		...
: 	done

: in perl, we need something like
           ^^^^^^^

We _can_, we don't _need_  ;-)


: 	foreach $file (&listfiles ("*.java"))
: 	{
: 		...
: 	}

foreach $file (<*.java>) {


: if we want it to be OS-independent.

I dunno if this works on Windoze though


: 5. And to emulate the Korn shell's

: 	echo >> myfile

: in perl, we need to open the file for append, write the string, then close the
: file. Of course, we can write a subroutine to do that, but it's still not as
: smooth as it is in Korn shell.

: 6. Here's something that's easy to do on the Korn shell:

: 	# invoke Informix and submit database commands:
: 	dbaccess << EoSQL
: 	connect to '$db';
: 	$dbcmd;
: 	EoSQL

: In perl this would be less straightforward, especially if we want our code to
: be portable to DOS and to NT's DOS shell, which don't recognize "<<".


: To repeat, my questions are:

: Has anyone found a good way to make perl code accessible from both perl and
: from the command line?

: Is anyone really using perl as a complete substitute for shell languages?

: Thank you.


It seems to me that most of the problems you see with Perl are
really problems with either the 'OS' (NT) or with the perl port
to that 'OS'?


If you want it to replace the Korn shell, then I guess you already
have a Korn shell on NT?


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 26 Feb 1997 09:14:52 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: PERL for NT & Netscape Enterprise Server
Message-Id: <w10pvxnu00z.fsf@wombat.staff.ichange.com>

Anthony John Doyle <strad@mondenet.com> writes:
> Have been working the last few weeks with the Netscape Communications
> Server 1.12 and have been doing some PERL scripts which would get
> executed as:
>   
>   http://host/cgi-bin/perl.exe?myscript.pl

AAUGH!  NO NO NO NO NO!  Tom Christiansen has provided a grumpy but
invaluable service with his "latro" program--available at
http://www.perl.com/perl/news/latro-announce.html--that could let
anyone anywhere run any program on your system that they like.

Ookie, in a word.

Cheers,
Laird

--
<laird.nelson@netsinc.com> perl FAQ: http://www.perl.com/perl/faq Perl manual:
http://www.perl.com/CPAN/doc/manual/html/frames.html. If CGI/web appears in
your comp.lang.perl.* post, see news:comp.infosystems.www.authoring.cgi. CGI
stands for Common Gateway *Interface*, not Language or Program or Script.
Consolidated perl reference page: http://www.amherst.edu/~ljnelson/perl.html


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

Date: Wed, 26 Feb 1997 09:05:50 -0600
From: Anthony John Doyle <strad@mondenet.com>
To: strad@mondenet.com
Subject: Re: PERL for NT & Netscape Enterprise Server
Message-Id: <3314514D.36DB@mondenet.com>

well as it turns out that was not even anywhere near the problem.

turns out that i had been using the line
  binmode(STDOUT);
for a number of reasons which seem to be needed under windows nt and not

on unix - sigh - end of line differences and all that - well - seems i
had that
binmode line prior to the
  print "Content-type: text/html\n\n";
line and well - wouldn't you know it - that seemed to have done a number

on the poor old enterprise 3.0beta2 server and everything was in a
tailspin
after that - finally moved that binmode code around a bit and lo and
behold
the script worked again

live and learn.

Andrew Myers wrote:

    Make sure your Perl Program has this line before any output is
  returned

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

  Hope this helps

  Cheers
  Andrew





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

Date: 26 Feb 1997 07:59:37 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: "Derek A. Crovo" <s14237dc@umassd.edu>
Subject: Re: perl forking problem
Message-Id: <qum7mjvzhg6.fsf@cyclone.stanford.edu>

[ Posted and mailed. ]

Derek A Crovo <s14237dc@umassd.edu> writes:

> I've written a small perl program that does a rsh to a bunch of other
> machines on a lan.  The way I do it now is:
> $result = `rsh $host last | grep $ARGV[0] | head -n 1`;

> I want all the rsh's to happen at the same time, so I don't have to wait
> so long for the output.  I tried putting each rsh into child processes,
> but it seems to fork off a child, and wait for it to complete before it
> forks the next one.

You've got a variety of conceptual problems here; let me see if I can
explain some of them.

It sounds like what you want to do is execute all of the rsh commands and
then go back and collect all of their output.  This is an inherently hard
thing to do, since the only way to do that is to fork off all of the rsh
processes at once and you then have to deal with child processes, IPC, and
all of those issues.

You have to have somewhere for the data to go when each rsh completes, and
you're going to be getting that data asynchronously.  In other words, you
won't know which rsh is going to finish first.  This is why Perl waits for
a command in backticks to finish; that way, it can get all the data, put
it in the scalar, and then move on.  There isn't any built-in mechanism to
say "go do this, put the results in $foo when it's done, and in the
meantime continue executing my script".  You'd need a full-blown parallel
programming language to have that as part of the language.

One way to do it would be to fork off another copy of your script for
every rsh process so that you could monitor each process and wait for it
to complete.  The problem is then in printing out the data; if you didn't
care about how it looked, you could have each child print out its results
as they came in, but even with line buffered output the chances are high
two clients would end up printing at the same time, which you don't want.
Communicating the information back to the parent is probably going to
require sysread and select (the four argument type), and that's going to
be quite a mess.

In short, there really isn't any clean way of doing this asychronously
without at least a good deal of work, at least that I can see right off.

-- 
Russ Allbery (rra@cs.stanford.edu)      <URL:http://www.eyrie.org/~eagle/>


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

Date: Wed, 26 Feb 1997 11:11:43 -0600
From: skindig@coe.edu
Subject: Perl History Help
Message-Id: <856970475.2908@dejanews.com>

Are there any ancestors or descendants of the perl language?

Has perl made any contributions to the body of programming
language?

What were the major changes that came with each new
version of perl?

Any help is sincerely appreciated.
Thank you Sherry

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Wed, 26 Feb 1997 14:56:13 GMT
From: kermit@cnad.dl.nec.com (Kermit Tensmeyer)
Subject: Re: Perl Script for DNS?
Message-Id: <5f1ir5$hg4@vivaldi.inoc.dl.nec.com>

In article <33120DF7.5590@slip.net>, jquist@slip.net wrote:
>I'm looking for a script to help maintain my DNS database. Any
>recommendations?

   Look in the the standard DNS delivery for Unix. Many of the support tools 
are in Perl.

  there is also a dns resource web page at http://www.dns.net/dnsrd/

  dnswalk for example is a perl script that will walk the dns tree. Very 
useful to see -what- someone else will see for your dns data..

 WebDns is another tool.  dig (or even the perl version of dig) is usefull.

  and with all the resources there,  it is very usefull to take the existing 
tools and rework them for your specfic needs. (that is _why_ you are trying to 
do this in perl!  correct?)


Kermit Tensmeyer       NEC InterNet Operations Centre (INOC)
kermit@cnad.dl.nec.com              Dallas, Texas


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

Date: Tue, 25 Feb 1997 22:44:04 GMT
From: Webmaster@UniversalClassifieds.com (Charles K. Kincaid)
Subject: Re: Perl5/Tk for Win95/NT
Message-Id: <5evpp1$qrm@ns2.microlink.net>

tarver@sky.net (Steve Tarver) wrote:

>I just downloaded the Win95/NT port of Perl by ActiveWare (from the
>oakland ftp site I think). This is a microsoft funded port but it
>looks pretty cool. The docs claim there are modules for the registry,
>ole, spawning processes, etc. I only know that ENV contains the right
>stuff, pipes work, and shelling other command line stuff works. I am
>on page 100 of Programming Pearl, so take that with a grain of
>whatever. I am pretty excited though - its like working on a real
>operating system.

>http://www.ActiveWare.com

I got the files from ActiveWare some time ago (week).  The only
problem that I have had is the message "flock not supported under
Win95".  I don't understand why they letft this out.  Makes testing my
CGI scripts a real pain.  I ran some speed trials.  After designing,
writing, testing, and supporting software for a living since 1972, I
am FLAT impressed with the speed of the programs running under this
interpreter.  If they ever come out with a native code COMPILER for
Win95/NT, it will be a speed demon for certain.

Keep up with the reading, I am less than 20% through my PERL book and
am writing CGI scripts just fine.  I have read 80% of a book on
"writing CGI with PERL 5". :-)

Charles K. Kincaid
"There is no acceptable scale on which to measure the worth of a
person"
- Charles K. Kincaid

(go ahead and flame me for quoting myself)



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

Date: 26 Feb 1997 14:18:29 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Perl5/Tk for Win95/NT
Message-Id: <5f1gnl$bf0@fridge-nf0.shore.net>

Charles K. Kincaid (Webmaster@UniversalClassifieds.com) wrote:

: I got the files from ActiveWare some time ago (week).  The only
: problem that I have had is the message "flock not supported under
: Win95".  I don't understand why they letft this out.  Makes testing my

I dunno - does NT have a file-locking exclusive-write mechanism?

--
Nathan V. Patwardhan
nvp@shore.net
"What is the wind speed of a sparrow?"


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

Date: Wed, 26 Feb 1997 07:16:57 GMT
From: irh@vms.automation.alfalaval.se (Ingemar Hansson)
Subject: Re: PerlWin32-95:Yes-NT4:No
Message-Id: <3313e227.1028821226@loke>

Mj Smith <mjsmith@isr.umd.edu> wrote:

>Simply, I want to delete all the files in a particular directory.  So, I
>used the glob <*.*> to select all the files.  This worked just find
>under Win95.  But, as soon as I try it in NT4Wkstn (I logged on as full
>administrator), the same exact set of lines, give me an error as soon as
>I reach the glob.  The error states roughly, that "the name specified is
>not recoginzed as an internal or external program, function...".
>
>Any thoughts?

Yes.
I experienced the same thing. Glob is a separate program which runs in a
subprocess.  The executable is named perlglob.exe. Either that program is
missing or is it residing in a directory *not* in your path.
If speed is essential to you, I think you should consider rewriting your
code to use opendir() and readdir() instead. This is much faster because
no new processes are started.

Ingemar
+--------------------------------------------------------------------+
| Ingemar Hansson, Alfa Laval Automation AB, S-205 22  Malmo, SWEDEN |
| System and application manager             PHONE: +46 40 226251    |
| Internet: irh@vms.automation.alfalaval.se  FAX:   +46 40 226893    |
|       or: ingemarh@hem1.passagen.se                                |
| CompuServe: 101354,2770                                            |
+--------------------------------------------------------------------+


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

Date: Wed, 26 Feb 1997 09:53:59 +0100
From: "admin www(-intern)/proxy/news" <WWWAdmin@amc.uva.nl>
Subject: QUESTION about multilpe filehandles
Message-Id: <3313FA27.4B37@amc.uva.nl>

Hello Folks,

Does anyone know how to open an INPUT and OUTPUT filehandle/pipe at the
same time to the same application?

@rnaud 
-- 
Internet???.....
Vroeger, toen de natuur nog schoon, en sex nog vies was, toen........
-------------------------
Arnaud Lauteslager (wwwadmin@amc.uva.nl)
WWW-site/News/Proxy Administrator, AMC(ADIV/Cluster Research Support)
Meibergdreef 9 / 1105 AZ Amsterdam Zuidoost / tel. 0(31)(20)5667096


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

Date: Wed, 26 Feb 1997 07:19:33 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: QUESTION about multilpe filehandles
Message-Id: <59d1f5.pn.ln@localhost>

admin www(-intern)/proxy/news (WWWAdmin@amc.uva.nl) wrote:
: Hello Folks,

: Does anyone know how to open an INPUT and OUTPUT filehandle/pipe at the
  ^^^^^^^^^^^^^^^^                                            ^^^^

If you grepped for 'pipe' in the fine Perl FAQ, then _you_ would know
how to do this (and you would also know that you probably do not
_really_ want to do this...)


5.14) How do I open a pipe both to and from a command?

    In general, this is a dangerous move because you can find yourself in a
    deadlock situation.  It's better to put one end of the pipe to a file.


: same time to the same application?


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Wed, 26 Feb 1997 14:25:19 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: QUESTION about multilpe filehandles
Message-Id: <E67s27.H7I@world.std.com>

"admin www(-intern)/proxy/news" <WWWAdmin@amc.uva.nl> writes:

>Does anyone know how to open an INPUT and OUTPUT filehandle/pipe at the
>same time to the same application?

With the IPC::Open2 module that is provided with the standard Perl
distribution.

Or if buffering is a problem, then maybe the Comm.pl library at
<http://www.perl.org/CPAN/authors/id/ERICA/Comm.pl-1.5beta.tar.gz>
-- 
Andrew Langmead


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

Date: Wed, 26 Feb 1997 00:51:52 -0800
From: Jerry Anders <anders@ix.netcom.com>
Subject: Re: Reading formatted (13.6E) data
Message-Id: <3313F9A8.5133@ix.netcom.com>

Jim Anderson wrote:
> 
> Jerry Anders <anders@ix.netcom.com> writes:
> 
> > The data that I'm trying to read is formatted in 10 columns and is in 13.6E format. The following is an example:
> >
> >  0.111000E+01-0.112000E+01 0.113000E+01 0.114000E+01 0.115000E+01 0.116000E+01 0.117000E+01 0.118000E+01 0.119000E+01-0.111000E+01
> >  0.121000E+01 0.122000E+01 0.123000E+01-0.124000E+01 0.125000E+01 0.126000E+01 0.127000E+01 0.128000E+01 0.129000E+01 0.121000E+01
> >  0.131000E+01 0.132000E+01 0.133000E+01 0.134000E+01 0.135000E+01 0.136000E+01
> >  0.111000E+01 0.112000E+01-0.113000E+01 0.114000E+01 0.115000E+01 0.116000E+01-0.117000E+01 0.118000E+01 0.119000E+01 0.111000E+01
> >  0.121000E+01 0.122000E+01 0.123000E+01 0.124000E+01 0.125000E+01 0.126000E+01 0.127000E+01 0.128000E+01 0.129000E+01 0.121000E+01
> > -0.131000E+01 0.132000E+01 0.133000E+01 0.134000E+01 0.135000E+01 0.136000E+01
> >  .
> >  .
> >
> > If the data came across the net properly you should see blocks of data in 10 columns and each block has 26 numbers.
> >
> > My question is, instead of reading the file line by line and then breaking that line ($_) down into numbers, can I read the file
> > number by number. Can I modify the input record separator ($/) such that it interprets 13.6E format instead of creating elaborate loops
> > which read every character or blocks of 13 characters? Is there and easier way to extract the data number by number?
> >
> > An example of what I'm doing with the data is, lets say, extract every 3, 6, 10-15, 20-22, number from each block and stuff them into and
> > array (i.e., extract protions of this data and save them in an array). Since I have lots of data which uses strict formats (engineering data)
> > as shown above, I'd like a solution which uses formats such as %13.6E. I understand how to print using formats, but can I read using formats?
> 
> =========================================================================
> #!/usr/bin/perl -w
> 
> my @nums;
> 
> while (<DATA>) {
>   push @nums, unpack "a13a13a13a13a13a13", $_;
> }
> 
> foreach (@nums) {
>   print "$_\n";
> }
> 
> __DATA__
>  0.111000E+01-0.112000E+01 0.113000E+01 0.114000E+01 0.115000E+01 0.116000E+01 0.117000E+01 0.118000E+01 0.119000E+01-0.111000E+01
>  0.121000E+01 0.122000E+01 0.123000E+01-0.124000E+01 0.125000E+01 0.126000E+01 0.127000E+01 0.128000E+01 0.129000E+01 0.121000E+01
>  0.131000E+01 0.132000E+01 0.133000E+01 0.134000E+01 0.135000E+01 0.136000E+01
>  0.111000E+01 0.112000E+01-0.113000E+01 0.114000E+01 0.115000E+01 0.116000E+01-0.117000E+01 0.118000E+01 0.119000E+01 0.111000E+01
>  0.121000E+01 0.122000E+01 0.123000E+01 0.124000E+01 0.125000E+01 0.126000E+01 0.127000E+01 0.128000E+01 0.129000E+01 0.121000E+01
> -0.131000E+01 0.132000E+01 0.133000E+01 0.134000E+01 0.135000E+01 0.136000E+01
> =========================================================================


Jim, 

Thanks for your input. I'm not sure if you tried your own suggestion because it only grabs the first 6 numbers from each row. 
Actually, I was looking for a routine which reads in a number at a time, not line by line. I used a modified version
of what you suggested. It looks like this:

sub process_data_file {
# Lets grab all the data and stuff it into an array (@nums).
    while (<DATA_FILE>){
	@a_line = ();		# Temporary -- @a_line is used to hold a row of numbers
	push (@a_line, unpack ("a13a13a13a13a13a13a13a13a13a13", $_));
	foreach (@a_line) {
	    if (/\w+/){		# in case there are blanks in @a_line
		$counter++;
		push (@nums, $_);
	    }
	}
    }
}

Unpack now reads in all 10 columns. I had to add the foreach loop to eliminate any blanks (blanks show up when a row has less than
10 columns). Although I was looking for something which allowed me to change the record separator ($/) to read a number at a time and
forego the cleanup loop (foreach), this works just fine.

Thanks again!
Jerry


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

Date: 26 Feb 97 13:09:27 GMT
From: jrs@alpha.hut.fi (Johan R Sundstr|m)
Subject: Re: Searching for Perl-supported Linux database
Message-Id: <jrs.856962567@snakemail.hut.fi>

Chris Schoenfeld <chris@ixlabs.com> writes:

>I'm in the market for a database with the following features:

>1. Native Linux and Spac Solaris support (i.e. share binary db's).
>2. A thoroughly tested Perl 5 module interface.
>3. Speedy, for CGI work.
>4. Either commercial or well-supported PD.
>5. Native file/record locking.

>We have been using Berkeley DB / DB_File but wish to move to something a
>little more robust, as we have been having some portability, locking,
>and corruption problems here and there.

>After some preliminary research, I have narrowed it down to the
>following:

Take a look at http://www.tcx.se/ It is used in commercial applications.

Johan

-- 
 jrs@cc.hut.fi            // 
 jrs@niksula.cs.hut.fi   // Phone: +358-40-5120550
 jrs@polycon.fi         //


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

Date: 26 Feb 1997 14:32:32 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Socket problem: sometimes getting garbage back on Solaris machine
Message-Id: <5f1hi0$bf0@fridge-nf0.shore.net>

Gideon King (gideon@csarc.otago.ac.nz) wrote:
: I am getting some odd behaviour running my sockets based system under  
: Solaris (it works fine under perl 5.002 and 5.003 on NeXTSTEP 3.3).

If you posted some code, it would be extremely helpful.  You might try
reading the socket and have it tell you what's happening ...

Example (not the best way, but will output some information so you get
an idea about the goings-on):

S is a socket handle.
read(S, $buffer, length($data));

--
Nathan V. Patwardhan
nvp@shore.net
"What is the wind speed of a sparrow?"


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

Date: Wed, 26 Feb 1997 10:39:27 +0000
From: Charlie Schofield <charlies@ctn.independent.co.za>
Subject: Sorting in perl
Message-Id: <331412DF.3B6B@ctn.independent.co.za>

Hi, I am fairly new to perl and am having some problems sorting.

I have the following table of filenames, creation dates and retire dates 
which I create from a directory of articles.

$table[$filecount] = {
      name => $file,
      date => $date, 
      retiredate => $retiredate};

then I want to be able to sort the articles by date or retiredate.

I have tried 

 @sorted = sort {$a.date cmp $b.date} @table;



but this does not work.  The dates are held as strings.  I am able to 
sort by the name but not by the date or retiredate.  Basically I want to 
know how to send the date field to the sort function.


Maybe I am on completely the wrong track and I should use a different 
data structure.  Any thoughts would be appreciated.

Thanks in advance,

Charlie Schofield
Independent Online
http://www.inc.co.za/


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

Date: Wed, 26 Feb 1997 15:06:03 GMT
From: bah6f@cs.virginia.edu (Paco Hope)
Subject: Standalone environment
Message-Id: <5f1jgr$33u@jazz.cs.Virginia.EDU>


I'm using Perl 5.003 and a bunch of included modules (DateCalc,
Text::Wrap, etc).  I'm writing this to help automate our backup
system here.  This script will be running on our fileserver.

I'm concerned that this script be able to run successfully, even
though some filesystems may be having problems.  In the past we had a
shell script which, more or less, listed the file systems and backed
them up one by one.  If a disk was failing, that disk's backup failed,
but all previous and subsequent disks were backed up correctly.

Unfortunately, if the disk that "perl" and its modules live on dies,
my backups won't run at all.

A perfectly acceptable solution to me would be to copy the perl binary
to a local disk on my fileserver, and copy over any modules that it
depends on. Then I'd tell it to execute from there, looking there for
libraries.

How do I do this?  How do I tell the program to look in a particular
directory for its modules?  Equally important: how do I tell it NOT to
look in the standard places for modules? (the paths to them are
different on the fileserver)

Please CC me on any replies, I read this newsgroup infrequently.

Thanks,
Paco
-- 
Paco Hope                                         Computer Systems Engineer
paco@cs.virginia.edu                         Department of Computer Science
http://www.cs.virginia.edu/~bah6f/                   University of Virginia


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

Date: 26 Feb 1997 13:00:31 GMT
From: Peter van Heusden <pvh@leftside.uwc.ac.za>
Subject: sv_setref_pvn VS sv_setref_pv?
Message-Id: <5f1c5f$2q@groa.uct.ac.za>

For an XS module I'm developing, I need to return multiple C structures. The
basic code (expanded of course to return multiple items) is such:

MODULE = Monitor		PACKAGE = Monitor

Diskstat *
get_one_dkstat_pp()
	PREINIT:
	Diskstat *diskstats[MAXDISKS];
	int count;
	PPCODE:
	memset(diskstats,0,MAXDISKS * sizeof(Diskstat *));
	count = get_dkstat(&diskstats);
       	EXTEND(sp,1);
	ST(0) = sv_newmortal();
	sv_setref_pv(ST(0), "DiskstatPtr", diskstats[0]);
	free(diskstats);
	XSRETURN(1);
	

and then to access structure members, something like:

MODULE = Monitor		PACKAGE = DiskstatPtr	PREFIX = diskstat_

 ....

void
diskstat_diskname(diskstat)
	Diskstat *diskstat
	PREINIT:
	char * diskname;
	PPCODE:
	diskname = diskstat->diskname;
	EXTEND(sp,1);
	PUSHs(sv_2mortal(newSVpv((char *)diskname,0)));
	XSRETURN(1);

This all works fine with sv_setref_pv(). But initially, due to what I
was reading in perlguts and advice I had got, I was using 

        sv_setref_pvn(ST(0), "DiskstatPtr", diskstats[0], sizeof(Diskstat *));

since, after all, I want to stuff a pointer in ST(0), and I felt safer telling
perl explicitly how large the space I needed was. However, this second
form doesn't work - the pointer ends up null when I try and use it in
diskstat_diskname(). Is this somehow expected behaviour? What did I do wrong?

Thanks for any advice,
Peter




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

Date: Wed, 26 Feb 1997 12:01:02 GMT
From: "Doug Bridgens" <doug@3dlabs.com>
Subject: Tap, tap, anyone here ?
Message-Id: <01bc23dc$d92b4480$36d880c1@aardvark.3dlabs.com>

Hi,
   I'm brand new to perl, just picked up the Llama book yesterday!   I need
to write CGI apps for our intranet (3Dlabs Inc.), unforunately running on
NT :(    The book (Llama book) suggests this news group as a source of
info/help.   I was just looking to see what discussions were currently
going on, and this place seems empty ?   Or do I have to wait for a while
before our news feed delivers the news, I just added this group to our
list.
   I may as well kick off with a question, so as not to completely waste
the bandwidth...   I am familiar with scripting (ksh) in Unix, but not when
it comes to NT.   Can anyone point me to a source of info on perl under NT
?   Typcally : I just tried the $ENV and it didn't work.   

Cheers
Doug


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

Date: Wed, 26 Feb 1997 10:12:16 -0500
From: "Douglas L. Cordero, PhD" <dcordero@giss.nasa.gov>
Subject: Re: Tap, tap, anyone here ?
Message-Id: <331452D0.41C6@giss.nasa.gov>

Try dejanews  (http://www.dejanews.com)

 
********************************************************
Douglas L. Cordero, PhD
Science Systems and Applications, Inc.
email:   dcordero@giss.nasa.gov
********************************************************


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

Date: 26 Feb 1997 07:18:25 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: Jim Anderson <jander@ml.com>
Subject: Re: Trying to understand regex's
Message-Id: <JFRIEDL.97Feb26161825@tubby.nff.ncl.omron.co.jp>


[mail and post]

Jim Anderson <jander@ml.com> wrote:
|> posenj@lancet.co.za (Kevin Posen) writes:
|> > I'm taking a course in Perl and am currently learning regex's. My book
|> > gave me this expression:
|> > 
|> > 	($first, $middle, $last) = (/\b(\w+)\b\s+\b(.*)\b\s?\b(\w+)\b/);
|> 
|> Looks to me like most (and probably all) of those word breaks (\b) are
|> completely unnecessary.

FWIW, only the 2nd \b is superfluous. All the others add logic or
efficiency to the expression.

	Jeffrey
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@omron.co.jp> Omron Corp, Nagaokakyo, Kyoto 617 Japan
See my Jap<->Eng dictionary at http://www.wg.omron.co.jp/cgi-bin/j-e
O'Reilly's Regular Expression book: http://enterprise.ic.gc.ca/~jfriedl/regex/


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

Date: Wed, 26 Feb 1997 07:12:57 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Trying to understand regex's
Message-Id: <psc1f5.pn.ln@localhost>

Jeffrey (jfriedl@tubby.nff.ncl.omron.co.jp) wrote:

: [mail and post]

: Jim Anderson <jander@ml.com> wrote:
: |> posenj@lancet.co.za (Kevin Posen) writes:
: |> > I'm taking a course in Perl and am currently learning regex's. My book
: |> > gave me this expression:
: |> > 
: |> > 	($first, $middle, $last) = (/\b(\w+)\b\s+\b(.*)\b\s?\b(\w+)\b/);
: |> 
: |> Looks to me like most (and probably all) of those word breaks (\b) are
: |> completely unnecessary.

: FWIW, only the 2nd \b is superfluous. All the others add logic or
: efficiency to the expression.


The last one can't be adding logic, there must be a /w followed by
a /W (or end of string) even without it.

So how does it add efficiency?


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 26 Feb 1997 11:10:29 +0100
From: Dominique Dumont <domi@marlis.grenoble.hp.com>
Subject: Re: Use "use" when and where
Message-Id: <vkzpvxnho8a.fsf@marlis.grenoble.hp.com>

efp@mindspring.com (Eric Palmer) writes:

> 
> Where should I place the use commands and if I put them in all of the
> above will this cause extra work.  I don't want the use use use ...
> to the point of causing extra work.
> 

use keeps track of what's already been imported. So the extra work is
minimal. 

Hope this helps.

-- 
Dominique_Dumont@grenoble.hp.com


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

Date: 26 Feb 1997 08:08:21 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: tbw@netcom.com (Tom Burton-West)
Subject: Re: Variable interpolation with s/// operator
Message-Id: <qum3eujzh1m.fsf@cyclone.stanford.edu>

[ Posted and mailed. ]

Tom Burton-West <tbw@netcom.com> writes:

> I am trying to convert some unusual characters using a table in a config
> file.  For in the example below, I want to convert from hex 5F to hex
> 2D.  For ease of entering the table data I am not escaping the hex
> characters (\x5F \x2D).  Instead, I am constructing the string
> representing the escaped characters in the subroutine.

[snip]

>         $EM_In="\\x" .$EM_In;        #convert to perl hex notation "\x00"
>         $EM_Out="\\x" .$EM_Out;      #convert to perl hex notation "\x00"

This isn't going to work everywhere you want, since it would require that
Perl double-interpolate your strings.  In other words, you're forming a
string "\x5F", but that doesn't become that character until it's
interpolated again, and forcing the second interpolation is rather a pain.

Instead, what you want to do is this:

	$EM_In = chr hex $EM_In;
	$EM_Out = chr hex $EM_Out;

hex takes a hex number and converts it to decimal, and chr gives you the
character with a given decimal value in ASCII.

-- 
Russ Allbery (rra@cs.stanford.edu)      <URL:http://www.eyrie.org/~eagle/>


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

Date: Wed, 26 Feb 1997 17:22:10 +0900
From: Kevin Baker <ol@twics.com>
Subject: vi & color coding
Message-Id: <Pine.HPP.3.95.970226171451.17142A-100000@beehive.twics.com>

Hi,

two newbie type questions. Hopefully I'll impress the oldtimers by my
interest in vi, the king of editors.

1) Can you get a color coded perl syntax 'vi' editor

&

2) On page 24 of the "Programming Perl" 2nd edition it has a snippet of
code for a foreach loop. 

	if (-f "$home{$user}/.nexrc") {
		print "$user is cool... they use a perl-aware vi!\n";
	}

What is "perl-aware vi"? 
Where do I get it? 
What platforms is it on?


get a mullet up ya...


Kev





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

Date: 26 Feb 1997 15:30:17 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: vi & color coding
Message-Id: <5f1ku9$llc@news-central.tiac.net>

In article <Pine.HPP.3.95.970226171451.17142A-100000@beehive.twics.com>,
Kevin Baker  <ol@twics.com> wrote:

>two newbie type questions. Hopefully I'll impress the oldtimers by my
>interest in vi, the king of editors.

You'd better don some flameproof clothes, people seem to get their
underwear all bunched up when people start that kind of talk :-)

>1) Can you get a color coded perl syntax 'vi' editor

I don't know, colour coding is fine if it works byt can be misleading,
exspecially in code generating code where string contents could be
considered to be code...

>2) On page 24 of the "Programming Perl" 2nd edition it has a snippet of
>code for a foreach loop. 

>What is "perl-aware vi"? 
>Where do I get it? 
>What platforms is it on?

nvi I guess, it's on the Comprehensive Perl Archive Network (CPAN) under
src/misc.  The master CPAN ftp site is at ftp.funet.fi under
/pub/languages/perl/CPAN and Tom Christiansen has a multiplexor on the web
at http://www.perl.com/CPAN/ (note the trailing /) which gets you to a
CPAN site.  Getting & umpacking the .tar.gz file and reading any README
might answer your other questions...

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Wed, 26 Feb 1997 08:11:49 -0800
From: Alan Karp <karp@hpl.hp.com>
Subject: Re: Win32::NetAdmin
Message-Id: <331460C5.4F92@hpl.hp.com>

JR Tietsort wrote:
> 
> Does anyone have any working code using the NetAdmin module under NT?  I
> have tried and tried to get something returned, but have had no success.
> 
> Any help is appreciated....
> 
> Thanks,
> JR Tietsort
> jrtietsort@micron.com

Here's a snippet of code.  It creates a new user account on the fly.  If
the account exists, I delete it and create a new one.  I got the numbers
used as parameters by creating an account by hand and using the query
function of NetAdmin to tell me what values to use.

--------

#
# Build account for pseudo-user
#
      unless (
Win32::NetAdmin::UserCreate('',$uid,'',1644487,1,'','',66049,'') ) {
         Win32::NetAdmin::UserDelete('',$uid);
        
Win32::NetAdmin::UserCreate('',$uid,'',1644487,1,'','',66049,'') ||
            return &error("$0: Could not create user ($uid): $!",0);
      }


-- 
Alan Karp
Hewlett-Packard Labs
1501 Page Mill Road
Palo Alto, CA 94304
(415) 857-6766, (415) 813-3381 (fax)


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

Date: 26 Feb 1997 02:55:29 -0600
From: will@Starbase.NeoSoft.COM (Will Morse)
Subject: Re: Yet another desirable pack format: (was re: Strange pack/unpack...)
Message-Id: <5f0tq1$r5@Starbase.NeoSoft.COM>

In article <5erlg0$m8n@news1.ucsd.edu>,
Jonathan King <king@cogsci.ucsd.edu> wrote:
>In article <Pine.GSO.3.95q.970223134151.18178I-100000@kelly.teleport.com>
>Tom Phoenix <rootbeer@teleport.com> writes:
>>On Sat, 22 Feb 1997, Craig Votava wrote:
>>>
>[deleted, it was about 'pack("B2", "10")'] etc.
>
>>It's not too hard to find out how many padding bits to add, as you show in
>>your workaround. So, we probably don't need to add something to pack. And
>>besides, some would say that pack and unpack have too many formats
>>already! 
>
>Well, it certainly has some formats I would never dream of
>using. :-) But it would be kinda cool if it had signed versions of
>"n" and "v", which are big- and little-endian respectively.  There's
>lots of (scientific) data out there in binary datafiles where you
>know that the bytes in the file are in one order or another, and
>they are signed.  (Think massaged output from an a/d converter, if
>you like).  But when you run your perl script, you neither know or
>care much about how that machine's endianosity, but still want to
>read the data correctly.  I'd love to be wrong about this, but the
>only portable=platform-ignorant way is to unpack the short as "v" or
>"n" to get the bytes right and tweak the result to get the correct
>sign.  (Same goes for longs, I suppose.)
>
>That's okay if you're just doing a couple of these, but when you've
>got thousands or millions of them...it's a bore.  Probably also a
>reason to use PerlDL, at least in the long run.  The Blue Camel sort
>of recognizes the issue, and the text it uses might have
>(unintentionally) seemed, uh, "funny" to other people, too:
>
>    Packing your shorts doesn't imply that you're portable. (p. 196)
>
>Any chance of seeing signed and ordered shorts after 5.004?  Any
>better chance if I provided a nifty patch? :-)
>
>jking
>
>

In my copious spare time, I am working on a module that will handle translation
of a string of IBM floating point numbers (IBM 370) to IEEE for use with
SEG-Y sesimic data tapes.  I had rather imagined that my situation 
was unique (at least to petroleum exploration).  Perhaps a more general
solution is in order.

Will

-- 
# Copyright 1997 Will Morse.  Internet repost/archive freely permitted.
# Hardcopy newspaper, magazine, etc. quoting requires permission.
# 
#      Gravity,                    #    Will Morse
#      not just a good idea,       #    Houston, Texas
#              it's the law.       #    will@starbase.neosoft.com
#
#   These are my views and do not necessarly reflect anyone else/


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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

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