[24137] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6331 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 29 14:05:40 2004

Date: Mon, 29 Mar 2004 11:05:09 -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           Mon, 29 Mar 2004     Volume: 10 Number: 6331

Today's topics:
    Re: Cannot reset LIBPATH in perl program on AIX <dmcbride@naboo.to.org.no.spam.for.me>
    Re: Choosing Perl/Python for my particular niche (Aahz)
        Contacted host in POE? <ggershSNACK@CAKEctc.net>
    Re: cpu use in threads ctcgag@hotmail.com
    Re: cpu use in threads (Walter Roberson)
    Re: Deleting old files in windows 2000 using Perl <ittyspam@yahoo.com>
    Re: Deleting old files in windows 2000 using Perl <jurgenex@hotmail.com>
    Re: Deleting old files in windows 2000 using Perl (Jim Keenan)
        DynaLoader  issues (APR/04) (Prabh)
    Re: how to capture multiple lines? <tadmc@augustmail.com>
    Re: how to capture multiple lines? <tadmc@augustmail.com>
    Re: how to capture multiple lines? <tadmc@augustmail.com>
    Re: how to capture multiple lines? (Anno Siegel)
    Re: how to capture multiple lines? <noreply@gunnar.cc>
    Re: how to capture multiple lines? <tadmc@augustmail.com>
    Re: how to capture multiple lines? <geoffacox@dontspamblueyonder.co.uk>
    Re: Lost data on socket - Can we start over politely? <tassilo.parseval@rwth-aachen.de>
    Re: LWP cookies (Peter Scott)
    Re: Net::SSH  Need example how to use..can't find one.. <glex_nospam@qwest.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 29 Mar 2004 16:12:20 GMT
From: Darin McBride <dmcbride@naboo.to.org.no.spam.for.me>
Subject: Re: Cannot reset LIBPATH in perl program on AIX
Message-Id: <EVX9c.42081$R27.32151@pd7tw2no>

Hemant Shah wrote:

> In comp.databases.ibm-db2 Big and Blue <No_4@dsl.pipex.com> wrote:
>> Hemant Shah wrote:
>>> 
>>>   I am having a problem with my perl module on AIX system. I cannot
>>>   reset LIBPATH variable from my perl module.
>> 
>>     You can set it.  What you mean is that setting it doesn't have any
>> effect.  This is true.  The value used is that at program startup.
> 
>   This is true.

You might be lucky enough to be able to put your env changes in a BEGIN
block and have that work.  If not, you may need to resort to some
serious amounts of trickery.

>>>                                     I have a perl script that uses my
>>>   perl module which in turn uses DBD::DB2 to get data from a database.
>>>
>>>   When user logs in, his environment may set LIBPATH and LD_LIBRARY_PATH
>>>   to another DB2 instance.
>> 
>>     Bad practice.  The values in here will refer to SPECIFIC
>>     APPLICATIONS,
>> so should not be set in a global context. (I trust that your Perl scripts
>> don't use global variables everywhere, but instead use correctly-scoped
>> ones?)
> 
>    I am not sure if it is a bad practice. When a user logs into the
>    system, his/her environment is set to access the database that is used
>    by the application in that development environment. Each development
>    area has different DB2 instance so the environment is set based upon
>    the active development area.

I would surmise that the "Bad practice" comment is coming from
comp.lang.perl.misc, and not from comp.databases.ibm-db2 ... to be
honest, I'm not sure of many database applications do not rely on
environment variables to specify which instance to use.

>    We store information of our source code in a seperate database and have
>    written several perl scripts that developer can use to search the
>    database.
> 
>    Until now all the DB2 instances were at same version (UDB V7.2) I
>    upgraded the source code database to UDB V8. Until I migrate all the
>    instances to UDB V8 I need to be able to run the scripts that access
>    source code database.

Can you simply catalog the v8 database from the v7 instances?  This
will necessarily restrict some of your access, but may be simpler than
any amount of trickery you might be forced to do.

