[7658] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1284 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 7 06:07:40 1997

Date: Fri, 7 Nov 97 03:00:22 -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           Fri, 7 Nov 1997     Volume: 8 Number: 1284

Today's topics:
     $perl vaiables to javascript vaiables <myleslawrence@email.msn.com>
     Re: An excellent example of perl madness (or "split stu <ghowland@hotlava.com>
     Re: Another batch of some simple newbie questions. :) <qdtcall@esb.ericsson.se>
     Re: Associative Array (HASH) problem <markm@nortel.ca>
     Re: Can I use Perl to mail form data under NT4/IIS3,4 ? (Nic Wolff)
     Re: CPAN confusion (William R. Ward)
     Re: Extended REs in Perl 5.00401: /x extension failure  (Ilya Zakharevich)
     How to set chmod before writing to a file? jmack@p3.net
     make ftp on perl script with windows 95/NT <h120996667@mail.chinatrust.com.tw>
     Re: memory leak in POP3Client or something else? <randy@null.net>
     Re: memory leak in POP3Client or something else? (brian d foy)
     Re: memory leak in POP3Client or something else? (William R. Ward)
     Re: Passing Variables <markm@nortel.ca>
     Perl 5.004.04 on SunOS 5.4 <canal@europa.com>
     Re: Perl->Java? Java->Perl? Gaaaaa! (Paul Murray)
     Re: Protecting Perl Source <randy@null.net>
     Re: rlogin from script <quillan@doitnow.com>
     Re: Self-Modifying Perl Scripts <qdtcall@esb.ericsson.se>
     Sorting integers in Perl as an array (Steve)
     Re: Sorting integers in Perl as an array (William R. Ward)
     Re: Sorting integers in Perl as an array (brian d foy)
     Re: that @#*$%#! redirection scripts <wtansill@erols.com>
     Re: Tricky problem... how to use open3() in "open3.pl"  <rra@stanford.edu>
     Re: Tricky problem... how to use open3() in "open3.pl"  (brian d foy)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 6 Nov 1997 20:27:04 -0800
From: "Myles Lawrence" <myleslawrence@email.msn.com>
Subject: $perl vaiables to javascript vaiables
Message-Id: <evnY5Sz68GA.332@upnetnews02.moswest.msn.net>

I have a routine that populates an array from a database. How can I get the
perl variables into the javascript variables.
myleslawrence@msn.com


require 'defects/defect-header.pl';
use Win32::ODBC;
use CGI_Lite;
local(%drec);
$db = new Win32::ODBC("dsn=LocalServer;uid=sa;pwd=;DATABASE=defects");
$db2 = new Win32::ODBC("dsn=LocalServer;uid=sa;pwd=;DATABASE=defects");
sub print_prompt {
   print <<END;
   <form action="javlist.pl" method="post">
   <input type="hidden" name="dosubmit" value="on">
  END
   ;
   print <<END;
   </table>
   </form>
   </div>
END
   ;
}

