[18005] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 165 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 29 06:05:34 2001

Date: Mon, 29 Jan 2001 03:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980766307-v10-i165@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 29 Jan 2001     Volume: 10 Number: 165

Today's topics:
    Re: <STDIN> as an array <jdf@pobox.com>
        ANNOUNCE: moodss-13.0 <jfontain@winealley.com>
    Re: bidirectional communication using sockets <sebastien.cottalorda@mageos.com>
    Re: Catching warnings from Getopt::Std (Johan Vromans)
    Re: closed filehandle error <jdf@pobox.com>
        copy construct reference to anonymous scalar <johnlin@chttl.com.tw>
    Re: Creating calendar (reminder) class (Garry Williams)
    Re: email address with receiver's name (Chris Fedde)
    Re: email address with receiver's name <johnlin@chttl.com.tw>
    Re: How to send a file ... (Joe Smith)
    Re: How to send a file ... (Garry Williams)
    Re: How to unload module from memory? <andrew@erlenstar.demon.co.uk>
        Matching problem <marekpow@email.hinet.hr>
    Re: Matching problem (Bernard El-Hagin)
        New Perl Book. <md5.bbs@bbs.ntu.edu.tw>
    Re: New Perl Book. <comdog@panix.com>
        Passing object reference, while parsing XML <thomastk@prodigy.net>
    Re: Passing object reference, while parsing XML <matt@sergeant.org>
    Re: passing parameter (Rafael Garcia-Suarez)
        Perl script for Cisco <jmeyer@pax.ch>
    Re: Perl script for Cisco (Garry Williams)
    Re: Receive email with attachments (Villy Kruse)
        single quotes in a system call jdallega@my-deja.com
    Re: single quotes in a system call (Garry Williams)
    Re: substition problem <jdf@pobox.com>
    Re: Unicode and URL encoding <cs@ccss.de>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 29 Jan 2001 01:33:32 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: <STDIN> as an array
Message-Id: <vgqyhnpf.fsf@pobox.com>

Jeff Traigle <traigle@si.umich.edu> writes:

> Well, that was a mistype on my part in the note. No such mistype in the
> script I was trying to run on my Linux box.

Since syntax is important, if you don't *copy* and *paste* the exact
code you were trying to run, we cannot be of much help!

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Mon, 29 Jan 2001 10:15:06 +0100
From: Jean-Luc Fontaine <jfontain@winealley.com>
Subject: ANNOUNCE: moodss-13.0
Message-Id: <953bve$l5n$2@s1.read.news.oleane.net>

Dear Perl afficionados: I think this might interest you since modules for 
this piece of software can be written in Perl.
Please let me know whether it is allright to post here or if there is a 
better way to reach the Perl community (I already have emailed the perl 
announce newsgroup moderator and am waiting for a response).


