[21996] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4218 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 5 00:05:56 2002

Date: Wed, 4 Dec 2002 21:05:10 -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           Wed, 4 Dec 2002     Volume: 10 Number: 4218

Today's topics:
    Re: [ADMIN:] re-posted usenet articles <flavell@mail.cern.ch>
    Re: any cool script site??? <palladium@spinn.net>
    Re: any cool script site??? <palladium@spinn.net>
        cgi.pm & multiple form widgets of same name (Rodney)
    Re: cgi.pm & multiple form widgets of same name <uri@stemsystems.com>
    Re: cgi.pm & multiple form widgets of same name <stevenm@blackwater-pacific.com>
    Re: child signal <lshaw-usenet@austin.rr.com>
    Re: child signal (Walter Roberson)
    Re: Converting DMYHMS to epoch (Jay Tilton)
    Re: Converting DMYHMS to epoch <flavell@mail.cern.ch>
        Creating TCP Sockets -- Client Can't Find Server <hal@thresholddigital.com>
    Re: forking server and autoflush? <lshaw-usenet@austin.rr.com>
    Re: Future of Perl as an application server language? <pkent77tea@yahoo.com.tea>
    Re: Getting a URL Page <cboston@e-duct-tape.com>
    Re: NT Drive mappings in perl <fixerdave@hot-NoSpamPlease-mail.com>
    Re: NT Drive mappings in perl <kevinsproule@hotmail.com>
    Re: RegExp: Capturing parentheses in quantified sub-pat <julian@mehnle.net>
    Re: RegExp: Capturing parentheses in quantified sub-pat <julian@mehnle.net>
        Telnet using "character mode" for modem control <me@planet-earth.com>
        Tough (or stupid =) Q: Using a variable with a variable <mikecook@cigarpool.com>
    Re: Tough (or stupid =) Q: Using a variable with a vari (Tad McClellan)
    Re: Tough (or stupid =) Q: Using a variable with a vari <bwalton@rochester.rr.com>
        wrong file sizes from script - 32 bit integer problem? <nospam@euro.com>
    Re: wrong file sizes from script - 32 bit integer probl <kha2536@rogers.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 5 Dec 2002 02:10:18 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: [ADMIN:] re-posted usenet articles
Message-Id: <Pine.LNX.4.40.0212050203390.23772-100000@lxplus073.cern.ch>

On Nov 22, Alan J. Flavell inscribed on the eternal scroll:

> I happened to notice in Google Groups that someone or something at
> 24.69.255.206 has re-posted at least three of my old articles, with
> their original message-id but a re-written date line of Fri, 22 Nov
> 2002.  The original postings of the re-posted articles which I've seen
> so far were all on the 10th Nov.  I've no idea whether it's just me
> that's affected.
>
> I've reported it to their abuse address, but I thought I'd just drop a
> brief heads-up into the group here.

My thanks to the other usenauts who contacted me by email to confirm
that they were seeing the same misbehaviour from that domain.

No thanks to the relevant provider's abuse department, who recently
responded to my report with:

| It is unclear to us as to what you are inquiring about.  Please be
| more specific as to what you are asking.

Inevitably, their domain goes into my killfile, and others will no
doubt draw their own conclusions.

cheers



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

Date: Wed, 4 Dec 2002 20:23:33 -0700
From: "Palladium Solutions" <palladium@spinn.net>
Subject: Re: any cool script site???
Message-Id: <uutj2u5fbraiff@corp.supernews.com>

Had anyone noticed I was being facetious....And sorry for the top post...I
was using a new usenet reader....my bad....





"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnaurvo7.32t.tadmc@magna.augustmail.com...
> palladium@spinn.net <palladium@spinn.net> wrote:
> > On 3 Dec 2002 04:32:01 -0800, keshavforever@rediffmail.com (keshav
> > prasad) wrote:
>
> >>if you know any cool network script site.. please tell me
>
>
> > Yeah.. Matt's Script Archive.....Everyone uses it !
>                                    ^^^^^^^^
>
> The world is full of silly people, emulating them is risky.
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Wed, 4 Dec 2002 20:38:34 -0700
From: "Palladium Solutions" <palladium@spinn.net>
Subject: Re: any cool script site???
Message-Id: <uutjv1d7tn7f5a@corp.supernews.com>


"Palladium Solutions" <palladium@spinn.net> wrote in message
news:uutj2u5fbraiff@corp.supernews.com...
> Had anyone noticed I was being facetious....And sorry for the top post...I
> was using a new usenet reader....my bad....
>
>
Did I do that again....sorry...Think I will switch readers ...