sub do_work {

print <<EOF;
<SCRIPT LANGUAGE="JavaScript">
var productType = new Array();
var deviceType = new Array();
var f = "mystuff";
function getthe(product) {
    var tIndex, selectedProduct
    tIndex=product.selectedIndex
    selectedProduct=product.options[tIndex].text
      project.value=selectedProduct
}
function putthe(ind,product) {
alert(product)
alert(ind)
    project.value=product
    index.value=ind
}

</SCRIPT>

<p>
<font size="-3">
<p>&nbsp;<br>
<div align="left">
<TABLE >
EOF
      ;
$sql   = "SELECT distinct proj_name from printers";
 if ($db->sql($sql)) {
   die ("Couldn't execute query: " . $db->error);
 }
$i=0;
while ($db->FetchRow())  {
 $prodType[$i] = $db->Data('proj_name');
 print "<br> type= $prodType[$i]<br>";
 $whereby = "'" . $prodType[$i] . "'";
 $i++;
 $sql2   = "SELECT printer_name from printers where proj_name = " .
$whereby;
 $db2->sql($sql2);
 $j = 0;
 while ($db2->FetchRow())  {
  $devType[$i,$j] = $db2->Data('printer_name');
  print "<br> printer= $devType[$i,$j]";
  $j++;
 }
}
$db2->Close();



$sql   = "SELECT proj_name from project";
 if ($db->sql($sql)) {
   die ("Couldn't execute query: " . $db->error);
 }
print "<select name=\"proj_name\" onChange=\"getthe(this)\">\n";
while ($db->FetchRow())  {
 local($selected)="SELECTED";
 ($proj_name) = $db->Data('proj_name');
 print "<option name=\"proj_name\" $selected
value=\"$proj_name\">$proj_name</option>";
 $selected= "";
}
print "</select></td>";
print "<INPUT NAME=\"project\" VALUE=\"\" SIZE=35>";
print "<INPUT NAME=\"index\" VALUE=\"\" SIZE=5>";
$sql   = "SELECT printer_name from printers";
 if ($db->sql($sql)) {
   die ("Couldn't execute query: " . $db->error);
 }
print "<select name=\"printer_name\" onChange=\"putthe(this)\">\n";
while ($db->FetchRow())  {
 local($selected)="SELECTED";
 ($printer_name) = $db->Data('printer_name');
 print "<option name=\"printer_name\" $selected
value=\"$printer_name\">$printer_name</option>";
 $selected= "";
}
print "</select></td>";

    return 1;
}
$cgi = new CGI_Lite ();
print "HTTP/1.0 200 OK\n";
print <<EOF;
Content-type: text/html
<html>
 <head>
  <title>Defect Listing</title>
 </head>
 <body bgcolor=#FFFFFF text=#000000>
 <form name="form1">
 <input type=\"button\" value =\"but\" name = \"but\" onClick
=\"putthe('2','stuff')\">
 </form>
EOF
;
&do_work($query);
$db->Close;
print <<EOF;
</body>
</html>
EOF
;





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

Date: Fri, 07 Nov 1997 11:40:09 +0100
From: Gary Howland <ghowland@hotlava.com>
To: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: An excellent example of perl madness (or "split stupidity")
Message-Id: <3462F009.7A49@hotlava.com>

Randal Schwartz wrote:
> 
> >>>>> "Gary" == Gary Howland <ghowland@hotlava.com> writes:
> 
> Gary> Three of the following work as expected.  A pint for anyone who can tell
> Gary> my which three (without running the code):
> 
> (Five, actually...)

Excellent!  This has caught Randal out! :-)  Proof of this perl
madness!!!
(and I don't have to get you that pint ...)

Here is the output:

	h, e, l, l, o, |, w, o, r, l, d
	h, e, l, l, o, |, w, o, r, l, d
	h, e, l, l, o, |, w, o, r, l, d
	hello, world
	h, e, l, l, o, |, w, o, r, l, d
	hello, world
	h, e, l, l, o, |, w, o, r, l, d
	h, e, l, l, o, |, w, o, r, l, d
	h, e, l, l, o, |, w, o, r, l, d
	hello, world

Only three work as hoped - so now do I have your sympathy?


> You just don't seem to realize two things:
> 
>         1) the first arg to split is *always* a regex
>         2) the | char is special in a regex

Ah, I didn't realise that it was always a regex, and I thought that
because this doesn't work:

	print join(", ", split("\s", "hello world")), "\n";

but this does:

	print join(", ", split(/\s/, "hello world")), "\n";

I reasoned that the first failed because it wasn't a regex,
whereas I now know it failed because I'm trying to split on 's'.

Life would be so much clearer if perl just refused to coerce these
strings into regexs, and made me type them explicitly ...


Gary
-- 
pub  1024/C001D00D 1996/01/22  Gary Howland <gary@hotlava.com>
Key fingerprint =  0C FB 60 61 4D 3B 24 7D  1C 89 1D BE 1F EE 09 06


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

Date: 07 Nov 1997 10:28:39 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Another batch of some simple newbie questions. :)
Message-Id: <isd8kdnjco.fsf@godzilla.kiere.ericsson.se>

