[18830] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 998 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 27 14:10:32 2001

Date: Sun, 27 May 2001 11:10:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <990987010-v10-i998@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 27 May 2001     Volume: 10 Number: 998

Today's topics:
    Re: Perl Compilers <pne-news-20010527@newton.digitalspace.net>
    Re: Perl Compilers <mikecook@cigarpool.com>
    Re: Perl Compilers (Randal L. Schwartz)
    Re: Perl Compilers <newspost@coppit.org>
        perl history (*?) (Charles Blair)
        Question <scott.bell1@ntlworld.com>
    Re: SCAN <newspost@coppit.org>
    Re: Search and Replace (Tad McClellan)
    Re: search keywords for text analysis tools (Tad McClellan)
    Re: Shuffler <goldbb2@earthlink.net>
    Re: tail -f in a perl-program (Mark Jason Dominus)
    Re: tail -f in a perl-program <uri@sysarch.com>
    Re: Too late for "-T" option at comment_form.cgi line 1 (Tad McClellan)
    Re: Too late for "-T" option at comment_form.cgi line 1 nobull@mail.com
    Re: What modules are being used? <newspost@coppit.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 27 May 2001 18:51:28 +0200
From: Philip Newton <pne-news-20010527@newton.digitalspace.net>
Subject: Re: Perl Compilers
Message-Id: <s2c2ht8s962lcq9tk88vcmvu8n7rpvf7sg@4ax.com>

On Sun, 27 May 2001 11:10:01 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:

> Peter Reid wrote:
> 
> >Does anyone know of any decent FREEWARE compilers that will take a Perl
> >script and compile it into a standalone .exe? URLs would be good.
> 
> First of all, those are not compilers. They simply wrap a perl
> interpreter and the script into one EXE file. The only thing it's really
> good for, is hiding your code. And not too well.

From what I hear, they're also good for turning a Perl script into a
stand-alone file: one that you can give to someone without a Perl
interpreter.

Not everyone already has Perl installed on their system.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Sun, 27 May 2001 10:19:13 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Re: Perl Compilers
Message-Id: <aHaQ6.1033$ip5.124261@news.uswest.net>

Hiding your code is not its only use - I wrote some system/network prep test
tools in Perl (not in our standard build) and compile them into binaries so
they can be run & deleted wothout having Perl on the box.
    Michael
--
== CigarPool ==
http://www.cigarpool.com
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:57o1ht0un3ofef4dc6spvh7esstuppa29i@4ax.com...
> Peter Reid wrote:
>
> >Does anyone know of any decent FREEWARE compilers that will take a Perl
> >script and compile it into a standalone .exe? URLs would be good.
>
> First of all, those are not compilers. They simply wrap a perl
> interpreter and the script into one EXE file. The only thing it's really
> good for, is hiding your code. And not too well.
>
> Why should anybody help you hide your code for free? You don't seem to
> be willing to do some sharing of code yourself.
>
> --
> Bart.
>




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

Date: 27 May 2001 10:39:46 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl Compilers
Message-Id: <m1r8xavggt.fsf@halfdome.holdit.com>

>>>>> "Philip" == Philip Newton <pne-news-20010527@newton.digitalspace.net> writes:
Philip> From what I hear, they're also good for turning a Perl script into a
Philip> stand-alone file: one that you can give to someone without a Perl
Philip> interpreter.

But you're also giving them the Perl interpreter, except that it can
be used only with that one program!  It'd be better to simply use
the free install of Perl, and give them the Perl program, than
to bundle the entire Perl distribution with each and every program
you want to hand around.  That's ludicrous.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sun, 27 May 2001 13:40:32 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Perl Compilers
Message-Id: <Pine.SUN.4.33.0105271339150.29478-100000@mamba.cs.Virginia.EDU>

On Sun, 27 May 2001, Philip Newton wrote:

> > First of all, those are not compilers. They simply wrap a perl
> > interpreter and the script into one EXE file. The only thing it's really
> > good for, is hiding your code. And not too well.
>
> From what I hear, they're also good for turning a Perl script into a
> stand-alone file: one that you can give to someone without a Perl
> interpreter.
>
> Not everyone already has Perl installed on their system.