>
>
>
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrnaurvo7.32t.tadmc@magna.augustmail.com...
> > palladium@spinn.net <palladium@spinn.net> wrote:
> > > On 3 Dec 2002 04:32:01 -0800, keshavforever@rediffmail.com (keshav
> > > prasad) wrote:
> >
> > >>if you know any cool network script site.. please tell me
> >
> >
> > > Yeah.. Matt's Script Archive.....Everyone uses it !
> >                                    ^^^^^^^^
> >
> > The world is full of silly people, emulating them is risky.
> >
> >
> > --
> >     Tad McClellan                          SGML consulting
> >     tadmc@augustmail.com                   Perl programming
> >     Fort Worth, Texas
>
>




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

Date: 4 Dec 2002 16:11:46 -0800
From: kc5sbj@yahoo.com (Rodney)
Subject: cgi.pm & multiple form widgets of same name
Message-Id: <4c772a11.0212041611.2fe1b38e@posting.google.com>

Using CGI.pm to create multiple HTML form widgets of the same name
(textfields bearing the name $variablename in this case) then using:
if (param($variablename)) { # check to see if there is anything worth
reading
   my @list = param($variablename); # read values into list
}
solves many problems for me. The trouble I run into is; if the first
widget named $variablename is vacant, the "if" returns false. For this
to work then, the user cannot leave the first one blank. Can anyone
offer a solution to this?


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

Date: Thu, 05 Dec 2002 00:16:34 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: cgi.pm & multiple form widgets of same name
Message-Id: <x7of81tj4u.fsf@mail.sysarch.com>

>>>>> "R" == Rodney  <kc5sbj@yahoo.com> writes:

  R> Using CGI.pm to create multiple HTML form widgets of the same name
  R> (textfields bearing the name $variablename in this case) then using:
  R> if (param($variablename)) { # check to see if there is anything worth
  R> reading
  R>    my @list = param($variablename); # read values into list
  R> }
  R> solves many problems for me. The trouble I run into is; if the first
  R> widget named $variablename is vacant, the "if" returns false. For this
  R> to work then, the user cannot leave the first one blank. Can anyone
  R> offer a solution to this?

just do the second thing and drop the first. you can check the @list
anyway you want after that.

uri

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


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

Date: Wed, 04 Dec 2002 16:54:25 -0800
From: Steven May <stevenm@blackwater-pacific.com>
Subject: Re: cgi.pm & multiple form widgets of same name
Message-Id: <asm7pq$bio$1@quark.scn.rain.com>

Uri Guttman wrote:
>>>>>>"R" == Rodney  <kc5sbj@yahoo.com> writes:
>>>>>
> 
>   R> Using CGI.pm to create multiple HTML form widgets of the same name
>   R> (textfields bearing the name $variablename in this case) then using:
>   R> if (param($variablename)) { # check to see if there is anything worth
>   R> reading
>   R>    my @list = param($variablename); # read values into list
>   R> }
>   R> solves many problems for me. The trouble I run into is; if the first
>   R> widget named $variablename is vacant, the "if" returns false. For this
>   R> to work then, the user cannot leave the first one blank. Can anyone
>   R> offer a solution to this?
> 
> just do the second thing and drop the first. you can check the @list
> anyway you want after that.
> 
> uri
> 

I wonder if it might make sense to check for existence?

Depending on who was using the form, who had access to the raw form or 
how it was generated, I might do something like:

my @list = param($variablename) if defined param($variablename);

My thinking being that if some bonehead (usually me) fiddles the form 
and drops a form element the script won't fail with an undefined value.

Or if I wanted to just bail when an expected parameter is not available:

defined param($variablename) or die "$variablename is not defined!\n";
my @list = param($variablename);

Just a thought (well..two thoughts).

s.



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

Date: Thu, 05 Dec 2002 01:29:29 GMT
From: Logan Shaw <lshaw-usenet@austin.rr.com>
Subject: Re: child signal
Message-Id: <ZZxH9.118208$8D.3089009@twister.austin.rr.com>

In article <20021204153321.727$8w@newsreader.com>, ctcgag@hotmail.com wrote:
> I think the problem is that the the SIG routine won't interrupt itself,
> so any CHLD received while perl is already in one zombie routine gets
> ignored.

The problem is this:  In Unix, signals may be delivered to a process,
but for a process to receive (and clear) the signal, it must be
scheduled to run on a processor.  If another of the same signal
arrives before that happens, then no action is taken.