>    I am NOT using global variables, all the varaibles are either within
>    the scope of the function or within the module (e.g. database handle).
>    That's why I want to change the path within the module.
> 
>    Here is the sample use of the module in the perl script:
> 
>    use MyModule;
> 
>    MyModule::ConnectToDatabase;
>    $SomeThing = MyModule::GetSomethingForMe($Var1, $Var2);
>    MyModule::TerminateConnection;

>>>   When functions from my perl module are called I would like to reset
>>>   LIBPATH to a different DB2 instance.
>> 
>> a) If you know where the dynamic libraries will be at the time you
>> compile the extension then set the relevant link-time options so that the
>> Perl extensions knows where to look.
> 
>   I tried that too. I set LIBPATH and LD_LIBRARY_PATH to what I wanted and
>   built DB2::DBD, but that did not help either.


>> b) if you can't do a) then run *your* application through a simple sehll
>> interlude script that does set LD_LIBRARY_PATH/LIBPATH to the value you
>> want and the exec your perl script.

local $ENV{LIBPATH} = ...;
local $ENV{LD_LIBRARY_PATH} = ...;
open(my $fh, "my_script.pl |") or die "can't open subprocess";
while (<$fh>)
{
}

Then have my_script.pl do the real work - it will have the right env
variables set up already.  You may actually be better off using
IPC::Open2 if you want to communicate with the subprocess.

>>>    One option I have is to write a wrapper shell script that resets the
>>>    variables and then calls the perl script. I am trying to avoid this
>>>    because there are many scripts (most of which are not under my
>>>    control) that call functions from my perl module and all of them will
>>>    have to change. I would rather change one module that is under my
>>>    control.
>>> 
>>>    Is there a way around it?
>> 
>>     Yes.
>> 
>> c) similar to b) but you pass in the name of the script you wish to run
>> as well, so that you only have one interlude script, but it can exec any
>> DB2 script.
> 
>  That will be difficult because I do not write the scripts, I wrote the
>  perl module that anyone can use to get the data from the database.




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

Date: 29 Mar 2004 11:57:02 -0500
From: aahz@pythoncraft.com (Aahz)
Subject: Re: Choosing Perl/Python for my particular niche
Message-Id: <c49kgu$r24$1@panix1.panix.com>

In article <40661C14.8365E058@doe.carleton.ca>,
Fred Ma  <fma@doe.carleton.ca> wrote:
>
>On the topic of speed, It's surprising to hear that this can be
>possibly rivaled by Perl/Python, considering that even my matlab code
>is about 10x slower than C++.  That's with extensive profiling and
>round-about coding styles to exploit vectorization tricks, and no such
>effort in the C++ code.

The reason people say this is because algorithmic experimentation is
cheap in Python/Perl.  An O(NlogN) algorithm in Python/Perl will lose to
an O(N^2) algorithm in C/C++ with a few elements, but as the data set
grows, the O(NlogN) algorithm will pull ahead.
-- 
Aahz (aahz@pythoncraft.com)           <*>         http://www.pythoncraft.com/

"usenet imitates usenet"  --Darkhawk


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

Date: Mon, 29 Mar 2004 13:00:05 -0500
From: Greg G <ggershSNACK@CAKEctc.net>
Subject: Contacted host in POE?
Message-Id: <2b6dnWOGqcSE-fXdRVn-uQ@ctc.net>


Another POE::Component::SNMP question here.

Once I'm inside of the callback, how do I find out what host this 
callback is for?  $kernel->hostname returns my local host name, and I 
can't figure out how Net::SNMP's session->hostname() is available.

Thanks.

-Greg G



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

Date: 29 Mar 2004 17:43:49 GMT
From: ctcgag@hotmail.com
Subject: Re: cpu use in threads
Message-Id: <20040329124349.700$Ys@newsreader.com>

"Angshuman Guin" <angshu31@hotmail.com> wrote:
> I am trying to use the capabilities of a multi(4) processor system to
> split a task by using threads. But when I run the program I see only one
> cpu being used although I have spawned 2 threads.
>
> Am I doing anything wrong? Here is some relevant portion of my code:
> __________________________________
> use threads;
> ...
> ...
> ...
> my $thr1 = threads->new(\&sub1, @det_files);
> my $thr2 = threads->new(\&sub1, @det_files1);
>
> $thr1->join;
> $thr2->join;

