[6940] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 565 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 3 17:08:09 1997

Date: Tue, 3 Jun 97 14:00:25 -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           Tue, 3 Jun 1997     Volume: 8 Number: 565

Today's topics:
     Re: any editor for perl? (Mark Bainter)
     Re: AWK vs Perl For Misc Data Processing Tasks (Russell Schulz)
     Code examples: right justify text? (Fred Elbel)
     Re: data structure question (Chipmunk)
     Re: database script needed... ( Thomas Lachlan XMS x4206 )
     Re: Help for "date" (Abigail)
     Help needed on a script <fdeng@cc.memphis.edu>
     Re: Help, embeding perl in C++ (Bob Wilkinson)
     Re: How can I set up this server to run perl faster?... (Michael Parson)
     How can perl fetch a http:// page? (maybe like a 'bot'? (J. Linder)
     Re: How to extract text enclosed by... (Bob Wilkinson)
     Re: Introductory Comparison of Perl and Python <tchrist@mox.perl.com>
     Re: LOG base 10  operator (Tung-chiang Yang)
     mailserver for this group? (J. Linder)
     Re: Output to a printer (Chipmunk)
     perl 5.03 by Activeware, for win95 (paul Spitalny)
     Re: perl 5.03 by Activeware, for win95 (Nathan V. Patwardhan)
     PERL on NT 4.0..not working (Djbomba)
     Possible bug handling '--' switch in v5.001n ??? (Gordon D. Pusch)
     Re: Printing Arrays to a file (Tad McClellan)
     Re: Protecting perl code *Important* <dean@tbone.biol.sc.edu>
     Re: Q: Perl on NT where is stdout? <Jan.Krynicky@st.mff.cuni.cz>
     Re: Reading Comma delimited, Quoted String records (Tad McClellan)
     Re: Setting a variable for both split and join... (Chipmunk)
     Re: STDERR to variable (Shawn Halpenny)
     Re: Text wrapping in variable? (Bob Wilkinson)
     uuidgen in perl? <mfw@criinc.com>
     Re: why won't 'print <<end_print...end_print' work? <sibsib@hotmail.com>
     Re: why won't 'print <<end_print...end_print' work? (Tung-chiang Yang)
     Re: why won't 'print <<end_print...end_print' work? (Faust Gertz)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 03 Jun 1997 20:19:54 GMT
From: mark@michiana.net (Mark Bainter)
Subject: Re: any editor for perl?
Message-Id: <33947bc6.1307680@news.michiana.net>

On Mon, 2 Jun 1997 13:21:54 GMT, dkcombs@netcom.com (David Combs)
wrote:

>In article <338AF477.FE11738D@hkstar.com>, ccm  <cat33@iname.com> wrote:
>>I am a new user in Perl.
>>I found that those .pl files edited under Win95/Dos Editor will not work
>>properly.
>>But if I edit them in the unix shell with pico, they works fine.
>>is out there any editor which workable with perl under Win95/Dos
>>Environment?
>
>Having read all the responses to this question, and
>all the suggested editors, I saw only one that mentioned
>emacs -- and that's all it did -- mention it.
>
>Does no one reading this newsgroup use Emacs??????
>
>Well, if not, you sure don't know what you are missing!
>

Hmm, I take it you haven't been hanging around unix newsgroups for
very long.  The Emacs vs. Vi thread is almost a garunteed flame-war
starter.  For people who use emacs, they love it, and the same for us
vi lovers.  Trying to convert someone between the two is always a bad
idea. :)


---
mailto:mark@turnergroup.com          
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GB/CS/CM/G/IT/P/O d++(+) s+(++):(-) a-- C++(+++)$ ULSC++++(on+++)$ P+>+++ L+ E--- W+$ N++$ !o !K w(++++)$ !O- M--(-) V-- PS--(---) PE++(+++) Y++ PGP++(+++)>++++ t+(++) 5++++(+++) X(-) R tv+ b+++(++++) DI++(+++)>++++ !D-- G>+++ e>+ h---(--) r+++ y+++(++++) 
------END GEEK CODE BLOCK------ 


--------------------------------------------------------------------------------------
 ex abusu non arguitur in usum                                      
 (the abuse of a thing is no argument against its use)  
--------------------------------------------------------------------------------------



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

Date: Tue, 3 Jun 1997 09:39:44 -0600
From: Russell_Schulz@locutus.ofB.ORG (Russell Schulz)
Subject: Re: AWK vs Perl For Misc Data Processing Tasks
Message-Id: <19970603.093944.6k7.rnr.w164w@locutus.ofB.ORG>

  [ I have included c.l.awk ]