Nor do they have the particular version of Perl, or a particular
version of a module, etc. I could care less about hiding my code
(since I also give it away), but saving some use the headache of
installing a bunch of modules is a big win for them.

David



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

Date: Sun, 27 May 2001 17:38:10 GMT
From: c-blair@uiuc.edu (Charles Blair)
Subject: perl history (*?)
Message-Id: <6YaQ6.7487$ki5.103869@vixen.cso.uiuc.edu>

   Has anyone compiled a list of when the most important
extensions were made to perl, both in terms of version and 
calendar time?

   For example, I have written something that uses the *?
capability for regular expressions.  I'm pretty sure this
was not in 4.036, which (I think) means that a lot of people
with five-year-old installations won't be able to run it.


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

Date: Sun, 27 May 2001 18:27:09 +0100
From: "scott.bell1" <scott.bell1@ntlworld.com>
Subject: Question
Message-Id: <yJaQ6.4414$lm5.784339@news6-win.server.ntlworld.com>

I'm trying to write a webpage in CGI that will remember the most recent
visitors to my page and will display them to anyone who visits the "who's
watching" page, all I'm interested in now is storing the last 10 IP
addresses. Can anyone help me with this?


--
Scott Bell





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

Date: Sun, 27 May 2001 13:36:15 -0400
From: David Coppit <newspost@coppit.org>
To: karthy muthiah kasi <kasi@students.uiuc.edu>
Subject: Re: SCAN
Message-Id: <Pine.SUN.4.33.0105271330270.29478-100000@mamba.cs.Virginia.EDU>

[posted & mailed]

On Fri, 25 May 2001, karthy muthiah kasi wrote:

> After opening a file, is there a way that I can scan the next two lines
> without having to move the read cursor?  The problem I am encountering is
> that after invoking <FILENAME>, the next line of the file is read and I am
> unable to read a previous line.

Here's one solution.

--------------
use FileHandle;

my $fileHandle = new FileHandle;
# Use '-' for STDIN
$fileHandle->open('/home/dwc3q/.profile');

PrintFirstLineOfFile($fileHandle);
PrintFirstLineOfFile($fileHandle);

sub PrintFirstLineOfFile
{
  my $fileHandle = shift;

  my $line = <$fileHandle>;
  print $line;

  PutBackString($fileHandle,$line);
}


# Puts a string back on a file handle
sub PutBackString
{
  my $fileHandle = shift;
  my $string = shift;

  while (defined $string && $string ne '')
  {
    my $char = chop $string;
    $fileHandle->ungetc(ord($char));
  }
}
--------------

-- 
David



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

Date: Sun, 27 May 2001 09:48:23 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Search and Replace
Message-Id: <slrn9h21d6.8jk.tadmc@tadmc26.august.net>

felan <felan_66@hotmail.com> wrote:
>I have the following program that prompts for a file name and searches
>and replaces strings in a given filen:
>
>print "Input file name: ";
>chop($infilename = <STDIN>);
 ^^^^

That looks like 6 year old Perl code. Nowadays that would be:

   chomp($infilename = <STDIN>);



>while (<IN>) {  # read a line from file IN into $_
                        ^^^^^^
                        ^^^^^^

>Now I have two problems:


(you have another problem bigger than either of the ones you _have_ seen...)


>1) I would like to search the text:
>
>Father
>and Mother
>
>and replace it with
>
>Parents
>
>with another words I would like to get rid of the linebreak. 


You never _have_ 2 lines in $_, as your own comment above states,
so you cannot operate on 2 lines.

You need to arrange to have a multiline string if you want to 
match it with a multiline pattern.

The $/ special variable might help with that:

   perldoc perlvar


>I have
>tried to add the following without success:
>
>s/Father and Mother/Parents/s;


   s/Father\nand Mother/Parents/s;
or
   s/Father\sand Mother/Parents/s;


Those will work, once you have arranged for the string to actually
contain what you are searching for.


>I get the following error:
>
>Substitution pattern not terminated in file 
>search-replace.pl at line 42, next char ^>
>parse error in file search-replace.pl at line 42, next 2 tokens


