[24396] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6584 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 19 18:10:48 2004

Date: Wed, 19 May 2004 15:10:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 19 May 2004     Volume: 10 Number: 6584

Today's topics:
        perl tcp server script works, but no data. (Eli Sidwell)
    Re: perl tcp server script works, but no data. <jgibson@mail.arc.nasa.gov>
        Perl vs PHP <porter970@lycos.com>
    Re: Perl vs PHP <wappler@gmx.net>
    Re: print all combinations (Chris Charley)
        problem with references <bornslippy.SPAM.IS.NOT.OK@o2.pl>
        Regular Expressions Help! (Leo Shumacher)
    Re: rmdir Question <tadmc@augustmail.com>
    Re: rmdir Question <gnari@simnet.is>
    Re: rmdir Question <tadmc@augustmail.com>
    Re: SOLVED: How do I scope a variable if the variable n (David Filmer)
    Re: test ignoreit plz <someone@somewhere.com>
    Re: test ignoreit plz <tadmc@augustmail.com>
        Test post from Nortel - pls ignore <chrisvz@nortelnetworks.com>
    Re: Test post from Nortel - pls ignore <blah@blah.com>
    Re: Testing whether given file is open? <vladimir@NoSpamPLZ.net>
        Was this clever or dumb? (Tiger Hillside)
    Re: Win32, FTP, line ends (Phil Hibbs)
    Re: Win32, FTP, line ends <blah@blah.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 19 May 2004 11:46:01 -0700
From: sidwelle@alexian.net (Eli Sidwell)
Subject: perl tcp server script works, but no data.
Message-Id: <ef9a95b0.0405191046.6ef2960e@posting.google.com>

I am trying to get the following script to accept data, but I never see any.
Is this a flushing issue ?

Any help is appreciated.


#!/usr/bin/perl -w

$server_port = "5001";

use IO::Socket;

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

    $server->autoflush();    

while ($client = $server->accept()) {
    # $client is the new connection
    
    $client->recv($str, 1024)
        or die "Can't recv: $!\n";
    
    $client_ip = $client->peerhost;
    $client_port = $client->peerport;

    print "Data is: $str \n";    
    print "Client IP: $client_ip\n";
    print "Client port: $client_port\n";
}

close($server);


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

Date: Wed, 19 May 2004 13:20:22 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: perl tcp server script works, but no data.
Message-Id: <190520041320228983%jgibson@mail.arc.nasa.gov>

In article <ef9a95b0.0405191046.6ef2960e@posting.google.com>, Eli
Sidwell <sidwelle@alexian.net> wrote:

> I am trying to get the following script to accept data, but I never see any.
> Is this a flushing issue ?
> 
> Any help is appreciated.
> 
> 
> #!/usr/bin/perl -w
> 
> $server_port = "5001";
> 
> use IO::Socket;
> 
> # make the socket
> $server = IO::Socket::INET->new(LocalPort => $server_port,
>                                 Type      => SOCK_STREAM,
>                                 Proto     => 'tcp',
>                                 Reuse     => 1,
>                                 Listen    => 10 )   # or SOMAXCONN
>     or die "Couldn't be a tcp server on port $server_port : $@\n";
> 
>     $server->autoflush();    
> 
> while ($client = $server->accept()) {
>     # $client is the new connection
>     
>     $client->recv($str, 1024)
>         or die "Can't recv: $!\n";

recv() is for UDP messages. You have specified  a TCP connection. Try 

   my $nread = $client->read($str,1024);
   die "Can't read from socket: $!" unless defined $nread;

instead.

>     
>     $client_ip = $client->peerhost;
>     $client_port = $client->peerport;
> 
>     print "Data is: $str \n";    
>     print "Client IP: $client_ip\n";
>     print "Client port: $client_port\n";
> }
> 
> close($server);

You have not shown the client program, so there could be a problem
there as well.


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

Date: Wed, 19 May 2004 13:55:53 -0500
From: "porter970" <porter970@lycos.com>
Subject: Perl vs PHP
Message-Id: <10anbdrachc1u4e@corp.supernews.com>

Is there a reason to use Perl rather than PHP?  I've got stuff that uses
both ... so much of the syntax, etc. is similar.  Is one more secure ... or
faster ... ?

Steve




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

Date: Wed, 19 May 2004 23:56:27 +0200
From: "Wappler" <wappler@gmx.net>
Subject: Re: Perl vs PHP
Message-Id: <40abd75d$0$18634$91cee783@newsreader02.highway.telekom.at>

