[23931] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6132 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 14 06:05:40 2004

Date: Sat, 14 Feb 2004 03:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 14 Feb 2004     Volume: 10 Number: 6132

Today's topics:
    Re: => operator, not just fancy comma (Anno Siegel)
    Re: => operator, not just fancy comma <uri@stemsystems.com>
    Re: => operator, not just fancy comma <nospam-abuse@ilyaz.org>
    Re: => operator, not just fancy comma <uri@stemsystems.com>
    Re: configure, WIN32 <ceo@nospan.on.net>
    Re: Is Windows running <lv@aol.com>
    Re: Is Windows running <usenet@morrow.me.uk>
    Re: Optimization request <dwall@fastmail.fm>
    Re: Perl : Cant Find String Terminator <donnmelda@earthlink.net>
    Re: Perl usage these days? thumb_42@yahoo.com
    Re: Problems with version 5.8.0 on OS/2 <bart.lateur@pandora.be>
    Re: Reading html into a source file <nospam@bigpond.com>
    Re: Reading html into a source file <segraves_f13@mindspring.com>
        Sending HASH over TCP (Brad)
    Re: Sending HASH over TCP <usenet@morrow.me.uk>
    Re: Sending HASH over TCP <ceo@nospan.on.net>
        Symbolic Reference Problem <ihatespam@hotmail.com>
    Re: Symbolic Reference Problem <noreply@gunnar.cc>
    Re: Term::Prompt broken? Or am I misreading documentati (Daniel M. Drucker)
    Re: why do some mail servers treat perl generated mails <noreply@gunnar.cc>
    Re: why do some mail servers treat perl generated mails (David Efflandt)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 13 Feb 2004 23:20:19 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: => operator, not just fancy comma
Message-Id: <c0jm3j$ct3$1@mamenchi.zrz.TU-Berlin.DE>

Tad McClellan  <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> Matija Papec <perl@my-header.org> wrote:
> > 
> > Clearly, it tries to quote its left side 
> 
> 
> Just like the docs say it does:
> 
>    perldoc perldata
> 
> 
>       The C<< => >> operator is mostly just a more visually 
>       distinctive synonym for a comma, but it also arranges for 
>       its left-hand operand to be interpreted as a string--if 
>       it's a bareword that would be a legal identifier.

In the particular case there's a little more going on.  Matija pointed out
that autoquoting happens in

    @files = grep -d => @files;
    
where "-d" is clearly not a legal identifier.  "-" is treated specially
by "=>".  The rationale for this behavior has never been quite clear to me,
but Tk users would have a hard time without it.

Anno


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

Date: Fri, 13 Feb 2004 23:28:52 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: => operator, not just fancy comma
Message-Id: <x7r7wyv9sc.fsf@mail.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS> @files = grep -d => @files;
    
  AS> where "-d" is clearly not a legal identifier.  "-" is treated
  AS> specially by "=>".  The rationale for this behavior has never been
  AS> quite clear to me, but Tk users would have a hard time without it.

that is the rationale. the docs could use a tweak and state that => will
quote an identifier or one with a leading -. the 5.8 docs don't mention
the - which is a known feature but not documented AFAIK.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Sat, 14 Feb 2004 00:34:01 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: => operator, not just fancy comma
Message-Id: <c0jqdp$12la$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Uri Guttman 
<uri@stemsystems.com>], who wrote in article <x7r7wyv9sc.fsf@mail.sysarch.com>:
> >>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
> 
>   AS> @files = grep -d => @files;
>     
>   AS> where "-d" is clearly not a legal identifier.  "-" is treated
>   AS> specially by "=>".  The rationale for this behavior has never been
>   AS> quite clear to me, but Tk users would have a hard time without it.
> 
> that is the rationale. the docs could use a tweak and state that => will
> quote an identifier or one with a leading -. the 5.8 docs don't mention
> the - which is a known feature but not documented AFAIK.

In

  -d => @files

=> quotes the preceding identifier ``d'', resulting in

  -'d', @files.

Since -'d' is '-d', one gets an illusion that it is ``-d'' which is quoted.

Hope this helps,
Ilya


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

Date: Sat, 14 Feb 2004 01:05:11 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: => operator, not just fancy comma
Message-Id: <x7isiav5bt.fsf@mail.sysarch.com>