You are running Perl 4. Perl 4 is dead. If you insist on using
a 6 year old perl, then you are on your own. Upgrade!


>"s/Father and Mother/Parents/s;"
>Execution of search-replace.pl aborted due to compilation errors.


I don't see how that message could be generated.

Not surprising, since I also cannot see the code that generated it (hint).


>so I have problems with the s-modifier


No, you have problems with accumulating a multiline string to match
against in the first place.

You also have a problem with a geriatric perl.


>2) I would like to run this program for all the files in a given
>directory, so that the search-replace operation can be done on all the
>.html files in a given directory


Ask perl to do inplace editing for you, then pass it a list of filenames:

   my_replacer -i.bak *.html


To learn how to get perl to do inplace editing for you:

   perldoc perlrun

and see the "-i" switch.

Since you are a good Usenet citizen, you have no doubt already
checked the Perl FAQs before posting. It appears you missed one
that applies to your situtation:

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

Which also mentions the use of the -i switch.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 27 May 2001 08:14:50 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: search keywords for text analysis tools
Message-Id: <slrn9h1rtq.8jk.tadmc@tadmc26.august.net>

Guy Worthington <guyw@multiline.com.au> wrote:
>I need my hand held when using "search.cpan.org".  I would like to build
>a sorted list of all the words, and the lines (or pages) they occur on,
>from a TeX file source (I think of it as a raw concordance table).  Could I
>prevail on some of you to give me keyword searches to help me find a tool
>that constructs a concordance table.


Such a thing would be so trivial to write anew each time you need
it that I doubt it would benefit from being put into a module.

Here is one version. It is roughly 6 lines long:

---------------------
#!/usr/bin/perl -w
use strict;

my %concord;
while ( <DATA> ) {
   foreach my $word ( /(\w+)/g ) {
      push @{$concord{$word}}, $.;  # record the line number
   }
}


# output the concordance
foreach my $word ( sort keys %concord ) {
   print "$word: @{$concord{$word}}\n";
}


__DATA__
word1
word2 word3 word1
word word3
---------------------


The two major issues are choosing a data structure (HoL) and deciding
what will be considered a "word".

For issue one, try:

    perldoc perlreftut
    perldoc perlref
    perldoc perllol
    perldoc perldsc

For issue two, it is up to you as to what will constitute a "word".


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 27 May 2001 11:12:41 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Shuffler
Message-Id: <3B111969.D1C80076@earthlink.net>

Philip Newton wrote:
> 
> On Sun, 27 May 2001 06:05:40 -0400, Benjamin Goldberg
> <goldbb2@earthlink.net> wrote:
[snip]
> > =head1 DESCRIPTION
> >
> > C<Shuffler> produces a psuedo-random permutation on a range of
> > integers,
> > using significantly less memory than a Durstenfeld.  It does this by
>                                          ^^^^^^^^^^^
> Do you want to explain what that is, or assume that anyone who might
> want to use your module already know about block ciphers (or whatever
> a Durstenfeld is)?

A fairly well-known shuffling algorithm.

