[22957] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5177 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 4 06:05:58 2003

Date: Fri, 4 Jul 2003 03:05:08 -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, 4 Jul 2003     Volume: 10 Number: 5177

Today's topics:
    Re: A little regex help? <abigail@abigail.nl>
    Re: Alternative to use vars <tassilo.parseval@rwth-aachen.de>
    Re: Alternative to use vars <mgjv@tradingpost.com.au>
    Re: Alternative to use vars <bart.lateur@pandora.be>
    Re: Alternative to use vars <bart.lateur@pandora.be>
    Re: Call parent method indirectly <bart.lateur@pandora.be>
        Delete trailing garbage chars from a set of files? <Patrick_member@newsguy.com>
    Re: Delete trailing garbage chars from a set of files? <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Delete trailing garbage chars from a set of files? <bart.lateur@pandora.be>
        From floating point to fraction <jon.rogers@tv.tu>
    Re: From floating point to fraction <abigail@abigail.nl>
    Re: From floating point to fraction <kalinabears@hdc.com.au>
    Re: Getting the size of files from a list? (Math55)
    Re: Need help with Win32::GuiTest and Indigo perl <kalinabears@hdc.com.au>
        Perl for Win32 (Armando Torres)
    Re: Perl for Win32 <tassilo.parseval@rwth-aachen.de>
    Re: Perl for Win32 <bart.lateur@pandora.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 04 Jul 2003 06:07:57 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: A little regex help?
Message-Id: <slrnbga6dt.poc.abigail@alexandra.abigail.nl>

Eric Schwartz (emschwar@pobox.com) wrote on MMMDXCIV September MCMXCIII
in <URL:news:etobrwbqhxl.fsf@wormtongue.emschwar>:
[]  "bd" <bdonlan@bd-home-comp.no-ip.org> writes:
[] > On Thu, 03 Jul 2003 11:45:27 -0600, Eric Schwartz wrote:
[] > [snip]
[] > > $ perl -i -pe 's/print\((.+?)(\\n)?"\);/print($1\\n");/g' input
[] > 
[] > Wouldn't \1 be more efficient, as it does not turn on the $n variables for
[] > all the regexes?
[]  
[]  No.  You also need to re-read perlre, specifically the section
[]  "Warning on \1 vs $1".  
[]  
[]  Just for kicks, though, I benchmarked the two approaches:
[]  
[]  $ cat /tmp/testbackref 
[]  #!/usr/bin/perl
[]  use warnings;
[]  use strict;
[]  use Benchmark;
[]  
[]  timethese(1000000, {
[]          '$n variables' => sub { 
[]                                  my $bob = 'print("foo");';
[]                                  $bob =~ s/print\((.+?)(\\n)?"\);/print($1\\n");/g;
[]                                },
[]          '\n backrefs' => sub { 
[]                                  my $bob = 'print("foo");';
[]                                  $bob =~ s/print\((.+?)(\\n)?"\);/print(\1\\n");/g;
[]                                },
[]  });


Well, his claim was that using '$1' would slow down all regexes. This
benchmark does little to disprove that fact; the first clause uses
'$1', so if "bd" is right, it would slow down the second clause as well.

But if you use strings as clauses instead of subs, you eliminate that:


#!/usr/bin/perl

use strict;
use warnings;

use Benchmark;

timethese -2 => {
    '$n' => '$_ = qq !print("foo");!; 
             s/print\((.+?)(\\n)?"\);/print($1\\n");/g;',
    '\n' => '$_ = qq !print("foo");!; 
             s/print\((.+?)(\\n)?"\);/print(\1\\n");/g;',
};

__END__
Benchmark: running $n, \n for at least 2 CPU seconds...
        $n:  2 wallclock secs ( 2.09 usr +  0.00 sys =  2.09 CPU)
             @ 75345.93/s (n=157473)
        \n:  3 wallclock secs ( 2.04 usr +  0.00 sys =  2.04 CPU)
             @ 80313.24/s (n=163839)