>>>>> "IZ" == Ilya Zakharevich <nospam-abuse@ilyaz.org> writes:

  IZ> -d => @files

  IZ> => quotes the preceding identifier ``d'', resulting in
  IZ> -'d', @files.

  IZ> Since -'d' is '-d', one gets an illusion that it is ``-d'' which is quoted.
that makes no sense at all. look at this:


perl -le '%h = ( -d => 3 ); print keys %h'
-d

your definition of - should not be part of the key string
there. something is grabbing the - into the string and it is =>.

and check this out in the source:

    case '-':
        if (s[1] && isALPHA(s[1]) && !isALNUM(s[2])) {
            I32 ftst = 0;

            s++;
            PL_bufptr = s;
            tmp = *s++;

            while (s < PL_bufend && SPACE_OR_TAB(*s))
                s++;

            if (strnEQ(s,"=>",2)) {
                s = force_word(PL_bufptr,WORD,FALSE,FALSE,FALSE);
                DEBUG_T( { PerlIO_printf(Perl_debug_log,
                            "### Saw unary minus before =>, forcing word '%s'\n"
, s);
                } )
                OPERATOR('-');          /* unary minus */
            }

so -word is special cased with =>. it is not some random side effect.
i recall it wasn't that way but the tk crowd and others wanted it since
they use -word for keys all the time.

  IZ> Hope this helps,

it didn't. sorry.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Sat, 14 Feb 2004 07:37:40 GMT
From: Chris <ceo@nospan.on.net>
Subject: Re: configure, WIN32
Message-Id: <8fkXb.34550$6p.32467@newssvr33.news.prodigy.com>

Torsten Mohr wrote:
> Hi,
> 
> i'd like to compile Perl on WIN32, i already did that by
> using the supplied Makefile for "nmake" and it went fine.
> 
> But i'd like to pass some additional parameters to the
> compile process.
> 

Is there some reason you've chosen to eliminate ActiveState Perl as a 
choice for Win32 Perl?  As hopeless as the Windows platform is, at least 
THAT package does provide more than reasonable service to Win32 users. 
It's "free," complete, powerful and pain-free to install...  I'd go so 
far as to say it's the de facto Perl standard on Win32 platforms.

Chris
-----
Chris Olive
chris -at- --___--___-- technologEase -dot- com
http://www.technologEase.com
(pronounced "technologies")


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

Date: Fri, 13 Feb 2004 21:58:28 -0600
From: l v <lv@aol.com>
Subject: Re: Is Windows running
Message-Id: <z1hXb.6675$5M.217701@dfw-read.news.verio.net>

Chris Arnott wrote:
> Hello and thanks for any help in advance.
> 
> I've written a perl script which connects to the machines in our domain and
> creates a software installed type report. The problem is some of our users
> have dual boot laptops, win2k/linux, and if the user is in linux the script
> fails.
> 
> So, does anyone know of a good way to determine if Windows is not the
> present operating system on a running machine.
> 
> Thanks,
> 
> Chris Arnott.
> 
> 
The dos command nbtstat -a remoteIpAddress would identify if windows was 
running.

Len



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

Date: Sat, 14 Feb 2004 04:17:27 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Is Windows running
Message-Id: <c0k7gn$ktn$1@wisteria.csv.warwick.ac.uk>


l v <lv@aol.com> wrote:
> Chris Arnott wrote:
> > So, does anyone know of a good way to determine if Windows is not the
> > present operating system on a running machine.
>
> The dos command nbtstat -a remoteIpAddress would identify if windows was 
> running.

Not if the remote machine was a unix box with samba running (not at
all unlikely in the given situation).

Ben

-- 
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based 
on the strictest morality.  [Samuel Butler, paraphrased]       ben@morrow.me.uk


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

Date: Sat, 14 Feb 2004 01:21:40 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Optimization request
Message-Id: <Xns948ECF20A6F39dkwwashere@216.168.3.30>

[posted and mailed]

ajs@ajs.com (Aaron Sherman) wrote:

> "David K. Wall" <dwall@fastmail.fm> wrote:
> 
>> The reason I responded to your post is because it seemed (and seems) to
>> criticize me and not my answer to the OP. I guess I tried too hard to
>> be polite and didn't make that point. 
> 
> If you heard me criticize YOU at any point, please quote it.

"b) when you answer someone's question, you might consider
answering the one they asked."

I did try to answer the one that was asked. My answer was wrong, you 
corrected me. No problem. If you had simply said "that's not what he 
asked" it wouldn't have bothered me. But I did "consider answering" the 
question that was asked, otherwise I wouldn't have posted. (Well, unless I 
had a related comment, but then I would have indicated in some way that it 
was just a comment and not intended to be an answer.)

