[15573] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2986 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 9 00:10:32 2000

Date: Mon, 8 May 2000 21:10:19 -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: <957845419-v9-i2986@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 8 May 2000     Volume: 9 Number: 2986

Today's topics:
    Re: How can I run auto-download file in browser ? <gellyfish@gellyfish.com>
    Re: how to delete all variables in Z::? <gellyfish@gellyfish.com>
    Re: HTTP::Request=HASH(0x7bb141c) ? <makarand_kulkarni@My-Deja.com>
    Re: HTTP::Request=HASH(0x7bb141c) ? <nospam@devnull.com>
    Re: HTTP::Request=HASH(0x7bb141c) ? <tony_curtis32@yahoo.com>
    Re: Mail::Mailer not setting from? (David Efflandt)
    Re: Mail::Mailer not setting from? <rootbeer@redcat.com>
    Re: making a package (NOT a module) (Bart Lateur)
    Re: Making my script not case-sensitive! <andy@u2me3.com>
    Re: mixing module versions with mod perl and apache <gellyfish@gellyfish.com>
    Re: Need help on displaying REMOTE_HOST (David Efflandt)
    Re: Need LWP module, but it's not installed on my serve <kerry@shetline.com>
    Re: Need LWP module, but it's not installed on my serve <jeff@vpservices.com>
    Re: nt, perl, and smtp mail <jamalone@earthlink.net>
    Re: Output PERL to excel <gellyfish@gellyfish.com>
    Re: Parallel port <gellyfish@gellyfish.com>
    Re: Perl code to check for broken links <rootbeer@redcat.com>
    Re: perl-corba documentation.. <gellyfish@gellyfish.com>
    Re: perlcc[more info] <gellyfish@gellyfish.com>
    Re: Please help cannot display REMOTE_HOST variable (Bart Lateur)
    Re: problem with "system" and file copy <gellyfish@gellyfish.com>
    Re: Proper use of resources (was Re: more regexp madnes (Bart Lateur)
    Re: Proper use of resources (was Re: more regexp madnes <uri@sysarch.com>
    Re: Question on references... <gellyfish@gellyfish.com>
        Reading a line from a file <benkmann@netins.net>
    Re: Reading a line from a file <tony_curtis32@yahoo.com>
        Socket Question- <adams1015@worldnet.att.net>
        SSH With Perl? <drewperron@cyberus.ca>
    Re: SSH With Perl? <rootbeer@redcat.com>
    Re: Suggest 'use Carp' to modify the messages of -w <johnlin@chttl.com.tw>
    Re: Suggest 'use Carp' to modify the messages of -w <rootbeer@redcat.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 7 May 2000 00:24:59 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How can I run auto-download file in browser ?
Message-Id: <8f29kb$65g$1@orpheus.gellyfish.com>

On 4 May 2000 20:32:49 GMT David Efflandt wrote:
> On Thu, 04 May 2000, Jonathan Kazmierczak <johny@supermedia.pl> wrote:
>>I've problem: In my application I must make function, that downloads
>>data from database and presents them in the text files. There are
>>virtual text files; I generate them and send to browser. So I want to
>>open browser window "Download", not new instance of browser with content
>>of the file.
>>Under Netscape this works correctly, but IE4.0 opens new browser window.
>>
>>How can I make it ?
> 
> You can't.  Contact Microsoft and tell them that their browser is broken
> because it ignores MIME headers.  On second thought, that is pretty hard
> to do, which explains why they don't have a clue.

Sure  bill@microsoft.com is a valid address ;-}

/J\
-- 
And Lord, we are especially thankful for nuclear power, the cleanest,
safest energy source there is. Except for solar, which is just a pipe
dream.
-- 
fortune oscar homer


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

Date: 6 May 2000 19:12:40 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: how to delete all variables in Z::?
Message-Id: <8f1nao$bja$1@orpheus.gellyfish.com>

On Thu, 04 May 2000 08:51:13 -0400 Shane Dewitt wrote:
> is there a way to undef Z:: so that i can start with empty variables?
> example:
> 
> foreach (@STUFF) {

%Z:: = ();

>  open(IN,"./STUFF{$_}");
>  $q = new CGI(IN);
>  $q->import_names('Z');
>  close(IN);
>  print $Z::STUFF1;
>  print $Z::STUFF2;
> }
> 


I think this discussed in the FAQ.

/J\
-- 
This is absolutely the last funeral we ever take you kids to.
-- 
fortune oscar homer


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

Date: Mon, 08 May 2000 18:13:48 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: HTTP::Request=HASH(0x7bb141c) ?
Message-Id: <3917664C.34BC901A@My-Deja.com>

> why does $request only contain "HTTP::Request=HASH(0x7bb14ac)" at output
> time?

$request is a ref to the HTTP Request object

 Instances of the HTTP::Request classes should be passed to the request()
  method of an LWP::UserAgent object:

      $ua = new LWP::UserAgent;
      $request = new HTTP::Request 'http://www.oslonett.no/';
      $response = $ua->request($request);
      print $response->as_string () ;

>>print OUT "$request";
This technique will NOT print the URL contents as $request
has not been handed over to the LWP::UserAgent object.
---





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

Date: 9 May 2000 02:23:39 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: HTTP::Request=HASH(0x7bb141c) ?
Message-Id: <8f7srb$i4h$1@216.155.33.112>

In article <3917664C.34BC901A@My-Deja.com>, Makarand Kulkarni 
<makarand_kulkarni@My-Deja.com> wrote:

 | > why does $request only contain "HTTP::Request=HASH(0x7bb14ac)" at 
 | > output
 | > time?
 | 
 | $request is a ref to the HTTP Request object
 | 
 |  Instances of the HTTP::Request classes should be passed to the 
 |  request()
 |   method of an LWP::UserAgent object:
 | 
 |       $ua = new LWP::UserAgent;
 |       $request = new HTTP::Request 'http://www.oslonett.no/';
 |       $response = $ua->request($request);
 |       print $response->as_string () ;
 | 
 | >>print OUT "$request";
 | This technique will NOT print the URL contents as $request
 | has not been handed over to the LWP::UserAgent object.
 | ---

aha, ok, so this :

#!perl -w
use strict;
use diagnostics -verbose;
use LWP::UserAgent;

my $ua = new LWP::UserAgent;
my $request = new HTTP::Request 
'http://www.planetunreal.com/nalicity/ut_dm_maps.htm';
my $response = $ua->request($request);
print $response->as_string () ;

however, all I get is this: 

--- HTTP::Response=HASH(0x80306ac) ---
RC: 400 (Bad Request)
Message: URL missing


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

but copying that URL to my web browser brings the page up right away. 

NOW what's wrong ? :/ 


is there some other module I need to update, or perhaps update THIS 
install of LWP ?

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: 08 May 2000 21:28:12 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: HTTP::Request=HASH(0x7bb141c) ?
Message-Id: <87og6g4fur.fsf@shleppie.uh.edu>

>> On 9 May 2000 02:23:39 GMT,
>> The WebDragon <nospam@devnull.com> said:

> my $request = new HTTP::Request
>           'http://www.planetunreal.com/nalicity/ut_dm_maps.htm';

Ahh, but what do you want to do with this URL?

The browser does a GET, that's what you have to do too.

my $request = new HTTP::Request GET => 'http......';

hth
t


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

Date: 9 May 2000 02:23:37 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Mail::Mailer not setting from?
Message-Id: <slrn8hetlu.5av.efflandt@efflandt.xnet.com>

On Mon, 8 May 2000 18:56:33 -0600, John Keiser <john@ieffects.com> wrote:
>Hey, gang, I'm having trouble getting this script to set the From field in
>my email.  Everything else appears to be working.  I looked around in the
>docs and decided to try 'MailFrom' as well, but that didn't work either.  No
>matter what, the From field in the email is set to my unix account.

That may be beyond your control, since your admin may not want you sending
spam.  But you could always set Reply-To => 'another@address'.  Then
hopefully most replies would go to that address.

>The script:
>
>use Mail::Mailer;
>$msg = new Mail::Mailer;
>$fh = $msg->open({
>        From => 'Weird guy <tony@ieffects.com>',
>        To => 'John Keiser <john@ieffects.com>',
>        Subject => 'This is just a test.'
>        });
>print $fh "This is a test.\nThis is only a test.\n";
>$fh->close;
>
>Can anyone see problems?  Suggestions?
>
>Thanks.
>
>--John Keiser


-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Mon, 8 May 2000 19:32:30 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Mail::Mailer not setting from?
Message-Id: <Pine.GSO.4.10.10005081930560.3921-100000@user2.teleport.com>

On Mon, 8 May 2000, John Keiser wrote:

> No matter what, the From field in the email is set to my unix account.

It sounds as if whatever method Mail::Mailer uses on your system isn't
configured to let you set that header. Maybe you won't be able to use
Mail::Mailer, or maybe you'll have to tell it to use a different method.
See the Mail::Mailer docs to find out how to choose a different method.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 09 May 2000 01:29:55 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: making a package (NOT a module)
Message-Id: <391a68a2.4983070@news.skynet.be>

The WebDragon wrote:

>on that thought, does it make sense to declare namespaces for cgi/perl 
>scripts running on webservers so that they don't step on each other, or 
>is that sort of unnecessary?

CGI scripts are independent programs. They won't ever trip on each
other's variables.

In situations as with mod_perl, you're better off using lexicals
(declared with "my"), because if they have the same name, or even it's
the same script running twice, they'll still have separate storage.

Namespaces (packages) in the old perl4 philosophy, mainly serve(d) to
make big projects managable. They predate lexicals. In fact, using
lexicals, you can largely eliminate the need for namespaces.

A second use for packages, is to implement classes for OO. Of course,
this kind of application can NOT be replaced by lexicals.

-- 
	Bart.


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

Date: Sat, 6 May 2000 18:46:20 +0100
From: "Andy Chantrill" <andy@u2me3.com>
Subject: Re: Making my script not case-sensitive!
Message-Id: <8f1lq2$5ot$1@uranium.btinternet.com>

Use the "/i" modifier within your regular expression to ignore
capitalisation.


Thanks, Andy.
andy@u2me3.com

Ola Jetlund wrote in message <39144217.1C018E13@tele.ntnu.no>...
>Hi,
>
>I'm using a script that reads all files in a directory and renames them.
>I recently discovered that when I read the names of the files in the
>directory it skips all with capital letters (since my naming convention)
>uses small letters. I use the following code to read the directory:
>
>opendir THISDIR, "." or die "Error: $!";
>@filer = readdir THISDIR;
>
>and then I operate on with:
>
>foreach(@sfiles){
>  // If file contains elements(which is listed whith small letters) from
>my naming convention then rename... //
>}
>
>Is there something I could do so the renaming also would happen when a
>file in the directory has an element that I have in my convention but
>with one or more large letters??
>
>
>regards
>
>J
>
>




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

Date: 6 May 2000 21:36:51 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: mixing module versions with mod perl and apache
Message-Id: <8f1vp3$6d0$1@orpheus.gellyfish.com>

On Wed, 03 May 2000 22:25:38 GMT cavenewt@my-deja.com wrote:
> 
> 
> 
> I'm running slashcode on my site.  I've also got several virtual hosts,
> and am attempting to 'test' new versions of the slash code.  However,
> it appears that once a version of the slash.pm gets loaded by httpd, it
> will not load the other version used by the other virtual host.
> 

'HUP'

/J\
-- 
In old days books were written by men of letters and read by the
public. Nowadays books are written by the public and read by nobody.
-- 
fortune oscar homer


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

Date: 9 May 2000 03:38:25 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Need help on displaying REMOTE_HOST
Message-Id: <slrn8hf225.5av.efflandt@efflandt.xnet.com>

On Tue, 09 May 2000, joydip_chaklader@my-deja.com
<joydip_chaklader@my-deja.com> wrote:
>I have developed a script for my hit counter the enviroment variables
>are displaying properly except the remote host.
>
>I think server may not be configured to set the REMOTE_HOST variable
>(it's a real drain on system resources to do a reverse DNS lookup for
>every request). Now I am trying  to use the REMOTE_ADDR variable
>instead. I am trying  set my scripts to check  REMOTE_HOST, and if it's
>empty,then using REMOTE_ADDR.
>
>But then again my programme  will be a hit counter for other sites
>which will be giving site stastics ,it will be very poor if i cannot
>provide the domain names of visitors to them.
>
>Can anybody give me some idea ?

Adapted from 'perldoc -f gethostbyname', the following would fill in
REMOTE_HOST with the name, if it resolves, or REMOTE_ADDR if that fails.
Just put this somewhere in your script before you need it.

use Socket;
unless ($ENV{REMOTE_HOST} && $ENV{REMOTE_HOST} ne $ENV{REMOTE_ADDR}) {
    my $ipaddr = $ENV{REMOTE_ADDR};
    $ENV{REMOTE_HOST}  = gethostbyaddr(inet_aton($ipaddr), AF_INET);
    $ENV{REMOTE_HOST} = $ENV{REMOTE_ADDR} unless $ENV{REMOTE_HOST};
}

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Mon, 08 May 2000 22:30:24 -0400
From: Kerry Shetline <kerry@shetline.com>
Subject: Re: Need LWP module, but it's not installed on my server
Message-Id: <39177840.60B7A9E4@shetline.com>

Tad McClellan wrote:
> > I tried the simple-minded approach of just dropping the LWP.pm file
> > and LWP folder from a set of Perl libraries I have into my cgi-bin
> > directory,
> 
> How did you do that without telnet (or similar) ?

I have FTP access, just no access to a command line interface. Basically
I'm allowed to shuffle files back and forth, but not execute anything on
the server -- except my Perl scripts, of course.

-Kerry

----------------------------------------------------------------------
See the stars (and Sun, and Moon, and planets) at the Sky View Cafe...

                 http://www.shetline.com/skyview.html
----------------------------------------------------------------------


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

Date: Mon, 08 May 2000 19:49:19 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Need LWP module, but it's not installed on my server
Message-Id: <39177CAF.C75235E0@vpservices.com>


Kerry Shetline wrote:
> 
> Tad McClellan wrote:
> > > I tried the simple-minded approach of just dropping the LWP.pm file
> > > and LWP folder from a set of Perl libraries I have into my cgi-bin
> > > directory,
> >
> > How did you do that without telnet (or similar) ?
> 
> I have FTP access, just no access to a command line interface. Basically
> I'm allowed to shuffle files back and forth, but not execute anything on
> the server -- except my Perl scripts, of course.

Some modules (those that do not require C compiling, called XS subs) can
be installed just by copying  the .pm files onto the server.  Many
others (including LWP) require either that you get a binary distribution
for your server's platform or that you run a script on the server to do
the installation.  If you can't telnet, it would be pretty tricky to
do.  I suppose you could write a CGI script that did the install
remotely, but that would certainly be violating the spirit of your
sysadmin's laws if not the letter.  Best bet is to get a better ISP or
convince the sysadmin to install the stuff.  In the long run getting
telnet access will be really handy, not just for installing modules, but
for testing and debugging stuff in the environment it will run in. 
Failing all that, you can binaries of LWP for windoze at
www.activestate.com and maybe ask here again if you need them for
another platform and can't find them.

-- 
Jeff


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

Date: Tue, 09 May 2000 02:06:37 GMT
From: "Jason Malone" <jamalone@earthlink.net>
Subject: Re: nt, perl, and smtp mail
Message-Id: <NoKR4.40241$x4.1318068@newsread1.prod.itd.earthlink.net>

> We are trying to get a perl cgi that previously used Unix's sendmail to
> work on NT.  WE ALREADY KNOW HOW TO GET MAIL WORKING WITH ASP'S BUT we
> need to get it working with perl.
>
> We've tried several methods:
>
> I. Net::SMTP and Mail::Sendmail.

The way that I have done this in the past is to use a program called BLAT.
It is a NT command line utility that will allow you to send mail in a
simmilar way to sendmail.

hth

Jason Malone




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

Date: 6 May 2000 14:38:13 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Output PERL to excel
Message-Id: <8f1785$nou$1@orpheus.gellyfish.com>

On Thu, 04 May 2000 18:52:46 GMT justin_d_merritt@hotmail.com wrote:
> Long story short, I want the output of a PERL script to be Content-
> type: application/msexcel. What I try is :
> 
> use CGI qw(:standard);
> my $query = new CGI;
> 
> print $query->header('application/msexcel');
> 
> Of course, this does not work. I read something about a BinaryWrite
> function, but I can't find enough in the way of an example to make it
> work - plus - I don't even know if I am on the right track here.
> 

I think you mean binmode().  Also I think you mean another Content-Type.

/J\
-- 
Awww, there's only one beer left and it's Barts.
-- 
fortune oscar homer


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

Date: 6 May 2000 23:15:54 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Parallel port
Message-Id: <8f25iq$p08$1@orpheus.gellyfish.com>

On Sat, 6 May 2000 17:53:25 +0200 Christian Goebel wrote:
> Hi,
> how I can send a byte to the parallel port (linux,apache)?
> Can you give me an example?
> best regards,

This is similar to the answer in perlfaq8:

       How do I read and write the serial port?

Except you use the appropriate device for your parallel port.  You might
also want to search Deja News as this was discussed recently.

/J\
-- 
Ahh, the college roadtrip. What better way to spread beer fueled mayhem?
-- 
fortune oscar homer


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

Date: Mon, 8 May 2000 19:14:52 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl code to check for broken links
Message-Id: <Pine.GSO.4.10.10005081913530.3921-100000@user2.teleport.com>

On Mon, 8 May 2000, Erick Jensen wrote:

> I am looking for some simple code to check whether a link is broken or not

Randal has several, a few with some amazing features.

   http://www.stonehenge.com/merlyn/WebTechniques/

Enjoy!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 6 May 2000 23:07:13 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: perl-corba documentation..
Message-Id: <8f252h$nco$1@orpheus.gellyfish.com>

On Fri, 05 May 2000 23:32:45 -0700 Joydeep Roy Chowdhury wrote:
> 
> i want to learn about implementation of CORBA in Perl. where can I get
> started ?
> 

Depends on what ORB you are using.  If you are using Linux you can use
ORBit (which is part of Gnome) and there is a Perl binding for that.
The documentation is a little sketchy but the example code should get you
started.  You can download CORBA::ORBit from CPAN <http://www.cpan.org>.

There is also a binding to MICO by the same author.

/J\
-- 
I wonder where Bart is, his dinner's getting all cold, and eaten.
-- 
fortune oscar homer


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

Date: 7 May 2000 00:06:20 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: perlcc[more info]
Message-Id: <8f28hc$2mk$1@orpheus.gellyfish.com>

On Sat, 6 May 2000 07:42:37 -0400 Jim Marley wrote:
> Sorry, should have also mentioned I'm running it on NT4.0.
> 
>  I'm running 5.005_3 and having trouble getting perlcc to work (at all).
> Can
>  anyone give me guidance on what files need to be modified to get this thing
>  rolling?  I've read there were problems in the past - but honestly haven't
>  kept up.
> 

Error message ?  I would guess the problem is that you dont have a C
compiler but that would be a guess.

/J\
-- 
Look at this country--U R Gay.
-- 
fortune oscar homer


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

Date: Tue, 09 May 2000 01:23:18 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Please help cannot display REMOTE_HOST variable
Message-Id: <391867b6.4746508@news.skynet.be>

joydip_chaklader@my-deja.com wrote:

>I think server may not be configured to set the REMOTE_HOST variable
>(it's a real drain on system resources to do a reverse DNS lookup for
>every request). Now I am trying  to use the REMOTE_ADDR variable
>instead.

Do the DNS lookup yourself. Perl even has a primitive for it:
gethostbyaddr(). This one expects the address to be in packed format, I
think (a string of 4 bytes).

-- 
	Bart.


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

Date: 6 May 2000 18:56:13 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: problem with "system" and file copy
Message-Id: <8f1mbt$8he$1@orpheus.gellyfish.com>

On Thu, 04 May 2000 07:24:09 -0500 Paul R. Andersen wrote:
> Andreas Boerner wrote:
>>
>> I have a problem with copy and a system call:
>>
>> When I enter at command prompt (UNIX) the following command, it works
>> as expected:
>>
>> cp ~/dir1/*.c ~/dir2
>>
>> The following perl routine however does not work:
>>
>> use strict;
>> my $command;
>> my $rc;
>>
>> $command = "cp ~/dir1/*.c ~dir2";
>> print $command;
>> $rc = system($command);
>> print "rc=$rc\n";
>>
>> it produces the following output:
>>
>> command=cp ~/dir1/*.c ~/dir2
>> cp: cannot access ~/dir1/*.c
>> rc=512
>>
>> Has anybody an idea, why this fails ???
> 
>
> Perl does not understand the ~, it is csh, or ksh, or bash, or whatever
> shell you are running that handles the tilde.  Perl cannot.  I wrote a
> routine that processes file names and converts the tilde and other
> shorthand notations to real names.  That works great, especially with Tk
> where I can let the users enter as they are used to.
> 
> 

Nope.  If the string passed to system() has shell meta characters in it
then it will be passed to the shell for the shell to run it.  But yes Perl
will not interpret those shell metacharacters itself.  You might want to
look at the module File::Glob which will let you expand '~' and so forth
yourself.  Then you can use File::Copy and forget about using an external
copy program.

/J\
-- 
What is abnormal in Life stands in normal relations to Art. It is the
only thing in Life that stands in normal relations to Art.
-- 
fortune oscar homer


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

Date: Tue, 09 May 2000 01:14:56 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Proper use of resources (was Re: more regexp madness extracting data    from files.)
Message-Id: <391765ff.4307383@news.skynet.be>

Randal L. Schwartz wrote:

>The>     for (@dataList) { print OUT "$_" }
>
>print OUT @datalist;

or 

	print OUT for @datalist;


The cute thing about this, is that it looks almost identical to what
Randal wrote. Only one word more. But, in fact, the syntax is completely
different. Trip over this, newbies. :-)

-- 
	Bart.


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

Date: Tue, 09 May 2000 02:46:03 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Proper use of resources (was Re: more regexp madness extracting data from files.)
Message-Id: <x7wvl4v3ti.fsf@home.sysarch.com>

>>>>> "TW" == The WebDragon <nospam@devnull.com> writes:

it is good you don't jeopardy quote but you should learn to edit quotes
as well. you quoted my entire message when all you needed to leave was a
few lines for context.

<big snip>

  TW> now from some other post I just saw on here and if I understood this 
  TW> correctly, I can replace 
  TW>     foreach my $text (@dataList) {
  TW>         print OUT $text;
  TW>     };
  TW> with
  TW>     print "$_\n" for @dataList;

  TW> correct?

partly. you forgot the OUT handle in the second print.

	print OUT "$_\n" for @dataList;

or
	print OUT map "$_\n", @dataList;

i like the map version since you can insert leader/trailer text in the
print statement like:

	print OUT "datalist:\n", map( "$_\n", @dataList ), "end of list\n" ;

  TW> on contemplation, I'd like to add to this script the ability to grab 
  TW> these six .html files containing the data I wish to extract via http, 
  TW> and save them locally, overwriting the previous ones, before running 
  TW> this script on them and generating my output file of the data. (this way 
  TW> I can daily keep my local output file up to date.)

  TW> Which modules do you recommend that would best suit this sort of
  TW> thing?  I'm guessing one of the Net:: or HTTP:: modules? Which
  TW> wuld you use? and why?

LWP::Simple has what you want. you can fetch a web page and store it to
a file with one simple (hence the name) call.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 6 May 2000 23:39:41 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Question on references...
Message-Id: <8f26vd$tdb$1@orpheus.gellyfish.com>

On Sat, 06 May 2000 17:19:48 GMT PropART wrote:
>[Uri Wrote]
>> you don't grok the reasons for the different ways.
> 
>> [@a] is used to create a new anonymous array and get a ref to
>> that. that new ref has freash copies of the data and can be passed
>> around and won't get destroyed as long at its ref count is > 0.
> 
> My difficulty is definitely a grokking thing, because I've never really
> used anonymous arrays.
>
> So, I guess you'd use an anonymous array when you just want to start
> out with array's values for some reason and you don't need a named
> array hanging around? 

One might use an 'anomymous array' (array reference) when you want to
store or pass that in a scalar, such as creating an hash of arrays or
when returning a large list from a subroutine.  Also bear in mind that
multi dimensional arrays are really arrays of array references .

>                        I should probably show up at the Boston PM
> meetings if I want to improve my Perl.

And to London.pm if you want to improve your drinking but worsen your
bank balance (and still be none the wiser about Perl :)

/J\
-- 
In times of trouble you've got to go with what you know.
-- 
fortune oscar homer


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

Date: Mon, 08 May 2000 21:29:28 -0500
From: Rhonda Mann <benkmann@netins.net>
Subject: Reading a line from a file
Message-Id: <39177806.3C5FC15A@netins.net>

How could I print one line to a file, then access that file from a
different script?

Usually I see:

foreach $i (@data) {
     split blah blah blah
}
Then you can use the variables

But what if you did this?

Open(LOG,">$datafile") || print "Can't open it!\n";
print LOG "$count1|$count2|$count3";
close(LOG);

Then, how could I get the variables $count1, $count2, $count3 in a
different script and use them?  Thank you!!



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

Date: 08 May 2000 21:33:50 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Reading a line from a file
Message-Id: <87ln1k4fld.fsf@shleppie.uh.edu>

>> On Mon, 08 May 2000 21:29:28 -0500,
>> Rhonda Mann <benkmann@netins.net> said:

> How could I print one line to a file, then access that
> file from a different script?

> Usually I see:

> foreach $i (@data) { split blah blah blah } Then you can
> use the variables

> But what if you did this?

> Open(LOG,">$datafile") || print "Can't open it!\n";
> print LOG "$count1|$count2|$count3"; close(LOG);

> Then, how could I get the variables $count1, $count2,
> $count3 in a different script and use them?

Well, you'd open the file for read and parse each line by
splitting on '|' (remember: '|' is a regexp
meta-character).

There's also a Storable module (perldoc Storable, and/or
install via cpan/ppm) which can be used for persistent
data structures if that's more to your needs.

OTOH, what are you trying to do?  There may be
other/better perl solutions, e.g. mod_perl for WWW/CGI
applications requiring persistence (a wild guess about the
context of your question :-).

hth
t


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

Date: Tue, 09 May 2000 02:24:51 GMT
From: "Veronica Adams" <adams1015@worldnet.att.net>
Subject: Socket Question-
Message-Id: <TFKR4.55650$fV.3440584@bgtnsc05-news.ops.worldnet.att.net>

Hey,

I'm trying to build a client-server app for fun and I've run into a problem
with some code I pulled off of www.perl.com
The code (both client and server) runs fine while in debug. But, when the
apps are fired normally the server will not send the client's input back to
the client. Or the client just won't display it. I can't tell.

The code for both apps is relatively small so I'm posting them both.  BTW
I'm runing windows 98 se and active perl build 5.6
Please forgive the loss of formating... my news reader butchered it

SERVER:
 use Socket;

($port) = @ARGV;
$port = 2345 unless $port;
($name, $aliases, $protocol) = getprotobyname('tcp');

if ($port !~ /^\d+$/) {
     ($name, $aliases, $port) = getservbyport($port, 'tcp');
}

print "Listening on port $port...\n";

socket(S,AF_INET,SOCK_STREAM,$protocol) || die "socket : $!";

$sockaddr = 'S n a4 x8';
$this = pack($sockaddr, AF_INET, $port, "\0\0\0\0");
bind(S, $this) || die "bind : $!";

listen(S,10) || die "listen: $!";

select(S);
$| = 1;
select(STDOUT);

for ($con = 1; ; $con++) {

     ($addr = accept(NS,S)) || die $!;

     select(NS);

     $| = 1;

     select(STDOUT);

     if (($child = fork()) == 0) {


           ($af,$port, $inetaddr) = unpack($sockaddr, $addr);
           @inetaddr = unpack('C4', $inetaddr);

           print "Serving connection $con @ Internet address @inetaddr\n";
           while (<NS>) {
              print "Received from client $con: $_";


              print NS "Server $con: $_\n";

           }
           close(NS);
           print "Client went away.  Forked server $con exiting...\n";
           exit;
     }

     close(NS);
}

CLIENT:
use Socket;

($them,$port) = @ARGV;
$port = 2345 unless $port;
$them = 'localhost' unless $them;
$SIG{'Int'} = 'dokill';
sub dokill {
    kill 9, $child if $child;
}
chop($hostname = `hostname`);
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $port) = getservbyname($port,'tcp')
    unless $port =~ /^\d+$/;
print "Using port $port to connect to server on host $them...\n";
($name,$aliases,$type,$len,$thisaddr) = gethostbyname($hostname);
($name, $aliases,$type,$len,$thataddr) = gethostbyname($them);
if (socket(S,AF_INET, SOCK_STREAM, $proto)) {
    print "Socket creation succeeded.\n";
}
else {
    die $!;
}

$sockaddr = 'S n a4 x8';
$this = pack($sockaddr, AF_INET, 0, $thisaddr);
$that = pack($sockaddr, AF_INET, $port, $thataddr);

if (bind(S, $this)) {
    print "Bind succeeded.\n";
}
else  {
    die $!;
}
if (connect(S, $that)) {
    print "Connect succeeded.\n";
}
else {
    die $!;
}
select(S);
$| = 1;
select(STDOUT);
if ($child = fork) {
    while (<STDIN>) {
        print S;
    }
    sleep 3;
    do dokill();
}
else {
    while (<S>) {
        print "Server: $_";
    }
}






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

Date: Tue, 09 May 2000 01:11:26 GMT
From: Andrew Perron <drewperron@cyberus.ca>
Subject: SSH With Perl?
Message-Id: <391765B6.E449C0E8@cyberus.ca>

Hello,

I am in the process of learning Perl and one application that I'm
writing would greatly be enhanced by the ability to communicate securely
using SSH.  Is there a Perl implementation of SSH (I only know of a Java
one, but that doesn't mean anything)?  The key is that I can't require
that anything (SSH, SSL, etc) be installed on the system, htough I cna
require any Perl module in existence.

I guess my question is really, if one does not exist, what would be
involved with making an SSH implementation?  Currently it is beyond my
abilities, so I really have no ideas...

Thanks

Andrew Perron


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

Date: Mon, 8 May 2000 19:37:20 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: SSH With Perl?
Message-Id: <Pine.GSO.4.10.10005081932480.3921-100000@user2.teleport.com>

On Tue, 9 May 2000, Andrew Perron wrote:

> Is there a Perl implementation of SSH 

In general, you should use Perl for its strengths. But implementing SSH in
Perl would be using Perl's weaknesses.

> The key is that I can't require that anything (SSH, SSL, etc) be
> installed on the system, htough I cna require any Perl module in
> existence.

Well, you could perhaps find or make a module that lets you install other
software.... :-)

But maybe you'll need to make an SSH module. It won't be trivial, and it
will be especially difficult if you haven't made a module before. It'll
almost certainly need to include some XS-code for efficiency. Start with
making a Perl-only module (that does something much simpler than SSH!) and
see how that goes as a learning experience. Good luck with it!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 9 May 2000 09:13:47 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Suggest 'use Carp' to modify the messages of -w
Message-Id: <8f7pcm$cuj@netnews.hinet.net>

Jonathan Stowe wrote
> John Lin Wrote:

> > Just like 'Carp::carp' improves the messages of 'warn',
> > I suggest 'use Carp' modify the "-w" messages to be like:
> >
> > Use of uninitialized value in concatenation (.)
> > at C:/Perl/lib/Foo.pm line 950, called at main.pl line 15.

> I am sure if you supply the patch it will be carefully considered ;-}

Hi,

For some posts I received the kind of answer:
Patches are welcomed!!!
Yes, but I don't know where to send patches to...
Can you give me a hint?

Thank you.




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

Date: Mon, 8 May 2000 19:12:33 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Suggest 'use Carp' to modify the messages of -w
Message-Id: <Pine.GSO.4.10.10005081910350.3921-100000@user2.teleport.com>

On Tue, 9 May 2000, John Lin wrote:

> Patches are welcomed!!!
> Yes, but I don't know where to send patches to...
> Can you give me a hint?

If you can't figure it out without asking, maybe you shouldn't be
submitting patches. :-)

No, just kidding. Use the perlbug program, if you're patching perl itself
or something from the Perl distribution. If you're patching some other
program or module, contact the author or (in a few cases) the mailing
list; the address should be in the software's docs. 

Happy patching!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

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


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