Check it out! (or at least the screenshots at
http://jfontain.free.fr/moodss3.gif or
http://jfontain.free.fr/moodss4.gif :).


Notes:
- moodss modules can now be written in Perl! Sample Random and
Minimal modules are provided. Documentation (see Random.pm file)
needs improving. Feedback is highly welcomed.

### CHANGES ###

--- version 13.0 ---
modules can now be written in the Perl language (the tclperl package
  is required, available in my homepage)
added Minimal and Random Perl modules (capitalized names)
module programmers: INCOMPATIBLE change, during a module loading
  phase, the current directory is the module directory, so the
  packageDirectory array is no longer required nor made available to
  the module
MySQL mystatus module updated to support 3.23.31 and 3.23.32 servers
removed a memory leak that occured during packages scan when
  dynamically loading a new module
removed error when no modules are found when trying to dynamically
  load a new module
a cell with a value of ? was not considered void by the thresholds
  code
removed libfilesystem and libnetwork linux binaries from distribution
  tarball

### README ###

This is moodss (Modular Object Oriented Dynamic SpreadSheet) version
13.0.

Moodss won in the Best System Admin Technology category (Tcl Tips and
Tricks, Valuable Real World Programming Examples) at the O'Reilly
Tcl/Tk 1999 Conference.
Linux Magazine calls it a "lifesaver".
Tucows gives it 5 penguins (stars :-).

Moodss is a modular application. It displays data described and
updated in one or more modules, which can be specified in the command
line or dynamically loaded or unloaded while the application is
running. Data is originally displayed in tables. Graphical views
(graph, bar, 3D pie charts, ...), summary tables (with current,
average, minimum and maximum values) and free text viewers can be
created from any number of table cells, originating from any of the
displayed viewers. Thresholds can be set on any number of cells.

Specific modules can easily be developed in the Tcl and Perl scripting
languages or in C.

A thorough and intuitive drag'n'drop scheme is used for most viewer
editing tasks: creation, modification, type mutation, destruction,
 .... and thresholds creation. Table rows can be sorted in increasing or
decreasing order by clicking on column titles. The current
configuration (modules, tables and viewers geometry, ...) can be saved
in a file at any time, and later reused through a command line switch,
thus achieving a dashboard functionality.

The module code is the link between the moodss core and the data to be
displayed. All the specific code is kept in the module package. Since
module data access is entirely customizable (through C code, Tcl,
Perl, HTTP, ...) and since several modules can be loaded at once,
applications for moodss become limitless.
For example, thoroughly monitor a dynamic web server on a single
dashboard with graphs, using the Apache, MySQL, cpustats, memstats,
 ....  modules. If you have replicated servers, dynamically add them to
your view, even load the snmp module on the fly and let your
imagination take over...

Along with a core trace module, random, ps, cpustats, memstats,
diskstats, mounts, route, arp, kernmods, netdev, pci, system, MySQL
(myquery, mystatus, myprocs, myvars) modules for Linux, ping, snmp and
snmptrap for UNIX, apache and apachex modules are included (running
"wish moodss ps cpustats memstats" mimics the "top" application with a
graphic edge and remote monitoring capability).

Thorough help is provided through menus, widget tips, a message area,
a module help window and a global help window with a complete HTML
documentation.

Moodss is multi-langual thanks to Tcl internationalization
capabilities. So far only English and partially French are
supported. Help with other languages will be very warmly welcomed.

Development of moodss is continuing and as more features are added in
future versions, backward module code compatibility will be maintained.

I cannot thank the authors of the tkTable, BLT, MIME/SMTP and the HTML
libraries enough for their great work.

In order to run moodss, you need to install the following packages
(unless you can use the rpm utility, see below):
Tcl/Tk 8.3.1 or above, at (or at a mirror near you)
  http://dev.scriptics.com/ or ftp://ftp.scriptics.com/
the latest tkTable widget library at:
  http://www.hobbs.wservice.com/tcl/main.html
the latest BLT library at:
  ftp://tcltk.sourceforge.net/pub/tcltk/blt/
eventually the latest tclperl library for wrinting modules in Perl at:
  http://jfontain.free.fr/
(see the INSTALL file for complete instructions, for UNIX and also
Windows platforms).

You also have the option of using the moodss rpm file (also in my
homepage), if you are using a Redhat Linux system (6.0 or above).
You can find the required tcl, tk, tktable, blt, tcpperl and other
rpms at: http://jfontain.free.fr/

Whether you like it (or hate it), please let me know. I would like to
hear about bugs and improvements you would like to see. I will correct
the bugs quickly, especially if you send me a test script (module code
with a data trace would be best).

###

you may find it now at my homepage:

http://jfontain.free.fr/moodss-13.0.tar.gz
http://jfontain.free.fr/moodss-13.0-1.i386.rpm
http://jfontain.free.fr/moodss-13.0-1.spec

and a bit later at:

ftp://contrib.redhat.com/ in libc6 sub-directory.

Enjoy and please let me know what you think.

---
Jean-Luc Fontaine  mailto:jfontain@free.fr  http://jfontain.free.fr/



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

Date: Mon, 29 Jan 2001 09:27:15 -0000
From: "Sébastien Cottalorda" <sebastien.cottalorda@mageos.com>
Subject: Re: bidirectional communication using sockets
Message-Id: <9539di$f7a$1@news2.isdnet.net>

Hi,

Send me directly on my e-mail adress a piece of your code,
Some person tried to adapt my script but they make mistakes in adapting
filehandlers.

As I'm concerned, I've runned successfully my code both on a Windows98 and
on a Linux RedHat 6.0 machine

Sebastien


Sean Blaire <ehsan.cheema@cis.canon.com> a écrit dans le message :
94l6nj$5ka$1@news.cis.canon.com...
> Hello Sebastian,
> I tried your client server program and this is the error message that I
get:
> Can't call method "recv" on an undefined value at <filename> line 14.
>
> I am using Windows NT
>
> any suggestions?
>
> Sean
>
> "Sébastien Cottalorda" <sebastien.cottalorda@mageos.com> wrote in message
> news:94hcri$1huf$1@news4.isdnet.net...
> > Hi,
> >
> > Here is a couple of perl script that works perfectly for me.
> >
> > CLIENT:
> > #!c:\perl\bin\perl -w
> > use IO::Socket;
> > $socket = IO::Socket::INET->new(PeerAddr=> '190.197.10.217',
> >     PeerPort=> '123456',
> >     Proto=> "tcp",
> >     Type=> SOCK_STREAM)
> >  or die "Couln\'t connect to 190.197.10.217:123456 $@\n";
> > $phrase = "How are you \?";
> > $socket->send("$phrase"."FIN",'') or die "Can\'t send $!\n";
> > print "> $phrase \n";
> > $data_read='seb';
> > ITER: while ($data_read) {
> >      $socket->recv($data_read,'256') or die "Can\'t recv $!\n";
> >      print "< $data_read \n" unless ($data_read=~/FIN/);
> >      last ITER if ($data_read=~/FIN/);
> > }
> > $data_read=~s/FIN//;
> > print "< $data_read \n";
> > exit 0;
> >
> >
> > SERVEUR:
> > #!c:\perl\bin\perl -w
> > use IO::Socket;
> > use Carp;
> > use POSIX qw(strftime);
> > $port_recep='123456';
> > $server= IO::Socket::INET->new(LocalPort=> $port_recep,
> >     Type=> SOCK_STREAM,
> >     Reuse=>1,
> >     Listen=>10)
> >  or die "Couln\'t be a tcp server on $port_recep $@\n";
> > while ($client=$server->accept()) {
> >      $data_read='seb';
> >      ITER: while ($data_read) {
> >           $client->recv($data_read,'256') or die "Can\'t recv $!\n";
> >           print "< $data_read \n" unless ($data_read=~/FIN/);
> >           last ITER if ($data_read=~/FIN/);
> >      }
> >      $data_read=~s/FIN//;
> >      print "< $data_read \n";
> >      $phrase = "I feel good thanks";
> >      $client->send($phrase."FIN",'') or die "Can\'t send $!\n";
> >      print "> $phrase \n";
> > }
> > exit 0;
> >
> > The principe:
> > The client connect to the server and send pack of 256 bytes, when
> finishing,
> > it send the word "FIN". Then the client go into listenning position.
> > The server listen a connection, open the socket, read 256 bytes packets
> > until the reception of word "FIN" (you can choose what you want).
> > then the server send the answer finishing with the word "FIN" (you can
> > choose of course).
> > The client record the server listening by pack of 256 bytes until the
word
> > "FIN".
> > Then it close the connection.
> >
> > This is the first version of my program, I've then replaced "FIN" by
"\r"
> :
> > Carriage Return
> >
> > BE VERY CAREFULL, it's very easy to make deadlock with that method :
> Server
> > listening and client listening too.
> >
> > Hope this helps.
> >
> > Sebastien
> >
> > <mmustafa@my-deja.com> a écrit dans le message :
> > 942bgq$aj5$1@nnrp1.deja.com...
> > > Hi,
> > >    I am trying to write a PERL program using sockets. One side ( which
> > > we call client ) is communicating with the listener ( which we call
> > > server) thru a specific port. This is working fine.
> > > The problem i am running into is after sending a couple of strings
> > > (haven't been able to pass an array), the listener/ server reads it,
> > > and does some processing. But if the listener wants to send some
> > > response back to the client, the client can't read it. I will give a
> > > brief code summnary here ( rather then the whole thing ) , this didn't
> > > work :
> > > CLIENT CODE :
> > > #socket initializination, $port and $server are arguments
> > > socket(SOCKET, PF_INET, SOCK_STREAM, (getprotobyname('tcp'))[2]);
> > > connect (SOCKET, pack('Sna4x8', AF_INET, $port,
> > >         (gethostbyname($server))[4]))
> > >         || die "Can't connect to server $server on port $port .\n";
> > > SOCKET->autoflush();
> > >
> > >
> > > print SOCKET "Command1 \r\n";
> > > print SOCKET "Command2 \r\n";
> > >
> > > # I need to read response from the server :
> > > # did NOT WORK
> > > #       shutdown(SOCKET,1);
> > > #       while (<SOCKET>) {
> > > #       while (defined ($string = <SOCKET>) ) {
> > >         recv(SOCKET,$string,100,0);
> > >         if ($string) {
> > >                 $string = $_;
> > >                 print "STRING : ****($string)****\n";
> > >                 if ($string == 1) {
> > >
> > >
> > > I tried threading the process , which created further problems ( maybe
> > > programing error).
> > > I tried shutdown , which also on the server side, so that the client
> > > doesn't keep on waiting ( according to the documentation , recv will
> > > keep on waiting).
> > >
> > >
> > > Here is a snippet of SERVER CODE :
> > > $server = IO::Socket::INET->new( Proto     => 'tcp',
> > >                                   LocalPort => $DEFAULT_PORT,
> > >                                   Listen    => SOMAXCONN,
> > >                                   Reuse     => 1);
> > >
> > > while(<$server>)
> > >   {
> > >         chomp($_);
> > >         print "Value of i = $i and this is what I got
> > >         from the other machine: **($_)** \n";
> > >         autoflush $server 5;
> > >         $i++;
> > >         if ($i == 1) {
> > >                 $input = $_ ;
> > >                 chomp($input);
> > >                 print "\tRELEASE OR DROP = ($input) \n";
> > >         }
> > >
> > >
> > > If anyone knows how to do it...  please post something....
> > > I apologise if the message is cryptic or vague, I would love to
explain
> > > further if anyone has interest to help.
> > >
> > > Thanks a lot in advance
> > > Farooq
> > >
> > >
> > > Sent via Deja.com
> > > http://www.deja.com/
> >
> >
>
>




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

Date: 29 Jan 2001 08:55:28 +0100
From: JVromans@Squirrel.nl (Johan Vromans)
Subject: Re: Catching warnings from Getopt::Std
Message-Id: <wl3g0i2hjwv.fsf@plume.nl.compuware.com>

James Taylor <james@NOSPAM.demon.co.uk> writes:

> Interesting thanks. I might very well use Getopt::Long next time I
> have a large program to write. It is so much larger than Getopt::Std
> that I wouldn't use it for small/fast stuff.

I assume for small/fast stuff you use assembler instead of Perl ;-)?

> Is that bundling bareword correct or should it be in quotes?

It should. Sorry.

-- Johan


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

Date: 29 Jan 2001 00:50:02 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: closed filehandle error
Message-Id: <zogahppx.fsf@pobox.com>

"Shane Lowry" <whtwlf@NOSPAMoptushome.com.au> writes:

> I have a problem with a simple script that is driving my nuts.

I am nonplussed, just about.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Mon, 29 Jan 2001 13:52:40 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: copy construct reference to anonymous scalar
Message-Id: <9530ih$g9r@netnews.hinet.net>

Dear all,

In Perl, we can use [], {}, sub{} to construct references to
anonymous arrays, hashes and codes.  What about scalars?

Comparing with '\' which creates hard references, we can use [], {}
and sub{} to copy construct a reference on arrays, hashes and codes.
What is the syntax of copy constructing reference on scalars?

my  $array_hard_ref = \@array;
my  $array_copy_ref = [@array];
my   $hash_hard_ref = \%hash;
my   $hash_copy_ref = {%hash};
my   $code_hard_ref = \&exit;
my   $code_copy_ref = sub {exit};
my $scalar_hard_ref = \$scalar;
my $scalar_copy_ref = ????????    # this is my question

By "copy constructing reference" I mean the reference that uses the
copied value of the variable and any further dereferencing will not
affect the original variable.

my $x = 3;
my $ref = ????????  # this is my question
$$ref++;
print "$x $$ref";   # should print 3 4

The following were my trials:

my $ref = \(my $dummy = $x);

It works.  But better to put the $dummy in a local block.

my $ref = \${\(my $dummy = $x)};

Good.  But how ugly.  Besides, this is not anonymous.

my $ref = \($x+0);

It works.  But not suitable if $x is not numeric.

my $ref = \"$x";

Up to now, this is the best answer I can find, but looks weird.

What is Perl's standard way to do this?

Thank you.

John Lin






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

Date: Mon, 29 Jan 2001 06:26:49 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Creating calendar (reminder) class
Message-Id: <J28d6.1596$GF2.52352@eagle.america.net>

On Sun, 28 Jan 2001 19:00:50 +0100, Marc Beck <marc.beck@bigfoot.com>
wrote:
>I would like to create a class that acts as a reminder. To create a
>reminder instance you just pass the time and a reference to a sub that
>should be executed.

[snip]

>I couldn't figure out how to manage it so the AddReminder methods
>return immidiately but still call &alarm at the specified time.
>Any hints for me?

  use Event;

-- 
Garry Williams


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

Date: Mon, 29 Jan 2001 06:55:01 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: email address with receiver's name
Message-Id: <9t8d6.1409$B9.191781888@news.frii.net>

In article <952omb$34a@netnews.hinet.net>,
John Lin <johnlin@chttl.com.tw> wrote:
>Dear all,
>
>
>My question is how can I send "with name"?  Could you help me please?
>

This works for me...

#!/usr/bin/perl

use MIME::Lite;

my $msg = MIME::Lite->new(
    From => '<cfedde@viawest.net>',
    To   => join( ', ',
                'Chris Fedde <chris@fedde.littleton.co.us>',
                '(another address) cfedde@bigi.com',
                'yet another address <cfedde@bcx.com>',
            ),

    Subject => 'Nothing much, Just a test',
    Data => <<eob );
Just a few lines of text for the message body.
If it works then I should recieve three copies of this message
from myself.
eob

print $msg->as_string;
$msg->send_by_smtp("localhost");

-- 
    This space intentionally left blank


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

Date: Mon, 29 Jan 2001 16:49:37 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: email address with receiver's name
Message-Id: <953aue$3to@netnews.hinet.net>

"Chris Fedde" wrote
> John Lin wrote:
> >My question is how can I send "with name"?  Could you help me please?
> This works for me...

>     From => '<cfedde@viawest.net>',
>     To   => join( ', ',
>                 'Chris Fedde <chris@fedde.littleton.co.us>',
>                 '(another address) cfedde@bigi.com',
>                 'yet another address <cfedde@bcx.com>',
>             ),

Thank you.

Our configuration must be different.  I can't run your program either.

SMTP DATA command failed:  at send.pl line 24

line 24 is  $msg->send_by_smtp;

As a matter of fact, after intensive guess and test, I got

     To   => join( ', ',
                 '"Chris Fedde" <chris@fedde.littleton.co.us>',
                 '"another address" <cfedde@bigi.com>',
                 '"yet another address" <cfedde@bcx.com>',
             ),

workable, and only this format workable on my machine.

Hmm... MIME::Lite is not machine independent...

Thank you.

John Lin





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

Date: 29 Jan 2001 03:03:26 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: How to send a file ...
Message-Id: <952mhu$28uq$1@nntp1.ba.best.com>

In article <951s0m$6ak$1@nnrp1.deja.com>,  <bits101010@my-deja.com> wrote:
>Steve,
>
>In Unix, do:
>$file = '/path/to/file';
>`cat $file | mail -s "Sub: $file" you@dot.com`;

Worthless use of `cat`.  Use "prog <$file" instead of "cat $file | prog".

The above command is better written as
   $_ = `mail <$file -s "Sub: $file" you@dot.com 2>&1`;
   print "Something went wrong: $?\n$_\n" if ($? or $_ ne "");

	-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Mon, 29 Jan 2001 06:07:01 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: How to send a file ...
Message-Id: <9M7d6.1590$GF2.51865@eagle.america.net>

[ re-ordered thread to match time sequence ]
[ fixed broken line-wrapping ]
[ snipped irrelavent parts ]

[ Please post reply text *after* the text you're replying to ]

On Sun, 28 Jan 2001 22:53:01 GMT, bits101010@my-deja.com
<bits101010@my-deja.com> wrote:
>In article <N97N30KI36919.9401736111@frog.nyarlatheotep.org>,
>  steve50@zxmail.com wrote:
>> On Sun, 28 Jan 2001, bits101010@my-deja.com wrote:
>> >In article <1UUY75UO36919.8319560185@frog.nyarlatheotep.org>,
>> >  Steve50@zxmail.com wrote:
>> >>
>> >> After a script has created a file on the server, I would like to email it
>> >> automatically to one mail address.
>> >>
>> >> How can I do ? (I am a newbie :-)


You should check the FAQ.  Take a look at "How do I send mail?" in the
perlfaq9 manual page.  

Answering a FAQ is usually not a good idea.  The answer can be in
error and it is much more likely that the FAQ answer is not.  In the
case of this thread, the answer was in error.  


>> >In Unix, do:
>> >$file = '/path/to/file';
>> >`cat $file | mail -s "Sub: $file" you@dot.com`;


Assuming you are quoting Perl code here, it will not compile.  Also,
you call for a useless use of cat.  Finally, not every mail program
supports a -s option.  My Solaris version does not.  Maybe you meant
mailx instead.  

A much better answer is in the FAQ cited above.  

You should refer the original poster to the FAQ instead of attempting
to answer it yourself.  


>> It works .. byt I always get an empty file.
>>
>> Maybe it comes from the fact that this file is created by :
>>
>> script [params]  >file.log
>>
>> And this is this file.log I want send by email


That's interesting.  How does your script "know" what file name you
redirected its stdout to?  I guess you hard-coded it.  


>> I put the command `cat $file | mail -s "Sub: $file" you@dot.com`; Just
>> before the script ends (The next line is just '1')
>> Maybe it sends the file BEFORE the file is closed ?


Again, that will *not* compile.  

    $ perl -e '`cat $file | mail -s "Sub: $file" you@dot.com`;'
    In string, @dot now must be written as \@dot at -e line 1, near
    "$file" you@dot"
    Execution of -e aborted due to compilation errors.

But you hit on the problem.  Unless you closed STDOUT *before*
attempting to read it (in your back-ticked pipeline), it will be
incomplete.  Unless there was a lot of data written (probably at least
8192 bytes), it will probably be empty.  The data you wrote to STDOUT
is still in a memory buffer when you call another program to read it
from a file.  


>> How can I fix this ?


I am going to assume that you need to write a file and you need to
send that same data as the body of an E-mail message.  I make that
assumption because you could just invoke your script like this,
otherwise: 

   script [params] | mail ...

But you can accomplish what I think you want by just doing: 

   script [params] | tee file.log | mail ...

If you must do it in Perl, read the FAQ I cited above.  Send the mail
and write the file at the same time in your script.  


[snip]

>`cat $file | mail -s "Sub: $file" you@dot.com`;


That code (if it's Perl code) will *NOT* compile.  It also makes use
of the cat command uselessly.  

Wow, three times in one thread! :-)  


>If you still get empty file in your email, make sure you open up
>file.log directly and see if it's really empty  :)


By the time he can "open up" file.log, it isn't empty.  But when his
command to pipe it to the mail command was executed, it *was* empty.  

-- 
Garry Williams


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

Date: 29 Jan 2001 05:40:22 +0000
From: Andrew Gierth <andrew@erlenstar.demon.co.uk>
Subject: Re: How to unload module from memory?
Message-Id: <877l3eq5kp.fsf@erlenstar.demon.co.uk>

>>>>> "tigra" == tigra  <tigra@sky.deep.ru> writes:

 tigra> OK. As I've understood the sufficient method is to recover all
 tigra> symbols contained in the package (wonder, howto do it?)

perhaps something along the lines of:

sub unload
{
    my $module = shift;
    my $pkg = qualify_to_ref("${module}::");
    my $symtab = *{$pkg}{HASH};
    undef *{qualify_to_ref($_,$module)} for keys %$symtab;
    delete_package($module);
}

-- 
Andrew.


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

Date: Mon, 29 Jan 2001 10:22:03 +0100
From: "MaxyM" <marekpow@email.hinet.hr>
Subject: Matching problem
Message-Id: <953cp6$5jar$1@as121.tel.hr>

I have data stored in one file and let's say that content is:
Mark Johnson
John M
Marcy Darcy, etc..


$name is equal to John.
I use expression: if (/$name/) {..} etc..

This is working fine, until we have words that are like this above, and then
result naturaly is:

Mark Johnson
John M

The result should be only:
John M.

How to improve this?







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

Date: Mon, 29 Jan 2001 09:35:43 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Matching problem
Message-Id: <slrn97aebf.2q0.bernard.el-hagin@gdndev25.lido-tech>

On Mon, 29 Jan 2001 10:22:03 +0100, MaxyM <marekpow@email.hinet.hr>
wrote:
>I have data stored in one file and let's say that content is:
>Mark Johnson
>John M
>Marcy Darcy, etc..
>
>
>$name is equal to John.
>I use expression: if (/$name/) {..} etc..
>
>This is working fine, until we have words that are like this above, and then
>result naturaly is:
>
>Mark Johnson
>John M
>
>The result should be only:
>John M.
>
>How to improve this?

Read about \b in:

perldoc perlre

Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'


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

Date: Mon, 29 Jan 2001 09:58:00 +0100
From: Abraham S. Lin <md5.bbs@bbs.ntu.edu.tw>
Subject: New Perl Book.
Message-Id: <a0ca7tceoc6git4rrko747634kmfaklrii@4ax.com>

Hi,
Has anyone read the new Programming Perl Version 3?
How is it different from Version 2?

Thanks/SL



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

Date: Mon, 29 Jan 2001 05:03:39 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: New Perl Book.
Message-Id: <comdog-C89458.05033929012001@news.panix.com>

In article <a0ca7tceoc6git4rrko747634kmfaklrii@4ax.com>, Abraham S. Lin 
<md5.bbs@bbs.ntu.edu.tw> wrote:

> Has anyone read the new Programming Perl Version 3?
> How is it different from Version 2?

it is updated for Perl 5.6.0 which is about 5 years worth of
new material.

-- 
brian d foy <comdog@panix.com>



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

Date: Mon, 29 Jan 2001 00:13:29 -0800
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Passing object reference, while parsing XML
Message-Id: <953863$kulc$1@newssvr06-en0.news.prodigy.com>

Hi All,

Using DOM module  I am trying to write a function that would basically
return the text associated with an element node.
At the last line of the calling program I get the following error:
Can't call method "getFirstChild" without a package or object reference at
 ...

This error refers to the getFirstChild call in the sub-routine. From the
error message, it looks like I am not passing the object reference
correctly. Those who are familiar with DOM module or object-oriented
features of Perl, please give me some directions to fix this problem.

Basically, I want to pass an element node to a sub-routine and process it to
extract the text value.

Thanks in advance
Thomas.

#Calling program
my $nodes= $doc->getElementsByTagName ($tag);
my  $xx = $nodes->item (0);
my $val = getElementValue($xx);

#sub-routine
sub getElementValue {

  my $xx = @_;
  my $nodexx = $xx->getFirstChild;   ######ERROR HAPPENS HERE

  while (defined $nodexx)  {

     if ($nodexx->getNodeType == 3)   { #TEXT_NODE
        my $val = $nodexx->getData;
        return ($val);
     }

     $nodexx = $nodexx->getNextSibling;
  }

  return undef;
}




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

Date: Mon, 29 Jan 2001 11:02:44 +0000
From: Matt Sergeant <matt@sergeant.org>
Subject: Re: Passing object reference, while parsing XML
Message-Id: <3A754DD4.6010402@sergeant.org>

Thomas Theakanath wrote:

> Hi All,
> 
> Using DOM module  I am trying to write a function that would basically
> return the text associated with an element node.
> At the last line of the calling program I get the following error:
> Can't call method "getFirstChild" without a package or object reference at
> ...
> 
> This error refers to the getFirstChild call in the sub-routine. From the
> error message, it looks like I am not passing the object reference
> correctly. Those who are familiar with DOM module or object-oriented
> features of Perl, please give me some directions to fix this problem.
> 
> Basically, I want to pass an element node to a sub-routine and process it to
> extract the text value.
> 
> Thanks in advance
> Thomas.
> 
> #Calling program
> my $nodes= $doc->getElementsByTagName ($tag);

It seems likely that the above is returning an empty nodelist. You 
should test for that.
Matt.



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

Date: Mon, 29 Jan 2001 08:43:30 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: passing parameter
Message-Id: <slrn97abam.nnf.rgarciasuarez@rafael.kazibao.net>

Bin - Lu wrote in comp.lang.perl.misc:
> ...
> 
> When calling the Perl cgi file, I have:
> http://..../image.pl?image.x=244&image.y=164

Use the CGI module to get the parameters. CGI is standard, distributed
with Perl, and its extensive documentation is also included.

Short example code:

use CGI;
my $q = new CGI;
my $x = $q->param('x');
my $y = $q->param('y');
print <<EOF
Content-Type: text/plain

Image x is $x
Image y is $y
EOF;

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: 29 Jan 2001 08:01:57 GMT
From: "Jerome" <jmeyer@pax.ch>
Subject: Perl script for Cisco
Message-Id: <01c089c9$f991fd20$152810ac@C1994>


I have some Cisco Router and Switch and I want to configure it or see the
show command but without a simple telnet.
I want to use a perl script for configure it or to show me the statistic!

Do anyone know what perl's module or perl's command I must to use to access
my router?
Is really possible to make that??

Thank for your help,
J. Meyer



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

Date: Mon, 29 Jan 2001 10:24:46 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Perl script for Cisco
Message-Id: <Oxbd6.1608$GF2.52875@eagle.america.net>

On 29 Jan 2001 08:01:57 GMT, Jerome <jmeyer@pax.ch> wrote:
>
>I have some Cisco Router and Switch and I want to configure it or see the
>show command but without a simple telnet.
>I want to use a perl script for configure it or to show me the statistic!
>
>Do anyone know what perl's module or perl's command I must to use to access
>my router?
>Is really possible to make that??

  Net::Telnet

or 

  SNMP

-- 
Garry Williams


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

Date: 29 Jan 2001 10:13:27 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Receive email with attachments
Message-Id: <slrn97agi5.bj1.vek@pharmnl.ohout.pharmapartners.nl>

On Sat, 27 Jan 2001 13:51:00 GMT, Antonio <antios@libero.it> wrote:
>Hi all!
>I'm searching a perl module that allow me to send and receive email with
>attachments.
>I have searched on cpan.org but i don't find that module!
>Help me,
>Antonio
>
>


Keyword: MIME



Villy


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

Date: Mon, 29 Jan 2001 08:14:30 GMT
From: jdallega@my-deja.com
Subject: single quotes in a system call
Message-Id: <9538p4$8ib$1@nnrp1.deja.com>

Can somebody please help?

I'm trying to use the system call, but it fails when I have single
quotes in it e.g.

   system('find . -name 'foo*' -mtime -1 -print');

The following also failed on a particular directory I was trying to
read:-

   foreach $file (<*>)

And glob doesnt work either - in fact both glob and foreach, return the
same error :- "blah ... there was an internal error while using glob
blah ... CHUNK blah ..."

In any event, I would like to get the system call to work!

Thanks in advance

Justin


Sent via Deja.com
http://www.deja.com/


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

Date: Mon, 29 Jan 2001 10:45:10 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: single quotes in a system call
Message-Id: <WQbd6.1610$GF2.52925@eagle.america.net>

On Mon, 29 Jan 2001 08:14:30 GMT, jdallega@my-deja.com
<jdallega@my-deja.com> wrote:

>I'm trying to use the system call, but it fails when I have single
>quotes in it e.g.
>
>   system('find . -name 'foo*' -mtime -1 -print');

It's not failing because there's quotes in there, it's failing because
there's not enough quotes in there: 

  system('find', '.', '-name', 'foo*', '-mtime', '-1', '-print');

Or it will work with only two quotes in there: 

  system('find . -name foo* -mtime -1 -print');

The system call (sic) is rather picky that way.  But once you get used
to it, it works with no quotes: 

  system qw(find . -name foo* -mtime -1 -print);

>The following also failed on a particular directory I was trying to
>read:-
>
>   foreach $file (<*>)
>
>And glob doesnt work either - in fact both glob and foreach, return the
>same error :- "blah ... there was an internal error while using glob
>blah ... CHUNK blah ..."

Hmm.  Another question in one post?  

I've never seen that message before.  As a matter of fact, I couldn't
find it in the perldiag manual page.  But it might be a bug in your
operating system.  You might try upgrading to perl 5.6.0.  

-- 
Garry Williams


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

Date: 29 Jan 2001 01:36:56 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: substition problem
Message-Id: <puh6hnjr.fsf@pobox.com>

Peter <anon@anon.com> writes:

> > You didn't post your code, so there's no telling where you've gone
> > wrong.
> 
> Your news reader is probably trying to decode the HTML. It's there.

Incorrect, sir.  I can see the complete text of your OP.  There is no
Perl in it whatsoever.  There is only HTML.  My point is that if
you're having trouble with some Perl code, then you have to post the
section of Perl code that's giving you trouble.  Capice?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Mon, 29 Jan 2001 09:17:48 GMT
From: Christoph Singer <cs@ccss.de>
Subject: Re: Unicode and URL encoding
Message-Id: <953cfo$bt5$1@nnrp1.deja.com>

In article <952l6a$mi1$1@netnews.upenn.edu>,
  chenb@red.seas.upenn.edu (Benjamin Chen) wrote:
> Hi all,
>
>   Thanks for replying but what I really wanted to do was convert the
> unicode character representation of the form $#xxxx; using some sort
of
> function in Perl.

I posted a similar question yesterday and didn't get an answer yet
(maybe because I posted via deja and the message doesn't show my real
name but the deja username):
Does anybody know a function that converts decimal unicode values as
used in the &#xxx; entities to UTF-8?

Can anybody tell me how to write such a routine? I guess it should be
possible using Perl's "pack" function?

Any help appreciated,
Christoph

Benjamin, if you find a solution anywhere else please tell me, too!
(Post it here!)


Sent via Deja.com
http://www.deja.com/


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

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


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