> My distinction was on the difference between "which is faster" and
> "which would you expect to be faster". That's all. Nothing personal.

Ok, that's good enough for me. Thank you. 
 
>> Just drop it, ok? You convinced me the first time, I don't need yet
>> another sermon.
> 
> Ah, the old "this is the last word, so don't reply!" ;-)

No, it's just that I tried to tell you that, intentionally or not, you had 
offended me, and you responded with another sermon on Perl internals, 
something that I had no intention of disputing.



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

Date: Sat, 14 Feb 2004 00:59:56 GMT
From: "Donald LaFramboise" <donnmelda@earthlink.net>
Subject: Re: Perl : Cant Find String Terminator
Message-Id: <gqeXb.3121$WW3.2998@newsread2.news.pas.earthlink.net>

print<<HTML_RESPOSE

needs a semicolon at the end of the line, where the string terminator at the
end of your print statement does not.

"TP" <pin@purdue.edu> wrote in message news:402AAAEB.1080900@purdue.edu...
> i get the message Cant Find String Terminator anywhere before EOF
> everytime i try to compile my script..
>
> i hope someone will help
>
> thanks
>
> here is the code
>
> #!/usr/bin/perl
>
> use CGI;
> my($query);
> $query = new CGI;
>
>
> ##Configuration section
>
> $dbpath = 'db.txt';
>
> $searchwhat = $query->param("searchwhat");
> $searchkey = $query->param ("searchkey");
>
> ##end of configuration
>
> #Begin search section
>
> open (DB, "<$dbpath") or die ("$!\n");
>
> while (<DB>){
>     if ($searchwhat eq "all"){
>     if (/$searchkey/i){
>     push @matches, $_
> };
> }
>
> elsif ($searchwhat  eq "mtype"){
> ($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
> if ($mtype =~ /$searchkey/i){
>     push @matches, $_
> };
> }
>
> elsif ($searchwhat  eq "mname"){
> ($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
> if ($mname =~ /$searchkey/i){
>     push @matches, $_
> };
> }
>
> elsif ($searchwhat  eq "mactor"){
> ($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
> if ($mactor =~ /$searchkey/i){
>     push @matches, $_
> };
> }
>
> elsif ($searchwhat  eq "mactress"){
> ($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
> if ($mactress =~ /$searchkey/i){
>     push @matches, $_
> };
> }
>
> elsif ($searchwhat  eq "mdes"){
> ($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
> if ($mdes =~ /$searchkey/i){
>     push @matches, $_
> };
> }
> close(DB);
>
> #end of search section
>
> #start of response page
>
> $nummatches = @matches;
>
>
>
> print<<HTML_RESPOSE
>
> Content-type: text/html
> <HTML>
> <BODY>
>
> <h2>Your search for $searchkey return $nummatches matches.</h2>
>
>
> foreach $matchedEntry (@matches){
>   print "$matchedEntry\n";
> }
>
> </BODY>
> </HTML>
> HTML_RESPONSE
>




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

Date: Sat, 14 Feb 2004 10:04:57 GMT
From: thumb_42@yahoo.com
Subject: Re: Perl usage these days?
Message-Id: <dpmXb.303152$I06.3079925@attbi_s01>

H. Wade Minter <minter@lunenburg.org> wrote:
> thumb_42@yahoo.com wrote:
>> Just a curious question:
>> 
>> What is perl being used for these days?
>> 
>> Seems almost everything web related I see is PHP or Java. (mostly PHP)
>> 
>> My own experience is that Perl is wonderful for batch processing, command
>> line stuff, cron and specialized servers but compared to what is available
>> today, really doesn't seem suitable for serious web applications anymore.
>> 
>> So... what are people doing with it? is it still alive? Do people actually
>> get paid to work in perl, or is it strictly a labor of love?
> 
> I wrote a frontend for the audio system at an improv comedy club in Perl/Tk.
> It interfaces between a MySQL backend and an XMMS frontend, and runs under
> X11 or Win32.
> 
> http://www.lunenburg.org/mrvoice/
> 
> The great GUI bindings, combined with the vast module selection and Perl's 
> ease of use, let me get a very useful and functional app up and running in
> a short period of time.

Looks impressive. :-)

Do you have issues in distributing/installing it compared to say, a jar
file?

Both PHP and Perl have a lot of issues in making software hard to install.
I'd say they're about equal with perl just slightly better than PHP in terms
of installation of 3rd party applications. (perl PAR looks promising in this
regard to compete with java's .war files)

Jamie



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

Date: Sat, 14 Feb 2004 10:00:15 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Problems with version 5.8.0 on OS/2
Message-Id: <k8sr20989jtp01mpkfbhhv72mgdcqmcihg@4ax.com>

David Smith wrote:

>Is anyone out there running this version of Perl on OS/2?  I am trying to 
>install it (obtained from Hobbes), and am encountering some problems.
> 
>I have the following files
> 
>perl-5.8.0-bin-aout.zip
>perl-5.8.0-bin.zip
>perl-5.8.0-core.zip
>perl-5.8.0-doc.zip
> 
>and am unable to execute programs.  I believe my problem is with a 
>thing called @INC.  According to @INC, this version of Perl was built 
>with a target drive of L:.  I want to change this to D:.   If I 
>understand correctly, the PERLLIB_PREFIX  statement placed (as one 
>option) in the config.sys (which I have done) should override the 
>prebuilt target drive with one of my choosing.

That's not what I read. From the README:

	Set the Perl environment variables, the most important of which
	is PERL_LIBPATH. Its format is build/path; install\path. For
	example:

	set PERL_LIBBATH = L:/Perl/lib; X:\Perl\lib;

	where X is the drive on which you install Perl. This can be done
	either in config.sys or at a command prompt.

So: you seem to be setting the wrong environment variable for this
effect.

-- 
	Bart.


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

Date: Sat, 14 Feb 2004 10:59:57 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Reading html into a source file
Message-Id: <c0jrv9$1812hm$1@ID-202028.news.uni-berlin.de>

David K. Wall wrote:

> If you're running this as CGI under Apache this might be a problem.

I dont think he even realises he needs a web server to run it.

gtoomey


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

Date: Sat, 14 Feb 2004 05:20:21 GMT
From: "Bill Segraves" <segraves_f13@mindspring.com>
Subject: Re: Reading html into a source file
Message-Id: <peiXb.4320$W74.1355@newsread1.news.atl.earthlink.net>

"Gregory Toomey" <nospam@bigpond.com> wrote in message
news:c0jrv9$1812hm$1@ID-202028.news.uni-berlin.de...
> David K. Wall wrote:
<snip>
> I dont think he even realises he needs a web server to run it.

Hmmm. Runs fine here from MS-DOS Prompt window, *without* "a web server to
run it."

perl chris_13Feb2004.pl > c:\windows\desktop\chris.html

puts the target HTML on my desktop so I can launch it by simply
double-clicking on it. Here are the first few lines of output:

Content-Type: text/plain

 This is Content:

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html><!-- InstanceBegin template="/Templates/MainTemplate.dwt"
codeOutsideHTMLIsLocked="false" -->

<head>

 ...

Naturally, the OP might prefer to do something different, e.g. avoid
corrupting the target HTML.

IMO, a web server is not required for the OP to run his script. OTOH, a live
TCP/IP connection at the time he runs his script *is* required.

Although the OP's script works O.K. as is, I've made slight modifications,
especially to show missing, as well as superfluous code, e.g.,

#!/usr/local/bin/perl -w
use strict;
#print "Content-Type: text/plain\n\n";
use LWP::Simple;
my $content = get ("http://www.webbuyeruk.co.uk/index.htm");
print
#" This is Content:\n\n",
$content,
#" \n\n"
;
#exit;

Cheers.

Bill Segraves




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

Date: 13 Feb 2004 17:01:09 -0800
From: pj_sammie@hotmail.com (Brad)
Subject: Sending HASH over TCP
Message-Id: <2abd2946.0402131701.78b4d2d6@posting.google.com>

I have been working on this for a few days now, and still feel stuck.
I have a large HASH which I need to send via TCP to a server. I need
to use IO::Socket::INET for the TCP connection. While there is
probably a _better_ way, I have been playing around with Data::Dumper
convert the HASH, then rebuild it on the other end. The problem is I
cannot seem to rebuild the data.

Code:

Client (sending HASH)
---------------------
    use Data::Dumper;
    use IO::Socket::INET;

    $TEST{'test'}{'test1'} = 1;
    $TEST{'test2'}{'test3'} = 2;

    $socket = IO::Socket::INET->new(PeerAddr => localhost,
                                PeerPort => 2002,
                                Proto    => "tcp",
                                Type     => SOCK_STREAM)
    or die "Couldn't connect to $remote_host:$remote_port : $!\n";

    $Data::Dumper::Pair = " : ";       # specify hash key/value
separator
    $Data::Dumper::Indent = 0;
    # send something over the socket,
    print $socket Dumper(\%TEST);

    # and terminate the connection when we're done.
    close($socket);
---------------------

Server
---------------------
    use Data::Dumper;
    use IO::Socket::INET;

    $server = IO::Socket::INET->new(LocalPort => 2002,
                                    Type      => SOCK_STREAM,
                                    Reuse     => 1,
                                    Listen    => 10 )   # or SOMAXCONN
        or die "Couldn't be a tcp server on port $server_port: $!\n";

    while ($client = $server->accept()) {
        $data = <$client>;
        #print "$data\n";
        #$Data::Dumper::Pair = " : ";       # specify hash key/value
separator
        #$Data::Dumper::Indent = 0;
        #eval $data;
        print Dumper $data;
    }

    close($server);
---------------------

I have tried other methods of re-building the hash on the server-end.
The answer is probably right in front of me, but I just don't see it
on the module's page (
http://search.cpan.org/~ilyam/Data-Dumper-2.121/Dumper.pm ) or in the
perldoc.

Any help, or any ideas for a better solution, is appreciated.

Thanks,
Brad


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

Date: Sat, 14 Feb 2004 01:27:34 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Sending HASH over TCP
Message-Id: <c0jti6$i93$1@wisteria.csv.warwick.ac.uk>


pj_sammie@hotmail.com (Brad) wrote:
> I have been working on this for a few days now, and still feel stuck.
> I have a large HASH which I need to send via TCP to a server. I need
> to use IO::Socket::INET for the TCP connection. While there is
> probably a _better_ way, I have been playing around with Data::Dumper
> convert the HASH, then rebuild it on the other end. The problem is I
> cannot seem to rebuild the data.
> 
> Code:
> 
> Client (sending HASH)
> ---------------------
>     use Data::Dumper;
>     use IO::Socket::INET;
> 
>     $TEST{'test'}{'test1'} = 1;
>     $TEST{'test2'}{'test3'} = 2;
> 
>     $socket = IO::Socket::INET->new(PeerAddr => localhost,
>                                 PeerPort => 2002,
>                                 Proto    => "tcp",
>                                 Type     => SOCK_STREAM)
>     or die "Couldn't connect to $remote_host:$remote_port : $!\n";
> 
>     $Data::Dumper::Pair = " : ";       # specify hash key/value
> separator

Why? If you want to be able to eval it, you need to leave it as =>.

>     $Data::Dumper::Indent = 0;
>     # send something over the socket,
>     print $socket Dumper(\%TEST);
> 
>     # and terminate the connection when we're done.
>     close($socket);
> ---------------------
> 
> Server
> ---------------------
>     use Data::Dumper;
>     use IO::Socket::INET;
> 
>     $server = IO::Socket::INET->new(LocalPort => 2002,
>                                     Type      => SOCK_STREAM,
>                                     Reuse     => 1,
>                                     Listen    => 10 )   # or SOMAXCONN
>         or die "Couldn't be a tcp server on port $server_port: $!\n";
> 
>     while ($client = $server->accept()) {
>         $data = <$client>;
>         #print "$data\n";
>         #$Data::Dumper::Pair = " : ";       # specify hash key/value
> separator
>         #$Data::Dumper::Indent = 0;
>         #eval $data;
>         print Dumper $data;

You don't need to Dumper it *again*... also, ITY realise that as
you've taken out the eval it won't do owt?

>     }
> 
>     close($server);
> ---------------------
> 
> I have tried other methods of re-building the hash on the server-end.

I would strongly recommend using the Storable module, and the
functions nstore_fd and fd_retrieve. I have had success with this in
the past. Each fd_retrieve will get one whole structure, so you can
push several through the socket one after the other and they won't get
mixed up.

Ben

-- 
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t    # ben@morrow.me.uk
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.


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

Date: Sat, 14 Feb 2004 07:53:15 GMT
From: Chris <ceo@nospan.on.net>
Subject: Re: Sending HASH over TCP
Message-Id: <LtkXb.34554$Hq.6178@newssvr33.news.prodigy.com>

Brad wrote:
> I have been working on this for a few days now, and still feel stuck.
> I have a large HASH which I need to send via TCP to a server. I need
> to use IO::Socket::INET for the TCP connection. While there is
> probably a _better_ way, I have been playing around with Data::Dumper
> convert the HASH, then rebuild it on the other end. The problem is I
> cannot seem to rebuild the data.
> 
> Code:
> 
> Client (sending HASH)
> ---------------------
>     use Data::Dumper;
>     use IO::Socket::INET;
> 
>     $TEST{'test'}{'test1'} = 1;
>     $TEST{'test2'}{'test3'} = 2;
> 
>     $socket = IO::Socket::INET->new(PeerAddr => localhost,
>                                 PeerPort => 2002,
>                                 Proto    => "tcp",
>                                 Type     => SOCK_STREAM)
>     or die "Couldn't connect to $remote_host:$remote_port : $!\n";
> 
>     $Data::Dumper::Pair = " : ";       # specify hash key/value
> separator
>     $Data::Dumper::Indent = 0;
>     # send something over the socket,
>     print $socket Dumper(\%TEST);
> 
>     # and terminate the connection when we're done.
>     close($socket);
> ---------------------
> 
> Server
> ---------------------
>     use Data::Dumper;
>     use IO::Socket::INET;
> 
>     $server = IO::Socket::INET->new(LocalPort => 2002,
>                                     Type      => SOCK_STREAM,
>                                     Reuse     => 1,
>                                     Listen    => 10 )   # or SOMAXCONN
>         or die "Couldn't be a tcp server on port $server_port: $!\n";
> 
>     while ($client = $server->accept()) {
>         $data = <$client>;
>         #print "$data\n";
>         #$Data::Dumper::Pair = " : ";       # specify hash key/value
> separator
>         #$Data::Dumper::Indent = 0;
>         #eval $data;
>         print Dumper $data;
>     }
> 
>     close($server);
> ---------------------
> 
> I have tried other methods of re-building the hash on the server-end.
> The answer is probably right in front of me, but I just don't see it
> on the module's page (
> http://search.cpan.org/~ilyam/Data-Dumper-2.121/Dumper.pm ) or in the
> perldoc.
> 
> Any help, or any ideas for a better solution, is appreciated.
> 

Aside from Ben Morrow's solution (which I wish I had the time to try), 
if you are stuck on a "Dumper()" solution, you might get more mileage 
out of the XML::Dumper::pl2xml() and xml2pl() routines.  Write yourself 
a psuedo-web service that passes XML structures back and forth. 
pl2xml() and xml2pl() will handle this rightly.

Without digging into your code too much (seeing as it's way past my bed 
time) and surmising WHY you might be trying to accomplish this in the 
first place, you may even have your wants satisfied by tossing the 
structure passing altogether and writing a real web service using 
XML-RPC.  Check out Frontier::RPC2 for more information.  XML-RPC in 
Perl is painless to setup and quite powerful (though inherently insecure 
I have to admit).  You can setup XML-RPC on your port 2002 if you want.

Chris
-----
Chris Olive
chris 0at0 00-00-00 technologEase 0dot0 com
http://www.technologEase.com
(pronounced "technologies")


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

Date: Sat, 14 Feb 2004 00:44:52 -0800
From: BigDaDDY <ihatespam@hotmail.com>
Subject: Symbolic Reference Problem
Message-Id: <102rnur3pp6lc3f@corp.supernews.com>

Hi all,

I previously had some repetitive code that I wanted to simplify.  The code 
was of the following nature:

#!/usr/bin/perl

while (<>){

   if (/Display vara/){chomp($vara = <>)}
   if (/Display varb/){chomp($varb = <>)}
 .
more of the same repeated
 .
 .
 .

I tried to simplify this with

while (<>){

   @vars = (vara, varb);

   foreach $variable (@vars){

      if (/Display $variable/){

         chomp($$variable = <>);
      }
   }
}

However, when I use strict, I get an error because I am using a symbolic 
reference.  Does anyone know an easier way of doing this?  I was trying to 
keep all the variables in one place (in an array), so that if the variable 
names change, I only have to change them in the array.  Thank you very much 
for your help.

Matt



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

Date: Sat, 14 Feb 2004 10:38:35 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Symbolic Reference Problem
Message-Id: <c0kqmp$18rq98$1@ID-184292.news.uni-berlin.de>

BigDaDDY wrote:
> I previously had some repetitive code that I wanted to simplify.
> The code was of the following nature:
> 
> #!/usr/bin/perl
> 
> while (<>){
> 
>    if (/Display vara/){chomp($vara = <>)}

Are you sure you don't mean:

     if (/Display vara/){chomp($vara = $_)}
--------------------------------------^^

> I tried to simplify this with
> 
> while (<>){
>    @vars = (vara, varb);
>    foreach $variable (@vars){
>       if (/Display $variable/){
>          chomp($$variable = <>);
>       }
>    }
> }
> 
> However, when I use strict, I get an error because I am using a
> symbolic reference.

Yes, you do. Btw, you get other errors as well under strictures, don't
you?

> Does anyone know an easier way of doing this?

I'd replace the array and the scalar variables with a hash:

     my %vars;
     @vars{ qw/vara varb/ } = ();
     while (<>) {
         for my $key (keys %vars) {
             if (/Display $key/) {
                 chomp( $vars{$key} = $_ );
                 last;
             }
         }
     }

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 14 Feb 2004 00:34:52 -0800
From: dmd@3e.org (Daniel M. Drucker)
Subject: Re: Term::Prompt broken? Or am I misreading documentation?
Message-Id: <b804d06d.0402140034.6755fcf9@posting.google.com>

Bill <wherrera@lynxview.com> wrote in message news:<j4Sdnbvce-eWh7bdRVn-iQ@adelphia.com>...
> I'm pretty sure that the above is not a correct call of the 'prompt'
> function. Though why it behaves the way it does is unclear. What happens 
> if you add 'use strict'?

Not sure, as I got Term::Prompt version 0.12 (in the process of being
posted to CPAN - there's been a change of package ownership that's
delayed it), which fixed the problem.

Daniel Drucker


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

Date: Sat, 14 Feb 2004 00:34:35 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: why do some mail servers treat perl generated mails as Bulk
Message-Id: <c0jn9d$172nm5$1@ID-184292.news.uni-berlin.de>

KK wrote:
> Subject: why do some mail servers treat perl generated mails as
> Bulk

It has nothing to do with which program was used to compose the mail.

Malcolm explained that the IP address of the sending mail server may
be one explanation. Another possible explanation is the actual
composition of the message, that is used by some spam filtering
software to detect spam. You may for instance want to check
SpamAssassin's web site for criteria that they are using.

> what is the best way to mail the same mail to 10 different people?

State multiple comma separated addresses in the "To:" field.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Sat, 14 Feb 2004 00:29:08 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: why do some mail servers treat perl generated mails as Bulk
Message-Id: <slrnc2qquk.7sp.efflandt@typhoon.xnet.com>

On 13 Feb 2004 10:06:09 -0800, KK <kewlkarun@yahoo.com> wrote:
>   With Mail::Sender I could finally able to send mails from windows
> machine. However, when I use yahoo DSL HMTP mail server, my mails are
> considered Bulk Emails. Is there a way I can avoid this ?
>   Peon, just curious as to why cant I use these modules to post mails
> to employers? would they be detecting them as spam? if yes, how? what
> is the best way to mail the same mail to 10 different people? After
> all, programming should be practical!
> regards,
> -KK

The cw.net (Cable & Wireless) IP you posted from has no name in DNS (which
may be considered by some to be suspicious).  If your script is actually
sending from SBC Yahoo DSL, then I have info for configuring sendmail or
postfix for outgoing authenticated smtp.*.yahoo.com relays at
http://efflandt.freeshell.org/sbc-smtp-auth.html

But that assumes that your local smtp is working in general, and that your 
script uses it for sending.  Depending upon what you are sending and how 
it is formatted, there might be something else in it that still triggers 
it as bulk (like too many recipients, headers, or content).

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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