In my opinion it helps not to think of signals as messages.  If
you think of signals as messages, then you may begin to believe
that signals are "lost".  Instead, a signal amounts to a type of
flag.  "Sending" a signal simply sets the flag.  If the flag is
already set, "sending" does nothing.  The process "receiving" the
signal can choose to be notified (via a signal handler) when the
flag makes a transition from clear to set.  This is not the same
thing as being notified when a signal is sent.

  - Logan

-- 
I'm currently looking for work as a Unix/Solaris
administrator, or Perl/C++/Java developer.  Resume
at http://home.austin.rr.com/logan/resume.html.


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

Date: 5 Dec 2002 00:12:22 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: child signal
Message-Id: <asm5l6$2am$1@canopus.cc.umanitoba.ca>

In article <ZZxH9.118208$8D.3089009@twister.austin.rr.com>,
Logan Shaw  <lshaw-usenet@austin.rr.com> wrote:
:The problem is this:  In Unix, signals may be delivered to a process,
:but for a process to receive (and clear) the signal, it must be
:scheduled to run on a processor.  If another of the same signal
:arrives before that happens, then no action is taken.

A small amplification of this point: POSIX.1's appendices say this
on the matter:

  Most historical implementations do not queue signals; i.e., a process's
  signal handler is invoked once, even if the signal has been generated
  multiple times before it is delivered. A notable exception to this
  is SIGCLD, which, in System V, is queued. The queueing of signals is
  neither required nor prohibited by POSIX.1. See 3.3.1.2. It is expected
  that a future realtime extension to POSIX.1 will address the issue
  of reliable queueing of event notification.

(Note: System V's SIGCLD is not the same as POSIX's SIGCHLD.
Although the semantics for the two do overlap, SIGCLD has more
cases, apparently.)
--
Would you buy a used bit from this man??


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

Date: Thu, 05 Dec 2002 00:05:30 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Converting DMYHMS to epoch
Message-Id: <3dee9819.593709@news.erols.com>

"Kevin" <k_devlin@hotmail.com> wrote:

: Sorry for probably being clueless but have just started coding in perl and
: am trying to convert
: a date such as "03-DEC-02" to epoch seconds.

    use Date::Manip;
    my $secs = UnixDate('03-DEC-02', '%s');

Not the speediest solution, but it's easy.  Also handy if the date strings
are not guaranteed to follow a uniform format.



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

Date: Thu, 5 Dec 2002 01:23:22 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Converting DMYHMS to epoch
Message-Id: <Pine.LNX.4.40.0212050111220.23772-100000@lxplus073.cern.ch>

On Dec 4, Kevin inscribed on the eternal scroll:

> Sorry for probably being clueless but have just started coding in perl and
> am trying to convert
> a date such as "03-DEC-02" to epoch seconds.

First we'd need to know whether that's supposed to be the 2nd of
December 2003, or the 3rd of December 2002, or whatever (you'll have
heard of the old lady who was visited on her 105th birthday by the
schools inspector to find out why she hadn't been enrolled for primary
school?).

What's so desperately hard about using a properly-specified
interworking format, such as IETF or ISO format e.g 2003-12-02 ?

(OT): when the Glasgow Underground was "refurbished" in the late
1970's, they evidently re-cycled a ticketing system that they had got
from somewhere else: the day and month were set correctly, but the
year was set according to which station you got on, e.g (IIRCBICBW) my
local station was 1972.  (Nowadays they use something more
conventional.)




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

Date: Thu, 05 Dec 2002 01:12:19 GMT
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Creating TCP Sockets -- Client Can't Find Server
Message-Id: <TJxH9.31843$pN3.2074@sccrnsc03>

I've posted earler a question about interprocess communication.  This is 
similar.  I want to have different processes on the same machine, but run 
by different users, communicate with each other.  While I've been looking 
at a lot of possibilities, it seems like creating a TCP socket would be the 
best, since I could also use that to communicate with a process on another 
box on the same LAN.

I've copied examples out of the Blue Camel, and I'm running both the client 
and server on the same box (I've also tried them on different boxes -- same 
result).  The server process runs and waits.  The client process is always 
unable to connect to the server.

Is this a Perl problem, or do I have to do something else to get it to work?

And, while I'm asking, the Camel says I can specify the address by number or 
name, and I can specify the port by name as well.  Do I just assign a name 
to the port instead of using a number?  (Right now I'm using a high number 
because 1) It didn't seem to be assigned in /etc/services, 2) I figure a 
high number like that hasn't been assigned yet.)

Thanks!

Hal

Here's the sample code, both from the client and the server:

Client:

#!/usr/bin/perl
        use IO::Socket::INET;
        $serveraddy = "192.168.100.13";
        $serverport = "20000";
        $socket = IO::Socket::INET->new(
                        PeerAddr => $serveraddy,
                        PeerPort => $serverport,
                        Proto    => "tcp",
                        Type     => SOCK_STREAM)
                or die "Couldn't connect to server\n";
                
        $in = "Test";
        while ($in = <STDIN>) {
                chomp($in);
                if (!$in) {last;}
                else {print $socket $in;}
        }
        close($socket);
        exit;

Server:

#!/usr/bin/perl
        use IO::Socket::INET;
        $serverport = "20000";
        $server = IO::Socket::INET->new(
                        Localport => $serverport,
                        Type      => SOCK_STREAM,
                        Reuse     => 1,
                        Listen    => SOMAXCONN )        #SOMAXCONN or 10
                or die "Could not open server socket\n";
        while ($client = $server->accept()) {
                $input = <$client>;
                print "$input\n";
                #print "Received: $client\n";
        }
        exit;




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

Date: Thu, 05 Dec 2002 04:54:27 GMT
From: Logan Shaw <lshaw-usenet@austin.rr.com>
Subject: Re: forking server and autoflush?
Message-Id: <7_AH9.118891$8D.3135461@twister.austin.rr.com>

In article <MPG.18589a8b2d6e0ed3989727@news.pandora.be>, astone wrote:
> Anyway, in the mean time, i figured out that is was a bug (or a 
> feature?) in activeperl, since i don't have that problem when 
> running the program on my slackware box. 

I'm not an expert on Windows, but I believe that Windows doesn't
have a true, native version of fork().  Thus, Activestate Perl does
some sort of emulation of fork().  I don't know much beyond this,
but it seems like maybe it's relevant to what's happening to you.

  - Logan

-- 
I'm currently looking for work as a Unix/Solaris
administrator, or Perl/C++/Java developer.  Resume
at http://home.austin.rr.com/logan/resume.html.


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

Date: Thu, 05 Dec 2002 02:04:26 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Future of Perl as an application server language?
Message-Id: <pkent77tea-35B33F.02042505122002@news-text.blueyonder.co.uk>

In article <3226c4d3.0212041132.538947eb@posting.google.com>,
 simonf@simonf.com (Simon) wrote:

> might not go. On the other hand, I looked at the program of the latest
> O'Reilly Perl conference, and the emphasis was much more on the
> language and the libraries rather than higher-level design concepts.

Some friends went to the last W3C conference which was dripping with 
XML. There seemed to be a lot of talk about high-level stuff, and a lot 
less emphasis on actually doing useful stuff with it and the tools to do 
it. I'd like to see a conference that had the whole lot - great 
blue-skies ideas, useful concepts, and reference implementations of 
tools to use the concepts. Like, we use Dublin Core metadata at work, 
but I don't know if we have special tools to use it well; likewise for 
RDF which we are also playing with.

> There are commercial Java OORDB tools
> out there, but no commercial Perl tools.

This is not /necessarily/ a mark of quality :-) I mean, Oracle is (I am 
told, read the licence) free for non-commercial personal use, or for 
application development. Apache is non-commercial but I trust it more 
than any commercial web server (although isn't Zeus based on Apache? I 
think Zeus is probably pretty good anyway). Sad to say that cost is not 
always equal to quality.

> More interesting is the question of web-object persistence. When the
> CGI parameters are received, some of them must be ignored, some should
 ...
> need to create more than one object from a single CGI hash. I have not
> seen a decent abstraction layer for this at all.

Interestingly that kind of logic that you describe sounds like the 
application-level business logic, and definitely hard to make abstract - 
you the programmer have to marshal the inputs and data into some 
abstract form and _then_ you can use generic back-end classes to "do 
stuff".

Example: you have a CGI parameter called 'foo', and your Boss wants to 
change it to 'Bar'. It seems to me that the only changes are going to be 
in the bit which says "get me parameter 'foo'" - there's no reason for 
anything lower level to _care_ what the parameter was physically called 
in the CGI layer, all it cares about is the logical significance of the 
parameter, and the valuethat was in it. That keeps the clean chain of 
interfaces with nice black-box interfaces, like
browser->tcp stack->ip-ethernet->ip->tcp->apache->cgi 
program->class->deeper class->oracle client 
library->sql*net->ethernet->sql*net->oracle->more oracle->operating 
system->scsi bus->hard disk->sector->row of data

> Perhaps this is a wrong group to bring up these issues. I will
> appreciate suggestions for a more appropriate forum.

No it's quite appropriate - we're talking about big concpets here, and 
how those may usefully be transferred to the perl world. Now I see that 
Uri has pointed you to 'stem', which might have interesting concepts 
that are done a bit differently in Java