Depends on what you plan to do.
If you want to develop Web Applications use PHP.
If you want to code programs not only for internet use PERL, there is
nothing you can't do with PERL.

"porter970" <porter970@lycos.com> schrieb im Newsbeitrag
news:10anbdrachc1u4e@corp.supernews.com...
> Is there a reason to use Perl rather than PHP?  I've got stuff that uses
> both ... so much of the syntax, etc. is similar.  Is one more secure ...
or
> faster ... ?
>
> Steve
>
>




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

Date: 19 May 2004 09:43:58 -0700
From: charley@pulsenet.com (Chris Charley)
Subject: Re: print all combinations
Message-Id: <4f7ed6d.0405190843.51cfb8a9@posting.google.com>

Michele Dondi <bik.mido@tiscalinet.it> wrote in message news:<5e6ha0hno4antrinkn4ro3bf303hfc24do@4ax.com>...

[snip]

> 
>   #!/usr/bin/perl -l
>   # ...
>   {
>       local $"=',' ;
>       print for glob "B{V,X}{@{[1..8]}}{@{['A'..'Z']}}";
>   }
> 
> 
> PS: We're *not* "here in google" ;-)

Yes, of course. I realize many do not access Usenet through Google  :-)
Many nice solutions posted.

Chris


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

Date: Wed, 19 May 2004 20:05:12 +0200
From: "jacek" <bornslippy.SPAM.IS.NOT.OK@o2.pl>
Subject: problem with references
Message-Id: <c8g7ko$6rd$1@sunflower.man.poznan.pl>

I'm new to perl (only yesterday I wrote my first .pl script)
and I have a problem with references

 ....
$var = 22;
$ptr = \$var;
$$ptr = 23;
print "$var\n"; #gives 23 ok
print "$ptr\n"; ################

$thread = new Thread \&ThreadProcedure, $ptr;
$thread->join;
print "$var\n"; #gives 23 which is not ok, I thought it'd be 24
 .......
sub ThreadProcedure
{
    $v = @_[0];
    print "$$v\n"; #gives 23 ok
    print "$v\n";   ###############
    $$v = 24;
}

2 lines with ############## give different memory address, so it's no doubt
that changing value of $var in ThreadProcedure is not seen in main thread.
what should I do to work it properly?

regards,
jacek



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

Date: 19 May 2004 10:46:43 -0700
From: lps@ucla.edu (Leo Shumacher)
Subject: Regular Expressions Help!
Message-Id: <ddc4b17c.0405190946.1f7cf798@posting.google.com>

Hi,
I have a project due today and am struggling with this line:

s/[,;:!\?\.\"\\\/\]\[]{1,}/ /g;
I am trying to replace the following characters with whitespace (These
are word separators and I'm writing a word-counting program.  I am
having trouble figuring out which of those characters need a '\' in
front of them, since perl doesn't give me an error even with -w when I
don't use them in the right places.. Here are the characters in a more
accesible format:

,;:!   --> These don't need a '\' in front (I think)
?."\/][   --> These all need it?
@ # $ % ^ & * ( ) + - = ~ ` { } < > | --> These I am not sure about.
Please help!



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

Date: Wed, 19 May 2004 10:24:12 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: rmdir Question
Message-Id: <slrncamv0s.6v0.tadmc@magna.augustmail.com>


[ Please do not top-post.
  Have you seen the Posting Guidelines that are posted here frequently?
]


George Kinley <georgekinley@hotmail.com> wrote:
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrncampsj.6k8.tadmc@magna.augustmail.com...
>> Jürgen Exner <jurgenex@hotmail.com> wrote:
>> > George Kinley wrote:
>> >> On Win2K, When I use rmdir ,  if the directory is  open in other
>> >> command window or in Explorer, it does not delete , and prints our
>> >> "cannot remove %"#" ,
>> >> my question is , is it possible to override this limitation
>> >
>> > And your Perl question is ....?
>>
>>
>> He's made off-topic posts before too:
>>
>>    Message-ID: <jmk3c.11154$k4.233803@news1.nokia.com>
>>
>> I've arranged to ignore all of his posts since that one.

> hey, what  is wrong with the question,


It is not about Perl.

It is about your filesystem/OS.


> I want to know if it is possible to delete the dir, even if it is being
> used, 


It depends on your filesystem/OS, not on the programming language
that you choose to use.


> is it possible to do in perl,


It depends on your filesystem/OS.

If allowed by your system, then Perl's unlink() should do the job.


> it is not good to see comments like > I've arranged to ignore all of his
> posts since that one.


If you do not want to be killfiled for socially unacceptable behavior
then do not engage in socially unacceptable behavior.

You build your reputation, and then you live with it.
(so consider building a good one!)


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


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

Date: Wed, 19 May 2004 18:17:34 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: rmdir Question
Message-Id: <c8g890$uml$1@news.simnet.is>

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrncampsj.6k8.tadmc@magna.augustmail.com...
> Jürgen Exner <jurgenex@hotmail.com> wrote:
> > George Kinley wrote:
> >> On Win2K, When I use rmdir ,  if the directory is  open in other
> >> command window or in Explorer, it does not delete , and prints our
> >> "cannot remove %"#" ,
> >> my question is , is it possible to override this limitation
> >
> > And your Perl question is ....?
>
>
> He's made off-topic posts before too:
>
>    Message-ID: <jmk3c.11154$k4.233803@news1.nokia.com>

well, he *did* post (or should I say top-post?) an
apology for that one.

gnari





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

Date: Wed, 19 May 2004 14:56:10 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: rmdir Question
Message-Id: <slrncaneuq.7dm.tadmc@magna.augustmail.com>

gnari <gnari@simnet.is> wrote:
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrncampsj.6k8.tadmc@magna.augustmail.com...
>> Jürgen Exner <jurgenex@hotmail.com> wrote:
>> > George Kinley wrote:
>> >> On Win2K, When I use rmdir ,  if the directory is  open in other
>> >> command window or in Explorer, it does not delete , and prints our
>> >> "cannot remove %"#" ,
>> >> my question is , is it possible to override this limitation
>> >
>> > And your Perl question is ....?
>>
>>
>> He's made off-topic posts before too:
>>
>>    Message-ID: <jmk3c.11154$k4.233803@news1.nokia.com>
> 
> well, he *did* post (or should I say top-post?) an
> apology for that one.


I never saw it, because he was already "in there".


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


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

Date: 19 May 2004 10:56:38 -0700
From: IneverReadAnythingSentToMe@hotmail.com (David Filmer)
Subject: Re: SOLVED: How do I scope a variable if the variable name contains a variable?
Message-Id: <e4c916dd.0405190956.557c5623@posting.google.com>

Uri wrote...
>   D> Hmmm. Either the question is not asked nearly as often as Uri recalls,
>   D> or else my Google search terms are far too general (I get over 1000
>   D> hits with: perl scope variable hash my symref - bad signal to noise
>   D> ratio).
> 
> try symrefs or symbolic references or soft references
> 
> use the words *I* mentioned.
> 

I did. 'symref' was one of the terms.   :)

> and you fell into the trap of the evil symref. do not go there if you
> value your coding career. there lies deamons you don't want to release.
> 
> and here is my standard rant on this:
> [rant...] ... so why would you
> use a specialized hash tree for this when a regular hash would work just
> as well? and a regular hash has many advantages....
 
Uri's right; my solution is not great; it obscures (but does not
avoid) the trap he discusses. But I believe he's asking, "why are you
bothering to use an array (@) when you could use a hash (%) instead?"

I agree that hashes offer many advantages, but I'm not free to use a
hash in this case. I'm constructing a series of parameters to pass to
a module (HTML::Template's TMPL_LOOP), which expects an array (@)
reference. I want my code to be portable, so I don't want to hack on
HTML::Template.

The script is running under mod_perl, so it's especially important
that I lexically scope my variables.

It does not seem possible to "properly" scope/use an array (@) in the
manner I'm attempting. bummer! Time to rewrite some code...


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

Date: Wed, 19 May 2004 16:18:22 +0100
From: "Bigus" <someone@somewhere.com>
Subject: Re: test ignoreit plz
Message-Id: <c8ftrv$h34@newton.cc.rl.ac.uk>

"Professor Jean Christian" <vendas.jeansoftware@globo.com> wrote in message
news:c8fsfm$apv$88@news-reader1.wanadoo.fr...
>     test only. do not spam please.

That's fine.. I'm sure lots of writers of email harvesters include:

  next if $messagebody =~ /do not spam please/i;

in their routines ;-)

Bigus



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

Date: Wed, 19 May 2004 10:26:32 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: test ignoreit plz
Message-Id: <slrncamv58.6v0.tadmc@magna.augustmail.com>

Professor Jean Christian <vendas.jeansoftware@globo.com> wrote:

>     test only. 


Into the killfile you go then. So long.


> do not spam please.


Do not make off-topic postings to our discussion newsgroup.

