[25028] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7278 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 21 00:07:29 2004

Date: Wed, 20 Oct 2004 21:05:07 -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, 20 Oct 2004     Volume: 10 Number: 7278

Today's topics:
        ANNOUNCE: New version of RPC::Simple <domi@komarr.grenoble.hp.com>
    Re: eval function (Anno Siegel)
    Re: hack out chunk from large text file? <noreply@fake.address>
    Re: Hash as an function argument <noreply@fake.address>
    Re: How can I know if STDOUT has been redirected? <No_4@dsl.pipex.com>
    Re: How is this Perl Script encrypted? <noreply@fake.address>
    Re: How to checking a file that writing is complete? <usenet@morrow.me.uk>
        How to I get an user email address, if I know the domai (Mav)
    Re: localizing %SIG handlers (Charles DeRykus)
    Re: Mail::Sender - Attaching output from pipe <tadmc@augustmail.com>
    Re: Mail::Sender - Attaching output from pipe <noreply@gunnar.cc>
    Re: Meaning of "Malformed UTF-8 character"? <elektrophyte-yahoo>
    Re: Meaning of "Malformed UTF-8 character"? <flavell@ph.gla.ac.uk>
    Re: Net::FTP and Passive mode problems (Hostile17)
    Re: Net::FTP and Passive mode problems <usa1@llenroc.ude.invalid>
    Re: Net::FTP and Passive mode problems <lv@aol.com>
    Re: options to shrink-wrap a perl script <tadmc@augustmail.com>
    Re: Perl output displaying ??? characteres <tadmc@augustmail.com>
    Re: perl to english (Anno Siegel)
    Re: perl to english <tadmc@augustmail.com>
    Re: Problem while changing file's modification time usi <usenet@morrow.me.uk>
    Re: Regex matching non-contiguous sheds of text <Jon.Ericson@jpl.nasa.gov>
    Re: Regular Expression for HTML Tags and Special Charac <tadmc@augustmail.com>
    Re: Regular Expression for HTML Tags and Special Charac <vijai.lists@gmail.com>
    Re: Regular Expression for HTML Tags and Special Charac <vijai.lists@gmail.com>
    Re: source a config file <usa1@llenroc.ude.invalid>
        Why go to raves when you can write code to do it (sad) (Happy White Rabbit)
    Re: Why go to raves when you can write code to do it (s <jwillmore@adelphia.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 18 Oct 2004 13:08:04 GMT
From: Dominique Dumont <domi@komarr.grenoble.hp.com>
Subject: ANNOUNCE: New version of RPC::Simple
Message-Id: <I5wuCv.1t0B@zorch.sf-bay.org>



Hello

I've uploaded v1.001 of the perl module RPC::Simple (yes, I know, the
last version is 6 years old...)

The main changes are:

- Removed possibility to use AutoLoader in classes communicating over
  network. User complained that using AutoLoading made debugging much
  harder.
- Using Tk control loop is now optional. A custom control loop can be
  used.
- changed Factory constructor API to use named parameters. Old API is
  still supported (although obsolete)
- better socket cleanup at exit.

Here's the README of RPC::Simple: 

This is the README file for RPC::Simple::* , a bunch of Perl classes
to perform simple asynchronous remote procedure calls in an object
oriented way.

This module uses an IO::Select based control loop on the server side.

On the local side, the user can use Tk's control loop or provide it's
own control loop using the socket provided by this module.

To use this set of classes, the user will have to create a set of twin 
classes. One will run on the local side, the other on the remote side.
Each twin class will inherit a RPC::Simple::Any[Local|Remote] class.

When done you'll be able to invoke a method from the remote class on the
local object and vice versa. (like $localObj->remotePrint). 

When calling the remote method from the local side, you may pass a
code reference which will be stored by the RPC::Simple objects. This
code ref will be called back when the remote function is over. Note
that the remote calls are not blocking, all feedback from the remote
side is performed through asynchronous call-back. 

Note that simultaneous remote calls on the same object (or on 
different objects) are supported, you'll get the relevant call-back 
as usual.

On the other hand (or side ...), the callback mechanism does not work 
when calling a method from the remote side to the local side. 
Only a simple method call (albeit with optionnal parameters) is allowed 
from the remote side.

Note that the attribute of the twin objects are not automagically
copied or updated on the other side. You will have to explicitely 
pass the necessary data from one side to the other if you need it.

See the man pages or the t/tk.t script to get further details.  Note
you have install Tk to be able to perform the tests.

About security: When running the server, only a localhost (127.0.0.1)
connection is allowed by default. You may call a server method to allow
connections from other IP (either numeric or name) addresses. Once this is
done, the declared address is considered as a "buddy" and the data
sent to the server are not checked for security (i.e. the Taint mechanism
is defeated). Consider yourself warned.

Note that if security is a real problem for you, you should consider
using penguin (see CPAN) or use SSH tunneling. Note also that I always
opened to comments and suggestion to improve the security aspects.

All in all, I've tried to keep things simple.

So this module should be :
 - quite simple to use 
 - lightweight

It sure is not :
 - DCE
 - CORBA (which is blocking)
 - bulletproof
 - foolproof