Alas, the only machine I have with 5.8 is a single CPU, but on
it each thread shows up a different process (with top), so I'm assuming
they would run simultaneously if I were to have multiple CPUs.

But there is one difference I notice in our versions that may be important:

>  useithreads=define usemultiplicity=
>     useperlio= d_sfio=undef uselargefiles=define usesocks=undef

your usemultiplicity seems to be unset (but strangly isn't listed as undef,
like most others are), while mine is :
usemultiplicity=define

I don't know that this is the problem, but it is what I would look into
first.

Well, actually, I'd probably not use threading at all, but rather fork.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 29 Mar 2004 18:17:43 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: cpu use in threads
Message-Id: <c49p87$8e3$1@canopus.cc.umanitoba.ca>

In article <c45vcg$4js$1@nets3.rz.RWTH-Aachen.DE>,
Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
:I am not an expert for Perl's threading capabilities. However, the POSIX
:thread library it uses (where available) isn't quite yet ready for SMP
:and wont distribute the threads over the processors (AFAIK).

I haven't looked at the standards in this regards, but on at least
one variety of "real" SMP (SGI Challenge XL), what happens is that
each of the threads may run on a different CPU but the time is
added into a single accounting structure -- resulting in oddities
like having a single process that is taking 700% of a CPU.
-- 
Warning: potentially contains traces of nuts.


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

Date: Mon, 29 Mar 2004 11:08:32 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Deleting old files in windows 2000 using Perl
Message-Id: <20040329110636.G25178@dishwasher.cs.rpi.edu>

On Mon, 29 Mar 2004, Avinash wrote:

> Hi,
> is someone have perl script wrote to delete files older than 30 days
> from diffrent diffretent folders in windows 2000 or similar.
> Or some one can guide any URL which can help me to write one.
>

Take a look at the File::Find module:
perldoc File::Find

and the file test operators:
perldoc -f \-X

and the unlink function:
perldoc -f unlink

Those three combined should definately give you the makings of such a
program.

Paul Lalli


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

Date: Mon, 29 Mar 2004 16:17:30 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Deleting old files in windows 2000 using Perl
Message-Id: <u_X9c.10245$Td3.5846@nwrddc02.gnilink.net>

Avinash wrote:
> is someone have perl script wrote to delete files older than 30 days
> from diffrent diffretent folders in windows 2000 or similar.
> Or some one can guide any URL which can help me to write one.

perldoc File::Find
perldoc -f -M
perldoc -f unlink

jue




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

Date: 29 Mar 2004 11:02:59 -0800
From: jkeen_via_google@yahoo.com (Jim Keenan)
Subject: Re: Deleting old files in windows 2000 using Perl
Message-Id: <196cb7af.0403291102.2aaec717@posting.google.com>

avindia@indiya.com (Avinash) wrote in message news:<fe5e1363.0403290757.650e4d75@posting.google.com>...
> is someone have perl script wrote to delete files older than 30 days
> from diffrent diffretent folders in windows 2000 or similar.
> Or some one can guide any URL which can help me to write one.
> 
> Pls advice

If you have Perl installed you can access all needed documentation
from the command prompt:

    perldoc perlfunc # for filetest operators, including '-M' for age
of file
    perldoc File::Find # module to process each file within a series
of directories
    perldoc -f unlink # 'unlink' is Perl's function to delete files

Jim Keenan


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

Date: 29 Mar 2004 09:47:24 -0800
From: Prab_kar@hotmail.com (Prabh)
Subject: DynaLoader  issues (APR/04)
Message-Id: <e7774537.0403290947.b4c8a11@posting.google.com>

Hello all,

I'm running to a few issues with (I think) DynaLoader being unable to
load a module.

This is run as part of integration of Rational ClearCase and Rational
ClearQuest on WIN XP.
ClearCase ver: 5.0 
ClearQuest ver: 2002.05.20 

The integration is supposed to bootstrap a particular Perl module
"CQPerlEXT.pm". It dies out with error messages,