"Nathan T. Wild" <nwild@codville.mb.ca> writes:

> We are porting some AWK-based systems over to NT, and I am
> wondering whether I should invest in the NT version of our AWK
> compiler, or just take this opportunity to switch to Perl?

are those your only options?  i.e., can you use a 32-bit free awk?

> AWK has been extremely useful, and at my first glance, Perl appears to
> be extremely cryptic (more so than it has to be!).

perl and awk can both be cryptic.  however, can perl be made clear?  :-)

> Is there a distinct advantage to using Perl over AWK.

  1. larger user base
  2. probable speed improvement
  3. perl just plain does some things awk doesn't.  if you need them, go
     with perl.  while I personally like awk a LOT more, I find myself
     in this situation every once in a while, and I live with it.

for a list of reasons to use awk over perl, see the c.l.a FAQ.

> If so, can anyone direct me to some documentation that is aimed at AWK
> programmers.

I don't know of any, other than the `awk programmer gotchas' listed in
the perl documentation.
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


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

Date: Tue, 03 Jun 1997 19:08:01 GMT
From: frelbel@N0SPAMcsn.net (Fred Elbel)
Subject: Code examples: right justify text?
Message-Id: <33946969.11658356@news-2.csn.net>

I'm about to design a routine to right justify text paragraphs, but
perhaps it's already been done :)    I checked various archives and
haven't found anything yet.

I need to reformat plain text paragraphs.  Each line is terminated
with \n.  However, each line is too long - I need to shorten them to
55 characters or so.

Code fragments or suggestions welcome.

Thanks
Fred

Sorry about the return address hack, but I'm getting a heck of a lot
of spam...
--  Fred Elbel  frelbel@csn.net


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

Date: 3 Jun 1997 18:18:09 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: data structure question
Message-Id: <5n1n51$unk$1@dartvax.dartmouth.edu>

In article <5muqmu$l0b$1@paladin.american.edu>
jn0729a@cage.cas.american.edu (Jon Nathan) writes:

I'll just comment on your code...

> open(QUOTES, "//usr//people//nathanj//quotes");

Why do you have two slashes?  That's just weird.
You should always check the return value of open:
open(QUOTES, $quotefile) || die "Unable to open $quotefile: $!";

> while ($quote=<QUOTES>){

This will end prematurely if a line in the file evaluates to false
(such as "0\n");
I'd suggest:
while (<QUOTES>) {

>         chop($quote);       #get a line from the file

If you have perl5, use chomp instead.
chomp($_);

>         $num=/$(\d+\.)/;    #digit(s) followed by a period

Whoa...  Several problems here.
This is a pattern match on the variable $_, which is undefined at this
point.
$ means match at the end of the string.  Having $ at the beginning of
the regexp is pretty silly. :-)
In a scalar context, m// returns the number of paranthesized groups
which matched.
If you use the while I suggest above:
($num) = /^(\d+\.)/;

>         $quote=~s/\1//;     #take the digit(s) and period out

This is a new regexp, so \1 doesn't refer to anything.
The above two lines can be replaced with:
s/^(\d+\.)//;
$num = $1;

Now, save the quote, with number removed, in $quote.
$quote = $_;

>         chop($source);      #get the next line from the file

That doesn't get the next line from the file.  That just chops $source,
which is undefined.

chop(<QUOTES>);

The source is now in $_;

>         $source=~s/\$1//;   #take the digit(s) and perious out

Your regexp matches a dollar sign followed by a 1.

s/^$num//;

Note that you don't check that the number is the same.

Save the source, with number removed, in $source.
$source = $_;

>         @\$1=($quote,$source);  #make an array called (the number of the quote)
>                                 #that holds the quote and its source
> 
>         %fullquote={           #then make a hash called %fullquote
>                                 #that's indexed by (the number of the quote)
>                                 #and points to the array with the 
> associated 
>                                 #number
>                 $1 => \@\$1,
>         }

Wow.  That's a very complicated data structure for such a simple
problem.

Why not two arrays, one with the quote and one with the source?
push(@quotes, $quote);
push(@sources, $source);

> }

Now, to choose a random quote, all you need is something like:

srand;
$idx = rand($#quotes);
print $quotes[$idx], "\n --", $sources[$idx], "\n";


Of course, the other posts in this thread contain many good suggestions
for solving your problem. This one was just to point out a few issues
regarding your code.

Chipmunk


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

Date: 3 Jun 1997 18:32:33 GMT
From: etltsln@etlxd30.ericsson.se ( Thomas Lachlan XMS x4206 )
Subject: Re: database script needed...
Message-Id: <5n1o01$2do@newstoo.ericsson.se>

ccm (cat33@iname.com) wrote:
: Anyone send me a sample database script with "search" , "edit", "input"
: capabilities.

: --

:     [BLACK DRaGON] from Hong Kong
:     mailto:cat33@iname.com
:     Fax: 852-2944-8842
:     BBS: 852-2614-0170 (16:700/1221@HKNet)
:     Pager: 78932748 a/c 486
:     Address: P.O.Box No.434, Texaco Road Post Office,
:              Tsuen Wan, HONG KONG.

If you could re-post this article divulging more information about
the platform, OS, DBMS, etc. that you intend to use I would be better
equipted to answer your question. Furthermore, when you refer to
search, edit, input are you implicating the use of the SQL type
phenomena of select'ing', update'ing' and insert'ing'? 
What is your reasoning behind using a perl script to carry out
these activities ?
Anyway, not wanting to sound like a comp.lang.perl.etc.etc. 
tight arsed groupy.
Please give us a break and a clue as to what you want.
No offence.
			Regards Tam.


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

Date: Tue, 3 Jun 1997 17:22:24 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help for "date"
Message-Id: <EB7MxC.IGH@nonexistent.com>

On 2 Jun 1997 18:32:11 GMT, Jun Zhuang (jzhuang@ringer.cs.utsa.edu) wrote in
comp.lang.perl.misc
<URL: news:5mv3jb$fd@ringer.cs.utsa.edu>:
++ Under UNIX prompt, enter "date" will get : Mon Jun 2 13:45:34 CDT 1997
++ Is there a similar function in PERL? What if I only want digits of the
++ date? i.e. I want 970602 instead of Jun 2 1997?


$date = localtime; print $date, "\n";

@chunks = localdate;
printf "%02d%02d%02d\n", $chunks [5], $chunks [4] + 1, $chunks [3];


Or use the POSIX routine strftime. Or Time::Local. Or Date::Manip.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$=new Math::BigInt+qq;$$783$[$%9889$47$|88768$596577669$%$5$3364$[$$$|838747$[8889739$%$|$673$%$98$76777$=56;;$=$]*(q.25..($=@))=>do{print+chr$%$;$/=$}while$!=$'


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

Date: Tue, 3 Jun 1997 15:40:20 -0500
From: "F J D" <fdeng@cc.memphis.edu>
Subject: Help needed on a script
Message-Id: <5n1vhd$fca@oolong.memphis.edu>

Hi, I am doing my dissertation and in a urgent need for a CGI script that

allows me to direct different users to different web pages based on the ID

they enter.  I know nothing about CGI.  I, however, pretty sure that I can

do a simple modification of a script so that it can fit my need.



Can anyone kindly point out to me where I can get a perl script that will

do what I want.  Thanks a lot.



F. Johnny Deng




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

Date: Mon, 02 Jun 1997 14:30:38 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: Help, embeding perl in C++
Message-Id: <b.wilkinson-0206971430380001@ip57-york.pindar.co.uk>

In article <3391E1BB.2C76@ix.netcom.com>, Larry D'Anna
<ldanna@ix.netcom.com> wrote:

> Does anyone know how to embed perl functions in C/C++? Thanks a lot.

Hello,

      Type "perldoc perlembed" at your shell prompt. All will be revealed.

Bob

-- 
I have become death, destroyer of the worlds.


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

Date: 3 Jun 1997 13:46:42 -0500
From: mparson@roloc.bl.org (Michael Parson)
Subject: Re: How can I set up this server to run perl faster?...
Message-Id: <5n1oqi$atm$1@roloc.bl.org>

In article <3392669D.73BE@hotmaill.com>,
perl guy  <perlprogrammer@hotmaill.com> wrote:
>Huge aplogies for the major cross-postings.. but I have NO idea where to
>post to, other then the fact that it has to do wth all the formentioned
>subjects.
>
>Ok, first off, I am running perl 5.003 on a Linux Kernel 2.0.18 on an
>i486 server with Red Hat 4, Apache 1.1.1, 5 disk partiions of 300 Megs
>each, 48 MEGS RAM with a 60 MEG swap file..

Eep, this sounds like weird partitioning scheme... you definately need
more swap. :/

These are the basic outlines for partitioning that I follow:

/       32-64 megs, depending on OS version.  Keep it small and as static
        as possible.  You need this partition to be able to survive a
        worse-case crash, the less of this partition that is changed 
        and only exists in RAM, the better.

<swap>  I make this 2x RAM, a good rule-of-thumb if you are running
        < 512meg of real RAM.  If you are running with more RAM, use
        your best judgement, experience will help a lot in this senario.

/var    I generally make this 64 megs as all that goes here is logs.  
        Rotate your logs.  If you need to keep a larger back-log, make
        this partition larger.

/home   This depends on how many users you have, and how much you plan on
        doing in your home dirs.  I generally put home-dirs under /usr/home

/usr    The rest of your disk, or another drive entirely...  This is the 
        most volitile partition you've got.  

if you are using solaris, you will also need

/opt    This partition is where you put prepackaged software.  Depending
        on the mood I'm in, this will either be a symlink to something under
        /usr, or a seperate partition whose size will be dictated by the 
        role this particular system will be serving.


>I am running a chat site that is getting a huge amount of traffic, and I
>need to find out a way, to only run one continous instance of perl, or
>something that won't chew up the drive or slow things down so terribly!
>It's literally killing the hard drive from all the people. I need to
>find out a way to configure something too possibly for the best way to
>run the server for this sort of thing. I wish it was on the NT bo,
>because I could do an ISAPI type thing.. but what can I do on a Linux
>with Perl?. I seriously have no idea. every time someone transfers the

A few things you might want to look at.

First is, update your version of Apache to the latest/greatest 1.2. 

Next, get mod_perl, you can find it at your favorite CPAN archive.

Another thing you can look at is fast-cgi (www.fastcgi.com).  FCGI
requires that you have perl compiled against sfio, which you can
grab from http://www.research.att.com/sw/tools/sfio/.  If you need
help compiling this, drop me a line, I can offer *some* assistance.

-- 
Michael Parson
Mail sent to this posting host will not make it to me, to reply,
send to just the domain.


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

Date: 3 Jun 1997 19:51:07 GMT
From: jann@internetMCI.com (J. Linder)
Subject: How can perl fetch a http:// page? (maybe like a 'bot'?)
Message-Id: <jann-0306971551350001@usr1-dialup53.mix2.boston.mci.net>

I need to know how I go about taking a http:// address & fetching it from
a web server.

I would like to then perform some functions on that page...(I can program
this part) but I do not know how to fetch that page from a web server.

PLEASE email me a response!

mailto:jann@internetMCI.com

Thanks

Jann Linder


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

Date: Mon, 02 Jun 1997 13:56:07 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: How to extract text enclosed by...
Message-Id: <b.wilkinson-0206971356070001@ip57-york.pindar.co.uk>

In article <338efdd0.67917556@news.sprynet.com>, ewharmby@sprynet.com wrote:

> In the same vein, how would I retrieve the first 60 characters? I want
> to work through the string inserting a linefeed after every 60
> characters.
> 

Hello,

      my $first60 = substr($full_string,0,60);

Now $first60 contains the first 60 chars of $full_string.

Bob

-- 
I have become death, destroyer of the worlds.


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

Date: 3 Jun 1997 18:59:27 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Introductory Comparison of Perl and Python
Message-Id: <5n1pif$t04$1@csnews.cs.colorado.edu>

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

In comp.lang.python, 
    tjreedy@udel.edu (Terry Reedy) writes:
:This article compares basic features of Perl (4.x) and Python (1.4) by means 
:of side-by-side code examples followed by minimal commentary.  

That's not very useful -- v4 Perl is six or seven years out of date.  
You need to think about v5.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
``I do quarrel with logic that says, `Stupid people are associated with X,
  therefore X is stupid.'  Stupid people are associated with everything.''
	--Larry Wall in <1992Dec31.203724.26018@netlabs.com>


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

Date: Tue, 3 Jun 1997 18:52:33 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: LOG base 10  operator
Message-Id: <tcyangEB7r3L.32x@netcom.com>

Oh, I understand the meaning of "$_[0]" (the first argument of the argument
list of the current subroutine's, from @_)  However, is it necessary to
restrict the operation of 'log10' to one entry only?

The commercial software Matlab by Mathworks allows list processing, so

>> x = [ 1 10 100 ]

x =

     1    10   100

>> log10(x)

ans =

     0     1     2

>> 

I wonder if the Perl Log10 routine should also work on all the given
input arguments, instead of evaluating on the first entry and ignore
all the rest.

====================================
Tom Phoenix (rootbeer@teleport.com) wrote:
: On Tue, 3 Jun 1997, Tung-chiang Yang wrote:

: > I am a newbie .....  but I wonder why we need to use "$_[0]"......

: That's Perl's way of saying "the first argument to the current
: subroutine", more or less. See perlsub(1) for details on passing
: parameters. Hope this helps!

--
Tung-chiang Yang                       tcyang@netcom.com

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml


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

Date: 3 Jun 1997 19:39:13 GMT
From: jann@internetMCI.com (J. Linder)
Subject: mailserver for this group?
Message-Id: <jann-0306971539400001@usr1-dialup53.mix2.boston.mci.net>

Is there a mailserv for this group?  I would like to get all posts to this
group via email.

if you know of one, please email me at:

mailto:jann@internetMCI.com

Thanks!

Jann Linder


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

Date: 3 Jun 1997 18:19:41 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Output to a printer
Message-Id: <5n1n7t$unk$2@dartvax.dartmouth.edu>

In article <5mv9iq$ctt@hrotti.ifi.uio.no>
tina@htmlhelp.com (Tina Marie Holmboe) writes:

>   open(PRINTER, ">>LPT1:") || die("Unable to open LPT1:, $!\n") ;
>   print "$Date\t $Photographer\t $Fee\n";
>   close(PRINTER) ;

Although it might help to actually print to the PRINTER file handle. 
Since you've gone to the trouble of opening it and all.

print PRINTER "$Date\t $Photographer\t $Fee\n";

Chipmunk


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

Date: Tue, 3 Jun 1997 12:01:17 GMT
From: pauls@seanet.com (paul Spitalny)
Subject: perl 5.03 by Activeware, for win95
Message-Id: <pauls.3.01030E60@seanet.com>

I recently downloaded perl 5.03 from active and have set it up to run.
I have found a funny little problem. Let's say I have a perl script in the 
directory c:\a\b\c called fred.bat. when I type "fred" in this directory perl 
seems to look for the script in another directory, a directory in the path 
variable in my autoexec.bat file.  One obvious solution is to write all of my 
perl scripts in this directory in the path, but that is a pain.

Is there any way to get perl to look in the current directory. Or, is there 
another way I should run perl??

Typically (with perl for dos) i wrote scripts which would be called as follows 
(ex.) by typing in a dos prompt window

"fred  1 3"
where fred is fred.bat that accepts two arguments and fred.bat live\s in the 
directory i typed the command in. Or, fred.bat is in another directory- one 
that is in the path variable in autoexec.bat. This is how I used to do things, 
is there a "new" way to run perl???

Please enlighten me oh wise ones...


Paul Spitalny


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

Date: 3 Jun 1997 20:34:05 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: perl 5.03 by Activeware, for win95
Message-Id: <5n1v3t$fr9@fridge-nf0.shore.net>

paul Spitalny (pauls@seanet.com) wrote:

: Is there any way to get perl to look in the current directory. Or, is there 
: another way I should run perl??

is c:\ in your path as well as the path to perl.exe?

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 3 Jun 1997 20:46:47 GMT
From: djbomba@aol.com (Djbomba)
Subject: PERL on NT 4.0..not working
Message-Id: <19970603204600.QAA11133@ladder02.news.aol.com>

I have installed PERL 5 on an NT 4.0 server and I believe I have it
configured properly, I have even used microsofts test 
(http://www.microsoft.com/kb/articles/q150/6/29.htm) to verify that perl
scripts will run on the server, and even there test script wont run, any
time I try to execute a perl script via my browser, I get an hourglass
forever and never any output.

I have checked my Registry entries and my IIS setup, cgi-bin permissions
are read and execute, Ive tried ending the URL with a "?", all with no
luck

has anyone else run into this, Ive tried 2 diferent servers, IIS is
version 3.0


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

Date: 03 Jun 1997 13:25:26 -0500
From: pusch@mcs.anl.gov (Gordon D. Pusch)
Subject: Possible bug handling '--' switch in v5.001n ???
Message-Id: <phn2p7k0h5.fsf@xanadu.mcs.anl.gov>

According to the revised version of ``Programming Perl (v5),'' 
the following ``pound-bang'' line should be legal for `perl5`,
and should force `emacs` into 'perl-mode':

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

I find that, while the `emacs` perl-mode part works, `perl5` yields an
'Unrecognized switch: - -- .' msg at compile-time. However, the 'bundled' 
single-character switch-format,

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

=does= appear to work as advertised. 

Is this in fact the correct behaviour?  Or peradventure, might there
be a bug in v5.001n's processing of the '--' switch ???


--  Gordon D. Pusch   <pusch@mcs.anl.gov>

Disclaimer:  I'm a consultant collaborating with Argonne researchers;
I don't speak for ANL or the DOE --- and they *certainly* don't speak
for =ME= !!!


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

Date: Mon, 2 Jun 1997 21:55:02 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Printing Arrays to a file
Message-Id: <6210n5.3ph.ln@localhost>

Byron Brummer (byron@thrush.omix.com) wrote:
: Tad McClellan <tadmc@flash.net> wrote:
: 	>snip<
: > OR (better)
: > foreach (@altsorted){
: >    print "$_\n";
: > }

: 	OR
: 	print join ("\n", @altsorted), "\n";

: 	IMHO, setting $" (and most of it's friends) is silly and
              ^^^^^^^^^^
: 	just causes problems latter.


I think you must have quoted the wrong one out of my examples.

The above method doesn't muck about with special variables.

That is exactly why I put that "(better)" in there...


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


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

Date: 03 Jun 1997 15:54:04 -0400
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: Protecting perl code *Important*
Message-Id: <m13eqz5uoz.fsf@nauplius.psc.sc.edu>

Carl Eklof  <noasat@acm.vt.edu> wrote:
>How does one protect perl code.
>
>I have a very serious issue; I am selling some code that I wrote and
>would like to protect it against copying, etc. I have heard that there
>are ways to convert perl into its binary form. Is that true? That would
>certainly solve my problem.  

No, it wouldn't.  Compiled code can pretty easily be
reverse-engineered.  You're trying to protect your efforts using a
"trade secret" strategy.  That strategy can work if your manufacturing
process can be kept physically secure and your product doesn't allow
deducing what the production process was.  Unfortunately, with
computer code, you _have_ to release the functioning "process" (or it
ain't much use).

A much better strategy is to protect yourself using copyright.
Computer code is, in fact, fully covered by copyright law.  It becomes
copyright by you the moment you create it (or, if it is a "work for
hire" it is copyright by your employer at that moment).  You can
assert your rights under copyright by including a statement like the
following within the code:

    Copyright 1997 Nicholas Dean Pentcheff.

(Uh, obviously, use your own name, or that of your employer if you are
doing this as an employee or consultant).  

If your code has an interactive component to it, it seems reasonable
to have it display the copyright text at startup, too.

As the saying goes, I am not a lawyer (and have no desire whatsoever
to be one).  But... if you're interested in more information on this
matter, see:

    <URL:http://www.aimnet.com/~carroll/copyright/faq-home.html>

Best of luck!

-Dean
-- 
N. Dean Pentcheff   <pentcheff@acm.org>   WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83  A0 BF CB C0 D1 0E 76 C0 
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"


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

Date: Tue, 03 Jun 1997 20:57:37 -0700
From: Jan Krynicky <Jan.Krynicky@st.mff.cuni.cz>
To: arnoudm@ijssel.xs4all.nl
Subject: Re: Q: Perl on NT where is stdout?
Message-Id: <3394E7B1.5706@st.mff.cuni.cz>

Arnoud Martens wrote:
> 
> Hello,
> 
> I have a problem with perl under NT 4.0. Perl is version 5.003 downloaded
> from CPAN. I have associated the .pl extension with perl.exe as stated in
> the FAQs.
> 
> My problem has to do with stdout, when I just type:
> 
> try.pl
> 
> all output is displayed on the console (MS DOS prompt). But when I type:
> 
> try.pl > out.dat
> 
> I end up with a zero byte out.dat file. Strange things is when I do
> 
> perl.exe try.pl > out.dat
> 
> all output is correctly available in the file out.dat. So it looks like
> the association is messing things up.
> 
> The association is made through:
> 
> assoc: .pl=plscript
> ftype: plscript=d:\progra~1\perl5\bin\perl.exe %1 %*
> 
> Any help or pointers appreciated.
> 
> --
> Arnoud Martens
> arnoudm@ijssel.xs4all.nl

It's not a perl problem. but a Microsloth's one.
They have not been able to make a working redirection in any 
"system" they made. I don't think you can do anything about that.

Try something.bat > somefile.txt
you get the same results. :-(((((

Jenda


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

Date: Mon, 2 Jun 1997 21:47:19 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Reading Comma delimited, Quoted String records
Message-Id: <nj00n5.3ph.ln@localhost>


[ comp.lang.perl is a non-group. It does not exist. It should not
  be posted to any more. Ask your System Administrator to remove
  it from your news server. Newsgroups and Followups trimmed 
  appropriately.
]


[ not an awk question, so comp.lang.awk trimmed from followups ]

[ not a SCO question, so comp.unix.sco.programmer trimmed from followups too ]


Sean M. McKee (mckee@misslink.net) wrote:
: Does anyone know of a way to read and parse comma delimited string quoted
: records with awk or perl?


Yes, someone knows. Some others have asked this question here with
such nauseating frequency, that some Perl folks collected this, and
many other, Questions that have been Asked Frequently into a
package of cumulative Perl wisdom. It is a valuable
resource. You should use it...

They call it the Perl Frequently Asked Question (FAQ) list.

Didn't do any good though, because folks won't check the FAQ for
a newsgroup before posting their question. Sad  ;-(


: I know how to read a comma delimited file (awk -F:) but if a string field
: contains a comma (eg. ...,"McKee, Sean",...) then the field is surrounded
: in double quotes.  Is there a way to deal with this?


Perl FAQ, part 4:

--------------------------------------------------------------------
=head2 How can I split a [character] delimited string except when 
       inside [character]? (Comma-separated files)

Take the example case of trying to split a string that is comma-separated
into its different fields.  (We'll pretend you said comma-separated, not
comma-delimited, which is different and almost never what you mean.) You
can't use C<split(/,/)> because you shouldn't split if the comma is inside
quotes.  For example, take a data line like this:

    SAR001,"","Cimetrix, Inc","Bob Smith","CAM",N,8,1,0,7,"Error, Core Dumped"

Due to the restriction of the quotes, this is a fairly complex
problem.  Thankfully, we have Jeffrey Friedl, author of a highly
recommended book on regular expressions, to handle these for us.  He
suggests (assuming your string is contained in the special variable
$_):

     @new = ();
     push(@new, $+) while $text =~ m{
         "([^\"\\]*(?:\\.[^\"\\]*)*)",?  # groups the phrase inside the quotes
       | ([^,]+),?
       | ,
     }gx;
     push(@new, undef) if substr($text,-1,1) eq ',';
--------------------------------------------------------------------


You just wanted to do your part to ensure that the 'F' in FAQ
remains accurate, I guess...


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


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

Date: 3 Jun 1997 17:52:29 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Setting a variable for both split and join...
Message-Id: <5n1lkt$rjr$1@dartvax.dartmouth.edu>

In article <33930D8A.15FB@itis.com>
Prince Mystery <mystery@itis.com> writes:

> CHAN TANG Eric-Aubert wrote:
> > $SEPARATOR = '|';
> > 
> > $string = join($SEPARTOR, @text);
> > 
> > @text = split(/$SEPARATOR/, $text);
> > 
> > This won't work because, 'split' should be call this way:
> > @text = split(/\|/, $text);
> 
> I think you have to run $SEPARATOR through the quotemeta() func before
> running it through split, ie:
> 
> @text = split(/quotemeta($SEPARATOR)/,$text);

This should work also:

@text = split(/\Q$SEPARATOR/, $string);
# as has been pointed out alreay, $string contains the text to be split

Chipmunk


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

Date: Tue, 3 Jun 1997 18:15:26 GMT
From: rsh@cci.com (Shawn Halpenny)
Subject: Re: STDERR to variable
Message-Id: <EB7pDr.Mzr@sunsrvr6.cci.com>

>From article:  <Pine.GSO.3.96.970603080800.1116J-100000@kelly.teleport.com>
       Author:  Tom Phoenix <rootbeer@teleport.com> {TP}
         Date:  Tue, 03 Jun 1997 15:10:29 GMT

TP> On Tue, 3 Jun 1997, Rob Dickens wrote:
TP> 
>> I am wanting to put the output of STDERR to a variable.
TP> 
TP> If you're calling external programs, this may be difficult to do directly.
TP> (Unless, of course, you've thought of something I haven't. :-)
TP> 
>> I do not want to put the output to a file and then read it back in
>> because the program could be called by many people.
TP> 
TP> Why not simply use a unique file name for each process?
TP> 
TP>     $my_stderr_file = "/usr/tmp/mystderr.$$.$^T.temp";
TP>     open STDERR, "> $my_stderr_file" or
TP> 	die "Can't write to '$my_stderr_file': $!";
TP> 
TP> Hope this helps!
TP> 
TP> -- Tom Phoenix        http://www.teleport.com/~rootbeer/
TP> rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
TP> Randal Schwartz Case:     http://www.lightlink.com/fors/


If calling external programs by way of Bourne shell, you can do something
like this:

$stderr_output = `prog 2>&1 1>/dev/null`;

to dump the stderr to stdout (and subsequently into your variable), while
the old stdout goes to /dev/null.

--
Shawn Halpenny

"I got food poisoning today.  I don't know when I'll use it."
                                            - Steven Wright


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

Date: Mon, 02 Jun 1997 14:15:49 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: Text wrapping in variable?
Message-Id: <b.wilkinson-0206971415490001@ip57-york.pindar.co.uk>

In article <338BF6A0.6ABD@moriah.com>, scott@moriah.com wrote:

> Quick question:
> 
> What is the proper way to assign a long text string to a variable.
> 
> Using MacPerl, this works fine but gives an error under Unix.
> 
> $foo = "This is a sample text string that
> wraps because of my window size";
> 
> Thanks in advance,
> 
> scott@moriah.com

Hello,

      My psychic batteries are running low today. Do you think that you could
say *what* the error is that you are getting from Unix?

Bob

-- 
I have become death, destroyer of the worlds.


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

Date: Tue, 03 Jun 1997 12:20:54 -0700
From: flint weiss <mfw@criinc.com>
Subject: uuidgen in perl?
Message-Id: <33946E96.72CAB4C5@criinc.com>

is there some perl code out there that will generate UUID's?

thanx in advance,
flint weiss



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

Date: Tue, 03 Jun 1997 14:43:44 -0400
From: Scott Blanksteen <sibsib@hotmail.com>
Subject: Re: why won't 'print <<end_print...end_print' work?
Message-Id: <339465E0.A00767F4@hotmail.com>

Will Sexton wrote:
>         print <<"end_print";
>         some text
>         some text on the next line
>         end_print

Will - 

Is it actually indented?  The ending delimiter (end_print, in 
your case) must be placed at the beginning of the line, with
no characters (including whitespace) in front of it.

Scott

-- 
Scott I. Blanksteen
sib (at) worldnet (dot) att (dot) net


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

Date: Tue, 3 Jun 1997 19:06:39 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: why won't 'print <<end_print...end_print' work?
Message-Id: <tcyangEB7rr3.4Az@netcom.com>

Check again whether there is any space or tab after "end_print" string in
the last line.  I tried the code below and experienced no problems.

===================================
Will Sexton (sextw@ils.unc.edu) wrote:
: If I do the following:

: 	print <<"end_print";
: 	some text
: 	some text on the next line
: 	end_print

--
Tung-chiang Yang                       tcyang@netcom.com

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml


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

Date: Tue, 03 Jun 1997 19:12:44 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: why won't 'print <<end_print...end_print' work?
Message-Id: <33946861.2487498@news.wwa.com>

Hmmm. . .  By merely reading the messages in this newsgroup, I, a perl
newbie who has suffered from the same problem, can answer your
question just like pro.  "How?" you ask.  By reading the replies to a
June 1st article not very helpfully entitled "help!!!" posted by Yan
Zhou <yzhou@mtu.edu>.

On 3 Jun 1997 14:10:36 GMT, sextw@ils.unc.edu (Will Sexton) wrote:

>If I do the following:
>
>	print <<"end_print";
>	some text
>	some text on the next line
>	end_print
>
>my (multiple) sources tell me the program should print the text, without 
>having to set the print command for each new line (said sources lacking 
>further explanation).  But when I try it, I get an error message ("Can't 
>find string terminator "end_print" anywhere before EOF at <progname> 
>line <line number>.")  And can't find feature documented among usual 
>suspects (camel, llama, etc.).

Did you try the FAQ?

>Why won't it work?

When using something like 'print <<"end_print";' , perl looks for
"end_print" to terminate the string.  It looks as if you have given it
'	end_print' instead of 'end_print'.  Opps.  So, I suggest that
you do one of two things.

1) Remove some leading whiote space form the line which reads 
'	end_print' and make it read 'end_print'.

or, if you really want to keep all that leading white space which
makes your code so pretty to look at

2) Add the white space to '	print <<"end_print";' and 
make it '		print <<"	end_print";' .  

I don't know for sure that the second suggestion will work, but if you
really want the white space, you might give it a try. 


Streben nach Wahrheit

Faust Gertz
Philosopher at Large

"Always strive to excel, but only on weekends." - Richard Rorty 



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

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

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