[ This reminds me of when I tried to convert banner(6) from C to perl. 
My first attempt was a transliteration, and was quite ugly... the next 
attempt went one level higher in abstraction and did things in a less 
C-like way. The program behaved exactly the same, from the outside, but 
internally had slight differences in approach. Neither was better, just 
different approaches. Well, the C one was probably faster. ]

In any case there are lots of posts here concerned with quite small 
aspects of the language so it's nice to have a post at the other end of 
the spectrum.

> Err... of course I use DBI. However, pretty much everybody agreed at
> the conference that having raw SQL in your code is bad design. It may
> be fine for a two-page script, but is unacceptable in an enterprise
> application. A good persistence layer is a must. IMHO omitted
> deliberately.

It's probably less 'omitted' and more 'put somewhere else'. Implementing 
persistence of low level objects like DBI database handles, for example, 
is easy (there's stuff on CPAN to do it, or roll your own if you have 
special needs), as is persistence of composited or higher-level (in the 
application's model) objects. I would guess that the design of the DBI 
is typically unixish - we will do one thing (talking to databases) and 
we will do it well, and we will make it easy to interoperate with other 
things. The persistence is added on by another module - I'd guess that 
under the hood a similar thing is going on in Java. E.g. a class uses 
the Oracle java libraries to run a database query and another class 
caches the handle object (or whatever the thing is). Mind you, I haven't 
really read the docs for the Oracle java libs.

Also I don't think you actually _need_ SQL in your code to use DBI. I 
await being corrected but there are query abstraction tools. OTOH as a 
fledgling Oracle (and other databases) developer I have the impression 
that if I want to SELECT * from TABLE WHERE foo = bar, the best way to 
express that is simply as 'SELECT * from TABLE WHERE foo = bar'. Values 
of 'best' will vary. It's simple, portable (ANSI SQL), obvious to any of 
the DB developers, DBAs, maintainers, etc. But that's my literally 
humble opinion.

> Model-View-Controller. Very roughly, Controller is the object
> processing requests (servlet proper), Model is the data, View is the
> HTML form. I am sure that there are 1400 implementations of this
> pattern out there, but this is a place where standards really would
> help, as this describes pretty much any web application. Otherwise, if
> you take over someone else's code, you will have to figure out his/her
> ideas about the implementation of this pattern.

Oh I get it - that's familiar but I'd never heard a name for the 
concept. I thought you meant somethign like a contoller for a model 
view, like some kind of virtual reality stuff! I shall remember this 
phrase to drop into conversation at an opportune moment :-)

Bah, anyway I think that the kind of apps we develop in our shop are of 
a different class (ho ho) - much less "session based" stuff. That is 
bound to change soon though...

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: Wed, 4 Dec 2002 18:31:08 -0500
From: "Chris Boston" <cboston@e-duct-tape.com>
Subject: Re: Getting a URL Page
Message-Id: <aawH9.23199$bq3.4878@news.bellsouth.net>

Have you tried WGET ?

It works great.

a2liter

"Kasp" <kasp@epatra.com> wrote in message
news:3b04990d.0212041057.5abbb2c1@posting.google.com...
> Hi!,
>
> I am a newbie in Perl World and my task is to get a Web Page, given
> the URL, and store it's contents in a temp.txt file.
> Frankly, I have to do more than that...but as of now getting a web
> page is bugging me.
>
> I want to know how I can do this. Is there a module to do this? (I bet
> there is..but dont know).
>
> A link or a URL (Uggh!!!) pointer will be greatly appreciated. :-)
> Thanks





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

Date: Wed, 4 Dec 2002 18:22:44 -0800
From: "Dave E" <fixerdave@hot-NoSpamPlease-mail.com>
Subject: Re: NT Drive mappings in perl
Message-Id: <3deeb844$1@obsidian.gov.bc.ca>

"Chris Howard" <google@chris-howard.fsnet.co.uk> wrote in message
news:4287fb4c.0212041008.486961fc@posting.google.com...
> Hi,
>
> I have a perl script which, does a :-
>
> system("net use R:  \\\\$target_host\\$sharename")
> ...

Well, the experts seem to have passed you by so I'll take a stab at it (in
other words, I'm no expert)

What I suggest is that you use Perl to map your drives rather than the OS
net use functions.  Win32::NetResource (which is included in ActiveStates
Perl) has a function called AddConnection.  I've pasted in my stock
subroutines, as working examples, that I use for doing this.  But, you
should be really careful about taking advice from someone that starts a post
with "I'm no expert" :)  Like they say, there's more than one way to do it,
and my way's probably not the best.  Oh yea, and I probably way overdocument
compared to most people - it works for me.

