[19129] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1324 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 18 09:06:10 2001

Date: Wed, 18 Jul 2001 06:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <995461512-v10-i1324@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 18 Jul 2001     Volume: 10 Number: 1324

Today's topics:
    Re: Advice REQ for newbie <andrew@mvt.ie>
    Re: All computers in world MUST sync with ATOMIC clock  <carlos@plant.student.utwente.nl>
    Re: Anyone used blat.exe? (Rene Nyffenegger)
    Re: Anyone used blat.exe? <wyzelli@yahoo.com>
        DBD::MSSQL module ??? <f_dubru@yahoo.com>
    Re: Debugger -- ActivePerl / Perl Builder / Perltk / <netmail@rehstreichler.de>
        Email Question (John Almberg)
        FAQ: How can I make my Perl program take less memory? <faq@denver.pm.org>
    Re: FAQ: How can I use curses with Perl? (Bernd St)
    Re: Getting Byref Argument nobull@mail.com
    Re: How to timeout a socket recv under win32? <bart.lateur@skynet.be>
        I'm just beggining. Where can I find good examples? <ruifortes@clix.pt>
    Re: I'm just beggining. Where can I find good examples? (John Almberg)
    Re: Including flock in code while developing in Windows <bart.lateur@skynet.be>
    Re: Including flock in code while developing in Windows <m.grimshaw@salford.ac.uk>
    Re: Perl or PHP? (John Almberg)
        perl-script and sftp (secure ftp) (Bernd St)
    Re: puzzle with 'if' statement nobull@mail.com
    Re: Reblessing part of object data structure in another (Anno Siegel)
        Removing .coms (Blstone77)
    Re: Removing .coms <carlos@plant.student.utwente.nl>
    Re: Replacing a specific line <flavell@mail.cern.ch>
        Scrollable lists in console <santtu.nyrhinen@nokia.com>
    Re: skipping a duplicate <bart.lateur@skynet.be>
        staroffice and Perl <jarausch@numa1.igpm.rwth-aachen.de>
        Trouble extracting strings - help needed (Mark Smith)
    Re: Trouble extracting strings - help needed (Bernard El-Hagin)
        Using a Perl module outside from Perl-dir? (T.Hopkins)
    Re: Using a Perl module outside from Perl-dir? <m.grimshaw@salford.ac.uk>
    Re: Using a Perl module outside from Perl-dir? (Rafael Garcia-Suarez)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 18 Jul 2001 11:27:57 +0100
From: "Andrew" <andrew@mvt.ie>
Subject: Re: Advice REQ for newbie
Message-Id: <9j3obs$32c$1@kermit.esat.net>


"Pete" <bloke6789@hotmail.com> wrote in message
news:c1c57.46228$WS4.7098239@news6-win.server.ntlworld.com...
> Here's the code, please can you tell me why
> it works as it stands, but not if I put "\d{1,2,3}" (no quotes), as an
> attempt to remove 98 99 _and_ 100? Excuse the hard coding - this is a
demo.

[Snip..]

If you look in the perlre section of the documentation, you'll see that
{n,m} will match at least n but not more than m times.  Therefore, what you
need is "\d{1,3}" to match between one and three digits.

Andrew





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

Date: Wed, 18 Jul 2001 12:32:09 +0200
From: "carlos" <carlos@plant.student.utwente.nl>
Subject: Re: All computers in world MUST sync with ATOMIC clock before 12:00 AM  21July 2001
Message-Id: <9j3ojc$nrm$1@dinkel.civ.utwente.nl>

isn't that why the NTP protocol uses UDP?

--
carlos

"Philip Newton" <pne-news-20010718@newton.digitalspace.net> wrote in message
news:nh7altkd9v3tm5tnb71do5bth5ke93agah@4ax.com...
> On Wed, 18 Jul 2001 12:45:42 +0930, "Wyzelli" <wyzelli@yahoo.com> wrote:
>
> > "alavoor" <alavoor@yahoo.com> wrote in message
> > news:3B54F753.7B166886@yahoo.com...
> > >
> > > Do you know that Cesium Atomic clock located in Boulder, Colarado, USA
> > > is the world's most accurate clock!! It does not lose or gain one
second
> >
> > Indeed.  More accurate than any other Cesium Atomic clock?
>
> And how accurate will your clock be if TCP packets take 1.5 seconds to
> go from there to your computer? Does the PHP applet take round-trip time
> into account and correct the reading? I rather doubt it. So much for the
> accuracy, then. "My computer clock doesn't keep the exact time, but at
> least it's always *exactly* 738ms slow!"
>
> Cheers,
> Philip
> --
> Philip Newton <nospam.newton@gmx.li>
> That really is my address; no need to remove anything to reply.
> If you're not part of the solution, you're part of the precipitate.




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