It doesn't show that '\n' is slightly faster in general - just for this
particular run. Running this repeatedly shows sometimes \n winning,
sometimes $n.



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: 4 Jul 2003 05:06:16 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Alternative to use vars
Message-Id: <be3208$lem$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Martien Verbruggen:

> On 3 Jul 2003 10:33:08 GMT,
> 	Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:

>> You are not the only one trying to grasp that. The concept of lexically
>> scoped global (that is, dynamic) variables truely escapes me. The only
>> advantage I see is that you can introduce new global variables
>> everywhere easily like so:
> 
> You can limit (with our) where that global variable is accessible:

Yes, and this feels pretty unnatural to me. It remotely reminds me of
the strange scoping that PHP has...where you have to put a global()
before a variable if you want to use it in a particular function:

    $var = "var";

    function func() {
        global $var;
        print "var: $var\n";
    }

I agree it's even more perverted in PHP because a block there can't
simply access variables that exists in the scope above. 

> #!/usr/local/bin/perl
> use strict;
> use warnings;
> 
> {
>     use vars qw/$var/;
>     $var = "var";
>     our $our = "our";
> 
>     print "var: $var\n";
>     print "our: $our\n";
> }
> 
> print "var: $var\n";
> # print "our: $our\n"; # impossible
> sub_needing_global();
> 
> sub sub_needing_global
> {
>     our $our;
>     print "our: $our\n";
> }
[...]
> In a single file, the same effect can be achieved with C<my>, but in
> multi-file projects that require a shared global, you can't use C<my>
> for the same purpose.

I don't think the above program could be rewritten with lexicals. Any
lexical declared in the upper bare block is lost once the block is left.

> Many people would say that it's better to avoid globals alltogether,
> but sometimes globals can make life a lot easier, and code much
> cleaner. In those cases, our is much preferable over C<use vars>
> because of the more finegrained control it gives you about the
> accessibility of that variable. It can prevent accidental access of
> globals in the same way that C<my> lexical scoping does.

And this is unlikely: You never really have many globals. Secondly, good
style demands that those global variables have a name that distinguishes
them from lexicals (like all uppercased). The danger of an accidental
access is therefore much lower than with lexicals of which you usually
have quite a bunch.

> C<use vars> is still deprecated, so it's probably better (unless you
> have to write code for 5.005) to not use it anymore.

I was lately busy making Perl5.00503 (the one that comes with FreeBSD 4.7)
work with the current autoconf package. It required a more recent
File::Copy module. I took this module from a 5.8.0 release and of
course, because of our(), it didn't work out of the box. It was easy to
fix because the finer grain of control that our() offers wasn't used.
And this seems to be the whole point: I haven't yet found any code in
the wild that made use of it. Usually it's used as a drop-in replacement
for 'use vars' with the exact same semantics.

I am really fearing the moment when 'use vars' will trigger a deprecated
warning in one of the future Perl5 releases. This will be the point
where you have to start to package-qualify all globals if you want to
write a module which is backwards compatible to at least 5.005.

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


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

Date: 04 Jul 2003 06:11:59 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Alternative to use vars
Message-Id: <slrnbga6li.1lu.mgjv@verbruggen.comdyn.com.au>

On 4 Jul 2003 05:06:16 GMT,
	Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:
> Also sprach Martien Verbruggen:
> 
>> On 3 Jul 2003 10:33:08 GMT,
>> 	Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:
> 
>>> You are not the only one trying to grasp that. The concept of lexically
>>> scoped global (that is, dynamic) variables truely escapes me. The only
>>> advantage I see is that you can introduce new global variables
>>> everywhere easily like so:
>> 
>> You can limit (with our) where that global variable is accessible:
> 
> Yes, and this feels pretty unnatural to me. It remotely reminds me of
> the strange scoping that PHP has...where you have to put a global()
> before a variable if you want to use it in a particular function:

It doesn't feel unnatural to me. But I guess that's a matter of
personal preference :)

[snip of program]

> [...]
>> In a single file, the same effect can be achieved with C<my>, but in
>> multi-file projects that require a shared global, you can't use C<my>
>> for the same purpose.
> 
> I don't think the above program could be rewritten with lexicals. Any
> lexical declared in the upper bare block is lost once the block is left.