-- 
#! perl -- This took a heck of a lot of work to make.  I hope it works.
@p{split//,'justaperlhacker'}=map hex,qw(6b 71 83 1c1 43 2 3 5 79d 71db
7835 1ddf07 23a871 72656b63); print map {$e=1;for(split//){$e*=$_};pack
'V',$e} qw(ptk ppppprre pperrrlau ppppphc ppjsa r);


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

Date: Sun, 27 May 2001 14:47:41 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: tail -f in a perl-program
Message-Id: <3b11138c.1e9e$c1@news.op.net>

In article <9eq0m2$7eu$1@sloth.swcp.com>, Tramm Hudson <hudson@swcp.com> wrote:
>Mark Jason Dominus <mjd@plover.com> wrote:
>>Konstantinos Agouros <elwood@news.agouros.de> wrote:
>>> ... open(DESK,"tail -f /var/log/messages|") ...
>>
>>I use:
>[snip the code example]
>
>Is there something wrong with the answer given by
>
>	perldoc -q 'tail -f'

I don't know.  Is there?

>Other than that your example does support multiple files and

Oh, I guess that's it then.  The perldoc example doesn't do multiple
files, and neither does the 'tail' on my computer.


>> I have no idea about the efficiency.
>
>Does efficiency really matter if the code does a "sleep 5" in a loop?

The original poster was the one asking about efficiency, so perhaps
you should ask him instead of me.  All I said was that I didn't know.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Sun, 27 May 2001 16:29:37 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: tail -f in a perl-program
Message-Id: <x7k83221se.fsf@home.sysarch.com>

>>>>> "MJD" == Mark Jason Dominus <mjd@plover.com> writes:

  >> Other than that your example does support multiple files and

  MJD> Oh, I guess that's it then.  The perldoc example doesn't do multiple
  MJD> files, and neither does the 'tail' on my computer.

ppt's tail supports multiple files. stem has an very good tailing system
which does tailing of multiple files on multiple machines and supports
al the networking as well as filtering, etc. check it out at
stemsystems.com

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Sun, 27 May 2001 09:56:51 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Too late for "-T" option at comment_form.cgi line 1.
Message-Id: <slrn9h21t3.8jk.tadmc@tadmc26.august.net>

David Soming <davsoming@lineone.net> wrote:

>I got as far as line 1 before I stumbled! lol
>
>Just testing this locally and got "Too late for "-T" option at
>comment_form.cgi line 1."


All of the messages that perl might issue are documented in the
'perldiag' standard doc. You should look up messages there as a
*first* step in troubleshooting.

   perldoc perldiag

--------------------------------
=item Too late for "B<-T>" option

(X) The #! line (or local equivalent) in a Perl script contains the
B<-T> option, but Perl was not invoked with B<-T> in its command line.
This is an error because, by the time Perl discovers a B<-T> in a
script, it's too late to properly taint everything from the environment.
So Perl gives up.

If the Perl script is being executed as a command using the #!
mechanism (or its local equivalent), this error can usually be fixed
by editing the #! line so that the B<-T> option is a part of Perl's
first argument: e.g. change C<perl -n -T> to C<perl -T -n>.

If the Perl script is being executed as C<perl scriptname>, then the
B<-T> option must appear on the command line: C<perl -T scriptname>.
--------------------------------


>What exactly is #!/usr/bin/perl -wT


perl's command line switches are documented in the 'perlrun' 
standard doc:

   perldoc perlrun


The entry there for "-T" says to see also:

   perldoc perlsec



Taint checking helps to protect against crackers breaking your code/site.
You should use it on all CGI programs that take form input.

Since you appear to be just starting out, you can develop without
taint checking, but do NOT put it in production without -T.

Turn off taint checking so that you can get it to run. Put taint
checking back in before you go "live" with it.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 27 May 2001 08:13:35 -0700
From: nobull@mail.com
Subject: Re: Too late for "-T" option at comment_form.cgi line 1.
Message-Id: <4dafc536.0105270713.28855627@posting.google.com>

"David Soming" <davsoming@lineone.net> wrote in message news:<th1e1up1errqf0@corp.supernews.co.uk>...


> Just testing this locally and got "Too late for "-T" option at
> comment_form.cgi line 1."

Perl error messages are explained in the "perldiag" Perl manual.


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

Date: Sun, 27 May 2001 13:28:04 -0400
From: David Coppit <newspost@coppit.org>
To: Terry Gliedt <tpg@umich.edu>
Subject: Re: What modules are being used?
Message-Id: <Pine.SUN.4.33.0105271324250.29478-100000@mamba.cs.Virginia.EDU>

[posted & mailed]

On Fri, 25 May 2001, Terry Gliedt wrote:

> Simply put, for a given Perl script, what are all the modules (and
> the version) used?

Here's what I use:

END
{
    foreach my $key (sort keys %INC)
    {
      my $package = $key;
      $package =~ s/\//::/g;
      $package =~ s/\.pm$//;

      my $version;

      if ($package =~ /^::/ || $package =~ /\./)
      {
        $version = 'undef';
      }
      else
      {
        $version = eval "\$${package}::VERSION";
      }

      $version = 'undef' unless defined $version;

      print "  $key ($version) =>\n    $INC{$key}";
    }
}



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

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

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 V10 Issue 998
**************************************


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