Date: 18 Jul 2001 11:39:36 GMT
From: rene.nyffenegger@gmx.ch (Rene Nyffenegger)
Subject: Re: Anyone used blat.exe?
Message-Id: <Xns90E2133A2E7EBgnuegischgnueg@130.133.1.4>


> system qq(blat.exe "$body"
>  -to "$rs22->Fields(3)->{Value}"
>  -subject "Your squad"
>  -i "$from"
>  -body "$body");
>
>As you can see, there's a mixture of scalars and hard-coded strings
>being passed to blat.  So far, nothing has appeared in my mailbox!
>
>Any help will be gratefully accepted.  If any other information is
>required, just say the word.
>
>TIA



This works on my machine:

my $blatout = `blat.exe  $temp_file -t $emailAddress -i "René Nyffenegger"   
-s "foo subject"`;

print "blat returned: $blatout\n";


It seems to me that the first argument to blat, if no option,
is a filename rather than text.

Then also, have you installed blat?
blat -install ...

Hth

Rene



-- 
http://www.adp-gmbh.ch/
rene dot nyffenegger at adp-gmbh dot ch



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

Date: Wed, 18 Jul 2001 21:38:39 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Anyone used blat.exe?
Message-Id: <uLe57.2$2j5.832@vic.nntp.telstra.net>

"Brian Spittles" <ng@spittles.freeuk.com> wrote in message
news:bf39ltki7uu11g78hogaolui661so651fd@4ax.com...
> Hi,
>
> I'm trying to use blat.exe (after my host switched from Unix to NT).
> Following answers given (to other questions) in other NGs, I've
> constructed the following:
>
>  system qq(blat.exe "$body"
>   -to "$rs22->Fields(3)->{Value}"
>   -subject "Your squad"
>   -i "$from"
>   -body "$body");
>
> As you can see, there's a mixture of scalars and hard-coded strings
> being passed to blat.  So far, nothing has appeared in my mailbox!
>
> Any help will be gratefully accepted.  If any other information is
> required, just say the word.
>

I've had more success with sendmail for windows.  Less script modifications
too.

Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';




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

Date: Wed, 18 Jul 2001 11:58:43 GMT
From: "Fred" <f_dubru@yahoo.com>
Subject: DBD::MSSQL module ???
Message-Id: <TRe57.91$H57.14508172@news2.randori.com>

Hi,

Is there any DBD::MSSQL module available? Otherwise anybody tryed to access
such kind of db through the DBD::ODBC? Did it work fine?

Thanks for the feed-back.

Fred.




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

Date: Wed, 18 Jul 2001 14:57:51 +0200
From: "Marcus Rudolph" <netmail@rehstreichler.de>
Subject: Re: Debugger -- ActivePerl / Perl Builder / Perltk /
Message-Id: <9j411i$mcisp$1@ID-58484.news.dfncis.de>

> Does ActivePerl come with the standard perl interpreter?  so that I
> can write code using ActivePerl,  then run it on unix's perl.  Any
> compatiblity problem?
>
I don't know all to much about the debugger thing but what you might want to
try is cygwin, available at www.cygwin.com . It provides an unix api ontop
of the win api and, because of that, allows many gnu tools and such to be
run on the windows machine inside the cygwin bash.
Perl is ported and works pretty well as far as I'm able to judge (but
then...). Just try it out, it will be a huge improvement to your windows
anyway, You can then use things like command line extention known on unix
systems....

Marcus




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

Date: 18 Jul 2001 05:42:18 -0700
From: jalmberg@identry.com (John Almberg)
Subject: Email Question
Message-Id: <c396bdba.0107180442.dfe228a@posting.google.com>

I am writing a perl script to send email to all our subscribers. The
email is a multipart/alternative containing both plain text and HTML
versions. No problem generating or sending the mail. I got the whole
program working & debugged, tested using Outlook, Yahoo, Hotmail,
Pine, etc.. Worked great!

Full of confidence, I sent a few test mails to Outlook, unplugged my
laptop, and walked down to the marketing guy to show him the results.
To my surprise, all of the test emails showed up as completely blank
pages in Outlook as long as my laptop wasn't connnected to the net.