----
sub net_connect {
    # Perl eq to Net Use Drive: \\Server\Share.
    # Requires: use Win32::NetResource (core Perl v5x)
    # IN (Server\Share, Drive, Account, Password, Comment)
    # OUT(Error string: nul = okay, otherwise = Error message.)
    my(%resource);                                  # hash for remote
network connection
    my($share, $drive, $account, $passwd, $comment, $error);

    ($share, $drive, $account, $passwd, $comment) = @_;
    %resource = (  'Scope'  => RESOURCE_CONNECTED,
        'Type'     => RESOURCETYPE_DISK,
        'DisplayType'   => RESOURCEDISPLAYTYPE_SERVER,
        'Usage'    => RESOURCEUSAGE_CONNECTABLE,
        'LocalName'   => $drive,
        'RemoteName'   => $share,
        'Comment'    => $comment,
        'Provider'    => "Microsoft Windows Network");
    $error="";                                         # nul if it works OK
    unless (Win32::NetResource::AddConnection(\%resource, $passwd,
$account,0)) {
        Win32::NetResource::GetError($error);
    }
    return($error);
} # end of sub net_connect


###
sub net_disconnect {
    # Perl eq to "Net Use Drive: /d"
    # Requires: use Win32::NetResource (core Perl v5x)
    # IN (Drive)
    # OUT ()
    my($drive);

    ($drive)=@_;
    Win32::NetResource::CancelConnection($drive,0,1);
} # end of sub net_disconnect


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

Also note, Win32::GetNextAvailDrive(); is also a very handy addition to your
toolkit as hardcoding a drive letter can burn you fairly easily.

    David...






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

Date: Thu, 05 Dec 2002 04:08:09 GMT
From: "Kevin Sproule" <kevinsproule@hotmail.com>
Subject: Re: NT Drive mappings in perl
Message-Id: <JiAH9.12467$Xb3.875543@news1.west.cox.net>


"Chris Howard" <google@chris-howard.fsnet.co.uk> wrote in message
news:4287fb4c.0212041008.486961fc@posting.google.com...
> Hi,
>
> I have a perl script which, does a :-
>
> system("net use R:  \\\\$target_host\\$sharename")
>
> which maps the R: drive fine, however, when the script has finished, I
> find it impossible to unmap the drive.
>
> If I run "net use R: /d",  I get "The network connection could not be
> found."
>
> In explorer it shows as "Remote Disk" rather than "Network
> Connection".
>
> I've run subst, which I know can map remote drives - no entries.
>
> Has anyone got any ideas ??
>
> Thanks
>
> Chris.
Chris,
The following works for me on XP using perl 5.6.0:

#!/perl/bin/perl.exe -w
system("net use R: \\\\cx883556-b\\c");
print `dir r:`;
system("net use R: /d");
print `dir r:`;

Output:

C:\pl>netuse.pl
The command completed successfully.

3COM                           Program\ Files
4ABUL.GIF                      QMSYS
 ... many files
R: was deleted successfully.

dir: r:: No such file or directory

C:\pl>

If I remove the "net use R: /d" from the script the mapping is still there
after the script terminates.  Sounds like an O/S issue and not anything to
do with perl.

Kevin




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

Date: Thu, 5 Dec 2002 00:25:04 +0100
From: "Julian Mehnle" <julian@mehnle.net>
Subject: Re: RegExp: Capturing parentheses in quantified sub-patterns -- how is it supposed to work? (ADDITION)
Message-Id: <asm2se$ssnfc$1@ID-65075.news.dfncis.de>

robertbu <robertbu@hotmail.com> wrote:
> Since you have nested delimiters, how about the Text::ParseWords module?

Didn't know that one! I'm going to try it out. Seems it comes with Perl 5.6
as well. :-)

Thanks!
Julian.




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

Date: Thu, 5 Dec 2002 00:26:52 +0100
From: "Julian Mehnle" <julian@mehnle.net>
Subject: Re: RegExp: Capturing parentheses in quantified sub-patterns -- how is it supposed to work? (ADDITION)
Message-Id: <asm2vq$sbstn$1@ID-65075.news.dfncis.de>

Tad McClellan <tadmc@augustmail.com> wrote:
> So you want to split a whitespace separated string, except
> when inside double quotes?
>
> That is a FAQ.
>
>    perldoc -q split

Thanks for the hint. It also contains a pointer to Text::ParseWords, woohoo!
;-)

Julian.




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

