[15601] in Perl-Users-Digest
Perl-Users Digest, Issue: 3014 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 11 06:05:21 2000
Date: Thu, 11 May 2000 03:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958039508-v9-i3014@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 11 May 2000 Volume: 9 Number: 3014
Today's topics:
Re: #How to parse and strip perl comments? (Csaba Raduly)
Behavior of split seems a bit inconsistent <junio@siamese.dhis.twinsun.com>
Re: Behavior of split seems a bit inconsistent nobull@mail.com
Re: can scalars evaluate as operators? nobull@mail.com
Re: Clear and then Reuse a package name space (Bart Lateur)
Dubbele Insert <huijgbv@casema.net>
Re: expungevirus.pl (Csaba Raduly)
Re: Getopt::Long : use of uninitialized value (Johan Vromans)
Getting rid of leading and trailing spaces prakash_ojha@my-deja.com
Re: Getting rid of leading and trailing spaces <billy@arnis-bsl.com>
How to delete one field in each line ? <koreags@thrunet.com>
Re: How to inspect "my" variables in perldebug? <michael.schlueter@philips.com>
Increase a selected fieldvalue <huijgbv@casema.net>
Locale setting fails (was: Re: Beginner: 8bit-regexp) ocromm@my-deja.com
Re: MUCH better DATA file formatting :) (THANK YOU) <nospam@devnull.com>
Re: Quit over the use of a script (ot) (Eric Bohlman)
regular expression <ii4533@fh-wedel.de>
remaining disk space <Michel.Verheijen@nl.origin-it.com>
Re: remaining disk space <peter_gonnissenNOpeSPAM@euroseek.com.invalid>
Re: remaining disk space <blah@nospam.com>
Re: shooting yourself in the foot ... <iltzu@sci.invalid>
XOR (was: Converting Macintosh files to UNIX) <iltzu@sci.invalid>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 May 2000 08:44:58 GMT
From: csaba_r@my-deja.com (Csaba Raduly)
Subject: Re: #How to parse and strip perl comments?
Message-Id: <8F316FA72quuxi@193.82.145.131>
10 May 2000: A formal bug report was sent to Seti@Home, because the
following message originated from bart.lateur@skynet.be (Bart Lateur)
was reported as containing signs of intelligence:
>Peter Hill wrote:
>
>>Jonathan Stowe wrote:
>
>>> fortune oscar homer
>
>>You're right, of course, how could you argue with an educated
>>gentleman who quotes Homer?
>
>Is that the acient Greek writer, AKA Homeros, or Homer Simpson?
>
I doubt Homeros caused too many accidents in his time (then again, he
was blind :-)
Csaba
--
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com http://www.sophos.com/
US Support +1 888 SOPHOS 9 UK Support +44 1235 559933
Life is complex, with real and imaginary parts.
-----BEGIN GEEK CODE BLOCK-----
Version 3.1
GCS/IT/MU d- s:- a31 C++$ UL+ P+>+++ L++ E- W+ N++ w++>$ O++$
M-(+) V- PGP- t+ X++ R* tv++ b++ DI+++ D++ G- e+++ h-- r-- !y+
-----END GEEK CODE BLOCK-----
------------------------------
Date: Thu, 11 May 2000 07:30:00 GMT
From: Jun Hamano <junio@siamese.dhis.twinsun.com>
Subject: Behavior of split seems a bit inconsistent
Message-Id: <7vwvl11r47.fsf@siamese.dhis.twinsun.com>
I had this code:
sub par {
my (@data) = @_;
if (@data == 0) { print "it is empty.\n"; }
else {
print "there is some data.\n";
print " <", join (">\n <", @data), ">\n";
}
}
par (split (/#/, "ab#c"));
par (split (/#/, "abc"));
par (split (/#/, "ab"));
par (split (/#/, "a"));
par (split (/#/, ""));
And this is the output:
there is some data.
<ab>
<c>
there is some data.
<abc>
there is some data.
<ab>
there is some data.
<a>
it is empty.
Because of the way it behaves for "abc", "ab", and "a", I
expected that the last case would report the sub received a
single element array with a single 0-length string "" in it, but
apparently it is not what I am seeing.
Is this a bug, or is it a documented, traditional semantics that
many existing code rely on?
------------------------------
Date: 11 May 2000 09:51:11 +0100
From: nobull@mail.com
Subject: Re: Behavior of split seems a bit inconsistent
Message-Id: <u9r9b9eagw.fsf@wcl-l.bham.ac.uk>
Jun Hamano <junio@siamese.dhis.twinsun.com> writes:
> par (split (/#/, ""));
> I expected that the last case would report the sub received a single
> element array with a single 0-length string "" in it, but apparently
> it is not what I am seeing.
>
> Is this a bug, or is it a documented,
perldoc -f split
Note the second sentence (at least in 5.5).
A more interesting question is why does split(/#/,"",-1) not return a
single element array with a single 0-length string "" in it.
Now is _this_ a bug?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 11 May 2000 10:14:17 +0100
From: nobull@mail.com
To: epement@jpusa.org
Subject: Re: can scalars evaluate as operators?
Message-Id: <u9puqte9ee.fsf@wcl-l.bham.ac.uk>
epement@jpusa.chi.il.us (Eric Pement) writes:
> I'm working on a Perl script tonight that I need to get finished in a
> few hours. Simple question, but I can't find the answer:
>
> Is there any way to coerce scalar variables to replace operators?
eval(EXPR)
But eval(EXPR) is evil - do not do it unless you absolutely must.
> Here's a highly-simplified way of expressing my question.
>
>
> if ($both) {
> $oper = "&&"
> } else {
> $oper = "||"
> }
> ....more code....
>
> if ($a $oper $b) { # 30 lines of code in this block }
if ( $both ? ( $a && $b) : ( $a || $b ) )
If you find the EXPR?EXPR:EXPR syntax hard to read (I know I do for
non-trival values of EXPR) you can spell it out:
if ( do {
if ($both) {
$a && $b
} else {
$a || $b
}
} )
Or if you want to do something more like what you originally tried
(perhaps because there really are more than two operators):
if ($both) {
$oper = sub { $_[0] && &{$_[1]} }
} else {
$oper = sub { $_[0] || &{$_[1]} }
}
if (&$oper($a,sub{$b}) { # 30 lines of code in this block }
Note: I'm passing $b as a CODE reference so that we don't loose the
lazy evaluation optomisation on the && an || operators. You may
remove this additional complexity if you do not need this optomisation.
> I've tried wrapping $oper with eval(),
eval("\$a $oper \$b") would work but it is not good style.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 11 May 2000 09:44:34 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Clear and then Reuse a package name space
Message-Id: <391a79f8.569462@news.skynet.be>
richard_chen@my-deja.com wrote:
>If in the main package you set
> *Q::myfunc=\&a_func_in_main;
>Then after calling scrub_package, the main::a_func_in_main
>is gone!
>sub scrub_package {
...
> # Get rid of everything with that name.
> undef $$fullname;
> undef @$fullname;
> undef %$fullname;
> undef &$fullname;
> undef *$fullname;
I wonder if a simple
undef *$fullname;
isn't enough. The chain reaction of decrementing reference counts should
release those things that need releasing, but no more.
--
Bart.
------------------------------
Date: Thu, 11 May 2000 08:12:12 +0200
From: "Eric van Huijgevoort" <huijgbv@casema.net>
Subject: Dubbele Insert
Message-Id: <391a4fa2$0$15323@reader4.casema.net>
Next code generates a dubbele insert:
foreach $product (sort keys %howmanyproducts) {
$dbh->do("INSERT INTO orderlist (ordernumber, amount, titel, system_id,
status)
VALUES (20000501, $howmanyproducts{$product}, '$product',
$systemideachproduct{$product}, '$statuseachproduct
{$product}')");
}
return "";
Does anyone know what could by the problem.
To complete: I use the auto_incement feature.
Thanks in advance, you can also mail me.
Erik van Huijgevoort
Holland
huijgbv@casema.net
------------------------------
Date: 11 May 2000 09:05:04 GMT
From: csaba_r@my-deja.com (Csaba Raduly)
Subject: Re: expungevirus.pl
Message-Id: <8F3160428quuxi@193.82.145.131>
09 May 2000: A formal bug report was sent to Seti@Home, because the
following message originated from carriec@doc.state.vt.us (Carrie
Coy) was reported as containing signs of intelligence:
>I've used the attached script to expunge offensive spam and/or
>viruses from user mailboxes. We can scan about 1000 user mailboxes
>(1G) in approximately 10 minutes. The expunged messages are logged
>with message flags so it's possible to know if the user already
>"saw" the message.
>
>It's proved helpful to us when something "slips through the cracks".
>--
>Carrie Coy
>Systems Administrator
>Vermont Department of Corrections
>
>
>begin 666 expungevirus.pl
>Attachment decoded: expungevirus.pl
>`
>end
>
>
As someone who works for an antivirus company, I have to object.
This script succeeds, above all, to give a false sense of safety.
First, it only detects a few subject lines the ILOVEYOU virus uses; new
variants still appear regularily. There's no substitute for a proper
antivirus solution.
The claim to be able to expunge offensive spam is absolutely
unsubstantiated. Also, the script doesn't "use strict" and -w.
I have a guess what the Dept. of Correction does; if it is correct, you
may expect some virus writers as your customers :-)
--
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com http://www.sophos.com/
US Support +1 888 SOPHOS 9 UK Support +44 1235 559933
Life is complex, with real and imaginary parts.
-----BEGIN GEEK CODE BLOCK-----
Version 3.1
GCS/IT/MU d- s:- a31 C++$ UL+ P+>+++ L++ E- W+ N++ w++>$ O++$
M-(+) V- PGP- t+ X++ R* tv++ b++ DI+++ D++ G- e+++ h-- r-- !y+
-----END GEEK CODE BLOCK-----
------------------------------
Date: 11 May 2000 08:56:43 +0200
From: JVromans@Squirrel.nl (Johan Vromans)
Subject: Re: Getopt::Long : use of uninitialized value
Message-Id: <wl3snvpefro.fsf@plume.nl.compuware.com>
tmohr@schleim.qwe.de (Torsten Mohr) writes:
> $result = GetOptions( "mode=s" => \$m,
> "I=s@" => \@INCS,
> "D=s%" => \%DEFS
> );
> When i call it two warnings are generated:
>
> These warnings are very disturbing. How can i get rid of them?
Options are matched case insensitive by default, so you can say:
$result = GetOptions( "mode=s" => \$m,
"i=s@" => \@INCS,
"d=s%" => \%DEFS
);
(with lowercase "i" and "d").
If you _require_ the options to be in uppercase only, use
Getopt::Long::Configure("noignorecase");
$result = GetOptions( "mode=s" => \$m,
"I=s@" => \@INCS,
"D=s%" => \%DEFS
);
before the call to GetOptions.
It's a bug, nevertheless, and I'll fix it.
-- Johan
Author and maintainer of Getopt::Long
------------------------------
Date: Thu, 11 May 2000 08:38:03 GMT
From: prakash_ojha@my-deja.com
Subject: Getting rid of leading and trailing spaces
Message-Id: <8fdrha$bm2$1@nnrp1.deja.com>
I need to clear a word, that I read from file, of leading and trailing
spaces and later compare this with some other query.
any help will be greatly appreciated,
prakash
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 11 May 2000 08:48:11 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: Getting rid of leading and trailing spaces
Message-Id: <8fds48$c9c$1@nnrp1.deja.com>
In article <8fdrha$bm2$1@nnrp1.deja.com>,
prakash_ojha@my-deja.com wrote:
> I need to clear a word, that I read from file, of leading and trailing
> spaces and later compare this with some other query.
>
1. This questions has been discussed here many times recently.
2. It's a FAQ: "How do I strip blank space from the beginning/end of a
string?" See 'perldoc perlfaq4' for details (or
http://www.cpan.org/doc/manual/html/pod/perlfaq4.html)
3. OK, here's the solution (one from FAQ):
$string =~ s/^\s+//;
$string =~ s/\s+$//;
Good luck.
Ilja.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 11 May 2000 19:04:52 +0900
From: "Joe" <koreags@thrunet.com>
Subject: How to delete one field in each line ?
Message-Id: <8fdvro$f8m$1@news1.kornet.net>
Hi,
Will you please direct me this ?
I want to delete one value in each line.
These lines (split by \|)
aaa|1111
eee|2222
ooo|3333
To (delete first value together with split \|)
1111
2222
3333
Thank you.
------------------------------
Date: Thu, 11 May 2000 09:13:28 +0200
From: "Michael Schlueter" <michael.schlueter@philips.com>
Subject: Re: How to inspect "my" variables in perldebug?
Message-Id: <8fdmfn$mqj$1@porthos.nl.uu.net>
Dai,
Are my variables invisible? Yes and no. It depends on their scope. E.g.:
my $x='abc';
for( my $i=0; $i<3; $i++) {
my $a = 123 + $i; # $a visible here
} # $a invisible here; $i visible here
# $i invisible here
The scope of $a is limited to the for-loop. More precisely it goes out of
scope for the next looping of for.
$i is limited to everywhere between the { } of the for-loop. $x is visible
everywhere after its 'declaration'.
When you use my, perl creates a new namespace for that variable. This is
done to avoid unwanted side-effects which can occure from global variables.
So for $i a new namespace is created when starting the for-loop and it is
removed when finished with this for-loop. For a new iteration in the
for-loop a new namespace is reserved for $a. It is removed just before the
next loop is made.
So at the line with the } you should be able to inspect $x and $i, but not
$a.
This is just an example. You gain more benefit from my when you use
subroutines, e.g.
my $x;
sub test {
my $x = shift;
...
}
sub print {
my $x = shift;
...
}
You now can't mix the $x'es. They are unique. Beware of not using my unless
you have pretty good reason:
$x = 'abc';
sub test {
$x = ...; # big trouble ahead
...
}
sub print {
$x = ...; # big trouble ahead
...
}
The scope of this $x is global. All $x'es are exactly the same namespaces
!!!
Michael Schlueter
------------------------------
Date: Thu, 11 May 2000 08:39:20 +0200
From: "Eric van Huijgevoort" <huijgbv@casema.net>
Subject: Increase a selected fieldvalue
Message-Id: <391a55fd$0$9490@reader3>
Can anyone tell my how to increase a selected fieldvalue in undermentioned
code.
$_max_ordernumber++; doesn't work, please tell my the right query.
<eval>
$max_ordernumber = $dbh->prepare("SELECT max(ordernumber) FROM
orderlist");
$_max_ordernumber++;
$max_ordernumber->execute;
#checking
while (my $ref = $max_ordernumber->fetchrow_hashref) {
print "Found maximum ordernumber: $ref->{'ordernumber'}\n";
}
$max_ordernumber->finish;
<eval>
Every suggestion is welcome.
Thanks in advance, you can also mail me.
Erik van Huijgevoort
Holland
huijgbv@casema.net
------------------------------
Date: Thu, 11 May 2000 09:00:27 GMT
From: ocromm@my-deja.com
Subject: Locale setting fails (was: Re: Beginner: 8bit-regexp)
Message-Id: <8fdsr5$cua$1@nnrp1.deja.com>
In article <8fbv8o$7ui$1@nnrp1.deja.com>,
ocromm@my-deja.com wrote:
> I'm using regexps to find similar strings in a dictionary (to describe
> it easily), but they're all in German, and perl doesn't like my
> non-7bit-characters in regexps (fine with strings, though).
>
> A quick search shows me that it has to do with uing the locale, but
After searching some web pages, I did try the following:
use POSIX qw(locale_h);
use locale;
$loc = POSIX::setlocale (LC_CTYPE);
print ("Locale = $loc\n");
POSIX::setlocale (LC_CTYPE, "de_DE");
$loc = POSIX::setlocale (LC_CTYPE);
print ("Locale = $loc\n");
locale -a on my computer shows me there are (among others) the locales
de
de_DE
deutsch
existent.
If I enter "de" in the above, the locale doesn't change!?
If I enter "de_DE" or "deutsch" in the above, the LC_CTYPE changes to
de_DE, but nothing changes about the regexp treatment:
In most cases where there is a non-ASCII character, perl
says "unmatched () in regexp"
Do I need a "de_DE.ISO-8859-1"?
Please help!
Oliver Cromm
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 11 May 2000 07:12:49 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: MUCH better DATA file formatting :) (THANK YOU)
Message-Id: <8fdmhh$ke2$0@216.155.32.24>
In article <8fd8on$jce$0@216.155.32.24>, The WebDragon
<nospam@devnull.com> wrote:
| ok, taking my cue from another post I saw around here regarding column
| transposition, and __DATA__ sections, I've made a few changes to my
| code. :)
|
| THIS should make my life a LOT easier when I go to convert this to
|
| my %master_list = (
| $game_type => {
| $filename => [ $title, $size, $review, $rating]
| }
| }
|
| you are welcome to try this one .. this should work beautifully. :D
| -=-fileGrab2.pl
| #!perl -w
| use strict;
| use diagnostics -verbose;
| use LWP::UserAgent;
| use File::Spec;
|
| my $input_dir = File::Spec->catfile( File::Spec->curdir(),
| 'input_files', '');
| my $baseURL = "http://www.planetunreal.com/nalicity/";
|
| # map fileslist to section titles
| my %files_list = (
| 'ut_assault_maps.htm' => 'utassault',
| 'ut_capturetheflag_maps.htm' => 'utctf',
| 'ut_dm_maps.htm' => 'utdm',
| 'ut_dm_maps_b.htm' => 'utdm',
| 'ut_domination_maps.htm' => 'utdomination',
| 'ut_other_maps.htm' => 'utother'
| );
|
| #active fileslist (now deprecated)
| #opendir(DIR, $input_dir) || die ("Cannot opendir $input_dir : $!");
| # my @files_list = readdir(DIR);
| #closedir DIR;
|
| for (keys %files_list) {
| my $ua = new LWP::UserAgent;
| my $request = new HTTP::Request 'GET' => $baseURL . $_;
| my $response = $ua->request($request);
| die "$baseURL $_ failed: ",$response->error_as_HTML
| unless $response->is_success;
| print "Successful request of $_\n";
| open(OUT, ">$input_dir$_") or die ('Aieeeeee');
| print OUT $response->content;
| close OUT;
| };
|
| my @data_List;
| for (sort(keys %files_list)) {
| my $grab_File = $input_dir . $_;
| open(GRAB, "<$grab_File") or die ("Cannot open file $grab_File :
| $!");
| print "Successful open of $grab_File\n";
| my $section = $files_list{$_};
| while(<GRAB>) {
| tr/\r//d;
| s/\"//g;
| s/\,/\|/g;
| next unless /^\Qmaps[i++] = new Map(\E([^)]+)/;
| push @data_List, "$section\|$1\|\n" ;
| }
| close (GRAB);
| };
|
| open(OUT, ">maps_list.txt") or die ("DOH! can't create the maps list :
| $!");
| # for (@data_List) { print OUT "$_\n" }
| print OUT @data_List;
| close (OUT);
| __END__
ok Teach,
yuh learned me. Aintchew proud a' me? *stubs toe in dirt*
OK, try THIS on for size, after running the above script ;)
-=-complextableINPUT.pl
#!perl -w
use strict;
use diagnostics -verbose;
use File::Spec;
my $input_File = File::Spec->catfile( File::Spec->curdir(),
'maps_list.txt');
my $output_File = File::Spec->catfile( File::Spec->curdir(),
'complex_test.txt');
my %master_maps_list = ();
my @data = ();
open(IN, "<$input_File");
#I don't understand how to dereference this yet. um, 'help'? :)
# @data = map {chomp; [split /\|/]} <IN>;
#so I did it the 'long' way. is this the 'better' way?
while (<IN>) {
chomp;
push @data, $_;
}
close IN;
foreach (@data) {
my($gametype, $filename, $title, $size, $review, $rating) = split
/\|/;
$master_maps_list{$gametype}{$filename} = [$title, $size, $review,
$rating];
}
my $totalcount = 0;
open(OUT, ">$output_File");
foreach my $GameType (sort (keys %master_maps_list)) {
print OUT "GameType is $GameType\n";
my $count = scalar keys (%{ $master_maps_list{$GameType}});
$totalcount += $count;
print OUT "Map Count: $count\n";
foreach my $mapName (sort (keys %{ $master_maps_list{$GameType}})) {
my($Title, $size, $review, $rating) = @{
$master_maps_list{$GameType}{$mapName}};
print OUT "MapName: $mapName.zip, Title: $Title, FileSize:
$size, ";
if ($rating != -1) {
print OUT "Review: $review.html, Rating: $rating\n"
} else {
print OUT "Review: N/A, Rating: N/A\n"
}
}
print OUT "==\n"
}
print OUT "Total # of Maps = $totalcount\n";
close OUT;
__END__
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: 11 May 2000 08:29:08 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Quit over the use of a script (ot)
Message-Id: <8fdr0k$mml$1@nntp9.atl.mindspring.net>
Peter (home@cordova.net) wrote:
: My bosses continue to use scripts that I have no respect for. Not
: necessarily because
: they don't do what there were intended for, but because they are like
: patchwork,imho.
:
: I liked to build websites where scripts rotate around the use of
: modules. My bosses began the company by patching together websites with
: the 'freeware' scripts and they are fond of these scripts ... yet they
: hired me for the ability to handle any type of web programming.
:
: On a regular basis a boss will jump in and put a script in a site and
: use one of those scripts to handle the output ... recently they asked me
: to make some changes to the script and I just didn't want to do it. I
: did not like what I considered an alien intruding in my universe. I did
: not want to waste my time working within the confines of this alien
: entity ... I've modularized so much of what these things do and I do
: nearly all my work with the mysql database as my data repository ... and
: this thing just ... well it just pisses me off.
Sounds to me like you should try to work up a business case for your
position, based on the fact that maintenance usually accounts for the
majority of the lifetime costs of a piece of software. You'll need to do
some research and get some hard numbers. It will also be useful to
document how often you discover security holes, race conditions, etc. in
the freebie scripts.
------------------------------
Date: Thu, 11 May 2000 11:07:42 +0200
From: Nils <ii4533@fh-wedel.de>
Subject: regular expression
Message-Id: <391A785E.5F909F32@fh-wedel.de>
Hi!
I am looking for an regular expression which matches something like
this:
<!-- Back:Text -->
:Text might ba anything excepted '-->' (somithing like ":this is a link
<a href=url> go here </a>' SHOULD be a valid expression for Text! also
if :Text is not present should be valid)
the expression I've got at moment is :
/<!--\s*Back(:.*)?\s*-->/
my problem is that (:.*)? also matches '-->' but I have no idea how to
say that it should NOT match '-->"
anyone an idea? thanks nils
------------------------------
Date: Thu, 11 May 2000 10:48:27 +0200
From: "Michel Verheijen" <Michel.Verheijen@nl.origin-it.com>
Subject: remaining disk space
Message-Id: <0E16861EE7BCD111BE9400805FE6841F0FEA0D8A@c1s5x001.cor.srvfarm.origin-it.com>
I'm running a Perl program in a Windows environment. Who knows how to get
the remaining disk space on a specific drive? (Is there a function for that
in Perl? If not, who knows how to do it?)
Thanx,
Michel
------------------------------
Date: Thu, 11 May 2000 02:25:08 -0700
From: Peter <peter_gonnissenNOpeSPAM@euroseek.com.invalid>
Subject: Re: remaining disk space
Message-Id: <274bbd15.6ac0e10b@usw-ex0102-084.remarq.com>
Hi,
I uses the following lines to obtain free disk space on NT4.
It's based on the dir output layout, so you will have to adapt it
for win98 or win95.
foreach $_ (`dir c:`){s/ //g;if (/bytesfree/) {$space=$`;}}
print $space;
Peter.
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Thu, 11 May 2000 11:44:29 +0200
From: Marco Natoni <blah@nospam.com>
Subject: Re: remaining disk space
Message-Id: <391A80FD.F415B56C@nospam.com>
Hi Michel,
Michel Verheijen wrote:
> I'm running a Perl program in a Windows environment. Who knows how
> to get the remaining disk space on a specific drive? (Is there
> a function for that in Perl? If not, who knows how to do it?)
A very quick & dirty (as well as a bit obfuscated) way to obtain the
free space on a Microsoft file system is to parse the output of the dir
command:
<code>
($frespace=(grep /^\d/,reverse split / /,
(`dir .`)[-1])[0])=~s/[^\d]//g;
</code>
Sure that a better way there is... ;)
Best regards,
Marco
------------------------------
Date: 11 May 2000 09:10:45 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: shooting yourself in the foot ...
Message-Id: <958035739.18315@itz.pp.sci.fi>
In article <391A2049.39E05465@citr.com.au>, James Beard wrote:
>I was just trolling through some old jokes, and I came across
>http://www.users.csbsju.edu/~lziegler/ShootingInFoot.html
>
>Does anyone have a "shooting yourself in the foot with perl"?
"You grab the gun and pull the trigger without aiming. The bullet
hits your foot, which is what Perl assumed you wanted."
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: 11 May 2000 08:14:17 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: XOR (was: Converting Macintosh files to UNIX)
Message-Id: <958032597.13345@itz.pp.sci.fi>
In article <391e7ebf.44508144@news.skynet.be>, Bart Lateur wrote:
> s/([\r\n])/$1 ^ "\r" ^ "\n"/ge;
>
>You may replace '"\r" ^ "\n"' with '"\07"' if you like, but it's not as
>clear.
Cool. Is this the point where I should post this?
perl -e 'for($_="db\n";print;s/..(?=d)/$&^"DB"/eg){s/^/ /}' | less
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3014
**************************************