[17579] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4999 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 30 14:05:39 2000

Date: Thu, 30 Nov 2000 11:05:11 -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: <975611110-v9-i4999@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 30 Nov 2000     Volume: 9 Number: 4999

Today's topics:
    Re: adduser (Honza Pazdziora)
    Re: checking if mail address is valid <bart.lateur@skynet.be>
    Re: checking if mail address is valid (Sander van Gennip)
    Re: checking if mail address is valid <bart.lateur@skynet.be>
    Re: checking if mail address is valid nobull@mail.com
        force the browser to download instead of viewing the fi (Trung Mai)
    Re: HELP! flock problem on NFS mounted dev? chuckk@monmouth.com
    Re: How do I format my message string ? (Tad McClellan)
    Re: How do I format my message string ? <bart.lateur@skynet.be>
    Re: How to allow other uid process send a signal to my  nobull@mail.com
        how to print file to browser? <me@privacy.net>
    Re: how to print webpage into a *.html file? (Anno Siegel)
        INIT blocks (was Re: how do i direct compiler errors to <uri@sysarch.com>
        IO::Socket::INET::sockopt() syntax? <hbarta@enteract.com>
        Looking for utility to show execution path <sg@loralskynet.com>
    Re: Problems with base64 encoding/decoding <geoff-at-farmline-dot-com@127.0.0.1>
    Re: Problems with base64 encoding/decoding <kingviking@hotmail.com>
        re Perl CGI with pgp <19wlr@globalnet.co.uk>
        reading from <STDIN> simbean@my-deja.com
    Re: Regexp q (Tad McClellan)
    Re: Regexp q (Tad McClellan)
    Re: SNMP agent written in perl? <wjhardaker@ucdavis.edu>
        Sorting the result of a function <jrw32982@my-deja.com>
    Re: Tieing an object bdesany@my-deja.com
    Re: use of Net::Telnet (Honza Pazdziora)
        Using s/// to extract information <eT@quidel.com>
    Re: Using s/// to extract information <joe+usenet@sunstarsys.com>
    Re: working with lists of associative arrays (Honza Pazdziora)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 29 Nov 2000 14:05:50 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: adduser
Message-Id: <G4sHtq.qM@news.muni.cz>

On Wed, 29 Nov 2000 14:34:59 +0100, Per- Fredrik Pollnow <Per-fredrik.Pollnow@epk.ericsson.se> wrote:
> 
> Ok this is what the program is going to do:
> First the user run the program and enter all the information I need, thats
> no problem..
> The problem begins here:  when I got all the information I whant to crate an
> account with his name and a random password.
> The name I now erlier from the program, I don't whant the user to enter the
> password(the user gets an email with all the information and password later
> in the program).

If the problem is is generating random sequence, look up the perlfunc
documentation about rand. Module Data::Random::WordList may also be
usefull and so might be Crypt::Cracklib. If the problem is sending the
email, browser the CPAN for /mail/i and /mime/i.

Yours,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Thu, 30 Nov 2000 16:12:30 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: checking if mail address is valid
Message-Id: <rsuc2t0rngembq6d6ghfvbr0cvn0qea0ck@4ax.com>

Sander van Gennip wrote:

>This all looks wonderful, but when I upload a script trying to test
>this, I get the error 'Net::DNS not found in @INC'. (On our intranet
>we have ActivePerl, but it doesnt have Net::DNS either). Nor can I
>find anything on this package in 'Perl in a Nutshell'.  :-(

It isn't installed, then. You can get it from CPAN:
<http://search.cpan.org/search?dist=Net-DNS>

-- 
	Bart.


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

Date: Thu, 30 Nov 2000 16:20:55 GMT
From: sander@veenhoven.com (Sander van Gennip)
Subject: Re: checking if mail address is valid
Message-Id: <3a2b7dee.29555278@news.xs4all.nl>

On Thu, 30 Nov 2000 16:12:30 GMT, Bart Lateur wrote:

>It isn't installed, then. You can get it from CPAN:
><http://search.cpan.org/search?dist=Net-DNS>

Yeah, i thought of that myself of course. This probably would work on
our intranet, but we don't host the scripts. Our provider does, and I
don't think I am allowed to install packages. I have to work with
what's available.

greetings,
Sander


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

Date: Thu, 30 Nov 2000 16:53:47 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: checking if mail address is valid
Message-Id: <7c1d2tkf9bop97dcg9aq7k2n922ru225ap@4ax.com>

Sander van Gennip wrote:

>>It isn't installed, then. You can get it from CPAN:
>><http://search.cpan.org/search?dist=Net-DNS>
>
>Yeah, i thought of that myself of course. This probably would work on
>our intranet, but we don't host the scripts. Our provider does, and I
>don't think I am allowed to install packages. I have to work with
>what's available.

It doesn't require installation, AFAI can tell. It looks like it's all
plain Perl code. It could be that all you need to do is decompress the
archive, get the proper subtree, and put it in a custom directory for
libraries. Then, all you need to do is

	use lib '/my/custim/lib/path';

at the top of your script.

See also, the FAQ, perlfaq8:

  How do I keep my own module/library directory?

-- 
	Bart.


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

Date: 30 Nov 2000 18:22:53 +0000
From: nobull@mail.com
Subject: Re: checking if mail address is valid
Message-Id: <u9bsuxnwua.fsf@wcl-l.bham.ac.uk>

Is it just me or since the "FAQ server" autoposts started up again has
the number of people posting questions that are almost verbatim out
the the FAQ actually increased?

sander@veenhoven.com (Sander van Gennip) writes:

> i am trying to check if a mail address is valid from perl.

See FAQ: "How do I check a valid mail address?"

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 30 Nov 2000 18:44:06 GMT
From: tmai@prince.carleton.ca (Trung Mai)
Subject: force the browser to download instead of viewing the file.
Message-Id: <90675m$fbb$1@bertrand.ccs.carleton.ca>


Hi
 I want to have a link in perl which will force the browser to download
the file. I'v a link <a href="http://link.com/linktofile/files.zip"> this
will do only if the file is zip,gzip,rar,... However, if the file is
file.txt the browser won't download. It's display the file. 
 I think I have to do some thing with the MINE type, but I don't know
how.. please help??

thanks.


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

Date: Thu, 30 Nov 2000 18:31:46 GMT
From: chuckk@monmouth.com
Subject: Re: HELP! flock problem on NFS mounted dev?
Message-Id: <9066ei$fa1$1@nnrp1.deja.com>

Hmmm,

I've heard of the mkdir idea before, but not this create link scheme...
interesting idea.

To resolve the stale lock problem - how about:

the mkdir or link you create has a time_stamp as part of the name (e.g.
mkdir mylock_HHMMSS_PID). Programs looking for the lock file, check for
mylock_* and check the time stamp. You could set a max valid time for
the lock to be considered valid, and ignore and delete it if the time
limit is past?

Just an idea.

Chuck



In article <905skf$o4s$1@lublin.zrz.tu-berlin.de>,
  anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> Henry_Barta  <hbarta@enteract.com> wrote in comp.lang.perl.misc:
>
> [when flock() isn't available]
>
> >    For a situation like this, could directory creation/deletion
> >    be used as a pseudo-lock? The scheme I'm thinking of would be:
> >
> >	Create directory. If not successful, delay and retry or
> >	conclude failure.
> >
> >	Do whatever is controlled by the 'lock'.
> >
> >	Remove the directory.
> >
> >    I believe this has been used in other situations where reliable
> >    locking is not available. It will work if directory creation
> >    is atomic. (e.g. success guarantees that another process has not
> >    and now cannot create the same directory.)
>
> Yes, that, or creating a hard link (with a given name) to an existing
> file.  That's another way of using the file system for a test-and-set
> operation.  Both are supposedly atomic in the sense that they are
> accomplished in a single system call.  The mkdir solution may be
> marginally slower (it creates two hard links in addition to the new
> directory), but that's a small concern.
>
> Both methods have been known as the poor man's lock for a long while.
> Both have the drawback that they create a file which can potentially
> survive the process that has created it.  Careful catching of signals
> and a suitable END block can help, but kill -9 is a sure way to create
> a permanent lock.  That's why flock() is preferable where available.
> It locks file handles, which are reliably returned to the system when
> a process ends.
>
> Anno
>


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


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

Date: Thu, 30 Nov 2000 10:17:05 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How do I format my message string ?
Message-Id: <slrn92crrh.6qd.tadmc@magna.metronet.com>

Jack Altradmon <gjchap99@my-deja.com> wrote:

>$message =<<'END_OF_MESSAGE'
             ^              ^
             ^              ^

>and use this string I get my formatted message but no substitution.


Single quoted strings do not do interpolation.

So use a double quoted string:

   $message =<<"END_OF_MESSAGE";

or, since it defaults to double-quotish anyway:

   $message =<<END_OF_MESSAGE;


>Is there any way I can convert the 1st string into the 'HERE' document
>style above programmatically with variable substitution etc..


Yes, just as it says in the description of here-docs in perldata.pod...


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


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

Date: Thu, 30 Nov 2000 17:58:31 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How do I format my message string ?
Message-Id: <da5d2t0utp370ugjfq7bgnpinhpo581btj@4ax.com>

Jack Altradmon wrote:

>However if I do something like this as a test :
>
>$message =<<'END_OF_MESSAGE'
 ...

>and use this string I get my formatted message but no substitution.

Of course not. You want:

	$message =<<"END_OF_MESSAGE"

(double quotes)

-- 
	Bart.


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

Date: 30 Nov 2000 18:00:28 +0000
From: nobull@mail.com
Subject: Re: How to allow other uid process send a signal to my uid process?
Message-Id: <u9d7fdnxvn.fsf@wcl-l.bham.ac.uk>

"Seednet News" <juhh@ms12.url.com.tw> writes:

> I'm looking for a method to allow other colleague's process
> send a signal to my process.

Several different mecahnisms for interprocess communications in Perl
are discussed in the perlipc manual.

You probably want to be using a named pipe or socket.

BTW: This exact same question has already been discussed here less
than a week ago.  You seem to think the correct use of Usenet is:

  Think of question -> post question -> get answers

You are wrong the correct use of usenet is:

  Think of question -> read manual -> read FAQ -> search newsgroup ->
  refine question -> post question -> get answers

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 30 Nov 2000 18:37:06 GMT
From: "EM" <me@privacy.net>
Subject: how to print file to browser?
Message-Id: <m7xV5.6064$Nw6.20379@news.iol.ie>

i would like to know how to open a file say /home/me/file.zip and print it
out browser for download
but i need to do this without first having to open the file into the server
memory because it could be very big
and it cant be a redirect either because the user must not know the true
location of the file

Thanks in advance
Eric




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

Date: 30 Nov 2000 17:45:51 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how to print webpage into a *.html file?
Message-Id: <9063of$obd$1@lublin.zrz.tu-berlin.de>

Ed Grosvenor <secursrver@hotmail.com> wrote in comp.lang.perl.misc:
>Of course, if you have to both save the HTML file and print it, here's what
>you can do...
>
>$htmlFile = "whatever.html";

Hmmm... You are apparently not expecting to run under strict.  If
you do that in example code, you should advise readers that you are
simplifying, and that a real program would have to say "my $htmlfile...".

>open (OUT, "+>$htmlFile") || die "Failed to open $htmlFile ($!)";

Why are you opening the file in read/write mode?

>#the previous line assumes you want to create a NEW file.  To re-write an
>existing file, use > instead of +>.

Oh... you are confused about the difference of ">" and "+>".  Read
up on it.

>print OUT "<html>Blah blah blah</html>";
>close OUT;
>#now open the file you just wrote and display it...
>open (OUT, "$htmlFile") || die "Failed to display $htmlFile ($!)";
>while (<OUT>)    {
>    $line = (<OUT>);

That's a funny way of assigning a scalar, though it works.  It is
also the reason why the program as a whole doesn't work.

>    print $line;
>    }
>close OUT;
>
>That's about all there is to that.

 ...if sending every other line to the browser is what you want.  Please,
if you give advice here, test your code before posting.  This doesn't
do what you say it does.

Anno


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

Date: Thu, 30 Nov 2000 16:44:25 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: INIT blocks (was Re: how do i direct compiler errors to a file-newbie)
Message-Id: <x7vgt59zpz.fsf_-_@home.sysarch.com>

>>>>> "RS" == Roman Stawski <roman.stawski@fr.adp.com> writes:

  RS> Bart Lateur wrote:
  >> 
  >> The requirement is that this BEGIN block should be in front of your
  >> error. Perl compiles sequentially, and executes a BEGIN block as soon as
  >> it is compiled. Yes, that does mean, before the rest of the script is
  >> compiled.
  >> 
  >> How else would you ever expect pragma's to work? (pragma = "module" that
  >> changes the behaviour of the compiler)

  RS> Yes, I use BEGIN blocks regularly for compile time initialisation, and 
  RS> occasionally debugging. It's just the idea of using the mechanism to
  RS> redirect the compiler output never occurred to me.

look into using INIT blocks for initialization. they are executed after
all compilation is done but before any main line code is
executed. basically INIT blocks run between the compile time and run
time phases.

why use INIT over BEGIN? what if you do some heavy or stateful
initilization that you don't want to do if there is any compile issues
elsewhere? a BEGIN block will execute even if there are syntax errors
later in the file (or any includede file). another case is where you do
some init work and that calls subs that are defined later in the source
or included later. INIT will work as all the code is compiled first
where as BEGIN would fail.

also the name is more descriptive than BEGIN for actual initialization
code. i put INIT blocks near the data structures and subs that do the
work.

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: 30 Nov 2000 17:13:44 GMT
From: Henry_Barta <hbarta@enteract.com>
Subject: IO::Socket::INET::sockopt() syntax?
Message-Id: <9061s8$n9j$1@bob.news.rcn.net>

    Is this the correct syntax for sockopt():

my $sock;
do
{
    $sock = IO::Socket::INET->new(Listen    => 5,
				 LocalPort => $port,
				 Proto     => 'tcp');
    sleep 10
	if !defined $sock;
} unless( defined $sock )
$sock->sockopt(SO_REUSEADDR, 1 );


    This code still produces the error
    "IO::Socket::INET: Address already in use at ..."
    If I kill and immediately restart the program.

    applicable section from the man page is:

     sockopt(OPT [, VAL])
         Unified method to both set and get options in the
         SOL_SOCKET level. If called with one argument then
         getsockopt is called, otherwise setsockopt is called.

    This is on Solaris with Perl 5.005_02 and
    IO::Socket 1.16.

    Thanks,



-- 
Hank Barta                            White Oak Software Inc.
hbarta@enteract.com                   Predictable Systems by Design.(tm)
		Beautiful Sunny Winfield, Illinois


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

Date: Thu, 30 Nov 2000 14:03:30 -0500
From: Stephan Gross <sg@loralskynet.com>
Subject: Looking for utility to show execution path
Message-Id: <pg8d2t0c7vsvvdcp7bhlle8lj0855qm5ub@4ax.com>

Is there a utility that will look through my source code and pull out
all subroutines, telling me which will get executed in what order?
For example, something like this:

Main------|
           sub1
           sub5-----|
                         sub3
           sub4
           sub17

etc.

================================================================
Stephan Gross          Loral Skynet           sg@loralskynet.com
Senior Software Engineer                      908-470-2388


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

Date: Thu, 30 Nov 2000 16:57:57 -0000
From: "Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1>
Subject: Re: Problems with base64 encoding/decoding
Message-Id: <9060tv$oac$1@soap.pipex.net>

"VikingKing" <kingviking@hotmail.com> wrote in message
news:t2ct5sh363ukf8@news.supernews.com...
: It seems that the sample "newPassword" has a NULL value (ASCII 0) after
each
: character when decoded using the library above.  The result I get when
: decoded with the MIME::Base64::decode() function is:
: "n\0e\0w\0P\0\a\0\s\0s\0w\0o\0r\0d\0".
:
: This value when base64 encoded is:  IgBuAGUAdwBQAGEAcwBzAHcAbwByAGQAIgA=
: The string "newPassword" when encoded is: Im5ld1Bhc3N3b3JkIg==
:
: Does anyone know what is going on here?  Where are these null values
coming
: from?

Unicode string?

Geoff




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

Date: Thu, 30 Nov 2000 11:14:41 -0600
From: "VikingKing" <kingviking@hotmail.com>
Subject: Re: Problems with base64 encoding/decoding
Message-Id: <t2d2o5s7ssb781@news.supernews.com>

> : Does anyone know what is going on here?  Where are these null values
> coming
> : from?
>
> Unicode string?
>

I have found some references to a "unicode string" in my web searches on a
solution here, but I am not sure how to handle this.  (I am not that
familiar with this encoding/decoding stuff.)  Do you have any
recommendations?

How can I translate it to its "normal" state via Perl?

Thanks,
VK




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

Date: Thu, 30 Nov 2000 16:19:27 -0000
From: "John Plaxton" <19wlr@globalnet.co.uk>
Subject: re Perl CGI with pgp
Message-Id: <905uou$pjh$1@gxsn.com>

Hi there

Does anyone know of any web tutorials for encrypting emails with pgp. I've
almost got things working but I am getting a no body text sent through.

$pgppath is something like '/home/www/.pgp' where I have the pubring.

$pgpe is  '/bin/pgp';

and $destname is my email address

sub pgp_email_to_availcheck {
        $ENV{'PGPPATH'}= $pgppath;

         my $pgpargs;

        $pgpargs = "-fea $destname";

open PGP, "| $pgpe $pgpargs | mail -s 'Encrypted transaction' $destname";

print PGP "Credit Card Transaction - \n";
print PGP "BLA BLA \n";
print PGP "BLA BLA \n";

close PGP;

Any answersgratefully received

john




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

Date: Thu, 30 Nov 2000 17:48:41 GMT
From: simbean@my-deja.com
Subject: reading from <STDIN>
Message-Id: <9063tm$cub$1@nnrp1.deja.com>

Hi all,

I stumbled over another problem. This might be really easy for you, but
I just cannot figure out how to do it:

All I want to do is have a non-blocking read from <STDIN>.

How do I do that??


Ciao,
René.


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


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

Date: Thu, 30 Nov 2000 10:08:04 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Regexp q
Message-Id: <slrn92crak.6qd.tadmc@magna.metronet.com>

Adrian Clark <adrian.clark@baesystems.com> wrote:
>
><nobull@mail.com> wrote in message news:u9elztoabj.fsf@wcl-l.bham.ac.uk...
>> "Adrian Clark" <adrian.clark@baesystems.com> thinks it is acceptable
>> to post without reading the FAQ.  He is wrong:
>
>For what it's worth, I did read the FAQs.  


You should say that then when asking about a FAQ.

We can't know what you have looked at if you don't tell
us what you have looked at.


>It was in translating it into a perl script file that I couldn't get it to
>work (because I failed to use the $/ trick, so I was still only looking at a
>single line, despite using the /s modifier in the regexp).
              ^^^^^^^

I wonder why people expect that modifier to change what
gets loaded into the string-to-be-matched-against.

It is a very common misconception.

The first thing I say when teaching pattern matching is:

   When a pattern match is not working as you expect, there
   are *two* things to consider: the pattern that you are
   trying to match, and the string that you are trying to
   match against.

People seem to give exclusive consideration to the "pattern"
part and never think to examine the string that it is to
match against.

To do multi-line pattern matching you need 2 things:

   a multi-line pattern

   a multi-line string to match against.


>I apologise if I wasted anybody's time.


Maybe someone will think of both parts the next time a patmat
is doing something "unexpected" due to reading this thread.

In which case, you may have _saved_ some people's time :-)


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


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

Date: Thu, 30 Nov 2000 10:12:16 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Regexp q
Message-Id: <slrn92crig.6qd.tadmc@magna.metronet.com>

Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote:

>Try setting the variable $/ to an empty value (perldoc perlvar for more
>info on this variable):
>

>$/ = '';


That would not work with:

------------------------
/* a comment with

   a blank line in it */
------------------------


Setting $/ to the empty string sets "paragraph mode" where
chunks are determined by blank line(s).

You don't want that here.

Setting $/ to undef sets "slurp mode" where you get the entire
file in a single read.


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


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

Date: 28 Nov 2000 13:09:30 -0800
From: Wes Hardaker <wjhardaker@ucdavis.edu>
Subject: Re: SNMP agent written in perl?
Message-Id: <sdlmu3ls6t.fsf@wanderer.hardakers.net>

>>>>> On Mon, 27 Nov 2000 17:51:46 -0600, Mike Eggleston <mikeegg@prodigy.net> said:

Mike> Looking at the net-snmp source this weekend it looks like if
Mike> #ifdef's were used in main() to initialize libperl.a and in
Mike> receive() that perl could be embedded inside net-snmp without
Mike> much effort and with *much* gain. Registering perl functions
Mike> with the alarm function so that modules can receive timed
Mike> callbacks then the monitoring functions can be merged with
Mike> recovery functions.

That *also* has been on my todo list...

-- 
Wes Hardaker
NAI Labs
Network Associates


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

Date: Thu, 30 Nov 2000 17:08:05 GMT
From: John Wiersba <jrw32982@my-deja.com>
Subject: Sorting the result of a function
Message-Id: <9061hd$anr$1@nnrp1.deja.com>

How can I sort the (list) result of a function without assigning it to a
temporary variable?  Why doesn't sort produce the expected result in
the following command?

   perl -e 'sub f { (3,2,1) } @a = sort   f() ; print "@a\n"'

--
John Wiersba


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


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

Date: Thu, 30 Nov 2000 16:19:15 GMT
From: bdesany@my-deja.com
Subject: Re: Tieing an object
Message-Id: <905ulp$801$1@nnrp1.deja.com>


> You don't appear to be as much the novice as you give yourself
> credit for. ;-)  Tie is probably not the word that you mean though.
> Serialize, freeze or marshal might be more 'Computer Science' words
> for what you are taling about.

> I'm not familiar with how Graph::Undirected is implemented.  If
> you 'use Data::Dumper" and then 'print Dumper($G)' do you get a
> dump of the structure of the $G object?  If you do then it might
> be possible to preserve it in an MLDBM file.  If you get just a
> blessed scalar or a blessed CODE object then the persistence will
> have to be added inside the Graph::Undirected class.

I know just enough about Perl's capabilities ask more questions. Since
I can't answer any of them, I'd say I'm very much a novice. :)

I can serialize the object with Data::Dumper and store it as a file,
and I can successfully recreate it by issuing 'do "file";' (learned
this from Effective Perl Programming). What I'd like to do is recreate
it such that the recreated object is actually still on the disk,
because it takes up so much memory. Or better yet just create it as an
_accessible_ data structure on the disk in the first place. (This is
why I thought "tie" might be part of the solution, since to my
understanding that's what you use to make (some kinds of) hashes reside
on disk instead of in memory.)

So I'm guessing the Graph::Undirected method I am using (and I am only
using one method) would need to be _unknowingly_ redirected to
operating on data on disk rather than data in memory.

Would this be as simple as creating an interface between the object and
MLDBM or would it require reengineering one or the other?
And if I could build an adaptor, what would its design requirements
consist of?

Is this a deceptively simple problem, or a hopelessly large one? :)

