[21791] in Perl-Users-Digest
Perl-Users Digest, Issue: 3995 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 18 18:10:41 2002
Date: Fri, 18 Oct 2002 15:10:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 18 Oct 2002 Volume: 10 Number: 3995
Today's topics:
Re: Read a single character from STDIN (W98) (Bryan Castillo)
RFC: TraceScalar.pm <bobesch@letras.net>
Re: RFC: TraceScalar.pm <lusol@Pandora.cc.lehigh.edu>
Re: RFC: TraceScalar.pm <Tassilo.Parseval@post.rwth-aachen.de>
Separating stdout and stderr <vilmos@vilmos.org>
Re: Small syntax utility function <goldbb2@earthlink.net>
Re: Sockets through a proxy/firewall <Nigel@mutualnet.co.uk>
streamline editor - removing a string from a file (raj guy)
Re: streamline editor - removing a string from a file <krahnj@acm.org>
Re: Switching from Python to Perl <goldbb2@earthlink.net>
Using File::Find with unc paths e.g. \\mymachine/start/ <rubberducky703@hotmail.com>
Re: Using File::Find with unc paths e.g. \\mymachine/st (Helgi Briem)
while loop to stop <kashmirnospam@bellnet.ca>
Re: while loop to stop <nobull@mail.com>
Re: while loop to stop <mbudash@sonic.net>
Re: while loop to stop <krahnj@acm.org>
Re: while loop to stop <pinyaj@rpi.edu>
Re: Win 32 IP Ping <smackdab1@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Oct 2002 11:33:49 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Read a single character from STDIN (W98)
Message-Id: <1bff1830.0210181033.7bbd06@posting.google.com>
>
> The problem is, perldoc lists four suggestions: to use the *nix stty command
> (not available on W98); the Posix interface suggestion (ditto); to use the
> W32 Perl ioctl function (doesn't work, returns -1); and to download the CPAN
> ReadKey module.
>
> I have spent several hours trying to get the CPAN module to build, without
> success. Apparently the strategy is to bypass the non-functioning ioctl
> with a C language module. I am pretty confident about building C/C++
> modules, but there are obvious nuances about the installation that continue
> to elude me. Anyone else succeed with this one?
You stated you were using ActivePerl on Win98. If you can't compile
it, use ppm.
You will probably have alot of issues trying to compile modules on
win98 with ActivePerl, unless you are using Visual Studio. You also
have to make sure you are runnin the vcvars32.bat (something like that
anyway) to set up your environment.
Many make scripts break on win98, because command.com sucks. Try
compiling Tk and link together 30 object files into a library with one
command.
[Example using ppm to install TermReadKey]
D:\>ppm
PPM interactive shell (2.1.5) - type 'help' for available commands.
PPM> Search Term
Packages available from
http://ppm.ActiveState.com/cgibin/PPM/ppmserver.pl?urn:/PPMServer:
Term-ANSIColor [1.03 ] Color screen output using ANSI escape
sequences
Term-Cap [1.07 ] Perl termcap interface
Term-Getch [0.20 ] A simple alternate ReadKey()-like
interface for
MSWin32
Term-InKey [1.02 ] Perl extension for clearing the screen and
receiving a keystroke.
Term-Info [1.1 ]
Term-ProgressBar [1 ] Perl extension to display a progress bar
Term-Prompt [0.10 ] Perl extension for prompting a user for
information
Term-ReadLine-Perl [1.0203]
Term-Sample [0.25 ] Finger printing of your keyboard typing
Term-Shell [0.01 ] A simple command-line shell framework.
Term-VT102 [0.74 ] emulate a DEC VT102 terminal
TermReadKey [2.14 ]
PPM> install TermReadKey
Version 2.14 of 'TermReadKey' is already installed.
Remove it, or use 'verify --upgrade TermReadKey'.
[Your system should start printing out info about the installation]
------------------------------
Date: 18 Oct 2002 22:22:25 +0200
From: Bodo Schulze <bobesch@letras.net>
Subject: RFC: TraceScalar.pm
Message-Id: <87d6q7sdj2.fsf@letras.net>
Hi All,
after lurking around here for a while, I would like to ask you for
some comment on a tiny module I wrote. It uses tie() to trace regex
substitutions operated on a scalar bound to TraceScalar. I found this
somewhat useful for debugging regexes, especially when I had to parse
irregularly formatted input using a lot of regexes in a row whose
interactions were sometimes hard to anticipate. The interface is pretty
simple. Here is an exemple:
#!/usr/bin/perl
use warnings;
use strict;
use TraceScalar;
$_ = " Word Sentence ";
TraceScalar->start($_, '$_'); # tie $_ to TraceScalar
s/^\s*//;
s/\s*$//;
s/(\S)\s+(\S)/$1\n$2/;
s/sentence/Sentence/i;
TraceScalar->stop($_); # untie $_, the last value of the tied $_
__END__ # gets restored to the untied $_
This will print out the following lines
### Assignement to < $_ >
### in Package < main > at line 7
->| Word Sentence |
### 1. Substitution at line 8
->|Word Sentence |
### 2. Substitution at line 9
->|Word Sentence|
### 3. Substitution at line 10
->|Word|
->|Sentence|
Note that the fourth substitution is not mentioned as it doesn't
change the value of $_.
I am only a hobby programmer, so I don't know whether this tool might
be of any utility to professionals. Anyway I would like to ask you
whether there is any interest to put it on CPAN, and if so, what
namespace you would suggest. In case you would like to have a look at
the code I include it here, since it's not very long (Pod included).
All comments are welcome.
Best regards, Bodo
<CODE>
package TraceScalar;
use warnings;
use strict;
use 5.6.0;
my ($message, $pkg) = ('','');
sub start { # Tie a variable to TraceScalar
tie $_[1], $_[0], $_[1], $_[2]; # $_[0] = TraceScalar class
} # $_[1] = Variable to tie
# $_[2] = Message
sub TIESCALAR {
my ($class, $scalar_value, $mess) = @_;
$message = $mess; # Info to print out
$pkg = (caller(1))[0];
bless [ { (caller(1))[2] => $scalar_value } ] # Store the original
=> $class; # assignement in tied scalar
}
sub FETCH {
my $self = shift; # Fetch the value of the last anon hash pushed
my $hr = $self->[-1]; # into the blessed arrayref
return (%$hr)[1];
}
sub STORE {
my ($self, $subst) = @_; # We need to remember the line for
my $line = (caller)[2]; # subsequent printing, so store it
push @$self, { $line, $subst }; # as the key to the subst value in the
} # anon hash and push it into the arrayref
sub DESTROY {
my $self = shift;
# Did we get more than just
if ( @$self > 1 ) { # an initial assignement?
my $hr = shift @$self; # If so, get the first
my ($line, $orig) = %$hr; # one for the "Assignement"
my $found = $orig; # message and remember it
print "\n### Assignement to < $message > ",# Then print it out
"\n### in Package < $pkg > at line $line\n";
print "->|$_|\n" for split /\n/, $orig; # caring for newlines if any
my $count = 0; # Substitution counter
while (@$self) {
my $hr = shift @$self; # Care for people using
next unless (%$hr)[0]; # local $v instead of my $v
# without initializing $v
# prior to localization
my ($line, $subst) = %$hr; # Print the substs
unless ( $subst eq $found ) { # skipping if current subst
$count++; # equals previous subst
print "### ${count}. Substitution at line $line\n";
my @lines = split /\n/, $subst;
if (@lines) {
print "->|$_|\n" for @lines;
} else {
print "->NULLSTRING\n";
}
$found = $subst;
}
}
} else {
print "No substitution operated on $message tied to TraceScalar",
" in package < $pkg > on line ", (keys %{$self->[0]})[0],
"\n";
}
}
sub stop {
my $obj = tied($_[1]);
my $tmp = (values %{ @$obj[-1] })[0]; # Remember the last value
undef $obj; # get rid of second reference
untie $_[1]; # untie the variable
$_[1] = $tmp; # and restore its last value
}
1;
=head1
=head1 NAME
TraceScalar - A module to trace regexp substitutions
=head1 SYNOPSIS
use TraceScalar;
TraceScalar->start($var, $message);
This will print out:
### Assignement to < $message > in PKG::NAME at line LINE
->|$var| # prints out the value assigned after tying $var
### 1. Substitution at line LINE
->|$var| # prints out the value assigned by the first substitution
### 2. Substitution etc.
TraceScalar->stop($var);
This unties $var restoring to it the last value it contained when tied.
=head1 DESCRIPTION
=head2 Overview
TraceScalar allows you to watch regular expression substitutions
operated on a variable tied to TraceScalar. This is especially useful
when parsing irregularly formatted input using a large number of
regular expressions in a row. Each time a substitution takes place
the TraceScalar object remembers the substitution result as well as
the code line it occured on. The module won't annoy you with
superfluous information about each read and write access to the tied
variable. It just signals what you are interested in: actual
substitution. To ease your work you may also tell the module the
*name* of the variable you desire to watch. This is what $message is
for.
=head2 Methods
TraceScalar->start($var, '$var')
This method binds $var to ScalarTrace. All subsequent assignments to
$var will be recorded by the implementation object.
TraceScalar->stop($var)
This method unties $var, restoring the current value of the previously
tied $var to the now untied variable $var.
When untying $var the internal DESTROY() method is called which prints
out all the stored substitutions previously operated on
$var. Generally speaking, it is not necessary to call stop(), unless
you accumulate really large amounts of information within the
implementation object. In this case you might want to free memory by
calling stop(). Any way the DESTROY() method gets called, when $var
runs out of scope or your programm ends.
=head1 EXAMPLE
Let's take an example, watching out to inclose the second argument to
start() within I<single> quotes
my $v = ' Word Sentence ';
TraceScalar->start($v, '$v');
$v =~ s/^\s*//;
$v =~ s/\s*$//;
$v =~ s/(\S)\s+(\S)/$1\n$2/;
$v =~ s/sentence/Sentence/i;
On the first line, where assignement takes place, this prints out:
### Assignement to < $v >
### in Package < main > at line 9
->| Word Sentence |
Note the pipe characters that delimite the actual string, showing also
leading and trailing whitspace. The subsequent substitution lines will only
mention the substitution number and the code line the substitution
occured on:
### 1. Substitution at line 10
->|Word Sentence |
### 2. Substitution at line 11
->|Word Sentence|
### 3. Substitution at line 12
->|Word|
->|Sentence|
The first substitution chops leading whitespace, the second one chops
trailing whitespace and the third one puts the two words on two
different lines. Note that the fourth substitution actuallay *does*
take place, but as we test for equality between the current and
the previous value this one gets filtered out.
=head1 NOTE
You may of course use this module not only to watch regular expression
substitution but also to trace a series of 'normal' assignements to a
variable in order to check the place where something goes wrong in your
script. This is actually the case envisaged by Damian Conway in Listing 9.1
(package Track) of his superiour book on "Object Oriented Perl", page 242.
I heavily drew on this example.
=head1 ACKNOWLEDGEMENT
I never would have imagined the simple interface proposed by Damian
Conway in the example mentioned above. His book opened the world of
OO-Perl to me. Thanks so much.
=head1 SEE ALSO
The perltie manpage; Damian Conway, "Object Oriented Perl",
Greenwich/C.T. (Manning) 1999, Chapter 9 on "Ties", as well as Sriram
Srinivasan, "Advanced Perl Programming", Sebastopol (O'Reilly) 1997,
Chapter 9 on "Tie".
=head1 COPYRIGHT
Copyright (C) 2002 Bodo Schulze. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 AUTHOR
Bodo Schulze <bobesch@letras.net>
=cut
</CODE>
------------------------------
Date: 18 Oct 2002 20:57:39 GMT
From: "Stephen O. Lidie" <lusol@Pandora.cc.lehigh.edu>
Subject: Re: RFC: TraceScalar.pm
Message-Id: <aopsk3$dji@fidoii.CC.Lehigh.EDU>
Bodo Schulze <bobesch@letras.net> wrote:
> Hi All,
> after lurking around here for a while, I would like to ask you for
> some comment on a tiny module I wrote. It uses tie() to trace regex
> substitutions operated on a scalar bound to TraceScalar. I found this
You might consider just using the CPAN module Tie::Watch and supply your
custom callbacks.
Steve
--
@_=map{eval"100${_}"}split/!/,'/5!*2!+$]!/10+$]';use Tk;$m=tkinit;$t='just an'.
'other perl hacker';$z='createText';$c=$m->Canvas(-wi,$_[1],-he,25)->grid;$c->$
z(@_[2,3],-te,$t,-fi,'gray50');$c->$z($_[2]-$],$_[3]-$],-te,$t);$m->bind('<En'.
'ter>',sub{$y=int(rand($m->screenheight));$m->geometry("+$y+$y")});MainLoop;
------------------------------
Date: 18 Oct 2002 21:53:20 GMT
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: RFC: TraceScalar.pm
Message-Id: <aopvsg$a5j$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Bodo Schulze:
> after lurking around here for a while, I would like to ask you for
> some comment on a tiny module I wrote. It uses tie() to trace regex
> substitutions operated on a scalar bound to TraceScalar. I found this
> somewhat useful for debugging regexes, especially when I had to parse
> irregularly formatted input using a lot of regexes in a row whose
> interactions were sometimes hard to anticipate. The interface is pretty
> simple. Here is an exemple:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
> use TraceScalar;
>
> $_ = " Word Sentence ";
> TraceScalar->start($_, '$_'); # tie $_ to TraceScalar
> s/^\s*//;
> s/\s*$//;
> s/(\S)\s+(\S)/$1\n$2/;
> s/sentence/Sentence/i;
> TraceScalar->stop($_); # untie $_, the last value of the tied $_
> __END__ # gets restored to the untied $_
>
> This will print out the following lines
>
> ### Assignement to < $_ >
> ### in Package < main > at line 7
> ->| Word Sentence |
> ### 1. Substitution at line 8
> ->|Word Sentence |
> ### 2. Substitution at line 9
> ->|Word Sentence|
> ### 3. Substitution at line 10
> ->|Word|
> ->|Sentence|
>
> Note that the fourth substitution is not mentioned as it doesn't
> change the value of $_.
Looks nice. It seems to have a lite flavour of "use re 'debug'". I also
see enough room for additions later on. For instance it'd be nice if you
could also track down substitutions that don't actually change anything
(as the fourth of yours). This may be beyond the scope of tying though.
But perhaps with the help of a little XS it might be possible. Enough
for your exploration. ;-)
> I am only a hobby programmer, so I don't know whether this tool might
> be of any utility to professionals. Anyway I would like to ask you
> whether there is any interest to put it on CPAN, and if so, what
> namespace you would suggest. In case you would like to have a look at
> the code I include it here, since it's not very long (Pod included).
Being a hobby programmer is fine. Most CPAN modules evolved from a
hobby, I am sure. The more fun there is in something the better the
result.
> All comments are welcome.
You require at least 5.6.0. Is there anything particular that wont run
under older perls (except for use warnings of course)?
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: 18 Oct 2002 14:59:56 -0700
From: Vilmos Soti <vilmos@vilmos.org>
Subject: Separating stdout and stderr
Message-Id: <87adlbqug3.fsf@my.vilmos.lan>
Hello,
If I open a process with open, then is it possible somehow to access
the process' stdout and stderr separately?
open (X, "tar cvf /dev/nst0 /mydir");
while (<X>) {
whatever;
}
close (X);
The problem here is that I get only stdout. If I put the "2>&1" to the
appropriate place, then I get both, but I cannot distinguish between
them.
I tried to crate a fifo and send stderr to that fifo and read it
later, but the whole program hanged.
All I can do now is to redirect stderr to a physical file and read
that file later. Is there a nicer solution?
If both go to the same filehandle but they are prepended with
sg like "stdout" or "stderr" then that would be perfect.
Thanks, Vilmos
------------------------------
Date: Fri, 18 Oct 2002 16:18:15 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Small syntax utility function
Message-Id: <3DB06C87.D5591C57@earthlink.net>
Richard J. Rauenzahn wrote:
>
> xach@xach.com writes:
> >In article <x7r8esett1.fsf@mail.sysarch.com>, Uri Guttman wrote:
> >>>>>>> "ZB" == Zachary Beane <xach@xach.com> writes:
> >>
> >> ZB> for (my $x = 0; $x < $#_; $x += 2) {
> >> ZB> local ($a, $b) = @_[$x, $x + 1];
> >>
> >> don't use $a and $b. they are special (see sort) and are scoped to
> >> the current package.
> >
> >I was hoping to use them exactly because they are special; they don't
> >trigger failures under "use strict" and they also make foreachpair
> >seem more like a built-in function like sort.
>
> List::Util gets to use them, so I don't see why you shouldn't be
> allowed to!
>
> How about....?
>
> sub foreachpair(&@) {
> my $code = shift @_;
> for my $i ( 0 .. $#_ / 2 ) {
> local ($a,$b) = @_[ $i * 2, $i * 2 + 1 ];
> &$code();
> }
> }
This uses the $a and $b of the package in which foreachpair is defined.
> foreachpair { print "$a => $b\n"; } 1,2,3,4,5,6;
This works if and only if it's called in the same package that
foreachpair was defined in, and does *not* work if we're in another
package, into which foreachpair was imported.
If you want to use the $a and $b of the caller's package, you have to
explicitly ask for them.
sub foreachpair(&@) {
my $coderef = shift;
my ($aref, $bref) = do {
my $caller = caller();
no strict 'refs';
map \${$caller."::$_"}, qw(a b);
};
# can't do "local ($$aref, $$bref)", unfortunatly :(
# This means that if &$code() dies, $a and $b won't
# get restored.
my ($asave, $bsave) = ($$aref, $$bref);
&$code() while ($$aref, $$bref) = splice @_, 0, 2;
($$aref, $$bref) = ($asave, $bsave);
}
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Fri, 18 Oct 2002 17:35:23 +0100
From: "NigelC" <Nigel@mutualnet.co.uk>
Subject: Re: Sockets through a proxy/firewall
Message-Id: <zJWr9.3048$H4.1599@news-binary.blueyonder.co.uk>
My own fault, the serv.pl script should read as follows - Still doesn't
solve my problem if someone could help?
use IO::Socket;
use Socket;
use Sys::Hostname;
my $host = hostname();
my $addr = inet_ntoa(scalar gethostbyname($host || 'localhost'));
my $server = IO::Socket::INET->new(
Listen => 5,
LocalAddr => $addr,
LocalPort => 5050,
Proto => 'tcp'
) or die "Can't create server socket: $!";
my $client = $server->accept;
$fl="c:/Perl/out1.pdf";
open FILE, ">$fl" or die "Can't open: $!";
binmode (FILE);
while (<$client>) {
print FILE $_;
}
close FILE;
"Nigel" <nhcannings@hotmail.com> wrote in message
news:361d2a80.0210180537.218396e3@posting.google.com...
> I have two simple scripts for passing pdf documents from one machine
> to another using sockets. These work perfectly well for most
> machines, but from time to time I'm going to want to get them through
> to a machine behind a corporate firewall. Assuming I know the IP
> address of the firewall, and the local Ip address of the machine
> itself, is there a simple way of modifying cli.pl (below) to pass the
> documents through
>
> thanks
>
> Nigel
>
> ===========
> (cli.pl)
>
> use IO::Socket;
> $remserv = 'xx.xx.xx.xx';
> my $server = IO::Socket::INET->new(
> PeerAddr => $remserv,
> PeerPort => 5050,
> Proto => 'tcp'
> ) or die "Can't create client socket: $!";
>
> open FILE, "c:/perl/ReadMe.pdf";
> binmode (FILE);
> while (<FILE>) {
> print $server $_;
> }
> close FILE;
>
>
> (serv.pl)
>
> use IO::Socket;
>
> my $server = IO::Socket::INET->new(
> Listen => 5,
> LocalAddr => 'localhost',
> LocalPort => 5050,
> Proto => 'tcp'
> ) or die "Can't create server socket: $!";
>
> my $client = $server->accept;
> $fl="c:/perl/out1.pdf";
>
> open FILE, ">$fl" or die "Can't open: $!";
> binmode (FILE);
>
> while (<$client>) {
> print FILE $_;
> }
> close FILE;
------------------------------
Date: 18 Oct 2002 13:37:10 -0700
From: rchacko@draftnet.com (raj guy)
Subject: streamline editor - removing a string from a file
Message-Id: <e6bd1e72.0210181237.2e99414@posting.google.com>
hi,
i am trying to remove a string from a file and just can't seem to do
it. here is a small part of the html file
<TD width="45" height="30" align="right" valign="middle"
class="readingText"><FONT color="#000000" > 78.3</FONT></TD>
The value '78.3' is a variable and i need to pull it out to a text
file. i thought that the best way to do it would be to remove
everything else from the file (the file has several such lines with
different values which i need without the html tags)
Any help is much appreciated,
Raj
------------------------------
Date: Fri, 18 Oct 2002 21:34:26 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: streamline editor - removing a string from a file
Message-Id: <3DB07E29.CBFC8348@acm.org>
raj guy wrote:
>
> i am trying to remove a string from a file and just can't seem to do
> it. here is a small part of the html file
>
> <TD width="45" height="30" align="right" valign="middle"
> class="readingText"><FONT color="#000000" > 78.3</FONT></TD>
>
> The value '78.3' is a variable and i need to pull it out to a text
> file. i thought that the best way to do it would be to remove
> everything else from the file (the file has several such lines with
> different values which i need without the html tags)
while ( <HTML> ) {
push @numbers, />\s*([\d.]+)\s*</;
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 18 Oct 2002 16:45:53 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Switching from Python to Perl
Message-Id: <3DB07301.D87964CA@earthlink.net>
Derek Thomson wrote:
> Benjamin Goldberg wrote:
[snip]
> >>So, is perl6 going to be written in perl6?
> >
> > [snip informative description of how perl6 is implemented in perl5]
> >
> > I suppose that when all of (or enough of) perl6 parsing is
> > implemented in perl5, the parser will get rewritten in perl6.
>
> Yes, that's all fine for *user* code, but you're missing the point.
>
> What is the *runtime* system written in? That's what I'm asking about.
>
> Take for example, the regex engine. Is that written in C, or perl5/6,
> or parrot?
The regex engine for perl5 is of course written in C. The regex engine
for perl6 will be written in perl6. Currently, of course, there's only
a parser, written in perl5, which translates regexen into PIR. In the
future, this will probably be a parser, written in perl6, which
translates regexen into either perl6 or PIR.
> If it's C, that's bad. If it's perl5/6 or parrot, that's much
> better, as the bytecode translator can do the work of porting the
> regex engine for us.
Well, *compiled* regexen are parrot bytecode. There isn't really a
regex runtime engine.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Fri, 18 Oct 2002 16:23:09 +0100
From: "Rubber Duck" <rubberducky703@hotmail.com>
Subject: Using File::Find with unc paths e.g. \\mymachine/start/
Message-Id: <aop8uk$odck8$1@ID-116287.news.dfncis.de>
Using File::Find with unc paths e.g. \\mymachine/start/
Is there any way to get file::find to work with unc paths? Whenever i pass
it a UNC path as a argument I get errors:
Creating stats for folder \\pc001/dir1/
Can't cd to \\pc001/dir: No such file or directory.
Has anyone got any ideas for getting file::find to work with UNC paths???
Thanks
RD
------------------------------
Date: Fri, 18 Oct 2002 15:43:52 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Using File::Find with unc paths e.g. \\mymachine/start/
Message-Id: <3db02c14.217859435@news.cis.dfn.de>
On Fri, 18 Oct 2002 16:23:09 +0100, "Rubber Duck"
<rubberducky703@hotmail.com> wrote:
>Using File::Find with unc paths e.g. \\mymachine/start/
>
>Is there any way to get file::find to work with unc paths? Whenever i pass
>it a UNC path as a argument I get errors:
>Creating stats for folder \\pc001/dir1/
>Can't cd to \\pc001/dir: No such file or directory.
>
>Has anyone got any ideas for getting file::find to work with UNC paths???
Sure. Use forward slashes:
my $folder = '//machine/share/folder?;
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Fri, 18 Oct 2002 15:33:17 -0400
From: "Kashmir" <kashmirnospam@bellnet.ca>
Subject: while loop to stop
Message-Id: <0mZr9.8157$q83.1551744@news20.bellglobal.com>
Hi,
I am trying to stop reading a text file once I have succesfully read the
parameters I was interested in. I have tried different things without
success.
open (FIC, $thefile) or die "file impossible to open";
while (<FIC> && ($_ != (/^Session Number:/)) )
{
if (/Time tag1:(.*)$/)
{
$TT1= $1;
$TT1=~ s/^\s+//; # Get rid of leading whitespace
print "$TT1\n";
}
if (/Time tag2:(.*)$/)
{
$TT2= $1;
$TT2=~ s/^\s+//; # Get rid of leading whitespace
print "$TT2\n";
}
}
The text file looks like this:
************************************
Time tag1: 04/18/2001 03:48:59
Time tag2: 04/18/2001 03:49:28
Output Value: 25
Session Number: 26
************************************
I want to stop the while loop before the end of file so that when the
program reads the line that contains "Session Number:" it quits the while
loop and continues with the remaining part of the code.
Any idea,
BTW any suggestions to shorten my code would be very much appreciated. Like
deleting the leading whitespace while placing the value in $1. I can't do
that.
Kashmir
------------------------------
Date: 18 Oct 2002 20:49:51 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: while loop to stop
Message-Id: <u9d6q7wmqo.fsf@wcl-l.bham.ac.uk>
"Kashmir" <kashmirnospam@bellnet.ca> writes:
> Subject: while loop to stop
> I have tried different things without success.
Try last().
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 18 Oct 2002 20:02:54 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: while loop to stop
Message-Id: <mbudash-B38DF7.13025318102002@typhoon.sonic.net>
In article <0mZr9.8157$q83.1551744@news20.bellglobal.com>,
"Kashmir" <kashmirnospam@bellnet.ca> wrote:
> Hi,
>
> I am trying to stop reading a text file once I have succesfully read the
> parameters I was interested in. I have tried different things without
> success.
>
> open (FIC, $thefile) or die "file impossible to open";
why not shwo why it died?:
open (FIC, $thefile) or die "file impossible to open: $!";
>
> while (<FIC> && ($_ != (/^Session Number:/)) )
should be:
while (<FIC> && ($_ !~ (/^Session Number:/)) )
> {
> if (/Time tag1:(.*)$/)
> {
> $TT1= $1;
> $TT1=~ s/^\s+//; # Get rid of leading whitespace
> print "$TT1\n";
> }
>
> if (/Time tag2:(.*)$/)
> {
> $TT2= $1;
> $TT2=~ s/^\s+//; # Get rid of leading whitespace
> print "$TT2\n";
> }
> }
>
> The text file looks like this:
> ************************************
> Time tag1: 04/18/2001 03:48:59
> Time tag2: 04/18/2001 03:49:28
> Output Value: 25
> Session Number: 26
> ************************************
> I want to stop the while loop before the end of file so that when the
> program reads the line that contains "Session Number:" it quits the while
> loop and continues with the remaining part of the code.
>
> Any idea,
>
> BTW any suggestions to shorten my code would be very much appreciated. Like
> deleting the leading whitespace while placing the value in $1. I can't do
> that.
>
> Kashmir
>
>
------------------------------
Date: Fri, 18 Oct 2002 21:24:53 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: while loop to stop
Message-Id: <3DB07BED.BB09BC69@acm.org>
Kashmir wrote:
>
> I am trying to stop reading a text file once I have succesfully read the
> parameters I was interested in. I have tried different things without
> success.
>
> open (FIC, $thefile) or die "file impossible to open";
>
> while (<FIC> && ($_ != (/^Session Number:/)) )
> {
> if (/Time tag1:(.*)$/)
> {
> $TT1= $1;
> $TT1=~ s/^\s+//; # Get rid of leading whitespace
> print "$TT1\n";
> }
>
> if (/Time tag2:(.*)$/)
> {
> $TT2= $1;
> $TT2=~ s/^\s+//; # Get rid of leading whitespace
> print "$TT2\n";
> }
> }
>
> The text file looks like this:
> ************************************
> Time tag1: 04/18/2001 03:48:59
> Time tag2: 04/18/2001 03:49:28
> Output Value: 25
> Session Number: 26
> ************************************
> I want to stop the while loop before the end of file so that when the
> program reads the line that contains "Session Number:" it quits the while
> loop and continues with the remaining part of the code.
open FIC, $thefile or die "$thefile impossible to open: $!";
while ( <FIC> ) {
last if /^Session Number:/;
print if s/^Time tag[12]:\s*//;
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 18 Oct 2002 17:34:52 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Kashmir <kashmirnospam@bellnet.ca>
Subject: Re: while loop to stop
Message-Id: <Pine.SGI.3.96.1021018173118.70202A-100000@vcmr-64.server.rpi.edu>
[posted & mailed]
On Fri, 18 Oct 2002, Kashmir wrote:
>open (FIC, $thefile) or die "file impossible to open";
You should really include $thefile and $! in the error message.
>while (<FIC> && ($_ != (/^Session Number:/)) )
Don't use !=, use !~. != is numerical not-equal. !~ is "does not match
this pattern". Also, <FIC> only stores a line in $_ if it's by itself:
while (<FIC>) {
last if /^Session Number:/;
# ...
}
or:
while (($_ = <FIC>) and !/^Session Number:/) {
# ...
}
or even better:
while (($_ = <FIC>) !~ /^Session Number:/) {
# ...
}
> if (/Time tag1:(.*)$/)
> {
> $TT1= $1;
> $TT1=~ s/^\s+//; # Get rid of leading whitespace
> print "$TT1\n";
> }
I'd suggest:
if (($tt1) = /Time tag1:\s*(.*)/) {
print "$tt1\n";
}
--
Jeff "japhy" Pinyan RPI Acacia Brother #734 2002 Acacia Senior Dean
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Fri, 18 Oct 2002 15:36:06 GMT
From: "smackdab" <smackdab1@hotmail.com>
Subject: Re: Win 32 IP Ping
Message-Id: <GTVr9.170608$S32.11901537@news2.west.cox.net>
there is a Net::Ping module that will make this easy for you
"NewsGroups" <mail@eircom.net> wrote in message
news:aokedh$755$1@dorito.esatclear.ie...
> can someone tell me where to get a perl script that will ping 24 windows
> computers from a windows server and report back ?
>
>
------------------------------
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 3995
***************************************