I meant that if you declare a my() variable at file scope, it'd be
available through the whole file, acting a bit as a global, but not
actually being a global. I agree that my wording did not at all
express what I meant :)

>> Many people would say that it's better to avoid globals alltogether,
>> but sometimes globals can make life a lot easier, and code much
>> cleaner. In those cases, our is much preferable over C<use vars>
>> because of the more finegrained control it gives you about the
>> accessibility of that variable. It can prevent accidental access of
>> globals in the same way that C<my> lexical scoping does.
> 
> And this is unlikely: You never really have many globals. Secondly, good
> style demands that those global variables have a name that distinguishes
> them from lexicals (like all uppercased). The danger of an accidental
> access is therefore much lower than with lexicals of which you usually
> have quite a bunch.

And, indeed, when I write brand new code, that's more or less the
strategy I follow. However, sometimes one needs to work with old
code, that was written by people who didn't understand the value of
limiting scope. Rather than rewriting the whole thing to have a clean
base, it's often easier just to accept what's there, and to add the
new functionality required, but this time trying to keep it clean. We
all know that next week we will have a chance to rewrite it to our
liking :)

Martien
-- 
                        | 
Martien Verbruggen      | 
Trading Post Australia  | Hi, Dave here, what's the root password?
                        | 


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

Date: Fri, 04 Jul 2003 08:02:37 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Alternative to use vars
Message-Id: <e4dagvo4quuiitiir00tsh87edr1vdhu4l@4ax.com>

Himal wrote:

>I am using 
>use vars qw ($scalar @array %hash);
>in my program. I would like to know how to declare this in an
>alternative way using our and EXPORT.

"EXPORT" ?!?

-- 
	Bart.


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

Date: Fri, 04 Jul 2003 08:29:58 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Alternative to use vars
Message-Id: <kieagv8h5k8bm0blo63u3t2nevq1net1qc@4ax.com>

Martien Verbruggen wrote:

>> You are not the only one trying to grasp that. The concept of lexically
>> scoped global (that is, dynamic) variables truely escapes me. The only
>> advantage I see is that you can introduce new global variables
>> everywhere easily like so:
>
>You can limit (with our) where that global variable is accessible:

The part that makes no sense to me, is how use of these var now crosses
package boundaries...

	$Bar::x = 123;
	package Foo;
	our $x = "abc";
	package Bar;
	print $x;

Guess what that'll print?

-- 
	Bart.


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

Date: Fri, 04 Jul 2003 08:42:13 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Call parent method indirectly
Message-Id: <0dfagvkdarvcrtfs0ht14d5h4q1akjjjae@4ax.com>

Steve Grazzini wrote:

>You can also do:
>
>  $self->can("SUPER::$method")->(@args);

You forgot to pass along the object itself.

	$self->can("SUPER::$method")->($self, @args);


I was wondering if there wasn't another way, something like

	$self->SUPER->can($method)

but I guess not... :)

-- 
	Bart.


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

Date: 4 Jul 2003 00:10:03 -0700
From: Patrick Flaherty <Patrick_member@newsguy.com>
Subject: Delete trailing garbage chars from a set of files?
Message-Id: <be398b0b7q@drn.newsguy.com>

Hi,

When I copy a text file from VMS to Windows (via PATHworks) there are often
(depending on the length of the file) trailing garbage characters.  I've
determined these to be byte value x1a (that it, hex 1a).

  I can delete these from a single file with:

perl -p0777 -i.bu -e 's/\x1a+$//g' use.lis

What happens when I copy over a whole bunch of *.lis, many of which might have
this problem?

  I can loop over all these with:

@list = glob("*.lis");
foreach $name (@list) {
print $name . "\n";
}

That prints all the names out.  But what I want to do is delete the garbage
chars from each file in turn.

  This doesn't work (not surprising):

@list = glob("*.lis");
foreach $name (@list) {
s/\x1a+$//g $name;
}

  Doubtless I'm doing something daft here.  Hope someone can help me out.

  pat



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