-Brian.


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


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

Date: Wed, 29 Nov 2000 14:02:11 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: use of Net::Telnet
Message-Id: <G4sHnn.KCu@news.muni.cz>

On Wed, 29 Nov 2000 13:19:01 +0100, Lex Hagen <l.hagen@HumanInference.com> wrote:
> 
> I'm really new to Perl. And have to use the Net::Telnet module, but
> don't really know how. Maybe someone can send me a short example on how
> to use the Net::Telnet module. (e.g. a piece of code that connects to a
> remote machine, loggs in, etc.)

Look what I've found for you by merely looking to the top of
Net::Telnet documentation:

         use Net::Telnet ();
         $t = new Net::Telnet (Timeout => 10,
                               Prompt => '/bash\$ $/');
         $t->open("sparky");
         $t->login($username, $passwd);
         @lines = $t->cmd("/usr/bin/who");
         print @lines;

Yours,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Thu, 30 Nov 2000 18:24:51 GMT
From: eT <eT@quidel.com>
Subject: Using s/// to extract information
Message-Id: <906617$f22$1@nnrp1.deja.com>

Greetings - I am currently using the following code to extract a zip
code:

 if ($address1 =~ m/(\d{5}\-\d{4})/) {
   ($zip) = ($1);
 }


My question is, can I replace the m/// with s/// in the same way to not
just extract the zip code from $address1, but also to remove the zip
code from $address1:

 if ($address1 =~ s/(\d{5}\-\d{4})//) {
   ($zip) = ($1);
 }