Date: Thu, 05 Dec 2002 01:33:30 GMT
From: Milan <me@planet-earth.com>
Subject: Telnet using "character mode" for modem control
Message-Id: <3DEE8217.7070902@planet-earth.com>

Does anyone know of a way to make the Net::Telnet modules use 
"character" mode instead of "line" mode.  I have checked the 
documentation but cannot find anything about this.

I'm trying to write a perl script that will be used to control some 
modems using the standard AT command set.  The modems are connected to a 
serial port server (Chase IOLAN), which has multiple serial ports, and 1 
ethernet port.  The server allows access the serial ports using telnet.

I've been playing with the modems via a standard Linux telnet client.  I 
was encountering a problem where I could not force the modem to go back 
into command mode after it had dialed out and connected to another 
modem.  Today I found out that I have to force the telnet client into 
"character" mode (instead of "line" mode) in order for the modem to 
properly recognize the "command mode" escape sequence ("+++" in my case).

Anyone know how to do this with Net::Telnet; or is there another, 
preferebly easy, way to do perform this telnet function within perl? 
Thanks.....



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

Date: Thu, 05 Dec 2002 01:03:28 GMT
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Tough (or stupid =) Q: Using a variable with a variable name
Message-Id: <ABxH9.10651$6Y4.9867@news1.central.cox.net>

Hi,
    I am trying to do something stupid I think  =)  I need the output of a
script to make 2 columns:

0    50
1    51
2    52

etc. with data pulled dynamically from a CSV file with data like:

0,dsafasd, asdf
1,adsf,asdf

etc.

I am parsing the table & putting the data into variables using their first
field as the var name (i.e. $NAME00, $ACCOUNT52, etc.). I then try to
retrieve them and use them in the 2 column placement above. I'd rather not
parse the file more than once if possible. Below is a snippet that mirrors
what I am trying to do without boring you with the whole enchilada (which I
will be happy to send  =) the snippet doesn't work - the slippery part for
me is trying to come up with a variable that works based on the iteration
number. Any ideas? Thx a mil!!! Michael

#!/usr/bin/perl -w
use strict;
my $DDD3="defined";
foreach my $num ( 1 ..4 )
{
 print "num=|$num|\n";
 ###
 # Broken line
 # I want the following line to ouput 'defined' for #3
 print "${DDD$num}";
 ###
 print "\n\n";
}

--
== CigarPool ==
http://www.cigarpool.com




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

Date: Wed, 4 Dec 2002 21:22:29 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Tough (or stupid =) Q: Using a variable with a variable name
Message-Id: <slrnauthjl.60s.tadmc@magna.augustmail.com>

Michael Cook <mikecook@cigarpool.com> wrote:
> Subject: Tough (or stupid =) Q: Using a variable with a variable name


   perldoc -q variable

      How can I use a variable as a variable name?



See also:

   http://www.plover.com/~mjd/perl/varvarname.html
   http://www.plover.com/~mjd/perl/varvarname2.html
   http://www.plover.com/~mjd/perl/varvarname3.html


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


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

Date: Thu, 05 Dec 2002 03:42:39 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Tough (or stupid =) Q: Using a variable with a variable name
Message-Id: <3DEECB29.5010508@rochester.rr.com>

Michael Cook wrote:

 ...

>     I am trying to do something stupid I think  =)  I need the output of a

> script to make 2 columns:
> 
> 0    50
> 1    51
> 2    52
> 
> etc. with data pulled dynamically from a CSV file with data like:
> 
> 0,dsafasd, asdf
> 1,adsf,asdf
> 
> etc.
> 
> I am parsing the table & putting the data into variables using their first
> field as the var name (i.e. $NAME00, $ACCOUNT52, etc.). I then try to
> retrieve them and use them in the 2 column placement above. I'd rather not
> parse the file more than once if possible. Below is a snippet that mirrors
> what I am trying to do without boring you with the whole enchilada (which I
> will be happy to send  =) the snippet doesn't work - the slippery part for
> me is trying to come up with a variable that works based on the iteration
> number. Any ideas? Thx a mil!!! Michael
> 
> #!/usr/bin/perl -w
> use strict;
> my $DDD3="defined";
> foreach my $num ( 1 ..4 )
> {
>  print "num=|$num|\n";
>  ###
>  # Broken line
>  # I want the following line to ouput 'defined' for #3
>  print "${DDD$num}";
>  ###
>  print "\n\n";
> }
> 
> --
> == CigarPool ==

See perlfaq7 "How can I use a variable as a variable name?"