But it works. (Although I'm opened to suggestion regarging the "un-
proof" areas)


Cheers
-- 
Dominique Dumont 
"Delivering successful solutions requires giving people what they
need, not what they want." Kurt Bittner




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

Date: 20 Oct 2004 22:31:22 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: eval function
Message-Id: <cl6ovq$poo$1@mamenchi.zrz.TU-Berlin.DE>

wana  <ioneabu@yahoo.com> wrote in comp.lang.perl.misc:
> wana wrote:
> 
> > Uri Guttman wrote:
> > 
> >>>>>>> "w" == wana  <ioneabu@yahoo.com> writes:

[...]

> >>   w> {
> >>   w>         my ($data, $filename, $append) = @_;
> >>   w>         $_ = $append;
> >> 
> >> blarg!! you just clobbered $_ which could be global (or localized) in
> >> the caller.
> >> 
> >>   w>         $append = (defined and /^append$/i) ?'>>':'>';
> > 
> > Thanks for pointing that out.  I had a bad feeling about that line when I

[...]

> local $_ = append;
> 
> Won't that fix it?

In most cases it would (if there were a "$" in front of "append"), but
there appear to be exceptions.  Brian?  You're the specialist!

In any case, a one-shot for-loop is often a better way to make
$_ represent something else for a moment, as in

    $_ = ( defined and /^append$/i) ? '>>' : '>' for $append;

This makes $_ an alias for $append, which can even be used as an
lvalue.  The technique is sometimes called topicalisation.

But I'd probably not use that here, but write (in the appropriate place)

    $append = shift || '>'; # default
    $append =~ s/^append$/>>/i;

which two lines, but clearer.

Anno


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

Date: Wed, 20 Oct 2004 21:40:35 -0500
From: Tommy Butler <noreply@fake.address>
Subject: Re: hack out chunk from large text file?
Message-Id: <1098326356.N1GF1iy3bja2R/lMtEpMWw@teranews>

Jason Kinkade wrote:
> I have a text file that looks like.
> 
> ---unique id---
> many lines
> ---------------
> ---unique id---
> many lines
> ---------------
> ---unique id---
> many lines
> ---------------
> ...etc.
> 
> I want to simply remove a section between the ---unique id--- and
> ---------.  Now I know I could go through it line by line and output
> the filtered text to a tmp file then copy the tmp file back, but thats
> impracticle with the file is like a gig in size.  Does anyone know a
> way I can operate on the text file directly and remove a section
> without copying the whole file to a tmp file or temporatily into
> memory?
> 
> Thanks
Which of the chunks are you trying to remove?  Are you trying to remove 
all of the chuncks?  Are you trying to remove only some?  What do you 
want to do with the chunks after you delete them; do you want to save 
any of the chunks to other files?  Look you've provided a really poor 
description of your problem and your goal.  Help us help you.  Provide 
these details and I'll probably be able to provide an answer.

-- 
Tommy Butler


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

Date: Wed, 20 Oct 2004 21:27:02 -0500
From: Tommy Butler <noreply@fake.address>
Subject: Re: Hash as an function argument
Message-Id: <1098325545.WYwuHlgZoeiqWipL5W09tw@teranews>

Lepi wrote:
> Hello
> 
> When I'm calling a subroutine with one or two aguments, I use
> something like this:
> my ($first,$second)=@_;
> to access them.
> 
> What if I want to pass a hash to function like:
> %something={$first=>1,$second=>2};
> function(%something);
> 
> sub function
> {
> How to access %something, and not to make it global???
> }

Several ways to do this!  Some of which are...

call the following subroutine like this:
	&example1(arg1 => value1, arg2 => value2, arg3 => value3);
	sub example1 { my(%args) = @_; ... }

 ...or call this one the same way:
	&example2(arg1 => value1, arg2 => value2, arg3 => value3);
	sub example2 { my($args) = { @_ }; ... }

 ...or call this third subroutine like this:
	&example3({ arg1 => value1, arg2 => value2, arg3 => value3 });
	sub example3 { my($args) = shift(@_) }

If you want to get more advanced than that see Class::OOorNO at CPAN

-- 
Tommy Butler


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

Date: Thu, 21 Oct 2004 00:39:10 +0100
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: How can I know if STDOUT has been redirected?
Message-Id: <4176f71e$0$1397$cc9e4d1f@news-text.dial.pipex.com>

Anno Siegel wrote:
 >
> The file test -t checks if a filehandle is open to a tty.  It does
> not check whether the handle has been redirected -- redirection is
> a shell action that simply offers the other program the named file
> as stdin (or stdout, or stderr).

    Well, if it has been redirected it will no longer be attached to a tty 
(unless you redirected it to /dev/tyy, or redirected stderr to stdout)!  (I 
was recently looking into the possibility of running a sub-process with its 
stdin/stdout attached to the parent tty, while the sub-process had its own 
tty, but couldn't see anyway to achieve it, since the only way to open a 
tty was to close all references to the current one first - but this is 
nothing to do with Perl).

    But the original question wasactually about it being a tty anyway...


-- 
      -*-    Just because I've written it here doesn't    -*-
      -*-    mean that you should, or I do, believe it.   -*-


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

Date: Wed, 20 Oct 2004 21:13:00 -0500
From: Tommy Butler <noreply@fake.address>
Subject: Re: How is this Perl Script encrypted?
Message-Id: <1098324700.rX0XmPNCDAIRmGtqot1rew@teranews>

Tim Hammerquist wrote:
> i6033162556-signup1@yahoo.com.cn <i6033162556-signup1@yahoo.com.cn> wrote:
> 
>> http://www.c3scripts.com/amazon/release/ae-040531.zip
>> 
>> I am not trying to hack this demo script, but I want to encrypt my own
>> scripts and distrubate them on the internet.
> 
> 
> As you indicate you have written your own scripts, I suggest examining
> the last line of code.  It will tell you how to encode your own scripts
> without ever needing to decode the script above.
Wow that's some pretty lame "encryption" LOL!

-- 
Tommy Butler


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

Date: Tue, 19 Oct 2004 18:22:37 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: How to checking a file that writing is complete?
Message-Id: <t3vf42-3v4.ln1@osiris.mauzo.dyndns.org>


Quoth Michele Dondi <bik.mido@tiscalinet.it>:
> On Mon, 18 Oct 2004 00:44:23 +0100, Ben Morrow <usenet@morrow.me.uk>
> wrote:
> 
> >fs iff stat returns the same first member for both. Be aware that 'fake'
> >filesystems (such as Linux' usbfs (/proc/bus/usb) and tmpfs (often used
> >for /dev and /dev/shm)) may return 'undef' for this member, so be
> 
> <OT>
> I think that nowadays it is common for /dev to be on devfs, which btw
> doesn't contradict the key point you're addressing, since it is just
> as 'fake'.

It was. As of 2.6 devfs is deprecated and the alternative is udev, which
is a tmpfs with device nodes created by a userspace daemon.

devfs, I believe, *does* have a device number (as does /proc); tmpfs
does not. :)