My problem is that the above does not seem to work, i.e. the $zip string
is empty after the above condition.  I would prefer not to use substr().


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


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

Date: 30 Nov 2000 13:47:54 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Using s/// to extract information
Message-Id: <m3g0k9uwit.fsf@mumonkan.sunstarsys.com>

eT <eT@quidel.com> writes:

> My question is, can I replace the m/// with s/// in the same way to not
> just extract the zip code from $address1, but also to remove the zip
> code from $address1:
> 
>  if ($address1 =~ s/(\d{5}\-\d{4})//) {
>    ($zip) = ($1);
>  }
> 
> My problem is that the above does not seem to work, i.e. the $zip string
> is empty after the above condition.  I would prefer not to use substr().

"-" doesn't need to be escaped outside a [] block, so your code 
could be written

  if ($address1 =~ s/(\d{5}-\d{4})//) {
        $zip = $1; 
  }

Why not post working code + output (including warnings) to show when 
it doesn't work? This saves everyone the trouble of trying to guess 
how you got it not to work, and you might even figure it out yourself 
before posting it.

HTH
-- 
Joe Schaefer


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

Date: Wed, 29 Nov 2000 14:00:37 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: working with lists of associative arrays
Message-Id: <G4sHL1.Iws@news.muni.cz>

On Wed, 29 Nov 2000 12:04:19 GMT, jim crawford <pfister_@mindspring.com> wrote:
> 
> Another tangible problem, possibly related for all I know, is that
> this doesn't work:
> sub sortentries #($field)
> { @data=sort { $a{$_[0]} cmp $b{$_[0]} } @data;
> }

$a{key} is a value of one element in hash %a. And sort block is passed
in scalars $a and $b. If you want element in a hash referenced by
scalar $a, use $a->{key}.

Hope this helps,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
   .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

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


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