Make test postings to a newsgroup for test postings (one with "test" in
the group's name).

If you are nice to us, we will be nice to you.


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


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

Date: Wed, 19 May 2004 16:20:03 -0400
From: "Chris" <chrisvz@nortelnetworks.com>
Subject: Test post from Nortel - pls ignore
Message-Id: <c8gfe4$7p5$1@zcars0v6.ca.nortel.com>

Testing outbound posts, please ignore.

News Admin @ Nortel




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

Date: Wed, 19 May 2004 16:32:00 -0400
From: Sherif Zaroubi <blah@blah.com>
Subject: Re: Test post from Nortel - pls ignore
Message-Id: <opr79knmv5cx74rp@news.videotron.ca>

On Wed, 19 May 2004 16:20:03 -0400, Chris <chrisvz@nortelnetworks.com> 
wrote:

> Testing outbound posts, please ignore.
>
> News Admin @ Nortel
>
>


I REFUSE TO IGNORE


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

Date: Wed, 19 May 2004 21:17:34 GMT
From: lostriver <vladimir@NoSpamPLZ.net>
Subject: Re: Testing whether given file is open?
Message-Id: <O9Qqc.143341$1f2.1413917@weber.videotron.net>

On Wed, 19 May 2004 10:15:51 -0400, Richard Morse wrote:
>
> One other option is to have the upload client send the size of the file 
> first, and then send the file.  When the uploaded file is the same as 
> the sent size, it's been entirely transferred.
>


You can also check the size of the file, go sleep()
for a while and check the size again. If sleep()
was long enough and size hasn't increased, you can assume
that the transfer is complete....


-- 
 .signature: No such file or directory


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

Date: 19 May 2004 11:51:24 -0700
From: tigerhillside@netscape.net (Tiger Hillside)
Subject: Was this clever or dumb?
Message-Id: <5dbe2141.0405191051.27a89a9f@posting.google.com>

My code is working, so this is not a question about that. But I just
came up with a solution that was either clever or dumb and I can't
figure it out.

The problem is this: I have a database that lists people doing stuff
at set times on various days. I was asked for a report that would say
something like:

"7 people worked at 7 PM on May 6"

The "7 PM" and the "May 6" are fields in the database. 

It seemed to me that I needed a multidimensional hash. Then I thought
that I could concatinate time and date and use that as a hash key:
$timeval . "+" . $datevalue.

That would have worked, but at the printing end I would have had to
pull the fields apart and get that right. Then I had what I thought
was a good idea. I did the following concatination: $timevalue . " on
" . $datevalue", sorted the keys, and just printed out the has value
and the key.

Something about this bothers me. You are not supposed to use keys that
way and I am making the keys larger which, I suppose, could cause
problems if I have really large results. OTOH the codes is neat and
clean and short without being, AFAICT, cryptic.

So was that clever? Normal? A bad idea? I am, as I have said in a
previous post, new to perl and I don't know if I am getting it. Any
comments?


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

Date: 19 May 2004 10:49:39 -0700
From: gg@snark.freeserve.co.uk (Phil Hibbs)
Subject: Re: Win32, FTP, line ends
Message-Id: <a9ec249e.0405190949.5fcf7d90@posting.google.com>

Sherm Pendley <spamtrap@dot-app.org> wrote in message news:<J_adnfTJWsZ88zbdRVn-gQ@adelphia.com>...
> If you want automagic EOL translation, you need to enable ASCII mode - see
> the description of the ascii() method in Net::FTP's docs.

I am, because I'm sending the files to an IBM mainframe, and they need
to be translated to EBCDIC.

Phil Hibbs.


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

Date: Wed, 19 May 2004 14:11:22 -0400
From: Sherif Zaroubi <blah@blah.com>
Subject: Re: Win32, FTP, line ends
Message-Id: <opr79d48e9cx74rp@news.videotron.ca>

On 19 May 2004 07:09:58 -0700, Phil Hibbs <gg@snark.freeserve.co.uk> wrote:

> I'm using Net::FTP on ActiveState perl 5.8.0 and I'm having a problem
> with line ends.
>
> The source files are MS-style with CR/LF line ends, and I'm FTPing the
> file to an MVS mainframe (EBCDIC). The files received at the other end
> still have the CR x'0D' character at the end.
>
> I have worked around the problem by making a temp copy of the file and
> converting the line ends to Unix-style and then FTPing that file, but
> how can I get Net::FTP to behave as though the local platform were
> Microsoft (which it is)? It's behaving like a *nix FTP client.
>
> Phil Hibbs
> http://www.perlmonks.org/index.pl?node=PhilHibbs


Is there a way to do the transpher as text mode and not binary mode?


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

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


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