> </OT>

Ben

-- 
'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'
                                                               ben@morrow.me.uk


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

Date: 20 Oct 2004 16:18:58 -0700
From: mluvw47@yahoo.com (Mav)
Subject: How to I get an user email address, if I know the domain/username
Message-Id: <dfaafecd.0410201518.7cc10ba3@posting.google.com>

Hi,
   Using Perl, Windows, if I know the person domain name(or the whole
user domain) and userid, like (google/foo). is that a way to return
that person the email address progrom? I am on the same domain.

  I found out on windows, I can right click on any folder,
Sharing -> Sharing this folder -> Permission -> Add
on the box "Enter the object names to select:"
If I enter something like google/foo, and Check name, that will return
me the email.

  Is that a way I can write I program to do to find out the email
address?

Thanks,
Mav


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

Date: Wed, 20 Oct 2004 22:37:38 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: localizing %SIG handlers
Message-Id: <I5wMuq.B6M@news.boeing.com>

In article <ckdtd2$of3$1@mamenchi.zrz.TU-Berlin.DE>,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>It is common practice to localize %SIG handlers in this fashion:
>    
>    $SIG{ HUP} = \ &global_handler;
>
>    {
>        local $SIG{ HUP} = \ &local_handler;
>        # provoke and deal with one or more HUP signals
>    }
>
>The assumption is that $SIG{ HUP} is either the global or the local
>handler at all times, so the (HUP) signal will always be caught, but
>apparently that assumption isn't true.  "local" sets the handler
>to undef, and then "=" sets it to \ &local_handler.  It is quite
>possible for a signal to arrive when the hander is undefined, which
>ends the program through an uncaught signal.  The following code
>shows this:
>
>    my ( $count_a, $count_b) = ( 0, 0); # unused, but left in place
>    $SIG{ HUP} = sub { $count_a ++ };
>
>    # create a stream of HUP signals from kid to parent
>    my $parent = $$;
>    defined( my $pid = fork ) or die "fork: $!";
>    unless ( $pid ) {
>        require Time::HiRes;
>        require POSIX;
>        my $tick = 1/POSIX::sysconf( POSIX::_SC_CLK_TCK());
>        while ( 1 ) {
>            kill HUP => $parent or exit; # don't survive parent
>            Time::HiRes::sleep( $tick); # shortest admissible sleep time
>        }
>        exit(); # not reached;
>    }
>
>    # main loop
>    while ( 1 ) {
>        {
>           local $SIG{ HUP} = sub { $count_b ++ };
>    #       my $save = $SIG{ HUP};
>    #       $SIG{ HUP} = sub { $count_b ++ };
>    #       $SIG{ HUP} = $save;
>        }
>    }
>
>With the "main loop" as shown ("local" active), after a few seconds
>the program ends with a "Hangup" message, characteristic for an
>uncaught HUP signal.  With "local" commented out and the other three
>lines active, the program runs happily as long as I let it.
>
>My conclusion:  The practice of localizing %SIG handlers isn't safe,
>and probably never has been.
>

I see the Hangup on 5.8.4 almost immediately but a HUP blocker
eliminates 'em (at least for a 10 min. test). Are you 
thinking perhaps a HUP block shouldn't be necessary..
or am I missing another point.. 


unless ( defined sigprocmask(SIG_BLOCK, $sigset, $old_sigset) ) {
   die "can't block SIGHUP\n";
} else {
   local $SIG{ HUP} = sub { $count_b ++ };
   unless ( defined sigprocmask(SIG_UNBLOCK, $old_sigset) ) {
      die "can't unblock SIGHUP\n";  # restore
   }
   ...
}