There you will learn that what you want to do is a BAD IDEA.
But if you insist on doing it anyway, you should know that symbolic 
references only work on global variables.  That means you have to get 
rid of the "my" in "my $DDD3='defined';".  And the use strict;.  If you 
do that, then:


     print ${"DDD$num"};

will work (but with warnings due to the undefined variables referenced).

What should you do?  Just use a hash.  Something like:

     my %hash;
     $hash{"DDD3"}='defined';
     ...
     print $hash{"DDD$num"};

Using a hash gives you a whole complete namespace all to yourself.  Just 
use the hash keys as you would have used the variable names.  The hash 
itself may be lexical so you can retain use strict;.  If you want to 
embed the hash reference in a double-quote string, you could do:

     print "$hash{'DDD'.$num}";

if you wish.  HTH.
-- 
Bob Walton



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

Date: Wed, 04 Dec 2002 17:47:20 -0800
From: Fr€d <nospam@euro.com>
Subject: wrong file sizes from script - 32 bit integer problem?
Message-Id: <3DEEB028.58FA@euro.com>

I have this script I picked up somewhere to find the largest files on 
a DEC/Compaq/HP Tru64 system.  Worked fine, but in trying to do this on
a 300Gb RAID disk with large files I seem to get overflow once the files
are larger than 2.1 Gb. (ie, ca 32 bits of size). 

perl 5.6.0, compiled on Tru64 4.0d

Typical output:

-1212345624:  /disks/fileA     #actually 3082621672 bytes
-1626209061:  /disks/fileB	# actually  2668758235 bytes
1717904656:  /disks/fileC	# these are the correct size
1661547692:  /disks/fileD
1631905065:  /disks/fileE
1631905065:  /disks/fileX

Is this something I can fix easily, or is it due to the 32-bit'edness of
perl?
Or do I need a newer version?

thanks


=====================================================
use File::Find;

  $depth_limit = 20;
  @directory_list = @ARGV;

# "-s" abbreviates "the size of",  and "-f" "... is a file".

   find   (sub   {$size{$File::Find::name} = -s if -f;},
@directory_list);
   @sorted = sort {$size{$b} <=>  $size{$a}} keys %size;
# Toss out anything not in the top   $depth_limit.

splice @sorted, $depth_limit if @sorted > $depth_limit;

   foreach (@sorted) {
# Tabulate the results in nice columns.
printf "%10d:  %s\n", $size{$_}, $_;  }


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

Date: Thu, 05 Dec 2002 03:23:09 GMT
From: KH <kha2536@rogers.com>
Subject: Re: wrong file sizes from script - 32 bit integer problem?
Message-Id: <3DEEC6B9.12B0A984@rogers.com>

"Fr?d" wrote:
> 
> I have this script I picked up somewhere to find the largest files on
> a DEC/Compaq/HP Tru64 system.  Worked fine, but in trying to do this on
> a 300Gb RAID disk with large files I seem to get overflow once the files
> are larger than 2.1 Gb. (ie, ca 32 bits of size).
> 
> perl 5.6.0, compiled on Tru64 4.0d
> 
> Typical output:
> 
> -1212345624:  /disks/fileA     #actually 3082621672 bytes
> -1626209061:  /disks/fileB      # actually  2668758235 bytes
> 1717904656:  /disks/fileC       # these are the correct size
> 1661547692:  /disks/fileD
> 1631905065:  /disks/fileE
> 1631905065:  /disks/fileX
> 

The output looks fine according to your sort criteria and your  

"actual" file sizes.

> Is this something I can fix easily, or is it due to the 32-bit'edness of
> perl?

Typically, the range for a 32-bit unsigned int. is from 0 to 4294967295,
and the range for a 32-bit signed int is from -2147483648 to 2147483647.
The conversion specifier in the printf statement causes the negative
output.  See below.

> Or do I need a newer version?
> 
> thanks
> 
> =====================================================
> use File::Find;
> 
>   $depth_limit = 20;
>   @directory_list = @ARGV;
> 
> # "-s" abbreviates "the size of",  and "-f" "... is a file".
> 
>    find   (sub   {$size{$File::Find::name} = -s if -f;},
> @directory_list);
>    @sorted = sort {$size{$b} <=>  $size{$a}} keys %size;
> # Toss out anything not in the top   $depth_limit.
> 
> splice @sorted, $depth_limit if @sorted > $depth_limit;
> 
>    foreach (@sorted) {
> # Tabulate the results in nice columns.
> printf "%10d:  %s\n", $size{$_}, $_;  }
             ^
  printf "%10u:  %s\n", $size{$_}, $_;  }

d is for integer
u is for unsigned int.

--


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

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


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