"Can't load C:\Program
Files\Rational\ClearQuest\lib\MSWin32-x86-multi-thread\auto\CQPerlExt\CQPerlExt.dll"
for module
CQPerlExt: load_file :The specified module could not be found at
C:\Program Files\Rational\ClearQuest\lib\MSWin32-x86-multi-thread\DynaLoader.pm
line 200

at C:\Program Files\Rational\ClearQuest\lib\CQPerlExt.pm Line 7" 

At Line 7 in CQPerlExt.pm is the statement to 'bootstrap CQPerlExt'. 
The .dll in question is very much present and available.

I've Googled for this error and the solutions offered for these has
almost always been, "check if the directories in question are defined
in @INC."
I've made sure of that and also made sure the version of Perl being
used is the version the CQ-CC integration is expecting.

Could anyone give some pointers, please?

Thanks for your time,
Prab


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

Date: Mon, 29 Mar 2004 09:14:57 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: how to capture multiple lines?
Message-Id: <slrnc6gfbh.bfu.tadmc@magna.augustmail.com>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:

> If grabbing everything between <p> tags is *all* there is,


>      push @paras, $1 while m!<\s*p[^>]*>(.*?)<\s*/\s*p\s*>!igs;
                                ^^              ^^^ ^^^
                                ^^              ^^^ ^^^

Whitespace is not allowed there in HTML.


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


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

Date: Mon, 29 Mar 2004 09:18:32 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: how to capture multiple lines?
Message-Id: <slrnc6gfi8.bfu.tadmc@magna.augustmail.com>

Geoff Cox <geoffacox@dontspamblueyonder.co.uk> wrote:

> The nearest I get with $/ is 
> 
> sub para {
> 
> local ($/ = "\0D\0A");
> 
> my ($linepara)  = @_;
> $linepara =~ /<p>(.*?)<\/p>/s;
> # print ("\$1 = $1 \n");
> print OUT ("<tr><td colspan=2>" . $1 . "<\/td><\/tr> \n");
> $/ = "";
> }


Why are you still changing the value of $/ ?

The value of $/ does NOT affect pattern matching.

The value of $/ may affect the string that the pattern is attempting
to match against, but you do not show that the string is being
input anywhere.


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


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

Date: Mon, 29 Mar 2004 09:21:18 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: how to capture multiple lines?
Message-Id: <slrnc6gfne.bfu.tadmc@magna.augustmail.com>

Geoff Cox <geoffacox@dontspamblueyonder.co.uk> wrote:

> $linepara =~ /<p>(.*?)<\/p>/s;
> print OUT ("<tr><td colspan=2>" . $1 . "<\/td><\/tr> \n");


You should never use the dollar-digit variables unless you
have first ensured that the match *succeeded*.

Slash characters are not special in strings, there is no
need to backslash them.


   if ( $linepara =~ /<p>(.*?)<\/p>/s ) {
      print OUT "<tr><td colspan=2>$1</td></tr>\n";
   }


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


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

Date: 29 Mar 2004 17:16:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how to capture multiple lines?
Message-Id: <c49llf$69n$1@mamenchi.zrz.TU-Berlin.DE>

Geoff Cox  <geoffacox@dontspamblueyonder.co.uk> wrote in comp.lang.perl.misc:
> On 29 Mar 2004 12:50:44 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
> Siegel) wrote:
> 
> >The parentheses counteract the intention of "local".  Parenthesized like
> >this, "\0d\0a" is assigned to $/ and that value is localized.  You want
> >to localize $/ first:
> >
> >    local $/ = "\0a\0d";
> 
> Anno,
> 
> I do not understand this! If I use
> 
> local $/ = "\0D\0A";     in the sub routine
> 
> I do not get the <p> ...... </p> text.
> 
> If I use
> 
> local ($/ = "\0D\0A");
> 
> I do get it !! But then I get some text which I do not wish to have!
> 
> Any ideas?

Well, for one I suggest that you print out "\0D\0A".  You will see
that it isn't what you think it is.  You want "\x0d\x0a".