pelt@madcoyote.com (Pelt) writes:

> $day = `date | awk '{print $1}'`

That's almost sacrilege...

$day = (split(" ",localtime))[0];

 ...will be many times faster, since it doesn't have to fork() off three
other processes. Among other things.

You can read about localtime() in a perlfunc manpage near you. For a
hint about what your snippet did wrong, have a closer look at those
nested backticks.

-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: 07 Nov 1997 02:16:52 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Associative Array (HASH) problem
Message-Id: <lq1n2jhjhqz.fsf@bmerhe83.nortel.ca>

Ryoko <faerielands@geocities.com> writes:

> I have a flat file that looks something like:
> 
> Paul::Jones::Houston::Texas::150
> Jack::Jones::Houston::Texas::150
> Paul::Jackson::Houston::Texas::150
> Kelly::Maxwell::Detroit::Michigan::20
> Matt::Howard::Pasadena::California::125
> Matt::Howard::Pasadena::Arkansas::125
> Oliver::Twist::Yonkers::New Jersey::5
> Fred::Flinstone::Hollywood::Californiay::70
> 
> [snip]
>
> My ultimate goal is to be able to SORT all the records according to
> their score (in descending order -- I have that taken care of). For
> players who have identical scores, they would appear next to each other
> in the sorting process.

# Here's the code to read the stuff in:
use English;
use FileHandle;

my $scores_f = new FileHandle("scores.txt", "r") ||
        die "$0: Open of scores file failed: $OS_ERROR\n";
my @scores = map { /::(\d+)$/; { person=>$PREMATCH, score=>$1 } } <$scores_f>;
my @sorted_scores = sort { $b->{score} <=> $a->{score} } @scores;


# And here's some code for printing out the data structures:
print_scores("Unsorted Scores:", @scores);
print_scores("Sorted Scores:", @sorted_scores);
sub print_scores
{
    my($header, @scores) = @_;
    print "$header\n";
    foreach (@scores) {
        printf "   %3d : %s\n", $_->{score}, $_->{person};
    }
}


hope this helps!
mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Fri, 7 Nov 1997 07:49:54 GMT
From: nicwolff@angel.net (Nic Wolff)
Subject: Re: Can I use Perl to mail form data under NT4/IIS3,4 ?
Message-Id: <EJ9n2K.D3s@nonexistent.com>

In article <345CDFC4.DDDD087A@ats.it>, bb@ats.it wrote:

> I have an HTML form collecting data, and I want the data mailed
> 
> I want to use CGI / Perl, but how I can convince IIS to accept the mail
> ?
> (no /usr/bin/sendmail to pipe to ..)
> 
> Thank You
> Leonardo Blanchi

Here's code to connect right to a mail server and send your mail...

#!/usr/bin/perl

use Socket;