Date: Fri, 4 Jul 2003 07:40:31 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Delete trailing garbage chars from a set of files?
Message-Id: <Xns93AE61FDFDF16elhber1lidotechnet@62.89.127.66>

Patrick Flaherty wrote:

> Hi,
> 
> When I copy a text file from VMS to Windows (via PATHworks) there are
> often (depending on the length of the file) trailing garbage
> characters.  I've determined these to be byte value x1a (that it, hex
> 1a). 
> 
>   I can delete these from a single file with:
> 
> perl -p0777 -i.bu -e 's/\x1a+$//g' use.lis
> 
> What happens when I copy over a whole bunch of *.lis, many of which
> might have this problem?


[...]


>   Doubtless I'm doing something daft here.  Hope someone can help me
>   out. 


Just change:


  perl -p0777 -i.bu -e 's/\x1a+$//g' use.lis


into:


  perl -p0777 -i.bu -e 's/\x1a+$//g' *.lis


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Fri, 04 Jul 2003 08:15:26 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Delete trailing garbage chars from a set of files?
Message-Id: <dndagvcn9f8sa7k16n63qssv055uhg4q8r@4ax.com>

Patrick Flaherty wrote:

>When I copy a text file from VMS to Windows (via PATHworks) there are often
>(depending on the length of the file) trailing garbage characters.  I've
>determined these to be byte value x1a (that it, hex 1a).

I hope those only happen in text files? Because in that case,
DOS/Windows is capable of ignoring the rest of the file... In fact, in
perl, when binmode() has not been applied to a filehandle, perl will see
this as the end of the file.

Anyway... Can you find out the exact file length on the original system,
externally? In that case, you could use truncate() to shorten the file.
See "perldoc -f truncate".

-- 
	Bart.


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

Date: Fri, 04 Jul 2003 11:37:39 +0200
From: jon rogers <jon.rogers@tv.tu>
Subject: From floating point to fraction
Message-Id: <be3h74$3tj$1@news.gu.se>

Hi

I'd like to, from inside my Perl script, go from a floating point number,
like 0.33333333333333333, to a fraction, in this case 1/3. Is that
possible? And if so, how?

/ JR


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

Date: 04 Jul 2003 09:55:43 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: From floating point to fraction
Message-Id: <slrnbgajov.ts.abigail@alexandra.abigail.nl>

jon rogers (jon.rogers@tv.tu) wrote on MMMDXCIV September MCMXCIII in
<URL:news:be3h74$3tj$1@news.gu.se>:
()  Hi
()  
()  I'd like to, from inside my Perl script, go from a floating point number,
()  like 0.33333333333333333, to a fraction, in this case 1/3. Is that
()  possible? And if so, how?


No, if only for the simple fact that 0.33333333333333333 isn't the
same as 1/3. There are an infinite amount of fractions that, when
converted to a float are mapped to 0.33333333333333333. Hence, the
mapping from fractions to floats isn't a bijection.

However, if you assume no rounding has taken place, it sure is
possible:


    my  $float = "0.33333333333333333";
    my ($frac) = $float =~ /[.](.*)/;

    print "$frac/1" . ("0" x length $frac);


Abigail
-- 
#!/opt/perl/bin/perl   --    # No trailing newline after the last line!    
BEGIN{$|=$SIG{__WARN__}=sub{$_=$_[0];y-_- -;print/(.)"$/;seek _,-open(_ 
,"+<$0"),2;truncate _,tell _;close _;exec$0}}//rekcaH_lreP_rehtona_tsuJ


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

Date: Fri, 4 Jul 2003 19:54:12 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: From floating point to fraction
Message-Id: <3f055000$0$22132@echo-01.iinet.net.au>


"jon rogers" <jon.rogers@tv.tu> wrote in message
news:be3h74$3tj$1@news.gu.se...
> Hi
>
> I'd like to, from inside my Perl script, go from a floating point number,
> like 0.33333333333333333, to a fraction, in this case 1/3. Is that
> possible? And if so, how?
>
> / JR