Setting $/ = "\0D\0A" means that the next read will slurp in the rest of
the file (because that sequence is unlikely to be met).  What that means
for the behavior of your program I don't know.  In any case, you ought
to get the intended end-of-line sequence right first.

The behavior of "local ( $/ = 'something')" is a bit mystifying.  Since
local() happens after the assignment, it should render $/ undefined,
but it preserves the value assigned.  It's probably the DWIMmer.
In any case, it assigns to $/ *before* local() happens, and so makes
local() useless.

Anno


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

Date: Mon, 29 Mar 2004 19:28:21 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how to capture multiple lines?
Message-Id: <c49md2$2grisb$1@ID-184292.news.uni-berlin.de>

Tad McClellan wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>>If grabbing everything between <p> tags is *all* there is,
> 
>>     push @paras, $1 while m!<\s*p[^>]*>(.*?)<\s*/\s*p\s*>!igs;
>                               ^^              ^^^ ^^^
>                               ^^              ^^^ ^^^
> 
> Whitespace is not allowed there in HTML.

Hmm.. I put in those just before sending in order to *prevent* 
objections to using a regex... ;-)

I'm sure you are right. My Mozilla browser doesn't seem to know, 
though, but to my surprise MSIE does.

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



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

Date: Mon, 29 Mar 2004 11:27:56 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: how to capture multiple lines?
Message-Id: <slrnc6gn4s.bia.tadmc@magna.augustmail.com>

Geoff Cox <geoffacox@dontspamblueyonder.co.uk> wrote:
> On Mon, 29 Mar 2004 07:51:24 -0600, Tad McClellan
><tadmc@augustmail.com> wrote:
>>Geoff Cox <geoffacox@dontspamblueyonder.co.uk> wrote:
>>
>>>  $/ = "\0a\0d";
>>>  $line =~ /<p>(.*?)<\/p>/s;
>>>  $/ = "\0a";
>>> 
>>> The 3rd line does not appear to put $/ back to the default value??
>>                        ^^^^^^
>>                        ^^^^^^
>>
>>There is nothing about the effect of $/ that can be observed
>>from the code you posted.
> 
> Tad,
> 
> the whole code follows !! 


Don't do that!

Make a short and complete program that we can run that illustrates
the problem you are asking about.

Have you seen the Posting Guidelines that are posted here frequently?


        First make a short (less than 20-30 lines) and *complete* program
        that illustrates the problem you are having. People should be able
        to run your program by copy/pasting the code from your article. (You
        will find that doing this step very often reveals your problem
        directly. Leading to an answer much more quickly and reliably than
        posting to Usenet.)

        Describe *precisely* the input to your program. Also provide example
        input data for your program. If you need to show file input, use the
        __DATA__ token (perldata.pod) to provide the file contents inside of
        your Perl program.


> I know it has little elegance 


It is downright horrid style.

You can make your life easier if you make you code easier to
read and understand.


> Perhaps you can see
> why the $/ is not working correctly? 


Because you set it *after* you have already read from the file.

It affects input, you much change it before you do the input
that you want to affect.



> warnings;


Please post your *actual* code:

   use warnings;


Have you seen the Posting Guidelines that are posted here frequently?

    Do not re-type Perl code
        Use copy/paste or your editor's "import" function rather than
        attempting to type in your code. If you make a typo you will get
        followups about your typos instead of about the question you are
        trying to get answered.