After thinking about this overnight, I am surprised that the images
(just a few,  mall ones) aren't cached, and even more surprised that
Outlook doesn't render the plain old HTML. In fact, I'm staring at a
couple of HTML emails (from other people) which behave that way when
my machine is off-line: Outlook renders the HTML okay, and leaves
spacers for the graphics it can't fetch from the net.

Any ideas what I'm doing wrong? And does anyone know of a newsgroup
devoted to email issues? Ever since I've started working on this
project, I've realized that email readers are even less standardized
than browsers and it is really tricky to get mail to render properly
in multiple readers.

Thanks in advance for any help! 

John


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

Date: Wed, 18 Jul 2001 12:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How can I make my Perl program take less memory?
Message-Id: <17f57.7$pQ2.203808256@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How can I make my Perl program take less memory?

    When it comes to time-space tradeoffs, Perl nearly always prefers to
    throw memory at a problem. Scalars in Perl use more memory than strings
    in C, arrays take more than that, and hashes use even more. While
    there's still a lot to be done, recent releases have been addressing
    these issues. For example, as of 5.004, duplicate hash keys are shared
    amongst all hashes using them, so require no reallocation.

    In some cases, using substr() or vec() to simulate arrays can be highly
    beneficial. For example, an array of a thousand booleans will take at
    least 20,000 bytes of space, but it can be turned into one 125-byte bit
    vector--a considerable memory savings. The standard Tie::SubstrHash
    module can also help for certain types of data structure. If you're
    working with specialist data structures (matrices, for instance) modules
    that implement these in C may use less memory than equivalent Perl
    modules.

    Another thing to try is learning whether your Perl was compiled with the
    system malloc or with Perl's builtin malloc. Whichever one it is, try
    using the other one and see whether this makes a difference. Information
    about malloc is in the INSTALL file in the source distribution. You can
    find out whether you are using perl's malloc by typing "perl
    -V:usemymalloc".

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           03.17
-- 
    This space intentionally left blank


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

Date: 18 Jul 2001 03:19:51 -0700
From: bernd.storsberg@arcor.net (Bernd St)
Subject: Re: FAQ: How can I use curses with Perl?
Message-Id: <4a656122.0107180219.352c832@posting.google.com>

Sorry, but the page you requested is unavailable


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

Date: 17 Jul 2001 23:38:52 +0100
From: nobull@mail.com
To: "Anil Kripalani" <anilk@broden.com>
Subject: Re: Getting Byref Argument
Message-Id: <u9d76ymutp.fsf@wcl-l.bham.ac.uk>

It's been so long I'm mailing this as well as posting.

"Anil Kripalani" <anilk@broden.com> writes:

> Is there some trick to reading a byref argument?  I am making a COM call (to
> VB ActiveX DLL) where the second argument is returned (byref).  I can't read
> it from a PerlScript call (It's just empty).  Is there anything special I
> need to do?

Are you still wondering about this?

I don't know about PerlScript and ActiveX but the answer for Perl and
COM/OLE can be found tacked on as an afterthought right at the end of
the manpage for Win32::OLE::Variant.

        my $x = Variant(VT_I4|VT_BYREF, 0);
        my $y = Variant(VT_I4|VT_BYREF, 0);

        $Corel->GetSize($x, $y);

        $x = $x->Value; # Convert Win32::OLE::Variant -> simple scalar
        $y = $y->Value; # ...probably redundant in most cases

I have an unpolished (i.e. undocumented) module that provides a
function ByRef() that lets you simply write this as:

        $Corel->GetSize(ByRef([VT_I4], my($x, $y)=(0,0)));

Because most byref arguments are VT_DISPATCH, ByRef() defaults to
assuming VT_DISPATCH if no type information is given.

       my $retval = $some_ole_object->SomeMethod(ByRef(my $another_ole_object));
       $another_ole_object->SomeOtherMethod();

If anyone wants to take this module and polish it up for publication
please let me know.

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


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

Date: Wed, 18 Jul 2001 12:25:45 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to timeout a socket recv under win32?
Message-Id: <2kvalts8rqekgkieulrqvkutjk73lefm34@4ax.com>

Benjamin Goldberg wrote:

>> So you mean recv().
>
>Umm, what do you mean by that comment?

Oops, I have ben mixing threads. I cconfused this with another current
thread, where the OP asked how you can know how many bytes there are
currently available for reading.

It all boils down to this: how do you receive all the data that the
other side is sending to you, without waiting for more that won't come?
How do you know that, for the moment, the transmission is complete?

<S>, read, sysread, recv are similar yet different. I guess that only
read() is not usable. select() or IO::Select can tell you that something
is available, but not how much. I have the feeling that there isn't a
real generic solution, that the sender somehow HAS to indicate how long
the transmission will be. Otherwise, the receiver can stop receiving too
soon, or wait for something that won't come.

-- 
	Bart.


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

Date: Wed, 18 Jul 2001 11:37:50 +0100
From: "Rui Fortes" <ruifortes@clix.pt>
Subject: I'm just beggining. Where can I find good examples?
Message-Id: <MEd57.12724$Oz6.37248122@newsserver.ip.pt>

Hello.

I'm just beggining learning Perl.
I installed Perl 5.6 but I found the documentation a little confuse.
I trying to embedd Perl in a C++ program and of course extendeng it .
I find a little confusing the extending part (the other a bit to) and my
brain isn't at its best after a days work...
Can someone point me some good online documentation and examples for slow
brains ;-)
If you could point me a good book also..something a begginer could
understand but covering the embedding and extending part would be great.

 Thanks a lot.




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

