[10418] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4011 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 19 16:02:47 1998

Date: Mon, 19 Oct 98 13:01:33 -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           Mon, 19 Oct 1998     Volume: 8 Number: 4011

Today's topics:
    Re: Removing spaces between fields in file records (Mark-Jason Dominus)
    Re: Removing spaces between fields in file records (John Stanley)
    Re: Resubmitted ... Removing spaces between fields in f <ff@otis.arraycomm.com>
    Re: Shell commands (Nathan V. Patwardhan)
    Re: Slow Sort (complex hashes sub-thread) <uri@camel.fastserv.com>
    Re: sorting file entries by time droby@copyright.com
    Re: sorting file entries by time <jdporter@min.net>
        Thanks for the help on my Perl/CGI tutorial (John Callender)
    Re: Trouble scheduling Perl scripts with WinNT AT comma <alext@NOSPAM.cri-boi.com>
    Re: Trouble scheduling Perl scripts with WinNT AT comma <alext@NOSPAM.cri-boi.com>
    Re: Wanted: programming (humor?) <uri@camel.fastserv.com>
    Re: what is strlen() in perl? <uri@camel.fastserv.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 19 Oct 1998 14:14:53 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Removing spaces between fields in file records
Message-Id: <70fvit$mfu$1@monet.op.net>

In article <362B695F.6210@scp1.bellcore.com>,
Paul White  <whitepr@scp1.bellcore.com> wrote:
>Unfortunately, spaces " " are inserted into 
>every record that I write.
>
>Here is the code:
>
>format DATAREC
>@<<<<< @<<<<< @<<<<< 
       ^      ^
       |      |
        spaces


format DATAREC =
@<<<<<@<<<<<@<<<<< 
      ^     ^
      |     |
     no spaces



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

Date: 19 Oct 1998 18:28:09 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Removing spaces between fields in file records
Message-Id: <70g0bp$h5t$1@news.NERO.NET>

In article <70fvit$mfu$1@monet.op.net>, Mark-Jason Dominus <mjd@op.net> wrote:
>In article <362B695F.6210@scp1.bellcore.com>,
>Paul White  <whitepr@scp1.bellcore.com> wrote:
>>Unfortunately, spaces " " are inserted into 
>>every record that I write.
>>
>>Here is the code:
>>
>>format DATAREC
>>@<<<<< @<<<<< @<<<<< 
>       ^      ^
>       |      |
>        spaces
>
>
>format DATAREC =
>@<<<<<@<<<<<@<<<<< 
>      ^     ^
>      |     |
>     no spaces

If $rec_a = 'a,', then

@<<<<<@<<<<<@<<<<<
  ^^^^-- spaces, too.



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

Date: Mon, 19 Oct 1998 18:59:15 GMT
From: Farhad Farzaneh <ff@otis.arraycomm.com>
Subject: Re: Resubmitted ... Removing spaces between fields in file records
Message-Id: <vulnmc2xa4.fsf@otis.arraycomm.com>


This script could not have possibly produced the output you send because it
is rife with syntax errors.  For example, 