> use File::Find;
> my $dir = 'd:/a-keep9/prog-nondb/old-prog';
> 
> find sub {
> my $name = $_;


There is no need to copy it from one scalar to another.

Why do you copy it from one scalar to another?


>    if ($name =~ /.htm/) {


That will match if $name = 'nightmare'.

Is that what you want? 

Probably not, so:

   if ( /\.htm$/ ) {


>    open (IN, "$name");

   perldoc -q vars

       What's wrong with always quoting "$vars"?

Lose the useless use of quotes.

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

   open IN, $_ or die "could not open '$_'  $!";
or
   open IN, $name or die "could not open '$name'  $!";


>        while (defined (my $line = <IN>)) {


You need to change $/ *before* that line of code...


>           if ($line =~ /<p>/) {
>           &para($line);


 ... but you change it *after* in the para() subroutine.

Too late, changing it there will not affect the contents of $line.


>    print OUT ("<\/table>\n<\/body>\n<\/html>");


Slashes are not special in strings, no backslashing needed.

   print OUT ("</table>\n</body>\n</html>");



> sub choice {
> my ($path) = @_;
>   if ($path =~/btec-first/) {
>   &intro($path);
>   &applefirst($path);
> } elsif ($path =~ /classroom-notes/) {
>   &intro($path);
>   &clasroomnotes($path);
> }elsif ($path =~/pears\/assignments/) {
>   &intro($path);
>   &pearsassignments($path);
> } else {
>   &intro($path);
>   &other($path);
>        }
> }


You call intro($path) for every alternative!

You should just call it once at the top of the sub instead.



>>
>>[ snip TOFU ]
> 


Please compose your followups properly.

Soon.

Like on your very next followup.


Have you seen the Posting Guidelines that are posted here frequently?

    Use an effective followup style
        When composing a followup, quote only enough text to establish the
        context for the comments that you will add. Always indicate who
        wrote the quoted material. Never quote an entire article. Never
        quote a .signature (unless that is what you are commenting on).

        Intersperse your comments *following* each section of quoted text to
        which they relate. Unappreciated followup styles are referred to as
        "top-posting", "Jeopardy" (because the answer comes before the
        question), or "TOFU" (Text Over, Fullquote Under).

        Reversing the chronology of the dialog makes it much harder to
        understand (some folks won't even read it if written in that style).
        For more information on quoting style, see:

         http://web.presby.edu/~nnqadmin/nnq/nquote.html


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


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

Date: Mon, 29 Mar 2004 18:44:50 GMT
From: Geoff Cox <geoffacox@dontspamblueyonder.co.uk>
Subject: Re: how to capture multiple lines?
Message-Id: <gjrg605ndfs2n1o9eojs61bule9qvg9r10@4ax.com>

On 29 Mar 2004 17:16:31 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:

>
>Well, for one I suggest that you print out "\0D\0A".  You will see
>that it isn't what you think it is.  You want "\x0d\x0a".
>
>Setting $/ = "\0D\0A" means that the next read will slurp in the rest of
>the file (because that sequence is unlikely to be met).  What that means
>for the behavior of your program I don't know.  In any case, you ought
>to get the intended end-of-line sequence right first.
>
>The behavior of "local ( $/ = 'something')" is a bit mystifying.  Since
>local() happens after the assignment, it should render $/ undefined,
>but it preserves the value assigned.  It's probably the DWIMmer.
>In any case, it assigns to $/ *before* local() happens, and so makes
>local() useless.

Anno

many thanks for this - will have to try a little later - must go out
for short while!

Cheers

Geoff


>
>Anno



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

Date: 29 Mar 2004 18:12:44 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Lost data on socket - Can we start over politely?
Message-Id: <c49ous$hif$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Vorxion:

> In light of some uh...disagreements, I've bent a bit.  Hopefully it's taken
> as a token of goodwill.  I could use the help, I'm willing to bend a bit to
> do it.  SO...
> 
> I've reworked this to both make it shorter, and so that my extra curly
> brackets are not present.  I also implemented strict and warnings.

Thank you for the time you invested into readability. 

> In short, connect with anything and toss, say... 4000 thousand lines of
> input at the server.  It should give up the ghost far early--somewhere
> around 1120-2200, depending on the phase of the moon.  You'll note that if
> you're still connected, you can even send more data.  It's purely a
> buffering issue.

It seems to be one:

    while ($single_conn->read($line,102400)) 

If I am not completely mistaken, perl internally uses recvfrom(2) when
reading from a socket. AFAIK, a socket's send and receive buffer is each
around 64kB. You try to read significantly more than that. What happens
when you read in smaller chunks? 

Also, I'd return to using sysread() which you initially used. You are
using select() which doesn't work particularly will with buffered I/O.

[...]

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Mon, 29 Mar 2004 17:34:27 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: LWP cookies
Message-Id: <D6Z9c.42492$R27.30956@pd7tw2no>

In article <8AW9c.42530$QO2.39890@pd7tw1no>, I wrote:
>In fairness to the OP he probably meant JavaScript - that has caused
>me problems on mechanizing some sites and I can easily imagine it
>being too difficult to figure out what it's doing.  Until we get a JS
>engine for Perl there's no way to avoid manual inspection.

Hmm, no sooner do I say that than this shows up:

===================
http://search.cpan.org/~abeltje/Win32-IE-Mechanize-0.004/

This module is mostly a port of the very popular WWW::Mechanize
module but uses InternetExplorer as the user-agent. This makes it
possible to also test JavaScript dependant webpages.
===================

Haven't tried it, don't have enough time + inclination, and it's brand new
(first version posted within last 24 hours).  Still, interesting...

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/


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

Date: Mon, 29 Mar 2004 11:11:17 -0600
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: Net::SSH  Need example how to use..can't find one...
Message-Id: <VMY9c.469$gv3.26724@news.uswest.net>

cayenne wrote:

> I've read the pm...and just don't know what to do with it. I've tried
> using ssh() and ssh_cmd() like the examples, but, I keep getting
> errors.
> 
> For instance I'm trying:
> 
>  print "Removing file = $file_name.tar.gz\n";
> 		 
> ssh_cmd("username\@sid","rm
> /data/VOL1/oradata/backups/sid/$directory/$file_name.tar.gz") || die
> "ssh: $!";
> 
> I've done numerious print statements, and my $directory and $file_name
> strings are correct. However, when I try it with the line above, with
> ssh_cmd, it blows. Here's the feedback from running this:
> 
> Removing file = fred_test_01_Mar_2004.tar.gz
> Undefined subroutine &main::ssh_cmd called at clean_backups2.pl line
> 64.

Make sure you have the following line in your code:

use Net::SSH qw(ssh_cmd);

Without that, your script doesn't know where to find "ssh_cmd".

> I tried using the ssh() function which looked similar to the ssh_cmd
> function..but, crashed about the same way.
> 
> I'm not sure what the => symbols mean in some examples I've seen.  The
> perldoc and pm give:

Makes your hash key & value settings look nicer and more readable.

 From perldoc perlop

The => operator is a synonym for the comma, but forces any word
to its left to be interpreted as a string (as of 5.001). It is helpful
in documenting the correspondence between keys and values in hashes,
and other paired elements in lists.


> The only example they give is for the sshopen2 function, and it seems
> to reading a file or something...I'm not sure what's going on there. I
> don't need to open a file, or move one around. I just need to delete
> one.

It allows you to read output from the command you send in the SSH. 
Since it doesn't appear that you need this, just using the ssh_cmd() 
seems correct.

> I'm sure this can be done with this package..but, in all my searches
> so far...nothing like what I want to do..or they are all using
> net::ssh::perl, which is not available to me.
> 
> I guess I'm confused as to why the ssh() and ssh_cmd() calls aren't
> working..they look simple enough...
> 
> Anyway, any simple example or link to one would be greatly
> appreciated!!

Based on your above code, your script should look something like the 
following (untested):

#!/usr/local/bin/perl
use strict;
use Net::SSH qw(ssh_cmd);

my $directory = '???'; #don't know what this is set to..
my $file_name = 'fred_test_01_Mar_2004';
my $user = 'user';
my $host = 'sid';

ssh_cmd( {
     user => $user,
     host => $host,
     command => "rm 
/data/VOL1/oradata/backups/sid/$directory/$file_name.tar.gz",
    } ) or die "Error: $!";

Same as using the ssh method:

ssh("$user\@host", "rm 
/data/VOL1/oradata/backups/sid/$directory/$file_name.tar.gz") or die 
"Error: $!";

only it's a bit more readable.

It's also much safer to use the full path to whatever command you're 
calling on the other machine.. e.g. "/bin/rm" instead of "rm".

If that gives you errors, after you set the variables correctly, post 
your short script and the error so we can see what might be the problem.

Thanks


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

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


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