Date: 18 Jul 2001 05:50:25 -0700
From: jalmberg@identry.com (John Almberg)
Subject: Re: I'm just beggining. Where can I find good examples?
Message-Id: <c396bdba.0107180450.ad2c7ed@posting.google.com>

"Rui Fortes" <ruifortes@clix.pt> wrote in message news:<MEd57.12724$Oz6.37248122@newsserver.ip.pt>...
> Hello.
> 
> I'm just beggining learning Perl.
> I installed Perl 5.6 but I found the documentation a little confuse.
> I trying to embedd Perl in a C++ program and of course extendeng it .

Wow. Nothing like starting with the hard bits!

Check out Programming Perl Chapter 21 and all the MAN pages referred
to in that chapter.

John


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

Date: Wed, 18 Jul 2001 10:41:44 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Including flock in code while developing in Windows for Unix??
Message-Id: <jupalto2oa4e40j02gg3lso854nmupdg0v@4ax.com>

Mark Grimshaw wrote:

>		if(eval "use Fcntl qw(:flock)")	# has flock()
 ...
><snip>
>
>on WinNT ActiveState, this prints:
>no flock:
>
>with nothing in $@ yet I can lock a filehandle with LOCK_EX...  Any idea
>what I'm doing wrong?

The code you eval doesn't fail, yet it doesn't return a value. Two
solutions:

 - use $@ as the definitive test.

		eval "use Fcntl qw(:flock)";
		unless($@)	# has flock()


 - add a true statement to your eval:

		if(eval "use Fcntl qw(:flock); 1")	# has flock()

-- 
	Bart.


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

Date: Wed, 18 Jul 2001 12:40:08 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: Including flock in code while developing in Windows for Unix??
Message-Id: <3B557598.BDB1F9FF@salford.ac.uk>



Bart Lateur wrote:
> 
> Mark Grimshaw wrote:
> 
> >               if(eval "use Fcntl qw(:flock)") # has flock()
> ...
> ><snip>
> >
> >on WinNT ActiveState, this prints:
> >no flock:
> >
> >with nothing in $@ yet I can lock a filehandle with LOCK_EX...  Any idea
> >what I'm doing wrong?
> 
> The code you eval doesn't fail, yet it doesn't return a value. Two
> solutions:
> 
>  - use $@ as the definitive test.
> 
>                 eval "use Fcntl qw(:flock)";
>                 unless($@)      # has flock()
> 

I'm not sure I understand that.  I thought $@ would contain something if
the eval failed in which case, it does NOT have flock() (if I understand
eval correctly).

>  - add a true statement to your eval:
> 
>                 if(eval "use Fcntl qw(:flock); 1")      # has flock()
> 

Is this simply to force the issue?


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

Date: 18 Jul 2001 05:34:47 -0700
From: jalmberg@identry.com (John Almberg)
Subject: Re: Perl or PHP?
Message-Id: <c396bdba.0107180434.cb408f5@posting.google.com>

>1.  What are the main differences/advantages between perl and PHP? 
As I
>understand it, PHP is used inline in HTML and perl is purely a CGI
language.
>In that case, what is the advantage of perl over PHP?