Sort of depends on what you mean. Does the numerator always have to be "1" ?
If not, how do you determine in advance the number it should be set to ?

Here's a spur-of-the-moment idea (not necessarily good :-)

use warnings;
my $x = "0.33333333333333333";
my $x2 = "0.83733333333333333";

my $y = fractionalise($x, 1);
my $y2 = fractionalise($x2, 1000);
print $y, "\n", $y2, "\n";

sub fractionalise {
    my $whole = int($_[1] / $_[0] + 0.5);
    return "$_[1]/". $whole;
    }




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

Date: 4 Jul 2003 00:19:16 -0700
From: magelord@t-online.de (Math55)
Subject: Re: Getting the size of files from a list?
Message-Id: <a2b8188a.0307032319.3bf73d7d@posting.google.com>

gbacon@hiwaay.net (Greg Bacon) wrote in message news:<vg8iancknatk3c@corp.supernews.com>...
> In article <a2b8188a.0307030543.19cea0e7@posting.google.com>,
>     Math55 <magelord@t-online.de> wrote:
> 
> : how can i get the size from the 9 files in /var/log/ksymoops and how
> : the size of the 8 files in /var/log? the list is noct always the same,
> : it can have more or less directories. i tried it like that so far:
> 
> Here's my implementation:
> 
>     #! /usr/local/bin/perl
> 
>     use strict;
>     use warnings;
> 
>     use File::Basename;
> 
>     sub to_bytes {
>         my $size = shift;
> 
>         if ($size =~ s/k$//) {
>             $size *= 1024;
>         }
>         elsif ($size =~ s/M$//) {
>             $size *= 1024 * 1024;
>         }
> 
>         $size;
>     }
> 
>     sub to_unit {
>         my $size = shift;
> 
>         if ($size > 1024 * 1024) {
>             $size = sprintf "%.1fM", $size / (1024*1024);
>         }
>         elsif ($size > 1024) {
>             $size = sprintf "%.1fk", $size / 1024;
>         }
> 
>         $size;
>     }
> 
>     ## main
>     my %size;
>     my @files = <DATA>;
> 
>     for (@files) {
>         chomp;
>         my($size,$path) = split;
> 
>         my $bytes = to_bytes $size;
>         my $dir = dirname $path;
>         $size{$dir} += $bytes;
>     }
> 
>     # pass two: zap subdirs from parents' totals
>     for (@files) {
>         chomp;
>         my($size,$path) = split;
> 
>         next unless exists $size{$path};
> 
>         my $dir = dirname $path;
>         my $bytes = to_bytes $size;
>         $size{$dir} -= $bytes;
>     }
> 
>     for (sort { $a cmp $b } keys %size) {
>         print "$_ - ", to_unit($size{$_}), "\n";
>     }
> 
>     __DATA__
>     32k     /var/log/XFree86.0.log
>     76k     /var/log/auth.log
>     116k    /var/log/auth.log.0
>     8.0k    /var/log/auth.log.1.gz
>     228k    /var/log/kdm.log
>     20k     /var/log/kern.log
>     1.2M    /var/log/kern.log.0
>     12k     /var/log/kern.log.1.gz
>     2.8M    /var/log/ksymoops
>     228k    /var/log/ksymoops/20030628062520.ksyms
>     4.0k    /var/log/ksymoops/20030628062520.modules
>     228k    /var/log/ksymoops/20030629062502.ksyms
>     4.0k    /var/log/ksymoops/20030629062502.modules
>     12k     /var/log/ksymoops/20030630.log
>     228k    /var/log/ksymoops/20030630062525.ksyms
>     4.0k    /var/log/ksymoops/20030630062525.modules
>     12k     /var/log/ksymoops/20030701.log
>     228k    /var/log/ksymoops/20030701062504.ksyms
> 
> I make two passes.  On the first, I sum the sizes, using dirname
> from the File::Basename module to grab the parent directory's name.
> On the second pass, I substract reported directories' sizes from
> their parents' totals (e.g., /var//var/log/ksymoops in this example).
> 
> : this is what  i want to have:
> : 
> : /var/log:1720.8
> : /var/log/ksymoops:3815.2
> : 
> : is therea better and less complicated way to do that?
> 
> My results are below:
> 
>     % ./try
>     /var/log - 1.7M
>     /var/log/ksymoops - 948.0k
> 
> Hope this helps,
> Greg