# CREATE SOCKET
socket( SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') );

# CONNECT TO SMTP SERVER
$port = getservbyname('smtp', 'tcp');
$socket = sockaddr_in( $port, inet_aton('127.0.0.1') ); # USE IP OF MAIL SERVER
connect( SOCK, $socket );
select( SOCK ); $|=1; select( STDOUT ); # SET WRITE-THROUGH ON SOCKET

# START MAILING
print SOCK "HELO mydomain.com\n";
print SOCK "MAIL FROM: me\@mydomain.com\n";
print SOCK "RCPT TO: you\@yourdomain.com\n";
print SOCK "DATA\n";
print SOCK "Print form data here.\n";
print SOCK ".\n";

# CLOSE SOCKET
close SOCK;

Nicolas Wolff                                 Angel Networks, Inc.
nicwolff@angel.net    http://www.angel.net    27 West 20th Street,
212/366-0881                                  New York City 10011
--> If this is all you see, stop reading news with a Web browser!


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

Date: 06 Nov 1997 20:56:59 -0800
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: CPAN confusion
Message-Id: <waan2jh9u90.fsf@ese.UCSC.EDU>


I wish to publicly apologize for my tone in my earlier complaint about
CPAN.  While I do believe that it could do with some improvement from
a user interface perspective, my post was out of line.  I was having a
bad day and it came out in my article as an attack on CPAN which is a
very good system in many respects.  Please be assured that my intent
was not to offend.

--Bill.


mgjv@comdyn.com.au (Martien Verbruggen) writes:
> In article <waan2jkyss9.fsf@am.ucsc.edu>,
> 	hermit@cats.ucsc.edu (William R. Ward) writes:
> > Maybe I'm just missing something here, but I find CPAN to be a total
> > pain in the ass to browse.  If I access the module list I am unable to
> 
> No one is forcing you to use CPAN. You could always just write all the
> modules yourself.
> 
> > Who maintains the CPAN web interface that I see mirrored all over the
> > place and how can I get him/her to change this?
> 
> If you are going to request a change, I would suggest that you change
> your tone of voice a bit. I for one (and obviously others) found it at
> least slightly on the offensive side.

-- 
William R Ward          Bay View Consulting   http://www.bayview.com/~hermit/
hermit@bayview.com     1803 Mission St. #339        voicemail +1 408/479-4072
hermit@cats.ucsc.edu  Santa Cruz CA 95060 USA           pager +1 408/458-8862


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

Date: 7 Nov 1997 06:35:11 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Extended REs in Perl 5.00401: /x extension failure or bogus code?
Message-Id: <63ucqv$n8f$1@agate.berkeley.edu>

In article <Pine.GSO.3.96.971106151718.7105K-100000@usertest.teleport.com>,
Tom Phoenix  <rootbeer@teleport.com> wrote:
> Also, to see that you've got all of the backslashes and other stuff that
> you intend, you should probably add something like this for debugging: 
> 
>     my $pattern = qq/$a($c_open)(.*?)$c/;
>     print "The pattern is really /$pattern/\n";
> 
> Remember that whenever you want to put a real backslash into a literal
> string, you should type two of them. Hope this helps!

This is in fact a very bad advice.  qq// quotes _very_ differently
from m//.  Even q'' and m'' are different.

I have some plans to alleviate such problems in 5.005, but if
everything goes well, 5.005 might emerge earlier than the code of mine.

Ilya


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

Date: Thu, 06 Nov 1997 22:11:31 -0600
From: jmack@p3.net
Subject: How to set chmod before writing to a file?
Message-Id: <878875563.946@dejanews.com>

I have a procmail script that sends specific email messages to a perl
script for processing.	This perl script simply adds some HTML tags to
the redirected email and writes it to it's own file in the web server
tree so it can be viewed as a web page.  The problem is the premissions
are 600 (not web viewable), I have to do a manual chmod of the file to
644.  I know I can do a chmod from the perl script, but is there a way to
set the permissions of a file to 644 before it is even written?

Thanks for any advice,

John Mack
jmack@p3.net

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


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

Date: 7 Nov 1997 05:35:47 GMT
From: "Tasuka Amano Hsu" <h120996667@mail.chinatrust.com.tw>
Subject: make ftp on perl script with windows 95/NT
Message-Id: <01bceb40$cff05640$0301a8c0@w95.tailyn.com.tw>

I want make a program to do ftp to the other site on  network,
with perl script and MS-windows 95/NT how to do that ?

PS:I use Perl 5.001 on MS-Windows 95

Tasuka Amano


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

Date: Thu, 06 Nov 1997 22:11:05 -0600
From: Randy Ford <randy@null.net>
Subject: Re: memory leak in POP3Client or something else?
Message-Id: <346294D9.177B@null.net>

schadsey@coralsys.com wrote:
> 
> Can someone help explain why the following program:
> --
> #!/usr/local/bin/perl -w
> 
> use Mail::POP3Client;
> use strict;
> 
> for(;;) {
>         my $pop = Mail::POP3Client->new("user","password","server",110);
>         print "Found ".$pop->Count()." messages\n";
>         $pop->Close;
>         undef($pop);
> }
> --
> adds about 4K to its main memory image size every 5-10 seconds?  this
> happens both with and without the undef line.
> 
> this is with perl version 5.003_02 on a solaris 2.5.1 machine
> 
> Thanks!
> 

In addition to upgrading to Perl 5.004_04, you could move the "my $pop"
out of the loop:

 #!/usr/local/bin/perl -w
 
 use Mail::POP3Client;
 use strict;

 my $pop; 
 for(;;) {
         $pop = Mail::POP3Client->new("user","password","server",110);
         print "Found ".$pop->Count()." messages\n";
         $pop->Close;
 }

Randy Ford


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

Date: Thu, 06 Nov 1997 23:38:57 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: memory leak in POP3Client or something else?
Message-Id: <comdog-ya02408000R0611972338570001@news.panix.com>

In article <346294D9.177B@null.net>, randy@null.net wrote:

>schadsey@coralsys.com wrote:

>> for(;;) {
>>         my $pop = Mail::POP3Client->new("user","password","server",110);
>>         print "Found ".$pop->Count()." messages\n";
>>         $pop->Close;
>>         undef($pop);
>> }

>In addition to upgrading to Perl 5.004_04, you could move the "my $pop"
>out of the loop:

unless you wanted it lexically scoped to within the loop, which seems
more reasonable - but then one could remove the undef()  :)

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 07 Nov 1997 01:39:58 -0800
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: memory leak in POP3Client or something else?
Message-Id: <waa7malt53l.fsf@ese.UCSC.EDU>