Unlike most people here (I'd guess), I learned PHP before Perl, so
I'll lend my perspective:

1. PHP is easier to learn than Perl. I say 'easier' in its most
relative sense -- easy if you spent ten years writing C (like me), not
so easy if you majored in Fine Art instead of Computer Science (like
my brother who had a VERY difficult time learning PHP and eventually
gave up.)

2. Both PHP and Perl do a good job of generating dynamic web pages.
PHP is always in-line . . . Perl can be used in-line, as a CGI script,
or as a purely stand-alone program (for example, I am currently using
Perl to generate plain-text and HTML email. I wouldn't want to try
that with PHP.)

3. Perl can be used for lots of other web-related tasks. For example,
I have a demo site where people can play with the content of the site.
I have a small perl program running in the background (a cron process)
that resets the database every 15 minutes, to foil users who feel the
compulsion to leave dirty words and pictures on my site. (Hey, what up
with THAT???)

4. Though PHP is easier to learn, Perl is easier to use in the long
run, because it has soooooo many coooooool features that make hard
things easy (to quote someone.)

5. UNFORTUNATELY, there are no really good PHP books out there, so it
isn't as easy to learn as it might be. There are any number of very
good Perl books (again, 'very good' being a relative term. If you are
a graphics person, you will find Programming Perl next to useless, but
you might try Learning Perl and see how you do.)

6. If you learn Perl, you can get a job. VERY few PHP jobs out there
so far.


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

Date: 18 Jul 2001 03:07:38 -0700
From: bernd.storsberg@arcor.net (Bernd St)
Subject: perl-script and sftp (secure ftp)
Message-Id: <4a656122.0107180207.24e09754@posting.google.com>

Dear pe(a)rls,
I have to this job:
Write perl script which transfers files from unix-A to unix-B by sftp
(secure ftp).
on unix-A runs the perl-script, this computer has no C-environment,
unix-B can only handle sftp.
I con not use sftp from CPAN (no C-Compiler). I have to write a
wrapper for sftp-commands. Because I had no test-sftp, I startet with
a perl-script for wrapping a ftp-session.
This works, I get messages and file-informations back, when I do "ls",
"dir" or something like this.
Wenn I change "ftp" with "sftp" and some other little things, I can't
read anything from unix-B.
Has anybody worked with this situatio ?
Would be nice to get a response.
Bernd
 
Here some pieces from the ftp/sftp-wrapper

#!/usr/bin/perl -w

use FileHandle;
use File::Basename;
use Time::Local;
use Time::localtime;
use IO::Handle;
use IO::Select;
use IPC::Open2;
use IPC::Open3;
use Fcntl;
use POSIX qw(:errno_h);
use strict;


my $program;
my $ftp;
my $sftp;
my $user_pw;
my $printline;
my $com;
my $pid;
my $fcntlflags='';
my $selector;
my $check;
my @ready=();
my $fh;
my @reply=();
my $count;
my $scr;
my $found;
my $waitfor;

$program = basename($0);


#$ftp = "ftp -i -n -v hb";
$sftp = "sftp -l user unix-B";
$user_pw="user username password\n";

$printline="";
$com="ls\n";


#$pid = open3(*WRITEME, *CCMD, *FEHL, $ftp);
$pid = open3(*WRITEME, *CCMD, *FEHL, $sftp);  # here starts sftp !!
#$pid = open2(\*CCMD, \*WRITEME, $ftp);

#$printline = sprintf("%s  Command: $ftp\n",prDate());
$printline = sprintf("%s  Command: $sftp\n",prDate());
printf STDOUT $printline;

# mit oder ohne * bzw. Reihenfolge ist Wurscht !!

*CCMD->autoflush(1);
*FEHL->autoflush(1);
*WRITEME->autoflush(1);

fcntl(*CCMD,F_GETFL,$fcntlflags);
$fcntlflags |= O_NONBLOCK;
fcntl(*CCMD,F_SETFL,$fcntlflags);
#    fcntl(*WRITEME,F_GETFL,$fcntlflags);
#    $fcntlflags |= O_NONBLOCK;
#    fcntl(*WRITEME,F_SETFL,$fcntlflags);
fcntl(*FEHL,F_GETFL,$fcntlflags);
$fcntlflags |= O_NONBLOCK;
fcntl(*FEHL,F_SETFL,$fcntlflags);

$SIG{CHLD} = sub{{print "Child-P beendet  $? bei $pid\n"
                     if waitpid($pid,0) > 0}
                  $selector->remove();
                  $printline = sprintf("%s  Done\n",prDate());
                  printf STDOUT $printline;
                  exit;
                };

#$selector=IO::Select->new(*WRITEME,*CCMD,*FEHL);
$selector=IO::Select->new(*CCMD);   # das reicht schon !!
#$selector->add(*FEHL,*CCMD);   # ueberfluessig !!
$count =$selector->count();
#print STDOUT "anz sel: $count \n";

#read_response(0,\@reply,\$count,"to transfer files",\$found);
$waitfor="220";    #ftp - syncronisation
$waitfor="sftp>";  # sftp ????
read_response(0,\@reply,\$count,$waitfor,\$found);  # nach dem
ftp-Start
print_response(\@reply,$count,$waitfor, $found);  
@reply=0;

ftp_ls (\@reply,\$count,\$found);
print_response(\@reply,$count,"ls",$found);  
@reply=0;

ftp_quit (\@reply,\$count,\$found);
print_response(\@reply,$count,"quit",$found);
@reply=0;

$selector->remove();
sleep(1);
$printline = sprintf("%s  Done\n",prDate());
printf STDOUT $printline;

########################################################################

sub read_response {
my $opt=$_[0];
my $reply_to_caller=$_[1];
my $count=$_[2];
my $waitstring=$_[3];
my $waitstring_found=$_[4];
my $response=1;
my $sleeptime=0.5;
my $timeout=0;
my $maxtimeout=5 / $sleeptime;
my $reply;
my @reply_ar;
my $anz=9;
my $i;

  ${$count}=0;
  ${$waitstring_found}=0;
  $check = 1;

  while ($response) {
    if (@ready = $selector->can_read(0.5)) {
#      foreach $fh (@ready)  arbeitet nicht korrekt, wenn nur 1 entry
!!
      $fh = $ready[0]; # statt foreach $fh (@ready) 
# print STDOUT " @ready  \$fh = $fh \n";
      if (fileno($fh) == fileno(CCMD)) {
        @reply_ar=<CCMD>;
        $anz = @reply_ar;
        for ($i=0; $i < $anz; $i++) {
          $reply_to_caller->[${$count}]=$reply_ar[$i];
          ${$count}+=1;
          if ($reply_ar[$i] =~ /$waitstring/) {
#  das wollte ich sehen !!  -> Abbruch
            $response=0;
            ${$waitstring_found}=1;
          }
        }
      } else {  # darf nicht vorkommen
        print STDOUT "Fehler filehandle $fh\n";
#        $response=0;
      }
    } else {  # timeout             
      $timeout++;
      if ($timeout > $maxtimeout) {
        $printline = sprintf("%s  timeout reached !!  ",prDate());
        $printline .= sprintf("max is $maxtimeout");
        $printline .= sprintf("  each $sleeptime sec\n");
        printf STDOUT $printline;
        $response=0;
      }
    }
  }
} #sub read_response 

sub ftp_ls {
my $reply=$_[0];
my $count=$_[1];
my $found=$_[2];

  $printline = sprintf("%s  Command: ls\n",prDate());
  printf STDOUT $printline;
  print WRITEME "ls\n";
  read_response(1,\@reply,$count,"226 Transfer",$found);

} # ftp_ls


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

Date: 18 Jul 2001 08:32:25 +0100
From: nobull@mail.com
Subject: Re: puzzle with 'if' statement
Message-Id: <u98zhmmubg.fsf@wcl-l.bham.ac.uk>

"Terence" <terence@nospam.hotbot.com> writes:

> I'm new to Perl.
> 
> Can someone help me?

Perl can.  Please do not ask for help from sentient entities until you
have exhausted all the help available to you from the non-sentient
entities in your vacinity.

Enable warnings.  For further information look up the warning messages
in the "perldiag" manpage or simply "use diagnostics".

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


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

Date: 18 Jul 2001 10:35:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Reblessing part of object data structure in another package
Message-Id: <9j3ops$cvi$1@mamenchi.zrz.TU-Berlin.DE>

According to Chetan Patil <someone@microsoft.com>:
> Hi,
> I have a complex data strucuture which I have blessed in a package.
> my ($selfA) = bless {
>     foo => {...},
>     goo => [ ...],
> }, $classA;
> 
> $selfA{poo} = new classB (config => $selfA);
> 
> Now in classB package,
> 
> my ($selfB) = $Vars{config}->{foo};
> # i.e. I create a refr to a sub-strucure in $selfA data structure
> 
> $selfB->{config} = $Vars{config};  # And I create a refr loop by pointing to
> $selfA
> 
> bless $selfB, $classB;
> 
> Then I can go and access $selfA{poo} as an object. I can get to both the
> objects from either one.
> 
> Is this a good approach? What are the pitfalls against this approach?
> Specifically, can I rebless part of data strucuture in another package? I
> think I can legally, but I am not sure if it is a good programming approach.
> I don't want to maintain two copies of {foo} data.

What you are doing is not really re-blessing unless $selfB has been
blessed into some other class before.  There is nothing wrong with
blessing parts of one object into another class; the result is simply
an object (in $classA) that contains an object in $classB.  Nothing
wrong with that, although it may be slightly clearer to have a
standard new() method in $classB and call that to do the blessing.
Then insert the $classB object into the $selfA structure.
 
> I would like to avoid the reference loop as well, but I want to be able to
> get to the config (i.e. $selfA) data from within $selfB methods as well.

Circular references of this type crop up occasionally with objects,
it's not entirely unusual.  The problem is, of course, that the
garbage collector can't reclaim objects of this type because the
refcount doesn't go to zero, even if no external reference points to
the cyclic structure.  See "perldoc WeakRef" for a discussion of this
problem and a way around.

Anno


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

Date: 18 Jul 2001 11:30:12 GMT
From: blstone77@aol.com (Blstone77)
Subject: Removing .coms
Message-Id: <20010718073012.19801.00000001@ng-fn1.aol.com>

Newbie question. Does anyone know of a simple way to remove anything with the
extentions .com, .org, or .net from a string? I tried substitution
$string =~ s /s+.*?.com//sg;

but this removes everything from first space. What am I missing, and is there a
better way.


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

Date: Wed, 18 Jul 2001 13:35:40 +0200
From: "carlos" <carlos@plant.student.utwente.nl>
Subject: Re: Removing .coms
Message-Id: <9j3sac$pi0$1@dinkel.civ.utwente.nl>

$string =~ s/\.(com|net|org)//g;

"Blstone77" <blstone77@aol.com> wrote in message
news:20010718073012.19801.00000001@ng-fn1.aol.com...
> Newbie question. Does anyone know of a simple way to remove anything with
the
> extentions .com, .org, or .net from a string? I tried substitution
> $string =~ s /s+.*?.com//sg;
>
> but this removes everything from first space. What am I missing, and is
there a
> better way.




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

Date: Wed, 18 Jul 2001 11:47:47 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Replacing a specific line
Message-Id: <Pine.LNX.4.30.0107181145170.26333-100000@lxplus003.cern.ch>

On Jul 17, mc eloquently disturbed the ether:

> >			if ($memsettings[($i-1)] != '') {
                                                    ^^

> Is this your actual code?  You're missing a closing double quote in
> the first line above

Hint: Don't try to read program code with a proportionally-spaced
font.

(And the same for ASCII-art, and people commenting on your postings
with ^^-markers, and so on...)

all the best



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

Date: Wed, 18 Jul 2001 11:53:02 GMT
From: "Santtu" <santtu.nyrhinen@nokia.com>
Subject: Scrollable lists in console
Message-Id: <yMe57.16422$cF.363457@news1.nokia.com>

Hi,

Does anyone know how to create scrollable lists in console window?
The idea is that there can be atleast 250 lines where user must select one
and then go on with other list.

Where can I get the size of my console window. Number of lines???

Br,
Santtu




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

Date: Wed, 18 Jul 2001 11:19:40 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: skipping a duplicate
Message-Id: <ukqalt42cvqnq2nb2gvjt997016g842vei@4ax.com>

Troy Lachinski wrote:

>I have a file that contains information about inventory items.  I need
>to split this information into 2 files. The first file is a PLU file,
>I will have one line of information in the [PLU FILE output] for each
>line in the input file. The [PPY FILE output] is a secondary
>information file where duplicates are not allowed.
>
>sample input:
>ABC123
>BCD234
>EFG345
>HIJ123
>KLM235
>NOP234
>QRS124
>
>wanted output:
>
>PLU FILE: 	PPY FILE:
>ABC1		123
>BCD2		234
>EFG3		345
>HIJ1		235
>KLM4		124
>NOP2
>QRS5

Skipping your code... here's how I would do this:

	$\ = "\n";
	print "PLU:";
	while(<DATA>) {
	    my($plu, $ppy) = /^([A-Z]+)(\S+)/ or next;
	    $ppy_id{$ppy} ||= keys %ppy_id;
	    print "$plu$ppy_id{$ppy}";
	}

	print "\nPPY:";
	foreach my $ppy (sort { $ppy_id{$a} <=> $ppy_id{$b} }
	  keys %ppy_id) {
	    print "$ppy ($ppy_id{$ppy})";
	}

	# align the following at the far left side of your script text:
	__DATA__
	ABC123
	BCD234
	EFG345
	HIJ123
	KLM235
	NOP234
	QRS124

So I populate a %ppy_id hash, which maps the PPY numbers to an index
number, with this line:

	    $ppy_id{$ppy} ||= keys %ppy_id;


This takes care of any duplicates. keys() in scalar context returns how
many keys there are. The ||= does two things: it prevents overwriting
the old value if one did exists, and otherwise, it makes an entry in the
hash before the RHS (keys) is calculated. So if the hash was empty, the
number assigned to the first entry, is 1.

Only after all input is processed, I print out the PPY's.

-- 
	Bart.


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

Date: Wed, 18 Jul 2001 13:31:42 +0200
From: Helmut Jarausch <jarausch@numa1.igpm.rwth-aachen.de>
Subject: staroffice and Perl
Message-Id: <3B55739E.FDF0742D@numa1.igpm.rwth-aachen.de>

Does anybody know a reference on howto (if at all) invoke Perl subs from
staroffice.
Or is there something which emulates a visual basic interface?

Thanks for any hints,

Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
Institute of Technology, RWTH Aachen
D 52056 Aachen, Germany




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

Date: 18 Jul 2001 04:03:43 -0700
From: Mark.S.Smith@marconi.com (Mark Smith)
Subject: Trouble extracting strings - help needed
Message-Id: <c4c08f5f.0107180303.608e8d6f@posting.google.com>

I have a perl script that reads in a file.  The contents of this file
may vary but at several points it contains a filename between double
quotes.  I need to extract every instance of the filename in quotes as
I need to then process each of these files.

The file would roughly be in this kind of format.

files {
"somefile.mst",
"Anotherfile.mst",
"further-file.mst"
}
config {

}

Can anyone help as I can't seem to devise a working method to get just
the filenames?  Also if possible could you mail me directly and
explain what your method is doing so I will have an understanding.

Once again this file could contains lots of information and I don't
know the filenames in advance so I need something that will not just
work with the above but would extract whatever lies between the two
quotes.

Thanks in advance.

Mark.


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

Date: Wed, 18 Jul 2001 11:55:55 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Trouble extracting strings - help needed
Message-Id: <slrn9latv0.aig.bernard.el-hagin@gdndev25.lido-tech>

On 18 Jul 2001 04:03:43 -0700, Mark Smith <Mark.S.Smith@marconi.com> wrote:
>I have a perl script that reads in a file.  The contents of this file
>may vary but at several points it contains a filename between double
>quotes.  I need to extract every instance of the filename in quotes as
>I need to then process each of these files.
>
>The file would roughly be in this kind of format.
>
>files {
>"somefile.mst",
>"Anotherfile.mst",
>"further-file.mst"
>}
>config {
>
>}

Assuming the file you're reading is in <FILE>:

my @files;

while( <FILE> ){
	push @files, $1 while /"([^"]*)"/g;
}