hi,works fine:-). thank you very much. how can i do that, when i call
a method with /var/log/ksymoops for example and i want to get the size
of that?

THANK YOU


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

Date: Fri, 4 Jul 2003 19:03:37 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Need help with Win32::GuiTest and Indigo perl
Message-Id: <3f054425$0$22141@echo-01.iinet.net.au>


"gw1500se" <awingnut@hotmail.com> wrote in message
>
> Or at least it fails different. I no longer get the error on the "use"
> statement. Now I get an error on the "FindWindowLike" statement. Here
> is what I tried as a test:
>
> @windows=FindWindowLike(0;"*","*");
>

Could that simply be a case of incorrect coding ?
Perhaps:
@windows=FindWindowLike(0,"^*","^*");

Cheers,
Rob




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

Date: 3 Jul 2003 21:52:30 -0700
From: Torres__Armando@msn.com (Armando Torres)
Subject: Perl for Win32
Message-Id: <5b4572c6.0307032052.41b67984@posting.google.com>

I am learning Perl, and I have never programed before.
I wrote a script that uses a Network path, but in the network path
thee is a space, and it's not working; this is a sample:

$PVCSDatabase = "\\\\PC\\Vault\\temp\\my folder";
   $SVRWEB = "C:/temp/eMitchell";
print " --- Getting Source Code...\n";
system("$PVCSClient get -pr$PVCSDatabase -a$SVRWEB -o -z -w
/archives")

It gives me an error becuse my folder.
If someone can give some ideas, or the place to get some info.

Thanks


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

Date: 4 Jul 2003 05:13:39 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Perl for Win32
Message-Id: <be32e3$llb$1@nets3.rz.RWTH-Aachen.DE>

[ f'up set to comp.lang.perl.misc ]

Also sprach Armando Torres:

> I am learning Perl, and I have never programed before.
> I wrote a script that uses a Network path, but in the network path
> thee is a space, and it's not working; this is a sample:
> 
> $PVCSDatabase = "\\\\PC\\Vault\\temp\\my folder";
>    $SVRWEB = "C:/temp/eMitchell";
> print " --- Getting Source Code...\n";
> system("$PVCSClient get -pr$PVCSDatabase -a$SVRWEB -o -z -w
> /archives")
> 
> It gives me an error becuse my folder.

This is because you pass one large string to system() in which case the
shell gets to see the command with the space in the path. You can use
system either with a list:

    $PVCSDatabase = "\\\\PC\\Vault\\temp\\my folder";
    $SVRWEB = "C:/temp/eMitchell";

    my @args = "get", "-pr", $PVCSDatabase, "-a", $SVRWEB, 
               "-o", "-z", "-w", "/archives";
    system($PVCSClient, @args);

or turn the path into something the shell will understand manually:

    $PVCSDatabase = '\\\\PC\Vault\temp\"my folder"';

Better use single quotes here because it saves you some escaping. The
only thing that needs escaping then are the two backslashes of an UNC-path.

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


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

Date: Fri, 04 Jul 2003 08:11:41 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl for Win32
Message-Id: <qjdagvgdag901qt798gnje2mukfhmaa3cp@4ax.com>

Armando Torres wrote:

>$PVCSDatabase = "\\\\PC\\Vault\\temp\\my folder";
>   $SVRWEB = "C:/temp/eMitchell";
>print " --- Getting Source Code...\n";
>system("$PVCSClient get -pr$PVCSDatabase -a$SVRWEB -o -z -w
>/archives")
>
>It gives me an error becuse my folder.

It's a shelling issue. Put quotes around that part with the folder in.

system("$PVCSClient get \"-pr$PVCSDatabase\" -a$SVRWEB -o -z -w
/archives")

-- 
	Bart.


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

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


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