--
Charles DeRykus


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

Date: Wed, 20 Oct 2004 19:17:39 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Mail::Sender - Attaching output from pipe
Message-Id: <slrncne013.5ts.tadmc@magna.augustmail.com>

bengee <postmaster@localhost.localdomain> wrote:


> Hope someone can help!


That seems an unrealistic expectation after:

   Message-ID: <akldmc$cea$1@news0.ifb.net>


You are on your own!


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


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

Date: Thu, 21 Oct 2004 03:00:57 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Mail::Sender - Attaching output from pipe
Message-Id: <2toghgF2175apU1@uni-berlin.de>

Tad McClellan wrote:
> bengee <postmaster@localhost.localdomain> wrote:
>> 
>>Hope someone can help!
> 
> That seems an unrealistic expectation after:
> 
>    Message-ID: <akldmc$cea$1@news0.ifb.net>
> 
> You are on your own!

Indeed.

It may be appropriate to quote the last para in the Mail::Sender POD:

"This program is free software; you can redistribute it and/or modify it 
under the same terms as Perl itself. There is only one aditional 
condition, you may NOT use this module for SPAMing! NEVER! (see 
http://spam.abuse.net/ for definition)"

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


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

Date: Wed, 20 Oct 2004 15:18:59 -0700
From: DM <elektrophyte-yahoo>
Subject: Re: Meaning of "Malformed UTF-8 character"?
Message-Id: <4176e47d$0$800$2c56edd9@news.cablerocket.com>

DM wrote:

> I'm using Perl 5.8.0 on RH Enterprise Linux. I'm trying to match this 
> pattern:
> 
> $pattern = "href=.*?\\.pdf\[^>]*?>";
> 
> 
> I'm seeing many of these errors:
> 
> Malformed UTF-8 character (unexpected continuation byte 0x96, with no 
> preceding start byte) in pattern match (m//) at 
> /home/emicha/bin/moveFileType.pl line 79, <INFILE> line 149.
> 
> 
> And a few of these:
> 
> Malformed UTF-8 character (unexpected non-continuation byte 0x20, 
> immediately after start byte 0xe9) in pattern match (m//) at 
> /home/emicha/bin/moveFileType.pl line 79, <INFILE> line 51.
> 
> 
> A Google search found a little bit of information on the second, but 
> nothing useful, and virtually nothing on the first.
> 
> 
> Any help in interpreting/resolving these would be greatly appreciated.
> 
> Thanks,
> 
> dm

Solution found. Sorry, my Google search wasn't thorough enough the first time.

It has to do with the "LANG" and "LC_CTYPE" environment variables. When I run 
the script like this...

# LANG=en_US LC_CTYPE=en_US perl -w /home/emicha/bin/moveFileType.pl

 ...there are no errors.

Thanks,

dm


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

Date: Wed, 20 Oct 2004 23:21:59 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Meaning of "Malformed UTF-8 character"?
Message-Id: <Pine.LNX.4.61.0410202314200.1958@ppepc56.ph.gla.ac.uk>

On Wed, 20 Oct 2004, it was written:

> I'm using Perl 5.8.0 on RH Enterprise Linux. I'm trying to match this pattern:
> 
> $pattern = "href=.*?\\.pdf\[^>]*?>";
> 
> I'm seeing many of these errors:
> 
> Malformed UTF-8 character (unexpected continuation byte 0x96, with no
> preceding start byte) in pattern match (m//) at
> /home/emicha/bin/moveFileType.pl line 79, <INFILE> line 149.

The error is self-explanatory, in its own terms.  Sounds as if you're 
not familiar with those terms yet...

Hmmm, 5.8.0.  My hunch is that you've got utf8 in your locale, but 
your data isn't really in utf8.  See earlier discussions of this issue 
in (e.g) redhat 9, where the problem frequently arose.

> And a few of these:
> 
> Malformed UTF-8 character (unexpected non-continuation byte 0x20, immediately
> after start byte 0xe9) in pattern match (m//) at
> /home/emicha/bin/moveFileType.pl line 79, <INFILE> line 51.

Again, self-explanatory in its own terms, but if the data is defective 
like this, we need to see where the data came from.

> Any help in interpreting/resolving these would be greatly appreciated.

The quick fix is to try taking the utf8 out of your locale.

Beyond that, I'd say we'd need a minimal but complete example which 
reproduces that problem and which we can run for ourselves, as a 
starting point to explain to you what's going wrong and how to fix it.


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

Date: 20 Oct 2004 19:28:33 -0700
From: hosti1e17@yahoo.com (Hostile17)
Subject: Re: Net::FTP and Passive mode problems
Message-Id: <a5522b8e.0410201828.65930bef@posting.google.com>

"A. Sinan Unur" <usa1@llenroc.ude.invalid> wrote in message news:<Xns9587D70455722asu1cornelledu@132.236.56.8>...
> hosti1e17@yahoo.com (Hostile17) wrote in 
> news:a5522b8e.0410191637.3971835d@posting.google.com:

> Where is the code you are actually using? Please provide the shortest 
> possible program that still exhibits the problem you are experiencing.

I didn't post it because there's almost nothing to tell. And I posted
the Debug info -- but here you go anyway:

use Net::FTP;
$ftp = Net::FTP->new(
  "server.name.com",
  Passive => 1,
 );
$ftp->login( 'username', 'password' );
$ftp->cwd("/path/to/desired/folder/");
$ftp->put( "adsf.txt", 'adsf.txt' ); ## 2-Minute wait on this line

Debug output:

> >      Timeout at ftpscript.pl line 23
> >      PASV


> > Line 23 is where the script says to $ftp->put() my file.
> 
> Then the error is on line 42.

That's an old joke for complete newbies, and I'm really not a
_complete_ newbie.

When my script gets to line 23, it waits for two minutes, then issues
the PASV message. That's why I turned on Debug and posted the output
here.

Unless you come and sit in my office, you're just going to have to
believe me about the two minutes.

My question is, when I told the module to use the Passive mode, why
does it wait two minutes, time out, and then switch to Passive mode?

After it's done that, the transfer happens in less than a second. 

Does Passive => 1, for instance, really mean "don't go into Passive
mode straight away, wait for <timeout value> seconds and then do it?"
and if so, shouldn't the doco say "if you use this, set Timeout to one
second"? I just checked, and it doesn't.


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

Date: 21 Oct 2004 03:00:22 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: Net::FTP and Passive mode problems
Message-Id: <Xns9588EA031B566asu1cornelledu@132.236.56.8>

hosti1e17@yahoo.com (Hostile17) wrote in
news:a5522b8e.0410201828.65930bef@posting.google.com: 

> "A. Sinan Unur" <usa1@llenroc.ude.invalid> wrote in message
> news:<Xns9587D70455722asu1cornelledu@132.236.56.8>... 
>> hosti1e17@yahoo.com (Hostile17) wrote in 
>> news:a5522b8e.0410191637.3971835d@posting.google.com:
> 
>> Where is the code you are actually using? Please provide the shortest
>> possible program that still exhibits the problem you are
>> experiencing. 
> 
> I didn't post it because there's almost nothing to tell. And I posted
> the Debug info -- but here you go anyway:
> 

Why don't you have:

use strict;
use warnings;


> use Net::FTP;
> $ftp = Net::FTP->new(
>   "server.name.com",
>   Passive => 1,
>  );
> $ftp->login( 'username', 'password' );
> $ftp->cwd("/path/to/desired/folder/");
> $ftp->put( "adsf.txt", 'adsf.txt' ); ## 2-Minute wait on this line
> 
> Debug output:
> 
>> >      Timeout at ftpscript.pl line 23
>> >      PASV
> 
> 
>> > Line 23 is where the script says to $ftp->put() my file.

 ...

> When my script gets to line 23, it waits for two minutes, then issues
> the PASV message. That's why I turned on Debug and posted the output
> here.
 
 ...

> My question is, when I told the module to use the Passive mode, why
> does it wait two minutes, time out, and then switch to Passive mode?

I don't know.

However, the Net::FTP docs do mention that you should normally not need to 
set this parameter.

On the other hand, did you try:

#! perl

use strict;
use warnings;

use Net::FTP;

my $ftp = Net::FTP->new('host.invalid', Debug => 1);
$ftp->login( 'user', 'pass' ) or die 'login failure';
$ftp->cwd('public_ftp') or die 'cannot cwd';
$ftp->pasv or die 'cannot set pasv mode';
$ftp->put('test.txt') or die 'transfer failure'; 
$ftp->quit;
__END__


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

Date: Wed, 20 Oct 2004 22:08:31 -0500
From: l v <lv@aol.com>
Subject: Re: Net::FTP and Passive mode problems
Message-Id: <41772611$1_4@127.0.0.1>

Hostile17 wrote:
> "A. Sinan Unur" <usa1@llenroc.ude.invalid> wrote in message news:<Xns9587D70455722asu1cornelledu@132.236.56.8>...
> 
>>hosti1e17@yahoo.com (Hostile17) wrote in 
>>news:a5522b8e.0410191637.3971835d@posting.google.com:
> 
> 
>>Where is the code you are actually using? Please provide the shortest 
>>possible program that still exhibits the problem you are experiencing.
> 
> 
> I didn't post it because there's almost nothing to tell. And I posted
> the Debug info -- but here you go anyway:
> 
> use Net::FTP;
> $ftp = Net::FTP->new(
>   "server.name.com",
>   Passive => 1,
>  );
> $ftp->login( 'username', 'password' );
> $ftp->cwd("/path/to/desired/folder/");
> $ftp->put( "adsf.txt", 'adsf.txt' ); ## 2-Minute wait on this line
> 
> Debug output:
> 
> 
>>>     Timeout at ftpscript.pl line 23
>>>     PASV
> 
> 
> 
>>>Line 23 is where the script says to $ftp->put() my file.
>>
>>Then the error is on line 42.
> 
> 
> That's an old joke for complete newbies, and I'm really not a
> _complete_ newbie.
> 
> When my script gets to line 23, it waits for two minutes, then issues
> the PASV message. That's why I turned on Debug and posted the output
> here.
> 
> Unless you come and sit in my office, you're just going to have to
> believe me about the two minutes.
> 
> My question is, when I told the module to use the Passive mode, why
> does it wait two minutes, time out, and then switch to Passive mode?
> 
> After it's done that, the transfer happens in less than a second. 
> 
> Does Passive => 1, for instance, really mean "don't go into Passive
> mode straight away, wait for <timeout value> seconds and then do it?"
> and if so, shouldn't the doco say "if you use this, set Timeout to one
> second"? I just checked, and it doesn't.

Not sure if this will help or not, but, I once had a problem (can't 
remember the specifics) with Net::FTP.  My problem was I had an older 
version of Net::FTP installed.  See if you are in the same boat.  Just a 
thought.

Len


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: Wed, 20 Oct 2004 16:16:38 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: options to shrink-wrap a perl script
Message-Id: <slrncndldm.5fu.tadmc@magna.augustmail.com>

dan baker <botfood@yahoo.com> wrote:
> Uri Guttman <uri@stemsystems.com> wrote in message news:<x7hdopcurb.fsf@mail.sysarch.com>...
>> >>>>> "db" == dan baker <botfood@yahoo.com> writes:
>> 
>>   db> You have renewed my faith that there are people in this group capable
>>   db> of demonstrating not only knowledge, but are interested in giving
>>   db> complete and thoughtful answers.
>> 
>> and you have renewed my faith in that there will always be those who
>> need hand holding and then whine about it.
>> 
>> uri
> ------------------
> 
> 
> didn't your mother ever teach you to keep your mouth shut if you dont
> have anything nice (or helpful) to say?


Where is the nice or helpful part in *your* followup, huh?


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


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

Date: Wed, 20 Oct 2004 18:09:57 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl output displaying ??? characteres
Message-Id: <slrncnds25.5fu.tadmc@magna.augustmail.com>

Jay <jay.mistry@gmail.com> wrote:


> chop($basfile = <STDIN>);


That is how it was done 8 years ago.

Why aren't you using chomp() instead?


> open OUTFILE, "> $basfile.out";


You should always, yes *always*, check the return value from open():


   open OUTFILE, "> $basfile.out" or die "could not open '$basfile.out'  $!";


> while(<INFILE>) {
> 	$_;


What do you think that that statement is doing for you?


> 		break;

You should always enable warnings when developing Perl (not PERL) code!


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


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

Date: 20 Oct 2004 22:40:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl to english
Message-Id: <cl6pgu$poo$2@mamenchi.zrz.TU-Berlin.DE>

Uri Guttman  <uguttman@athenahealth.com> wrote in comp.lang.perl.misc:

[programming languages that look like English]

> so again, you are barking up the wrong tree. this has been tried many
> times and is doomed to failure. natural languages are not good for

The latest attempt is AppleScript or, more generally, OS dialects.
I have only seen AppleScript, and it's horror, just *because* it
tries to look like English.

> logical flow descriptions and only perl is good for program poetry!

Oh, come on.  There must be some Cobol poetry.  Something long
and impenetrable, in hexameter...

Anno


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

Date: Wed, 20 Oct 2004 19:13:55 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: perl to english
Message-Id: <slrncndvq3.5ts.tadmc@magna.augustmail.com>

wana <ioneabu@yahoo.com> wrote:
> buildmorelines wrote:
> 
>> Is there any script or pragma or something that will translate perl
>> code to pure english,

> It is possible!  I have written and tested a preliminary version of the
> program that performs the task you are requesting.  Here it is:

> ReplaceInFile('=', 'is equal to', $file);
> 
> I tested it on several perl scripts and it worked beautifully.


Seems to me that it should be either:

   ReplaceInFile('==', 'is numerically equal to', $file);
or
   ReplaceInFile('eq', 'is stringwise equal to', $file);
or
   ReplaceInFile('=', 'gets the value', $file);


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


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

Date: Tue, 19 Oct 2004 18:43:09 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Problem while changing file's modification time using utime() on windows
Message-Id: <da0g42-3v4.ln1@osiris.mauzo.dyndns.org>


Quoth sudeepgeorge@gmail.com (Sudeep George):
> I have implemented a perl script to 'touch' all files in a directory
> using utime().
> The implementation is working fine, but due to limitations of utime()
> on Windows, utime() will not modify the attributes of a file if it is
> opened or read-only.
> I am using Active State Perl v5.8.4 on a Windows 2000 machine.
> 
> There is an existing perl module Win32API::File::Time which addresses
> this specific problem. But this perl module is not installed by
> default[atleast by Active State]. I would like the people using this
> script, to avoid installing a perl module inorder to run the same.

Try PAR.
Or, if WIN32API::File::Time is pure perl, copy it into a BEGIN block at
the top of your script and add an import after, like

BEGIN {
    # stuff from WIN32API::File::Time
}
Win32API::File::Time->import(qw/what you would have put after use
    Win32API::File::Time/);

> I used Win32::File [GetAttribute , SetAttribute] to handle the
> read-only issue. This is working fine.
> 
> Any ideas how to handle the case when the file being 'touch'ed is
> opened already?

This is not a Perl question, it is a Win32 question. The answer will the
same for a program written in any other language that runs on Win32.

Ben

-- 
   If you put all the prophets,   |   You'd have so much more reason
   Mystics and saints             |   Than ever was born
   In one room together,          |   Out of all of the conflicts of time.
ben@morrow.me.uk                                    The Levellers, 'Believers'


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

Date: Wed, 20 Oct 2004 15:30:59 -0700
From: Jon Ericson <Jon.Ericson@jpl.nasa.gov>
Subject: Re: Regex matching non-contiguous sheds of text
Message-Id: <rcghdopauos.fsf@Jon-Ericson.sdsio.prv>

DM <elektrophyte-yahoo> writes:

> Jon Ericson wrote:
>
>> DM <elektrophyte-yahoo> writes:
>>
>>>However, in a few cases what is matched is totally unexpected.

>> If you were actually using perl, this wouldn't be too difficult with
>> the HTML::Parser module.  See perldoc -q html for some discussion
>> about the pitfalls of using a regex to parse HTML.
>
> Thanks for the reply. I don't see how the HTML::Parser module would
> help me in the task I described in my original post.
>
> I checked perldoc as you recommended, but the "pitfalls" mentioned
> don't seem to apply to what I'm doing.
>
> As I explained in my original post, I'm not trying to do some kind of
> general HTML parsing operation, such as stripping out HTML tags. I'm
> trying to find this string:
>
> href="[SOME_URL_FRAGMENT].pdf">
>
> My regex almost works, but is acting really weird in a few cases. I'm
> trying to nail down the reason for that. Perhaps I have a
> misconception or misunderstanding of regex syntax?

It looks like you got some help with the regex itself.  I hope this
works for you.

If you're doing something quick and dirty, and you don't mind the
occational mistake, there's nothing wrong with the regex approach.
But little scripts sometimes become mission-critical.  If that
happens, the regex might not be a good idea.  

Jon


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

Date: Wed, 20 Oct 2004 16:14:38 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regular Expression for HTML Tags and Special Characters
Message-Id: <slrncndl9u.5fu.tadmc@magna.augustmail.com>

Vijai Kalyan <vijai.kalyan@gmail.com> wrote:
>> How can I allowed some HTML-Tags like <BR>, <B>, <P> but
>> filter out <, >, when they stand alone? 
>> 
>> Must be something like: "^[A-Za-Z0-9\>\<]+$"
>> for the < and >, but where do i have to put in my tags?
> 
> As others said below, you should be using a parser instead of regexp
> for this, but I am just a beginner with perl and am trying to answer
> questions to get practice.
> 
> If you really want to use a regexp, lookup an example that's in the
> first chapter of the Camel book.
> 
> It goes something like this: (I will let u do the homework :)
> 
> m/<(.*?)>.*?(\/\1)/
               ^^^^

Where are the <angle brackets> for the endtag?


> m/<\s*(\w+)\s+.*?>.*?(\/\1)/
     ^^^


It is invalid HTML if it has whitespace there.

Will that work on the below (after taking out the \s*)?

   <foo>bar</foo>


> As someone said, it gets complicated. 


here are some more complications to try and match correctly:

   <!--  there are no <tags></tags> on this line at all! -->

   <img src="cool.jpg" alt=">>cool pic!<<">


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


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

Date: Wed, 20 Oct 2004 21:37:11 -0500
From: Vijayaraghavan Kalyanapasupathy <vijai.lists@gmail.com>
Subject: Re: Regular Expression for HTML Tags and Special Characters
Message-Id: <MPG.1be0dcb79485157d989684@news.vanderbilt.edu>

In article <slrncndl9u.5fu.tadmc@magna.augustmail.com>, 
tadmc@augustmail.com says...

> > m/<(.*?)>.*?(\/\1)/
>                ^^^^
> 
> Where are the <angle brackets> for the endtag?

Oops, apologies are in order. I missed them!

> 
> > m/<\s*(\w+)\s+.*?>.*?(\/\1)/
>      ^^^
> 
> It is invalid HTML if it has whitespace there.

I didn't know that. In this case we would modify it to

m/<(\w+)\s+.*?>.*?(\/\1)/

> 
> Will that work on the below (after taking out the \s*)?
> 
>    <foo>bar</foo>

(I am trying to answer without running the code. So if there's a 
mistake, you know whom you have to blame me.)

You are right it wouldn't. I would have to do this instead:

m/<(\w+)*?\s+.*?>.*?<\/\1>/

This will catch the "foo" minimally.

> here are some more complications to try and match correctly:
> 
>    <!--  there are no <tags></tags> on this line at all! -->

But if we had a regular expression that matched a <!-- . --> wouldn't 
that gobble up the <tags></tags> inbetween?

Of course, I am thinking more along the lines of a Lex input 
specification where you would typically do a:

<YYINITIAL> "<!--"   { yybegin(COMMENT);   } 
<COMMENT>   "-->"    { yybegin(YYINITIAL); }
<COMMENT>   \n       {                     }
<COMMENT>   \r       { yybegin(DOSEOL);    }
<COMMENT>   .        {			  }
<DOSEOL>    \n       {                     }
<DOSEOL>    .        { yybegin(COMMENT);   }

This is actually JLex input. But you can understand what it does. (I 
just sligthly modified from a JLex input for ASN.1 that I wrote. That's 
why you see the redundant state transitions on \n and \r. In ASN.1 a 
comment can be multiline but each multiline comment has to have the 
comment starter; in this case --)

> 
>    <img src="cool.jpg" alt=">>cool pic!<<">

Yes, I think the modified regexp above would get this.

Why? The minimal matcher should stop at the first ">" in the substring 
">> . Also because of the intervening \s+ and .*? the back reference 
would yield only "img" . But, the input itself in this case is incorrect 
right? 

If I am wrong, do correct. 

thanx,

hth,
-----
-vijai.


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

Date: Wed, 20 Oct 2004 21:42:59 -0500
From: Vijayaraghavan Kalyanapasupathy <vijai.lists@gmail.com>
Subject: Re: Regular Expression for HTML Tags and Special Characters
Message-Id: <MPG.1be0de32f0fac545989685@news.vanderbilt.edu>

In article <MPG.1be0dcb79485157d989684@news.vanderbilt.edu>, 
vijai.lists@gmail.com says...
> In article <slrncndl9u.5fu.tadmc@magna.augustmail.com>, 
> tadmc@augustmail.com says...
> 

The waters do get murkier. No, you are correct, I made a mistake in the 

<img src=".." alt=">>CoolPic<<">

example you gave.

the reg exp would actually do the wrong thing because it's too simple. 
As I said, it would definitely be easier with a lexer where you can 
remember state! 

It does get exceedingly complicated. But, then I am not sure if a 
regular expression can really match all types of input. Isn't that what 
the Chomsky hierarchy is about?

Correct me if I am wrong.

------
-vijai.


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

Date: 20 Oct 2004 22:37:16 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: source a config file
Message-Id: <Xns9588BD6C3B50Casu1cornelledu@132.236.56.8>

carloschoenberg@yahoo.com wrote in
news:8c526b62.0410201404.55667a9a@posting.google.com: 

>> carloschoenberg@yahoo.com wrote in 
>> news:8c526b62.0410192023.4c2ce6b@posting.google.com:
>> 
>> > I want to source (do/require/use) a config file. It must be
>> > compatible with warnings and strict.
>> > 
>> > I don't want warnings about a variable being used only once.
>> > 
>> > I don't want to put too much cruft in the config file. A package
>> > statement or a my is ok but an exporter is not. There will be many
>> > config files.
 ...

> Here's one way I tried to do it, based on a random suggestion found on
> the net:
> 
> $ cat a
> $x="hi";
> 
> $ cat b
> use strict;
> use warnings;
> 
> { package MyConfig; do './a'; }
> 
> print "$MyConfig::x\n";
> 
> But this happens:
> $ perl b
> Name "MyConfig::x" used only once: possible typo at b line 6.
> hi

If all you want is to be able to refer to variables etc in the MyConfig 
namespace, you why not just use a proper module (with no exporter):

D:\Home> cat MyConfig.pm
package MyConfig;
our $x = 'hi';
1;
__END__

D:\Home> cat c.pl
#! perl;

use strict;
use warnings;

use MyConfig;

print $MyConfig::x;
__END__

D:\Home> perl c.pl
hi


Sinan.



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

Date: 20 Oct 2004 16:29:26 -0700
From: happywhiterabbit@hotmail.com (Happy White Rabbit)
Subject: Why go to raves when you can write code to do it (sad)
Message-Id: <c93f7dfa.0410201529.5d81432b@posting.google.com>

What can I say? I was bored drunk and wanted to be at a party lol

It does run!




#!C:/Perl/bin/perl.exe -w 


no warnings; 

our $sober = 0; 
my $drugs = 5; # Just picked up 
my $money = 5; # Got some cash 

# Start the get wasted routine - pass in money and drugs 

&getwasted ($money, $drugs); 

sub getwasted { 

my @pills = ("Sense(?)","Psychdelic Twaddle","Yogurt Weaving nonsense", 
"Things which are offensive to everyone","Incredably embarassing 
and personal stuff", "Bollocks", "Sketchy shit people try to ignore"); 

my $money = $_[0]; 
my $drugs = $_[1]; 
my $fucked = 10; # when we hit ten we are there! 

for ($steve = $sober; $steve < $fucked; $snorted++){ 
$crap = pop @pills; 
print "Steve starts talking $crap \n"; 
push (@pills, $toanyone); 
chomp(my $stash = "\n"); 
pop(@pills); 
$steve += $snorted; 
} 

while ($drugs > 0) { 

do { 
my $ketamin = $loads; 
my $speed = $abit; 
my $acid = $toomuch; 
my $mushrooms = $notenough; 
$drugs--; 
} 
} 


if (not $fucked){ 
$buymore = "true" unless $money == 0; 
} 
}


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

Date: Wed, 20 Oct 2004 23:43:14 -0400
From: James Willmore <jwillmore@adelphia.net>
Subject: Re: Why go to raves when you can write code to do it (sad)
Message-Id: <-pydndDyabDWrercRVn-jA@adelphia.com>

Happy White Rabbit wrote:
> What can I say? I was bored drunk and wanted to be at a party lol
> 
> It does run!
<snip>

Without a doubt ... you were bored *and* drunk :-)
Now ... after you sober up a bit, try it *with* warnings :-)


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

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


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