for (i=0;i=5:i++){

is not perl code.  Try:

foreach $i (0..5) or

for ( $i = 0; $i < 5; $i++ ) {
}

Once corrected, the format statement will work!  Here's a quick example
based upon your script:

#!/bin/perl

format STDOUT =
@<<<< @<<<< @<<<<<<<<<
$rec_a, $rec_b, $rec_c
 .
for ($i=0;$i<5;$i++){
$rec_a = "aaaaa" . ",";
$rec_b = "bbbbb" . ",";
$rec_c = $rec_a . $rec_b;
write STDOUT;
}

which gives 

aaaaa bbbbb aaaaa,bbbb
aaaaa bbbbb aaaaa,bbbb
aaaaa bbbbb aaaaa,bbbb
aaaaa bbbbb aaaaa,bbbb
aaaaa bbbbb aaaaa,bbbb

as it should.  Please also read the perl style guide if you're going to do
any perl code requiring maintenance.

Good luck.


Paul White <whitepr@scp1.bellcore.com> writes:

> 
> Paul White wrote:
> > 
> > I am trying to write a record to a file
> > that is a series of data fields separated
> > by commas.
> > 
> > Unfortunately, spaces " " are inserted into
> > every record that I write.
> > 
> > Here is the code:
> > 
> > format DATAREC
> > @<<<< @<<<< @<<<<<<<<<
> > $rec_a, $rec_b, $rec_c
> > .
> > open (DATAREC,">output.dat");
> > for (i=0;i=5:i++){
> > $rec_a = "aaaaa" . ",";
> > $rec_b = "bbbbb" . ",";
> > $rec_c = $rec_a . $rec_b;
> > write DATAREC;
> > }
> > close (DATAREC);
> > 
> > Here is the output, which I don't want:
> >  aaaaa, bbbbb, aaaaabbbbb
> >  aaaaa, bbbbb, aaaaabbbbb
> >  aaaaa, bbbbb, aaaaabbbbb
> >  aaaaa, bbbbb, aaaaabbbbb
> >  aaaaa, bbbbb, aaaaabbbbb
> >  aaaaa, bbbbb, aaaaabbbbb
> > 
> > Here is what I want as an output:
> > aaaaa,bbbbb,aaaaabbbbb
> > aaaaa,bbbbb,aaaaabbbbb
> > aaaaa,bbbbb,aaaaabbbbb
> > aaaaa,bbbbb,aaaaabbbbb
> > aaaaa,bbbbb,aaaaabbbbb
> > 
> > All comments, suggestions ... welcomed.
> > 
> > Paul

-- 
Farhad


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

Date: Mon, 19 Oct 1998 18:27:43 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Shell commands
Message-Id: <zwLW1.161$OZ4.42242@news.shore.net>

Mark-Jason Dominus (mjd@op.net) wrote:

: Nope.  In the shell, you use `echo', which is usually, but not always
: built-in.  

Hmm.  For ksh, print appears to be a built-in.

$ uname -a
SunOS sugar 5.6 Generic sun4m sparc SUNW,SPARCstation-5

$ man print
Reformatting page.  Wait... done

User Commands                                            print(1)

NAME
     print - shell built-in function to output characters to  the
     screen or window

SYNOPSIS
  ksh
     print [ -Rnprsu[n ] ] [ arg ... ]
[snip]

--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>


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

Date: 19 Oct 1998 14:43:12 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: Alexis Huxley <alexis@danae.demon.co.uk>
Subject: Re: Slow Sort (complex hashes sub-thread)
Message-Id: <sar1zo4pf3z.fsf@camel.fastserv.com>

>>>>> "AH" == Alexis Huxley <alexis@danae.demon.co.uk> writes:


  AH> What I actually wanted to do (a long time ago), was make the
  AH> variables %names and %attribs "file static" (a la "C") *WITHOUT*
  AH> turning the file into a package. But I couldn't work out how to do
  AH> that in Perl, so I wound up making them global. perl's "-w" option
  AH> then complained that a package name was missing, so I just
  AH> prefixed them with "main::" and it was happy.

  AH> I'm sure there is a better way do to it. What's the neatest way to
  AH> make a variable "file static" without turning the file into a
  AH> package? - I'm reluctant to make a package out of the functions
  AH> that access these strutures because it makes running different
  AH> versions of the programs on the same system cleaner.

you can use 'my' at the file level. that is similar to file static in C.

  AH> printf $out_handle [ long hideous printf snipped ]

  AH> save a large amount of time since you are just printf'ing string
  AH> and

  AH> Yes, the printf is messy, I agree. It will get replaced by a
  AH> print-join later, but since it's certainly not the printf that
  AH> causes the problem, it can wait :-)

don't need a join either. just a simple print will handle a list of
values. when i see print with lots of . or join of disparate things, my
skin crawls. i only do print join when i join values in an array or
something like that. print will just print anything you give it. very
nice way to do it.

  AH> PS Uri, sorry about anti-spam mail you must have got; I've added
  AH> you to my whitelist now.  -- Alexis Huxley
  AH> alexis@danae.demon.co.uk email key: 549812

that was strange. but it's ok. i also mail from this address (which
should not have a camel in it but sendmail sux).

uri

-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Mon, 19 Oct 1998 19:24:49 GMT
From: droby@copyright.com
Subject: Re: sorting file entries by time
Message-Id: <70g3m0$u27$1@nnrp1.dejanews.com>

In article <lad87povnm.fsf@erh.ericsson.se>,
  Michal Rutka <erhmiru@erh.ericsson.se> wrote:
> John Porter <jdporter@min.net> writes:
> >
> > Of course it is.
> >
> > That's why the sort should use the built-in sort routine,
> > rather than an explicitly defined one.
> >
> > Something like this will do nicely:
> >
> > @sorted_lines =
> >   map { substr($_,8) }
> >   sort
> >   map { substr($_,25,8).$_ }
> >     @unsorted _lines;
>
> I see John that you like this construction which came from my post about
> sorting the IPs. I like it too, and seems that other people too. I've got
> few requires from  guys that saw my post and wanted to find some refference
> about it. I don't have any, as I 'invented' it on the fly. I wonder if it
> was discussed before my post? Nevertheless, as I find it quite usefull
> I am thinking about naming it. Because it is quite simillar to ST, maybe
> I should call it FST -> Flat ST. Because, as opposite to ST, which uses
> two dimensional arrays to sort, this one operates on one dimesional
> arrays. Or maybe it should be named Linear ST?
>

Perhaps it should be called a Rutka Transform?  You too can have a tranform
named after you, and join the ranks of Laplace, Fourier, Mellin, Schwartz, ...

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 19 Oct 1998 15:35:30 -0400
From: John Porter <jdporter@min.net>
Subject: Re: sorting file entries by time
Message-Id: <362B9482.1E9B861E@min.net>

Michal Rutka wrote:
> 

Thanks a lot, jerk.

You also mailed this to me.
Has it ever occured to you that most people deal with their
email before hitting the newsgroups?

Please, next time put something like "[Posted and mailed]"
at the top.

The Net and I thank you.

Also, please set your line width to something less than 80.
Thanks again.


> I see John that you like this construction which came from my post
> about
> sorting the IPs. I like it too, and seems that other people too. I've
> got
> few requires from  guys that saw my post and wanted to find some
> refference
> about it. I don't have any, as I 'invented' it on the fly. I wonder
> if it
> was discussed before my post? Nevertheless, as I find it quite usefull
> I am thinking about naming it. Because it is quite simillar to ST,
> maybe
> I should call it FST -> Flat ST. Because, as opposite to ST, which
> uses
> two dimensional arrays to sort, this one operates on one dimesional
> arrays. Or maybe it should be named Linear ST?

1. This is not similar enough to the Schwartzian Transform to
   merit a derivative name.  The ST specifically uses anonymous
   arrays, created in map#1, passed to sort and to map#2, to work
   its magic.

2. This technique is general and generic enough to not need
   labeling, IMO.  It is more like a maxim, a Rule of Thumb:
   "If speed is critical [isn't it always?], use the built-in
   sort if at all possible".  Depending on what the stuff to
   be sorted looks like, this could range in difficulty from
   trivial to impossible.

-- 
John "Gashlycrumb" Porter

"A fugitive and lurid gleam
  Obliquely gilds the gliding stream." -- EG


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

Date: 19 Oct 1998 12:36:19 -0700
From: jbc@west.net (John Callender)
Subject: Thanks for the help on my Perl/CGI tutorial
Message-Id: <70g4bj$80q@acme.sb.west.net>

A number of people were kind enough to review the Perl/CGI tutorial I 
recently put up, and offer suggestions for improving it. I've now 
implemented most of those suggestions (to some degree or other), and just 
wanted to voice a public thanks (you know who you are).

The tutorial can be found at:

http://www.lies.com/begperl/

I'll continue to work on it as people suggest changes/improvements.

There was really just one major suggestion that I failed to implement; 
one reviewer wanted me to add "use strict" to the sample form-to-email 
and guestbook scripts. After thinking about it, I decided not to. Given 
the no-programming-experience-assumed nature of the tutorial, I just 
couldn't bring myself to add the additional burden of learning about 
lexical scoping on top of all the other new concepts this hypothetical 
non-programmer would be grappling with.

I realize this brands me as evil in the eyes of a significant portion of 
this group's regulars; so be it. I don't doubt that most of them view the 
whole enterprise as evil from the get-go, so I'm not going to lose sleep 
over that particular transgression.

Anyway, thanks again for all the help.


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

Date: Mon, 19 Oct 1998 12:38:33 -0600
From: Alex Tatistcheff <alext@NOSPAM.cri-boi.com>
To: Georg Buehler <gbuehler@med.unc.edu>
Subject: Re: Trouble scheduling Perl scripts with WinNT AT command
Message-Id: <362B8729.4F3855E@NOSPAM.cri-boi.com>

I find that calling a batch or .CMD file from the AT scheduler works best for
me.  That way I can make sure it's running in the right directory, calling the
right perl.exe, etc.  I don't have to depend on the path to do anything for me.

Alex

Georg Buehler wrote:

> I've read in the FAQs that folks use the "at" command in WinNT to schedule
> events. However, I'll be gosh-durned if I can make it work in my system.
>
> I've tried every permutation of the commands that I can think of:
> at 03:00 perl e:\weblogs\getdailylog.pl
> at 03:00 cmd /c perl e:\weblogs\getdailylog.pl
> at 03:00 "e:\perl\5.00502\bin\MSWin32-x86-object\bin\perl.exe
> e:\weblogs\getdailylog.pl"
>
> Nothing seems to work. I know my script is working properly, it runs without
> a hitch from a command-line, manaully. The schedule service is working, I
> can successfully schedule NT commands, just not my Perl scripts.
> What am I missing?
>
> --Georg Buehler
> gbuehler@elsitech.com





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

Date: Mon, 19 Oct 1998 12:38:00 -0600
From: Alex Tatistcheff <alext@NOSPAM.cri-boi.com>
To: Georg Buehler <gbuehler@med.unc.edu>
Subject: Re: Trouble scheduling Perl scripts with WinNT AT command
Message-Id: <362B8708.E05088C5@NOSPAM.cri-boi.com>

I find that calling a batch or .CMD file from the AT scheduler works best for
me.  That way I can make sure it's running in the right directory, calling the
right perl.exe, etc.  I don't have to depend on the path to do anything for me.

Alex

Georg Buehler wrote:

> I've read in the FAQs that folks use the "at" command in WinNT to schedule
> events. However, I'll be gosh-durned if I can make it work in my system.
>
> I've tried every permutation of the commands that I can think of:
> at 03:00 perl e:\weblogs\getdailylog.pl
> at 03:00 cmd /c perl e:\weblogs\getdailylog.pl
> at 03:00 "e:\perl\5.00502\bin\MSWin32-x86-object\bin\perl.exe
> e:\weblogs\getdailylog.pl"
>
> Nothing seems to work. I know my script is working properly, it runs without
> a hitch from a command-line, manaully. The schedule service is working, I
> can successfully schedule NT commands, just not my Perl scripts.
> What am I missing?
>
> --Georg Buehler
> gbuehler@elsitech.com





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

Date: 19 Oct 1998 15:01:18 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: stevenjm@olywa.net
Subject: Re: Wanted: programming (humor?)
Message-Id: <saru310nzpd.fsf@camel.fastserv.com>

>>>>> "s" == stevenjm  <stevenjm@olywa.net> writes:

  s> (humor, sort of) Can anybody here spend several (hours|days|weeks)
  s> writing me a program for my use (which I fully intend to make money
  s> on) in exchange for something you could get without my help, but
  s> that I will geneously offer as payment?

i will do the job for $5000/hr (sic), with 100 hours of retainer prepaid
into my swiss bank account. after i get the money i will let you give me
what details you have and i may do some work for you if i feel like it.

:-)

uri



-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: 19 Oct 1998 14:54:19 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: Michal Rutka <erhmiru@erh.ericsson.se>
Subject: Re: what is strlen() in perl?
Message-Id: <sarww5wo010.fsf@camel.fastserv.com>

>>>>> "MR" == Michal Rutka <erhmiru@erh.ericsson.se> writes:

  MR> Mehdi Beygi <mjb@voodoo.ca.boeing.com> writes:

  >> Perl is wonderful!

  MR> What so wonderful about it?

michal,

why do you make comments like that after helping someone out? if you
don't like perl, than why do you use it? and why do you follow this
group? we know plenty of people who dislike perl for various reasons and
that is fine. but to denigrate it while actually answering a query in
the group can get a little irritating to the rest of us. we like the
language and like helping out others with it.

there have been plenty of flame wars about perl as you have seen so
please keep comments about you perl love/hate to those threads. and keep
the language answers focused on just the problem. i know the poster said
"perl is wonderful" but they probably didn't expect your retort.

and this is not like the rtfm and other responses to newbies that get
bandied about here. it is just jarring seeing an answer juxtaposed with a
negative comment like that.

uri


-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

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

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