And then process each file in the @files array:

for( @files ){
	open( IN, $_ ) or die "I ain't openin' $_: $!";
	#do something with <IN>
}

Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'


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

Date: Wed, 18 Jul 2001 11:15:32 GMT
From: boa@freemail.c3.hu (T.Hopkins)
Subject: Using a Perl module outside from Perl-dir?
Message-Id: <3b576f36.1589811@news.matav.hu>

Hi guys,
how can I use a module (in my case: File::ReadBackwards.pm) from my
own 'cgi-bin' (or other) directory directly that is not installed on
the ISP's server?
Our ISP is an ugly face and lazy to install this module.

thanks,
T.Hopkins



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

Date: Wed, 18 Jul 2001 13:36:41 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: Using a Perl module outside from Perl-dir?
Message-Id: <3B5582D9.B5525513@salford.ac.uk>



"T.Hopkins" wrote:
> 
> Hi guys,
> how can I use a module (in my case: File::ReadBackwards.pm) from my
> own 'cgi-bin' (or other) directory directly that is not installed on
> the ISP's server?
> Our ISP is an ugly face and lazy to install this module.
> 
> thanks,
> T.Hopkins

use lib '<directorypath>';
use <Module>;

I think.


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

Date: 18 Jul 2001 12:54:15 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Using a Perl module outside from Perl-dir?
Message-Id: <slrn9lb1oo.7r9.rgarciasuarez@rafael.kazibao.net>

T.Hopkins wrote in comp.lang.perl.misc:
} Hi guys,
} how can I use a module (in my case: File::ReadBackwards.pm) from my
} own 'cgi-bin' (or other) directory directly that is not installed on
} the ISP's server?

See the FAQ :

  perldoc -q "own module"

and also, the perlmodinstall manpage.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

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.  

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


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