Randy Ford <randy@null.net> writes:
> schadsey@coralsys.com wrote:
> > for(;;) {
> >         my $pop = Mail::POP3Client->new("user","password","server",110);
> >         print "Found ".$pop->Count()." messages\n";
> >         $pop->Close;
> >         undef($pop);
[...]
> In addition to upgrading to Perl 5.004_04, you could move the "my $pop"
> out of the loop:
> 
>  my $pop; 
>  for(;;) {
>          $pop = Mail::POP3Client->new("user","password","server",110);
>          print "Found ".$pop->Count()." messages\n";
>          $pop->Close;
>  }

Does this really make a difference?  I would hope that Perl would be
smart enough to not actually deallocate and reallocate the memory for
$pop each time through the loop, but rather to just reset its value to
undef each time.

If not, this may be one area where Perl's compiler could stand some
optimization....

--Bill.

-- 
William R Ward          Bay View Consulting   http://www.bayview.com/~hermit/
hermit@bayview.com     1803 Mission St. #339        voicemail +1 408/479-4072
hermit@cats.ucsc.edu  Santa Cruz CA 95060 USA           pager +1 408/458-8862


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

Date: 06 Nov 1997 23:16:07 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Passing Variables
Message-Id: <lq1lnz1e3ug.fsf@bmers2e5.i-did-not-set--mail-host-address--so-shoot-me>

Dale Chavez <dale@horizonint.com> writes:

> I've got a Web page that calls a Perl script which in turn, calls
> another Perl script.  How can I pass variables from my first script to
> my second (or subsequent) scripts?

Hi:

If you attempting to pass a single scalar which is hopefully not too big,
you can use environment variables (assuming unix).

    --- SCRIPT A ---
    #!/usr/bin/perl
    $ENV{COMMAND} = "Be Happy!";
    system "B";


    --- SCRIPT B ---
    #!/usr/bin/perl
    print $ENV{COMMAND}, "\n";


If you ran script A, it would look like this:

    $ A
    Be Happy!

If you want to try passing complex structures you should probably look
into something called "Serialization" which is partially covered on
page 159 of the "Advanced Perl Programming" book. Similar approach, but
you would "serialize" a data structure into a single scalar, then pass
it through $ENV{...} and the sub-script would un-"serialize" the $ENV{...}
back into a data structure. If you want to pass LOTS of data... like >1K
i would suggest using a pipe/socket of some kind... a tad more effort.

hope this helps,
mark    


--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Fri, 07 Nov 1997 20:11:10 -0800
From: Lon Canaday <canal@europa.com>
Subject: Perl 5.004.04 on SunOS 5.4
Message-Id: <3463E65E.431@europa.com>

I have been trying to install perl 5.004 on a Sun box running SunOS 5.4.
After some checking around I used the default (Solaris_2) as the
installation type but I kept getting a fatal error during make when it
couldn't find the lndbm and ldbm.nfs libraries.  The other apparent
options are SunOS 4.0 and SunOS 4.1 both of which are quite different
from version 5.4 I've been told.  Does anyone have any suggestions?


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

Date: 7 Nov 1997 10:12:05 GMT
From: murray-paul@usa.net (Paul Murray)
Subject: Re: Perl->Java? Java->Perl? Gaaaaa!
Message-Id: <63uphl$rgr@tmp.boc.com>

On Tue, 04 Nov 1997 12:22:48 -0600, dg50@chrysler.com <dg50@chrysler.com> wrote:
>I've got a nasty little problem I'd like some advice on.
>
>I need to create a program that adds/edits/deletes from a little flat-file
>database, and executes a subroutine that then does something with the data
>in the flat file.
>
>This by itself is a no-brainer. I've done similar programs (using a web
>interface as the API) so many times that I've lost count.
>
>This time, however, it a little bit different. In this case, I don't have
>the luxury of a web server with Perl running behind it to act as my API
>manager. Instead, the application has to run offline - quite possibly on a
>*gasp* Wintel box. :(
>
>I also can't count on having perlwin32 on this PC, nor can I count on
>this application staying on any particular machine. Next week, it may
>need to run on a Mac, or on Linux, or whatever.

You could keep it as a perl script for those machines which have perl
installed, and use Perl2Exe (http://www.demobuilders.com/) to create a
standalone executable for the windows machines. Unfortunately
Perl2Exe currently only works with ActiveWare Perl, not standard Perl,
which means you can't use Tk, unless you want to compile it yourself.
(See Msg-ID <63rujg$o3e@tmp.boc.com>, Title "Response from Demobuilders 
about Perl2Exe with standard perl (Win32)" in comp.lang.perl.misc for
more details)

-Paul Murray


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

Date: Thu, 06 Nov 1997 22:06:31 -0600
From: Randy Ford <randy@null.net>
Subject: Re: Protecting Perl Source
Message-Id: <346293C7.4B8C@null.net>

Michael A. Suarez wrote:
> 
> What is a good way to protect perl source...  I want to give some perl
> programs to a client, but I need to keep them from being modified,
> edited, etc.  I want to distribute them more as binaries, but compiling
> them is not allowed.  Any ideas?
> 
> Michael

On CPAN the other day, I saw a module that would encrypt a script, and
dynamical unencrypt it when it ran. I don't remember which one: I didn't
need it; I just thought that it sounded neat.

Randy Ford


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

Date: Thu, 06 Nov 1997 22:45:44 -0500
From: "John C. Quillan" <quillan@doitnow.com>
Subject: Re: rlogin from script
Message-Id: <34628EE8.6E2071CC@doitnow.com>

Tom Turton wrote:
> 
> I am trying to rlogin from one machine to another (same
> account on both machines) in order to chmod a file which I
> have already ftp'd over.  I can't for the life of me figure
> out how to do this.
> 
> Ideally, I'd like to use variables for:
> the server, $server
> the target directory, $tgt_dir
> the filename, $filename
> chmod options, $chmod_opts
> 
> I have tried various methods of putting these in strings
> and running these through system( ); but to no avail.
> 
> Also, need to input a password to the rlogin string.
> 
> Sample which didn't work:

[SNIP]

> I'm sure there is a simple way to do this, but I am obviously
> overlooking
> it.  I'd appreciate any tips.
> 
> ---Tom Turton

I think what you are looking for is to use the rsh command
not the rlogin command.  Also to avoid the password problem
you will need to put a host entry for the host you are rshing
from in you .rhost file (Make sure permissions are 600).  A
man on rsh shoule probide you with the necessary information.

Hope this helps,

John C. Quillan



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

Date: 07 Nov 1997 10:43:00 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Self-Modifying Perl Scripts
Message-Id: <isbtzxnior.fsf@godzilla.kiere.ericsson.se>

zink@uiuc.edu (Dan Zink) writes:

> Is it possible to write a perl script that modifies itself?

Yes.

> I tried to do this, but was unable to open the script file for write
> access while it was running. Is there any way to get around this?

Probably.

It works without any fancy footwork at all on my Solaris machine.
Since you don't say anything about what kind of operating system
you're using (Unix variant? Windows NT? VMS? MacOS? AmigaOS? TOS?),
it's impossible to give more help than that.

-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: Fri, 07 Nov 1997 08:19:25 GMT
From: syarbrou@ais.net (Steve)
Subject: Sorting integers in Perl as an array
Message-Id: <3463cef8.55524922@news.ais.net>

I have an array, let's call it @list.

Consists of data in the following format:

102|/etc/pub/host.htm
25|/pub/home/john.htm

and so on.  The data has a number, then a pipe and the path.  I need
this list sorted by the numbers, highest to lowest.  The problem is
since perl treats this as a string, the numbers 5 300 40 are sorted
from highest to lowest as 5 40 300 because it treats them as 5 4 3.  

How do you sor the above data by their integer values so it would sort
in the 300 40 5 format?  Thanks.

Steve


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

Date: 07 Nov 1997 01:45:09 -0800
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: Sorting integers in Perl as an array
Message-Id: <waa67q5t4uy.fsf@ese.UCSC.EDU>

syarbrou@ais.net (Steve) writes:
> I have an array, let's call it @list.
> 
> Consists of data in the following format:
> 
> 102|/etc/pub/host.htm
> 25|/pub/home/john.htm
> 
> and so on.  The data has a number, then a pipe and the path.  I need
> this list sorted by the numbers, highest to lowest.  The problem is
> since perl treats this as a string, the numbers 5 300 40 are sorted
> from highest to lowest as 5 40 300 because it treats them as 5 4 3.  
> 
> How do you sor the above data by their integer values so it would sort
> in the 300 40 5 format?  Thanks.

How about this:

#!perl
@list = ('102|/etc/pub/host.htm', '25|/pub/home/john.htm');
@list = sort { (split(/\|/, $a, 2))[0] <=> (split(/\|/, $b, 2))[0] } @list;
map { print "$_\n"} @list;
__END__

I think that ought to do the trick.  Perl sure is fun, eh?

--Bill.

-- 
William R Ward          Bay View Consulting   http://www.bayview.com/~hermit/
hermit@bayview.com     1803 Mission St. #339        voicemail +1 408/479-4072
hermit@cats.ucsc.edu  Santa Cruz CA 95060 USA           pager +1 408/458-8862


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

Date: Fri, 07 Nov 1997 05:36:23 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Sorting integers in Perl as an array
Message-Id: <comdog-ya02408000R0711970536230001@news.panix.com>

In article <waa67q5t4uy.fsf@ese.UCSC.EDU>, hermit@cats.ucsc.edu (William R. Ward) wrote:

>syarbrou@ais.net (Steve) writes:

>> Consists of data in the following format:

>> 102|/etc/pub/host.htm

>> How do you sor the above data by their integer values so it would sort
>> in the 300 40 5 format?

>@list = sort { (split(/\|/, $a, 2))[0] <=> (split(/\|/, $b, 2))[0] } @list;

well, if you really want to split that many times...

#!/usr/bin/perl
# not that i recommend this method, but i was surprised that it worked

@array = sort {$a <=> $b or $a cmp $b}
qw( 4| 1| 87|b 2| 7| 56| 4| 25| ew| 100| 101| 99| 8| 87| 0| 87|a );

$" = ", ";
print "@array\n";

__END__
0|, ew|, 1|, 2|, 4|, 4|, 7|, 8|, 25|, 56|, 87|, 87|a, 87|b, 99|, 100|, 101|

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
don't try this with -w, it's not pretty


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

Date: Thu, 06 Nov 1997 23:15:28 -0500
From: "William B. Tansill, III" <wtansill@erols.com>
Subject: Re: that @#*$%#! redirection scripts
Message-Id: <346295E0.36F2@erols.com>

Aram Gurekian wrote:
> 
> Hi all.
> I'm trying to set up a redirection script: someone hits "go" on a form,
> URL-XYZ is passed via "GET" method and then the script should redirect
> the browser to URL-XYZ.
> I tried two different freeware perl scripts:
> clickgo.pl first... and the selection.pl
> I did chmod 755 on both, and the path for Perl is correct...
> 
> The scripts work fine when executed on the shell (perl clickgo.pl)
> 
> But when I try to call them from the web I get an "internal error,
> misconfiguration etc etc"...
> 
> I don't know what I should do, I'm a newbie to Perl and CGI in
> general... I made a little modification on selection.pl, but I don't
> think it's significant. Furthermore, I have the same prob on clickgo,
> which I didn't change.
> 
> On the same server I was able to set-up another perl script, and it
> works fine even from the web.
> 
> Please, could you help me figure out what the problem is, at least to
> give an hint to our system administrator? (server HP, running Unix)
> 
> TIA
> 
>         ciao :)
> 
> --
> aram gurekian  -  weirdo@weirdo.it
> ----------------------------------
> dance like nobody's watching
> love like it's never going to hurt
Does the first line of your script look something like this:

#!/whatever/bin/perl

where /whatever/bin/ is teh directory in which perl is located?  If not,
then the script will not execute when called by the web server.  Also,
our web administrator has cnfigured the server to only recognize scripts
ending with the suffix .cgi (only when call directly by the server
though.  OTher scripts may end in .pl/.pm as necessary).

HTH, Bill.
-- 

How do I set my laser printer to "stun"?


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

Date: 06 Nov 1997 20:03:08 -0800
From: Russ Allbery <rra@stanford.edu>
To: T.Nugent@sct.gu.edu.au
Subject: Re: Tricky problem... how to use open3() in "open3.pl" ??
Message-Id: <m3200ts64j.fsf@windlord.Stanford.EDU>

[ Posted and mailed. ]

Tony Nugent <T.Nugent@sct.gu.edu.au> writes:

> So I have:
>   1. a program, say $FILTER, with a command line array in @OPTIONS.
>   2. an array variable, @DATA, that contains the data that needs to be
>      feed into the stdin of $FILTER.
> I want to run the program and end up with two more arrays:
>   a. @RESULT - contains the data from $FILTER's stdout that is the result of
>                processing @DATA, and
>   b. @ERRORS - contains anything that was issued from $FILTER's stderr.
>   c. $STATUS - the exit code status of the program.

use IPC::Open3;
use FileHandle;

my $data = new FileHandle;
my $result = new FileHandle;
my $errors = new FileHandle;

# Ignore SIGPIPE; we'll catch errors on exit.
local $SIG{PIPE} = 'IGNORE';

# Open a bidirectional pipe to the filter.
eval { open3 ($data, $result, $errors, $FILTER, @OPTIONS) };
if ($@) { die "open3 failed: $@\n" }

# Feed it all of the data, and then close the input pipe to avoid blocking
# problems.
print $data @DATA;
close $data;

# Grab the output.
@RESULT = <$result>;
@ERRORS = <$errors>;
close $result;
close $errors;

# Grab the exit status.
$STATUS = $?;

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Thu, 06 Nov 1997 23:36:08 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Tricky problem... how to use open3() in "open3.pl" ??
Message-Id: <comdog-ya02408000R0611972336080001@news.panix.com>

In article <63tvcj$nbr$1@griffin.itc.gu.edu.au>, T.Nugent@sct.gu.edu.au wrote:

>`perldoc open3' isn't much more informative:
>
>SYNOPSIS
>           $pid = open3(\*WTRFH, \*RDRFH, \*ERRFH
>                           'some cmd and args', 'optarg', ...);

>So exactly how do you use this function?


you give it three references to filehandles, a command, and optional
arguments.  then you can read STDOUT and STDERR, and write to STDIN
of the open3-ed program.

i made a post about PGP a couple of weeks ago that gave an example of
open3.  you should be able to find it in Dejanews [1]


[1]
<URL:http://www.dejanews.com>

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

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

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