[13489] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 899 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 24 12:14:57 1999

Date: Fri, 24 Sep 1999 09:05:15 -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: <938189114-v9-i899@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 24 Sep 1999     Volume: 9 Number: 899

Today's topics:
        A better way to exclude a phrase in a PATTERN? (Eric Smith)
    Re: A better way to exclude a phrase in a PATTERN? (Kragen Sitaker)
    Re: Adding commas to long numbers. <owensk@cadvision.com>
    Re: Arrays?!? <choco@duke.edu>
        automated submission to a perl script lenny_jolin@my-deja.com
    Re: beauty of a Y2K bug (Kragen Sitaker)
    Re: CGI sending email with attachment (Kragen Sitaker)
    Re: CGI sending email with attachment (Kragen Sitaker)
    Re: combination <skilchen@swissonline.ch>
    Re: decomposing an outline-style text body (ugly regexp <george.willman@2asc.com>
    Re: decomposing an outline-style text body (ugly regexp (Kragen Sitaker)
    Re: decomposing an outline-style text body (ugly regexp <george.willman@2asc.com>
    Re: Fork / Pipe Problem (Kragen Sitaker)
    Re: Help with compiling a list <jeff@jhmi.edu>
    Re: How can I "undo" a require ? (Kragen Sitaker)
    Re: How to RLOGIN - try again <g-preston1@ti.com>
    Re: How to RLOGIN - try again (Kragen Sitaker)
    Re: How to RLOGIN - try again <gellyfish@gellyfish.com>
    Re: How to split one variable into two? <aqumsieh@matrox.com>
        Installing with CPAN.pm (Bill Moseley)
    Re: Interesting behavior of IO::Handle - bug? <brundlefly76@hotmail.com>
    Re: Interesting behavior of IO::Handle - bug? (Kragen Sitaker)
        LWP questions and SSL, too (Bill Moseley)
    Re: Pass by reference <tchrist@mox.perl.com>
    Re: Pass by reference <ltl@rgsun5.viasystems.com>
    Re: Perl - CGI -MySQL <neil@pacifier.com>
        Round off an array? <hanz@chello.nl>
    Re: Round off an array? (Larry Rosler)
    Re: Strict? <gellyfish@gellyfish.com>
    Re: Strict? <rasmusr@online.no>
    Re: Strict? <camerond@mail.uca.edu>
    Re: Substitution fails intermittently (Kragen Sitaker)
        Wanted: help with dev of VRML Browser in Perl. <john.stewart@crc.ca>
        Win32::NetAdmin GroupIsMember voodoo magic? <david.lindsay@columbian.com>
        Win32::ODBC - problems accessing database on network <micklemj@serviceteam.ltd.uk>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 24 Sep 1999 14:32:38 GMT
From: eric@fruitcom.com (Eric Smith)
Subject: A better way to exclude a phrase in a PATTERN?
Message-Id: <slrn7un2s6.72r.eric@plum.fruitcom.com>

I often need refer to a phrase that must not occur in a certain
context for a match to be true and when I refer to the Camel Book on (my)
page 68, I am told:
/foo(?!bar)/ matches any occurance of "foo" that isn't followed by "bar"
However the options given to find something as long as it is not _preceeded_
by a phrase are cumbersome:
/(?:(?!foo)...|^..?)bar/

Now I had trouble transcribing that, let alone remembering it.
The other option given is:
if (/bar/ and $` !~ /foo$/) 
is much better but will still be clumsy ina
complex regex where "bar" may not be at the start of the match - then I have
to resort to using parens and the $+ operator.  

Is there an easier way, perhaps?

-- 
Eric Smith
eric@fruitcom.com
www.fruitcom.com

If I had 20 fingers, I could program at twice the speed.


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

Date: Fri, 24 Sep 1999 14:50:57 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: A better way to exclude a phrase in a PATTERN?
Message-Id: <ldMG3.28332$I6.482002@typ12.nn.bcandid.com>

In article <slrn7un2s6.72r.eric@plum.fruitcom.com>,
Eric Smith <eric@fruitcom.com> wrote:
>Is there an easier way, perhaps?

You want lookbehind.  It has been added to recent perls, with the
hideous syntax of (?<=pattern).  HTH.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 24 Sep 1999 08:03:53 -0600
From: "K C Owens" <owensk@cadvision.com>
Subject: Re: Adding commas to long numbers.
Message-Id: <37eb8504@news.cadvision.com>

This is from page 64 of the Perl Cookbook by Tom Christiansen and Nathan
Torkington.  It is a very useful book.

sub commify {
  my $text = reverse $_[0];
  $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
  return scalar reverse $text;
}

mirak63@yahoo.com wrote in message <37ea7ee9.82764281@news.vnet.net>...
>Can anyone tell me a way to add the commas to long numbers?
>Example:      123456789   to 123,456,789.
>
>I could probably write a sub that could do this for me but it would be
>nice if perl had a quick way of doing it.
>
>Thanks,
>Karim Wall




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

Date: Fri, 24 Sep 1999 11:26:33 -0400
From: Robert Campbell <choco@duke.edu>
Subject: Re: Arrays?!?
Message-Id: <Pine.SOL.3.91.990924112417.15391A-100000@godzilla6.acpub.duke.edu>

I am having problems with part 1.  How do i get the first field of the 
 ... nevermind.  I was going to say "How do i get the first field of the 
next to last record but the last record is put in there by the program so 
i can get the next to last record which is the last record until i print, 
as long as i get it b4 i print the last record to the file.  But if i 
wanted to get the last to next record.  How would i do that?

On Wed, 22 Sep 1999, Kragen Sitaker wrote:

> Date: Wed, 22 SEP 1999 19:43:32 GMT 
> From: Kragen Sitaker <kragen@dnaco.net>
> Newgroups: comp.lang.perl.misc
> Subject: Re: Arrays?!? 
> 
> In article <Pine.LNX.4.10.9909221233090.7611-100000@fnord.io.com>,
> Poohba  <poohba@io.com> wrote:
> >I have a data file.  The first field has a number in it.  When I run my
> >program it creates another record.  I want to subtract the next to last
> >record first field from the last record first field.  How do I do that?
> 
> Well, in three steps.
> 1. Get the last field of the next-to-last record and store it in a variable
>   $foo.
> 2. Get the last field of the last record and store it in a variable $bar.
> 3. Subtract $foo from $bar like so: $bar - $foo.
> 4. Do something with the result.
> 
> Which steps are you having trouble with?
> 
> -- 
> <kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
> Wed Sep 22 1999
> 47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
> <URL:http://www.pobox.com/~kragen/bubble.html>
> 
> 

  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

			_/_/_/		     _/     _/
		       _/  _/	            _/     _/		
  Web Page Designs    _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/_/_/ choco@duke.edu 
    Small Programs   _/     _/   / _/  _/ _/  _/ _/  _/ _/  _/  poohba@io.com
www.io.com/~poohba  _/	   _/_/_/ _/_/_/ _/  _/ _/_/_/ _/_/\_ 	(919)506-5883

  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/



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

Date: Fri, 24 Sep 1999 13:26:25 GMT
From: lenny_jolin@my-deja.com
Subject: automated submission to a perl script
Message-Id: <7sfu5j$1gs$1@nnrp1.deja.com>

I was wondering if anyone has the script for an automated form
submission? I found one in the perl cookbook but forgot the book this
morning. If anyone has that book near a keyboard could you please post
that script?

thanks
-lj


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 24 Sep 1999 15:07:25 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: beauty of a Y2K bug
Message-Id: <NsMG3.28380$I6.486852@typ12.nn.bcandid.com>

In article <slrn7umb1t.nou.sholden@pgrad.cs.usyd.edu.au>,
Sam Holden <sholden@cs.usyd.edu.au> wrote:
>On Fri, 24 Sep 1999 05:53:07 GMT, Kragen Sitaker <kragen@dnaco.net> wrote:
>>But what does tm_year being (year -1900) buy you?  You can fit it into
>>a byte instead of two bytes?  It certainly doesn't make your program
>>any faster or simpler, and it doesn't make the library any faster or
>>simpler either.  All it does is cause bugs.
>
>It shows you who are the idiots that don't read the specs and thus
>should not be employed.

Someone claimed that Larry had a "19$year" bug in an earlier edition of
the Camel.  (Can anyone confirm or deny?)

It is true that putting people in mistake-prone environments is more
likely to show you who is more careful.  But it also tends to make
everyone either (a) make more mistakes or (b) work slower.  Usually
(b).
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 24 Sep 1999 15:24:02 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: CGI sending email with attachment
Message-Id: <mIMG3.28419$I6.491020@typ12.nn.bcandid.com>

In article <hftG3.65$RA1.2811@client>,
Burt Hwang <BurtHwangSPAMSUCKS@SPAMSUCKS.ufsltd.com> wrote:
>>I suggest that he read RFC 1521 if he's going to be writing his own
>>MIME messages instead of using MIME::Lite.
>
>1.  Where can I read up on RFC 1521?

http://info.internet.isi.edu/in-notes/rfc/files/rfc1521.txt

Except now it's obsoleted by RFCs 2045 through 2049.

>2.  If I were to use MIME::Lite, how?  The web server is not really mine.
>It really belongs to "host-express".  I'm their customer and my site
>registered with them.  Can I install then use MIME::Lite even if it is not
>really my server?  Should I find out whether they already support it?  Or am
>I totally off here?

You should find out whether they already support it, but yes, you can
install it yourself.  See perlfaq8, "How do I keep my own
module/library directory?"

-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 24 Sep 1999 15:26:58 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: CGI sending email with attachment
Message-Id: <6LMG3.28426$I6.491440@typ12.nn.bcandid.com>

In article <FIK5xK.L3@csc.liv.ac.uk>, I.J. Garlick <ijg@connect.org.uk> wrote:
>In article <vvsG3.6202$QJ.362386@typ11.nn.bcandid.com>,
>kragen@dnaco.net (Kragen Sitaker) writes:
>> Actually, Burt Hwang is correct.  From RFC 1521:
>>    The Content-Type field for multipart entities requires one parameter,
>>    "boundary", which is used to specify the encapsulation boundary.  The
>>    encapsulation boundary is defined as a line consisting entirely of
>>    two hyphen characters ("-", decimal code 45) followed by the boundary
>>    parameter value from the Content-Type header field.
>
>I though the preceeding blank line was necessary as well. ie like Burt did
>"\n--whatever"

Well, it needs to be a line by itself, not part of a line.  So you need
to have a newline before it (or have it be at the beginning of the
file, which is not an option in this case).

(Shouldn't we be using \r\n?)

>Whoever he did get something wrong.
>
>	print MAIL "\n--gc0y0pkb9ex\n";
>	close MAIL;
>
>that last line should be
>
>	print MAIL "\n--gc0y0pkb9ex--\n";
>
>according to everything I have read.

Evidently my post, and the RFC I quoted, are not among "everything you
have read".  Either that, or you think the RFC is mistaken, or I have
quoted it incorrectly.

I assure you none of the above is true.

-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 24 Sep 1999 15:17:33 GMT
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: combination
Message-Id: <hCMG3.18466$m4.74940509@news.magma.ca>

<sn0brdr@yahoo.com> wrote in: news:7sdr1n$ibn$1@nnrp1.deja.com
>
> i'm trying to get the most possible combination of elements from 3
> arrays (not equal in size).
>
> @one = qw(blue green yellow)
> @two = qw(john nancy)
> @three = qw(north south east west)
>
> no repeat and order matters.
>
> i am open for any (intellectual) suggestion if there is another away
> of doing this.
>
A little "intellectual" challenge for you (derived from one of Abigail's
jewels):

my @out = ("");
foreach ([@three], [@two], [@one]) {
  @out = map {my $new = $_; map {length () ? "$new, $_" : $new} @out}
@$_;
}
$" = "\n"; print "@out\n";







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

Date: Fri, 24 Sep 1999 10:40:15 -0400
From: "George Willman" <george.willman@2asc.com>
Subject: Re: decomposing an outline-style text body (ugly regexp question)
Message-Id: <7sg2gh$or5$1@winter.news.rcn.net>

Indeed, thanks to you both.  $/ was previously redefined, since there is a
tremendous amount of other info in the files I am parsing.  The entire
Events block was (luckily!) conveniently blocked off by "//...//" so that's
why $/="" doesn't work (at least not in this instance).  The look ahead
matching hits the spot with just a minor bit of tweaking the last record (I
used a little $' mojo).

That being said... is what I'm doing even a good idea since I have to go and
now decompose each of the Event sub headings?  The primary database table
will be stuffed with the event title, paragraph number and sub paragraph
letter of an item and then the contents of that item.  So an example record
would be [Foundation of Rome,1,A,*contents of A*] and so forth.

I'm not so much worried about any penalties for invoking the regexp engine,
etc since after an initial onslaught this script will be run one a day on a
meg or so of data at most - I just want to structure the decomposition in
such a way that it, you know, I don't wind up hating myself later. :)

Again, thanks - I appreciate it.

-GW




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

Date: Fri, 24 Sep 1999 15:03:33 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: decomposing an outline-style text body (ugly regexp question)
Message-Id: <9pMG3.28371$I6.474036@typ12.nn.bcandid.com>

In article <7sdrht$ahh$1@winter.news.rcn.net>,
George Willman <george.willman@2asc.com> wrote:
>    What I -think- I would want to do is decompose the large text bodies by
>reading them in (trivial), then stuff @paragraph with a repeating set of 3
>items from each main heading number, the heading title and finally
>everything else (subheadings, et al).

Do you mean @paragraph is something like
	($headingnumber1, $headingtitle1, $everythingelse1,
	 $headingnumber2, $headingtitle2, $everythingelse2,
	. . . )?

><START OF $_>
>1. Event: Foundation of Rome\n
>    A. blah blah....\n
>blah Romulus.\n
>    B. yet more blah... Remulus\n
>blah Wolf blah blah Rivers.\n
>2. Event: Foundation of 3 River's Stadium\n
>    A. blah blah...Hoffa...blah\n
>blah blah concrete.\n
>    B. blah... dirt nap.\n
>    C. you get the picture...\n
><END OF $_>
>
>Ideally (well maybe not, suggestions are certainly welcome on any fronts),
>
>@paragraph=(1,Foundation of Rome,A. blah *everything up to*
>Rivers.,2,Foundation of 3 River's Stadium,A. blah *everything up to* nap.)

Maybe something like this:

#!/usr/bin/perl -w
use strict;
my $state = 'initial';
my $header_regex = '^(\d+)\.\s+Event: (.*)';
my @paragraph;
my $paragraph;

while (<>) {
	if (m/$header_regex/) {
		if ($state eq 'in paragraph') {
			push @paragraph, $paragraph;
		}
		push @paragraph, $1, $2;
		$paragraph = '';
		$state = 'in paragraph';
	} else {
		if ($state eq 'initial') {
			die "First line didn't match $header_regex: $_";
		}
		$paragraph .= $_;
	}
}

if ($state eq 'in paragraph') {
	push @paragraph, $paragraph;
}

print join "\n--\n", @paragraph;
print "\n";

It does work on your given test input.

HTH.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 24 Sep 1999 11:03:36 -0400
From: "George Willman" <george.willman@2asc.com>
Subject: Re: decomposing an outline-style text body (ugly regexp question)
Message-Id: <7sg3sb$2eo$1@winter.news.rcn.net>

Argh, stupid news client.  file://...// should read just //<stuff// (no
"file;:").

I hate AUTO substitution I didn't ask for.  The default should be off.

-GW

George Willman wrote in message <7sg2gh$or5$1@winter.news.rcn.net>...
>Events block was (luckily!) conveniently blocked off by "file://...//" so
that's





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

Date: Fri, 24 Sep 1999 14:27:12 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Fork / Pipe Problem
Message-Id: <4TLG3.28282$I6.474722@typ12.nn.bcandid.com>

In article <37E7A0E2.94719EBF@gmt.nl>, Frank Husmann  <fhusmann@gmt.nl> wrote:
>Ok, so now I do it like this but still how can I stop reading from the
>childs? This won't work:

>while ($line = <CHILD>) {
>	# Read from the children but it never stops
>	print "Parent Pid $$ just read this: '$line'\n";
>}

It never stops because PARENT is still open.  Close PARENT in the
parent after you spawn all the children, and you'll get an end-of-file
when you read the last child output.

By the way, if the child output is more than a K or so (usually 5K), or
if it's written in more than one write command, output from the
children may be interleaved.  You can avoid this by using a separate
socketpair per child.

Sorry to take so long to respond :)
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 24 Sep 1999 15:19:53 GMT
From: Jeff S. <jeff@jhmi.edu>
Subject: Re: Help with compiling a list
Message-Id: <7sg4q8$734$1@nnrp1.deja.com>

Thanks a lot! This was exactly the information I needed, and after trial
and error and learning more about refs and hashes, my script works
exactly as I intended.
  thanks again.

In article <37DE767A.8A077861@mccarthy.org>,
  Jamie McCarthy <jamie@mccarthy.org> wrote:
<snip! - long, informative reply. See earlier posts...>
--
 | |\  /\ ---------------------------------------*
 | | | \      Jeffrey D. Silverman * jeff@jhmi.edu
\/ |/  \/ Johns Hopkins University * Baltimore, MD


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 24 Sep 1999 14:47:35 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: How can I "undo" a require ?
Message-Id: <baMG3.28328$I6.479461@typ12.nn.bcandid.com>

In article <37EB514F.E955A760@sophos.com>,
Csaba Raduly  <csaba.raduly@sophos.com> wrote:
>Lack Mr G M wrote:
>> undef %INC{$expfile};
>
>Can't use subscript on hash deref at ... near "$expfile}"
>(Did you mean $ or @ instead of % ?)

He does, of course, mean $ instead of %.  He doesn't know it, but he
means delete, not undef.

>>  which will tell perl to forget that you have read it already, and so to
>> read it again on the next require. 
>
>Not even  undef $INC{$expfile};   works this way :-(
>$INC{$expfile} is undefined before the require but the hash doesn't
>rise from its ashes.

Right -- $INC{$expfile} still exists.  You have to delete it.

I have a file 'requireme.pl':

print "I am Risen!\n";
1;

and another file 'testrequire':

#!/usr/bin/perl -w
use strict;
require 'requireme.pl';
print "did #1;\n";
require 'requireme.pl';
print "did #2;\n";
my @files = keys %INC;
print "keys %INC is @files\n";
undef $INC{'requireme.pl'};
require 'requireme.pl';
print "did #3;\n";
delete $INC{'requireme.pl'};
require 'requireme.pl';
print "did #4.\n";

Only the first and last requires actually work:
I am Risen!
did #1;
did #2;
keys %INC is requireme.pl strict.pm
did #3;
I am Risen!
did #4.

This is contrary to the documentation in perldoc -f require, which
would lead one to believe that 'undef' should work.

HTH.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 24 Sep 1999 08:27:05 -0500
From: Jerry Preston <g-preston1@ti.com>
Subject: Re: How to RLOGIN - try again
Message-Id: <37EB7C29.49297B7C@ti.com>

I want to copy/read a file on the remote server.  What are backticks and
Net::Telnet?

Thanks,

Jerry

Martien Verbruggen wrote:

> In article <37EAAE34.9C37C1ED@ti.com>,
>         Jerry Preston <g-preston1@ti.com> writes:
> > From within my Perl program,  I need to 'rlogin' to another server on  my
> > network with
> > password and user id.  Can you use system?
>
> Maybe.
>
> system('rlogin', @args);
>
> will work, but maybe it doesn't do what you want. Maybe you need
> backticks. I don't know. I don't know what you want to do, except
> rlogin.
>
> How are you going to interact with the rlogin?
>
> Maybe you really want Net::Telnet
>
> hard to tell.
>
> Martien
> --
> Martien Verbruggen                  |
> Interactive Media Division          | Never hire a poor lawyer. Never buy
> Commercial Dynamics Pty. Ltd.       | from a rich salesperson.
> NSW, Australia                      |



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

Date: Fri, 24 Sep 1999 14:33:26 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: How to RLOGIN - try again
Message-Id: <WYLG3.28296$I6.476906@typ12.nn.bcandid.com>

In article <37EB7C29.49297B7C@ti.com>,
Jerry Preston  <g-preston1@ti.com> wrote:
>I want to copy/read a file on the remote server.  What are backticks and
>Net::Telnet?

Backticks let you capture the output of a command, like `ls`.  You
could read the file with something like `rsh othermachine cat
/var/local/bin/trash` or `echo cat /var/local/bin/trash; exit | rlogin
othermachine`.  (The second is untested, as I don't have any machines
for which .rhosts is set up.)

Net::Telnet is a module that helps you establish telnet sessions from Perl.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: 24 Sep 1999 16:10:06 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to RLOGIN - try again
Message-Id: <37eb944e_1@newsread3.dircon.co.uk>

Jerry Preston <g-preston1@ti.com> wrote:
> Martien Verbruggen wrote:
> 
>> In article <37EAAE34.9C37C1ED@ti.com>,
>>         Jerry Preston <g-preston1@ti.com> writes:
>> > From within my Perl program,  I need to 'rlogin' to another server on  my
>> > network with
>> > password and user id.  Can you use system?
>>
>> Maybe.
>>
>> system('rlogin', @args);
>>
>> will work, but maybe it doesn't do what you want. Maybe you need
>> backticks. I don't know. I don't know what you want to do, except
>> rlogin.
>>
>> How are you going to interact with the rlogin?
>>
>> Maybe you really want Net::Telnet
>>

> I want to copy/read a file on the remote server.  What are backticks and
> Net::Telnet?
> 

The backticks are described in the perlop manpage (aka qx{}) in the section
entitled :

       Quote and Quote-like Operators

They allow you to run a command and capture the output.

Net::Telnet is a module available from CPAN <www.cpan.org> that gives you
telnet functionality in Perl.

I gather that you are not very familiar with Perl.  I would recommend that
you read some of the documentation that is supplied to get started.

Type:

perldoc perl

at some command prompt on your system.

/J\
-- 
"What is the future for beef? Curtains?" - Graham Norton


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

Date: Fri, 24 Sep 1999 10:53:02 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: How to split one variable into two?
Message-Id: <x3yk8pgwecx.fsf@tigre.matrox.com>


tyarkoni@chat.carleton.ca (Tal Yarkoni) writes:

>                                                 so let's say $x happens to
> be "test"... how can I create two variables, $test1 and
> $test2? 

What you are trying to do is called symbolic referencing. I would
avoid this if I were you since it can get very confusing very easily.
What you really need to use is a slightly more complicated data
structure: a hash of arrays (see perldsc for more info on Perl's way
of creating complex data structures).

So, for every variable $x, you would do something like:

	$hash{$x}[0] = 'a';
	$hash{$x}[1] = 'b';

The above says that you have a hash (%hash), with key $x. The value
associated with the key $x is an array reference. The first element of
this array is set to 'a', the second to 'b'.

So, effectively, instead of you saying $test1, you would say
$hash{test}[1].

HTH,
--Ala



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

Date: Fri, 24 Sep 1999 06:40:42 -0700
From: moseley@best.com (Bill Moseley)
Subject: Installing with CPAN.pm
Message-Id: <MPG.12551f324a75c7a998977c@nntp1.ba.best.com>

I'm using CPAN.pm, and I have my CPAN config file set to install 
locally.  The config file has not changed in a while.  I reinstalled 
libnet, and it installed in a different location:

I was trying to install Net::SSL (as described in another post).

I first did a install Bundle::Libnet, just in case Net::SSL was part of 
that (it was just a guess, as Perl was reporting it couldn't find 
Net::SSL).  I'm installing into a local library ~/perl_lib/.  I had done 
this just a few weeks ago (Sept 9), but this time it installed all the 
Net files into a different directory.  And now I'm trying to understand 
why....

For example, from the 'install Bundle::libnet' just now, here's a few 
cut lines:

Installing /home/moseley/perl_lib/lib/site_perl/5.005/Net/Cmd.pm

## Differing version of Net/Cmd.pm found. You might like to
rm /home/moseley/perl_lib/lib/site_perl/5.005/sun4-solaris/Net/Cmd.pm

Same CPAN config file was used to install both.  I wonder why this time 
it was installed in different locations?  One thing I DID change since 
Sept 9, was I adjusted my PERLLIB environment variable.


Thanks,



-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: Fri, 24 Sep 1999 13:29:24 GMT
From: Brundle <brundlefly76@hotmail.com>
Subject: Re: Interesting behavior of IO::Handle - bug?
Message-Id: <7sfub6$1pn$1@nnrp1.deja.com>

In article <x7ln9z5x8t.fsf@home.sysarch.com>,
  Uri Guttman <uri@sysarch.com> wrote:
> >>>>> "KS" == Kragen Sitaker <kragen@dnaco.net> writes:
>
>   KS> In article <7s984c$86e$1@nnrp1.deja.com>,
>   KS> Brundle  <brundlefly76@hotmail.com> wrote:
>   >> But if I simply assign the value of the array index to another
scalar,
>   >> it works as expected:
>   >>
>   >> $currentpipe=$PIPES[$CURRENTPIPE];
>   >> print $currentpipe $stuff;
>
>   KS> I saw something about it the other day -- either in Tom's
FMTYEWTK
>   KS> about filehandles or in the FAQ.  You should be able to say
print
>   KS> {$PIPES[$CURRENTPIPE]} $stuff.  I didn't understand why.
Filehandles
>   KS> are brain-damaged.
>
> if you are going to be the top poster here, at least learn to research
> basic things yourself. the filehandle object after print and printf
must
> be a real filehandle or a single scalar variable with a file handle
> value

In the both examples $PIPES[$CURRENTPIPE] *IS* a single scalar variable
with a filehandle value.




Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 24 Sep 1999 14:34:50 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Interesting behavior of IO::Handle - bug?
Message-Id: <e_LG3.28297$I6.478103@typ12.nn.bcandid.com>

In article <7sfub6$1pn$1@nnrp1.deja.com>,
Brundle  <brundlefly76@hotmail.com> wrote:
>In article <x7ln9z5x8t.fsf@home.sysarch.com>,
>  Uri Guttman <uri@sysarch.com> wrote:
>> if you are going to be the top poster here, at least learn to research
>> basic things yourself. the filehandle object after print and printf
>must
>> be a real filehandle or a single scalar variable with a file handle
>> value
>
>In the both examples $PIPES[$CURRENTPIPE] *IS* a single scalar variable
>with a filehandle value.

No, it's an array element.  A scalar variable is something like $asdf.

-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 24 Sep 1999 06:41:04 -0700
From: moseley@best.com (Bill Moseley)
Subject: LWP questions and SSL, too
Message-Id: <MPG.12551f46aa5ea49a98977d@nntp1.ba.best.com>

Howdy,

I have two LWP questions asked here, with additional details included 
below (please remove the extra details before responding).


1) I'm using LWP::UserAgent, which returns on https:// requests:

501 Can't locate object method "new" via package "LWP::Protocol::https"

What do I need to do to get https requests to work with LWP::UserAgent?
(see below for what I tried to install).


2) On LWP request to http://www.hawaii.net/ I get a 302 "moved" response 
with the Location header set as '/cgi-bin/hhp?'

In LWP::UserAgent it says:

  # And then we update the URL based on the Location:-header.
  my $referral_uri = $response->header('Location');
  {
      # Some servers erroneously return a relative URL for redirects,
      # so make it absolute if it not already is.

So I thought the Location would be converted into an absolute URL.  Do I 
need to set something in LWP to make it convert '/cgi-bin/hhp?' to an 
absolute URL?




My attempts at installing SSL support
-------------------------------------

I just tried to Install Net::SSL using CPAN.pm, but that failed with

In file included from SSLeay.xs:21:
crypt_ssleay_version.h:1: ssl.h: No such file or directory
crypt_ssleay_version.h:2: crypto.h: No such file or directory
*** Error code 1
make: Fatal error: Command failed for target `SSLeay.o'

So I then tried install Net::SSLeay and got:

I could not find your OpenSSL in `PREFIX=/home/cleita/perl_lib'
Please provide OpenSSL-0.9.3a installation directory (get from
 http://www.openssl.org/ if you don't have it; please note that
 SSLeay is no longer supported, see README)

And the readme didn't clear up my confusion.

Thanks,



-- 
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.


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

Date: 24 Sep 1999 09:22:06 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Pass by reference
Message-Id: <37eb971e@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    hudson@swcp.com (Tramm Hudson) writes:
:use strict;
:use Benchmark;
:
:my $count = shift || 1<<20;
:timethese( $count, {
:        Globs   => sub { no strict;  my $i=10 ; *j=\$i   ; $j++; },
:        Refs    => sub { use strict; my $i=10 ; my $r=\$i; $$r++; },
:});
:__END__
:
:/tmp$ ./timet
:Benchmark: timing 1048576 iterations of Globs, Refs...
:     Globs: 11 wallclock secs (11.60 usr +  0.00 sys = 11.60 CPU)
:      Refs:  9 wallclock secs ( 9.90 usr +  0.01 sys =  9.91 CPU)
:
:Oh dear.  It looks like I need to submit a bug report to O'Reilly
:for the next printing of _Advanced Perl Programming_.  The globs are
:actually slower in this case by a 20% margin.  

Nope, your benchmark is flawed.

    use Benchmark;
    $i = 10;
    *ia = $ir = \$i;
    my $count = shift || 1<<20;
    timethese $count => {
	    Globs   => sub { $ia++; },
	    Refs    => sub { $$ir++; },
    };            

Reveals:

    Benchmark: timing 1048576 iterations of Globs, Refs...
	 Globs:  2 wallclock secs ( 2.87 usr +  0.00 sys =  2.87 CPU)
	  Refs:  3 wallclock secs ( 3.28 usr +  0.00 sys =  3.28 CPU)

--tom
-- 
"Usenet is like a herd of performing elephants with diarrhea --
massive, difficult to redirect, awe-inspiring, entertaining, and a
source of mind-boggling amounts of excrement when you least expect
it." --gene spafford, 1992


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

Date: 24 Sep 1999 15:19:21 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: Pass by reference
Message-Id: <7sg4pp$nqp$1@rguxd.viasystems.com>

Tramm Hudson <hudson@swcp.com> wrote:
:>Here's a quick quote from page 44, on 'Using Typeglob Aliases':

:>	Efficient Parameter Passing

:>	Aliases happen to be quite a bit faster than references, because
:>	they don't need to do any dereferencing.  Consider:

I was bitten by that same delusion for a while last year and sprinkled
those typeglobs everywhere.  Unfortunately, I propogated the practice
to some coworkers who found them easier to understand and manage than
the -> dereferencing.  Now I can't get them to stop.

Since I found most of what Siriam wrote enlightening, I want to
assume that the typeglobs *were* faster than the dereferencing at one
time.  


-- 
// Lee.Lindley   /// 
// @bigfoot.com  ///   Go Hokies!
////////////////////


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

Date: 24 Sep 1999 06:49:47 PST
From: Neil <neil@pacifier.com>
Subject: Re: Perl - CGI -MySQL
Message-Id: <37eb817b.0@news.pacifier.com>


> Where is the MySQL newsgroup? I searched deja.com before I posted here,
> but could not find such a newsgroup.

There is an incredibly helpful Mysql mailing list that you might consider.
Send a message to mysql-subscribe@lists.mysql.com and join the list. There
your question will not be off topic.

Neil


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

Date: Fri, 24 Sep 1999 14:57:08 GMT
From: "HPK" <hanz@chello.nl>
Subject: Round off an array?
Message-Id: <8jMG3.1$86.208@amsnews02.chello.com>


Hi !

Can someone tell me how I can round off an array ($)  to two numbers after
the comma?

Thanks in advance,
HPK




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

Date: Fri, 24 Sep 1999 08:50:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Round off an array?
Message-Id: <MPG.12553d90635d7c46989fd4@nntp.hpl.hp.com>

In article <8jMG3.1$86.208@amsnews02.chello.com> on Fri, 24 Sep 1999 
14:57:08 GMT, HPK <hanz@chello.nl> says...
> Can someone tell me how I can round off an array ($)  to two numbers after
> the comma?

I'll take a guess that this means, "How can I round off each element in 
an array of scalars to two decimal places?" where 'comma' is the locale-
derived value of the decimal-fraction indicator.

You might read the first entry in perlfaq4: "Why am I getting long 
decimals (eg, 19.9499999999999) instead of the numbers I should be 
getting (eg, 19.95)?"

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 24 Sep 1999 14:30:24 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Strict?
Message-Id: <37eb7cf0_2@newsread3.dircon.co.uk>

amerar@ci.chi.il.us wrote:
> 
> 
> Hello,
> 
> I have the following program:
> 
> #!/usr/local/bin/perl
> use strict;
> 
> my $yesterday = time - 24 * 60 * 60;
> print +(localtime $yesterday)[6], "\n";
> print substr(localtime $yesterday, 0, 3), "\n";
> 
> I am really not sure what this 'use strict' does.  But this program
> calculates the previous weekday.  I want to assign that value to a
> variable within the program.........
> 
> When I try this:
> 
> #!/usr/local/bin/perl
> use strict;
> 
> my $yesterday = time - 24 * 60 * 60;
> print +(localtime $yesterday)[6], "\n";
> $tmp = +(localtime $yesterday)[6];
> print "HI:  $tmp\n";
> print substr(localtime $yesterday, 0, 3), "\n";
> 
> I get this error:
> 
> Global symbol "tmp" requires explicit package name at ./test line 8.
> Execution of ./test aborted due to compilation errors.
> 

From perldoc perldiaq:

Global symbol "%s" requires explicit package name
           (F) You've said "use strict vars", which indicates
           that all variables must either be lexically scoped
           (using "my"), or explicitly qualified to say which
           package the global variable is in (using "::").


From perldoc strict:

       strict vars
             This generates a compile-time error if you access a
             variable that wasn't localized via my() or wasn't
             fully qualified.  Because this is to avoid variable
             suicide problems and subtle dynamic scoping issues,
             a merely local() variable isn't good enough.  See
             the my entry in the perlfunc manpage and the local
             entry in the perlfunc manpage.

                 use strict 'vars';
                 $X::foo = 1;         # ok, fully qualified
                 my $foo = 10;        # ok, my() var
                 local $foo = 9;      # blows up

             The local() generated a compile-time error because
             you just touched a global name without fully
             qualifying it.


(plain use strict implies 'strict vars').

So where do you have to put another 'my' ?

/J\
-- 
"It's easier for a man to enter a camel is he stands on a box" -
Jonathan Creek


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

Date: Fri, 24 Sep 1999 15:38:49 +0100
From: "Rasmus Rimestad" <rasmusr@online.no>
Subject: Re: Strict?
Message-Id: <GhLG3.708$pn4.4437@news1.online.no>

When you are using strict, you will have to declare all variables using my
or local. This is very useful for debugging and so on. Your problem is you
have not declared the variable $tmp. A my $tmp line will fix it.

Yours sincerely
   Rasmus Rimestad




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

Date: Fri, 24 Sep 1999 09:05:50 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
To: amerar@ci.chi.il.us
Subject: Re: Strict?
Message-Id: <37EB853E.86FD3DD4@mail.uca.edu>

[cc'd to a]

amerar@ci.chi.il.us wrote:
> 
> Hello,
> 
> I have the following program:
> 
> #!/usr/local/bin/perl
> use strict;
> 
> [snip]
> I am really not sure what this 'use strict' does.  But this program
> calculates the previous weekday.  I want to assign that value to a
> variable within the program.........

perldoc -X strict

Cameron

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu


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

Date: Fri, 24 Sep 1999 15:18:22 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Substitution fails intermittently
Message-Id: <2DMG3.28412$I6.488931@typ12.nn.bcandid.com>

In article <7sdg74$9op$1@nnrp1.deja.com>,  <drew3966@my-deja.com> wrote:
>I have a script which makes substitutions to HTML files using a regular
>expression. I am running Windows NT (SP5). There are 118 input files.
>For 70, the substitution works. For the other 38, there is no
>substitution. It is file related. The files are all ASCII and all
>read/write. I have tried with and without binmode and with and without
>/s of /gis.

I am mystified.  What does 'no substitution' mean?  The output file is
exactly identical to the input file?  If your files are bigger than
$HTML_MAX, you could reasonably end up with truncated output files.

>Open/read the file:
>   open(HTMLFILE,"<$Dir"."$File") || ErrorOpen("$Dir"."$File", $!);
>   $Bytes = 0;
>   $Bytes = read(HTMLFILE, $Buffer, $HTML_MAX) ||
>LogError("$Dir"."$File", $!);

You could reasonably do this with do {local $/; <HTMLFILE>}.  Or just
undef $/ globally if you like.  That wouldn't give you HTML_MAX limit,
of course.  But unless that's your problem, that wouldn't fix it.

>     $Bytes = length $Buffer;
>     $Bytes = syswrite(HTMLFILE, $Buffer, $Bytes) || ErrorOpen($Dir .
>$File, $!);

You could say "print HTMLFILE ($buffer) or ErrorOpen(...);".  (Nothing
to do with your problem, of course.)

Totally bizarre problem.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 23 1999
46 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 24 Sep 1999 10:13:47 -0500
From: John Stewart <john.stewart@crc.ca>
Subject: Wanted: help with dev of VRML Browser in Perl.
Message-Id: <37EB952B.2006D68E@crc.ca>

Hi guys/gals;

I maintain a VRML browser that runs on Unix platforms (mainly
Linux!) that is written mostly in perl. It is open source.

It needs work to make it conform to standards, and to make
it install easily.

I have some help, but, I could do with more. It is not
really part of my work - I use the browser for shared
virtual world work.

If anyone with perl experience is looking for a challenge
and to get their name up there in lights, go have a peek
at:

http://www.crc.ca/FreeWRL/

Thanks!

John Stewart
john.stewart@crc.ca


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

Date: Fri, 24 Sep 1999 09:05:08 -0700
From: David Lindsay <david.lindsay@columbian.com>
Subject: Win32::NetAdmin GroupIsMember voodoo magic?
Message-Id: <37EBA133.67E739AF@columbian.com>

I'm using the following code to check to see if a particular user is a
member of a specified group. I can get this to work when I use
LocalGroupIsMember on my local box, but when I try to use GroupIsMember
and specify a DOMAIN, I get no result back in the $im variable. Is there
any special voodoo magic that I'm missing?

# ismember.pl

 use Win32::NetAdmin qw(GetUsers GroupIsMember LocalGroupIsMember
                           UserGetAttributes UserSetAttributes);
 $domainname = shift;
 $username = shift;
 $groupname = shift;


        $im = GroupIsMember($domainname, $groupname, $username);
         if ($im == 1)
          { exit (1);}
   else
          { exit (0);}



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

Date: Fri, 24 Sep 1999 14:25:37 +0100
From: "JGM" <micklemj@serviceteam.ltd.uk>
Subject: Win32::ODBC - problems accessing database on network
Message-Id: <4ZKG3.3575$cm.84500@wards>

Hi,

I'm having trouble accessing a database on a network drive using Win32::ODBC
and perl for isapi:

- the query does work under two conditions
    1) when run from the command prompt
    2) if the database sits locally as opposed to on a mapped network
         drive.

I've read the win32::ODBC faq and I think I've covered everything:
    - the DSN is a system DSN
    - the anonymous internet user has sufficient rights to the drive
       containing the database
    - the database is not exclusive

Any ideas?




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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 899
*************************************


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