[19522] in Perl-Users-Digest
Perl-Users Digest, Issue: 1717 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 9 06:05:39 2001
Date: Sun, 9 Sep 2001 03:05:07 -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: <1000029907-v10-i1717@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 9 Sep 2001 Volume: 10 Number: 1717
Today's topics:
Re: ActivePerl says Out of Memory, but I'm not out of m <goldbb2@earthlink.net>
CR/LF <sh@planetquake.com>
Re: CR/LF (Tim Hammerquist)
Re: Extract the relative sorting of items from multiple (Tim Hammerquist)
Re: Extract the relative sorting of items from multiple <goldbb2@earthlink.net>
Re: Extract the relative sorting of items from multiple (Tim Hammerquist)
Re: How can I find the PID's of my children? <goldbb2@earthlink.net>
Re: How can I find the PID's of my children? <goldbb2@earthlink.net>
Re: newbe problem with Perl <michealo@ozemail.com.au>
Perl is TOO much fun (Sara)
Re: Perl is TOO much fun <uri@sysarch.com>
Re: Perl objects problems (mirvine555)
Re: Perl objects problems <Tassilo.Parseval@post.rwth-aachen.de>
Re: Perl objects problems mirvine@compsoc.com
recognize MS Windows with perl <news@althepal#nospam#.com>
Re: recognize MS Windows with perl <davidhilseenews@yahoo.com>
Re: recognize MS Windows with perl <kyros.ironforge@yahoo.com>
Re: recognize MS Windows with perl <kalinabears@hdc.com.au>
Re: Recommendations for a PERL editor (Tim Hammerquist)
Re: Recommendations for a PERL editor <michealo@ozemail.com.au>
Re: Simple regexp <chengkail@home.com>
strange Win32 IO behavior! (Newbie)
Re: Why doesn't this regex work? (Martien Verbruggen)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 08 Sep 2001 23:22:46 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: ActivePerl says Out of Memory, but I'm not out of memory? Is this a limitation in the Perl build I have?
Message-Id: <3B9AE086.C2D09327@earthlink.net>
Jonadab the Unsightly One wrote:
>
> #!perl
> $_="
> Bob Walton wrote:
> > Please whittle your script down to the smallest number of
> > lines that will execute verbatim if copy/pasted and will
> > also illustrate the problem you have having, and repost.
>
> Okay, I've got it under 100 lines, and if I try to make it any
> shorter it'll be obfuscated; already it's lacking comments...
>
> To recap, what's happening is, Perl is using roughly 112MB
> of memory but I still have about 50MB free (as reported by
> mem) but ActivePerl says 'Out of memory!' and bails. What
> I want to know is why Perl can't use the other 50MB and/or
> the virtual memory Windoze provides, and whether using a
> different Perl binary will help me. Here's the script...";
>
> sub stackpush; sub stackpop; sub stacktop; sub workfrom;
> sub winning; sub trytoplay; sub canplay;
>
> $nothing=0; %cell=(1=>0,2=>0,3=>0,4=>0);
I'm positive don't *really* need $nothing.
I would replace %cell with @cell, and index from 0, not 1.
> %sabr=(0=>"h",14=>"d",28=>"c",42=>"s");
> %cabr=(10=>"t",11=>"j",12=>"q",13=>"k"); foreach $c (0..9) {
> $cabr{$c}="$c";}
cabr could be an array.
> %cardsuit=reverse(%sabr);%cardval=reverse(%cabr);$cardval{"a"}=1;
> %stack=(0=>"7c8hasqdqs6cah",1=>"2djctsjs9h8dqh",2=>"tc3had7h5d2h8c",
> 3=>"ks6d9d3c3d2c5h",4=>"7s8s4ckc4d9c", 5=>"5c9s2skh6h6s",
> 6=>"jhkdjd7d5s4h", 7=>"ac4htdth3sqc"); #25160
stack, too.
my @cabr = 0..9, qw(t j q k);
my (%sabr, %cardsuit, %cardval); @sabr{0, 14, 28, 42} = qw(h d c s);
%cardsuit=reverse(%sabr);
@cardval{@cabr, "a"} = 0..13, 1;
#25160
our @stack = qw(
7c8hasqdqs6cah 2djctsjs9h8dqh tc3had7h5d2h8c ks6d9d3c3d2c5h
7s8s4ckc4d9c 5c9s2skh6h6s jhkdjd7d5s4h ac4htdth3sqc);
our (@cell, @build);
> workfrom($stack{0}, $stack{1}, $stack{2}, $stack{3}, $stack{4},
> $stack{5}, $stack{6}, $stack{7}, 0, 0, 0, 0, 0, 0, 0, 0, "");
Neither the stack, nor the cells, nor the build spaces are ever never
localized in any of the functions below, though I think they should be.
There's no reason to pass them in arguments... just use them as globals,
and local() them as necessary. The last argument, $moves, also should
be localized.
our $moves = "";
workfrom();
> print "No solution found!\n"; exit 1;
>
> sub workfrom { local $card;
> ( $stack{0}, $stack{1}, $stack{2}, $stack{3}, $stack{4},
> $stack{5},
> $stack{6}, $stack{7}, $cell{1}, $cell{2}, $cell{3},
> $cell{4},
> $build{0}, $build{14}, $build{28}, $build{42},
> $moves) = @_;
I would write this as:
local @stack = @stack;
local @cell = @cell;
local @build = @build;
local $moves = shift;
my $card;
> $p = $stack{0} .".". $stack{1} .".". $stack{2} .".". $stack{3}
> "."
> . $stack{4} .".". $stack{5} .".". $stack{6} .".". $stack{7}
> "."
> . $cell{1} .".". $cell{2} .".". $cell{3} .".". $cell{4};
my $p = join ".", @stack, @cell;
>
> if (winning()) { print $moves; exit 0; }
> elsif ($catalog{$p}) { return; } else { $catalog{$p} += 1;
> foreach $showing (0 .. 7) {
> $card=stackpop($showing);
> if (not ($card==$nothing)) {trytoplay($card, $showing);}}
> foreach $showing (1 .. 4) {
> $card=$cell{$showing};
> if ($card
> != $nothing)
> { trytoplay($card, 100); }}}}
I can really tell you're coming from lisp, the way you've cuddled up
those dangling parens :) It might be good style for that language, but
in idiomatic perl you generally don't do that.
print($moves,"\n") if winning();
return if $catalog{$p};
++$catalog{$p};
foreach (0..7) {
my $card = stackpop($_) or next;
trytoplay($card, $_);
}
foreach (0..3) {
next if !$cell[$_];
trytoplay($cell[$_], 100);
}
}
>
> sub canplay {
> (local $ctp, local $stp) = @_;
> local $stackcard = stacktop($stp);
> if ($stackcard==$nothing) { return 1; }
> if (($ctp % 14) + 1 == ($stackcard % 14)) {
> return ((($ctp - ($ctp % 14))>14) xor
> (($stackcard - ($stackcard % 14))>14));}}
None of the parens in your return are needed.
Unless you're using $ctp, $stp, and $stackcard outside of canplay, then
you want my, not local.
my ($ctp, $stp) = @_;
my $stc = stacktop($stp) or return 1;
# $ctp is one card up from $stc
return ($ctp % 14 + 1 == $stc % 14) &&
# and they are different colors
($ctp > 28) != ($stc > 28);
}
Yes, I realize that I've made a change to what's actually being
returned, but the original version checked "one is hearts and the other
is't hearts," when what you really want is "one is hearts or diamonds,
and the other is clubs or spades."
> sub trytoplay {
> (local $card, $origloc) = @_; local $sta; $avail=0;
local, without parens, will only bind to $card. Anyway, I think you
want my here.
my ($card, $origloc) = @_;
my $avail = 0;
> foreach $sta (0 .. 7) {
foreach my $sta (0 .. 7) {
> if (canplay($card, $sta)>0) {
next if !canplay($card, $sta);
This avoids having to add a deeper level of nesting.
In perl, entering and leaving scopes can cost.
> $other = stacktop($sta); stackpush($sta, $card);
my $other = stackpop($sta); stackpush($sta, $card);
> $moves .= "put " . $cabr{$card % 14} . $sabr{$card -
> ($card % 14)} . " on ";
> if ($other==$nothing) { $moves .= "an empty column\n"; }
> else { $moves .= $cabr{$other % 14} . $sabr{$other -
> ($other % 14)} . "\n"; }
This is one of the places which $moves needs to be localized, otherwise
it grows beyond what you want it to.
local $moves = $moves .
"put $cabr[ $card % 14 ]$sabr[$card/14] on " .
. $other ?
"$cabr[$other % 14]$sabr[$other / 14]\n" :
"an empty column\n";
There's alot of other things which should be changed, but I'm not going
to bother. Doing a brute-force search just doesn't seem like the right
way to do it, and even if it were, ... well, I would probably do it
differently.
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
Date: Sun, 09 Sep 2001 07:39:46 GMT
From: "Sean Hamilton" <sh@planetquake.com>
Subject: CR/LF
Message-Id: <61Fm7.13304$C57.2048679@news1.telusplanet.net>
Greetings,
I am assuming \r translates directly to CR, but does \n always translate to
LF? Or does it translate to LF on Unix, CR on Mac, CRLF on Windows? Is it
identical in behavior to C's \n escape?
sh
------------------------------
Date: Sun, 09 Sep 2001 09:25:54 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: CR/LF
Message-Id: <slrn9pme49.du7.tim@vegeta.ath.cx>
Me parece que Sean Hamilton <sh@planetquake.com> dijo:
> Greetings,
>
> I am assuming \r translates directly to CR, but does \n always translate to
> LF? Or does it translate to LF on Unix, CR on Mac, CRLF on Windows? Is it
> identical in behavior to C's \n escape?
The perlport manpage discusses '\n' as the "logical" newline, silently
converting to and from whatever it should be, usually intelligently
enough. OTOH, as perlport says, \n cannot always be trusted. If the
actual value of \n is important or even in question, it's possible you
should specify explicitly what you want. ("\012" for newline, "\015" for
carriage-return).
see `perldoc perlport` for more details, and some modules which provide
tools for making working with this concept easier (and more
maintainable). ;)
--
Watch my captor grow old and die.
No satisfaction. Still here.
-- Morpheus, The Sandman
------------------------------
Date: Sun, 09 Sep 2001 02:31:34 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: Extract the relative sorting of items from multiple lists
Message-Id: <slrn9pllre.dhp.tim@vegeta.ath.cx>
Me parece que Paul David Fardy <pdf@morgan.ucs.mun.ca> dijo:
> Me parece que Benjamin Goldberg <goldbb2@earthlink.net> dijo:
> >> I forget where I saw it, but this makes me think of a quote that was
> >> something like "Real Programmers edit using 'cat'" :)
>
> tim@vegeta.ath.cx (Tim Hammerquist) writes:
> >http://ars.userfriendly.org/cartoons/?id=19990508
>
> >It's actually DOS, but who couldn't have a similar argument about unix?
> >
> >s/edit/pico/g;
> >s/edlin/ex/g;
> >s/copy con/cat;
>
> DOS filesystems have inodes? Isn't she's talking about a UNIX filesystem?
She must have been. Unfortunately, however, I had no appropriate regex
to convert them. edlin is a poor substitute for ex, whether you're
familiar with line editors or not. ;)
[ snip ]
> Paul Fardy <pdf@mun.ca>
Tim
--
Anyway, comdemning her to an eternity in Hell, just because
she turned you down... That's a really shitty thing to do.
-- Death, The Sandman
------------------------------
Date: Sat, 08 Sep 2001 23:41:02 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Extract the relative sorting of items from multiple lists
Message-Id: <3B9AE4CE.3C85B4F4@earthlink.net>
Tim Hammerquist wrote:
>
> Me parece que Benjamin Goldberg <goldbb2@earthlink.net> dijo:
> > I forget where I saw it, but this makes me think of a quote that was
> > something like "Real Programmers edit using 'cat'" :)
>
> http://ars.userfriendly.org/cartoons/?id=19990508
>
> It's actually DOS, but who couldn't have a similar argument about
> unix?
>
> s/edit/pico/g;
> s/edlin/ex/g;
> s/copy con/cat/g;
Hmm, now that I think about it, I think the quote had been more like,
Real Programers program using DEBUG. [was it DEBUG.EXE or DEBUG.COM ?]
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
Date: Sun, 09 Sep 2001 07:07:08 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: Extract the relative sorting of items from multiple lists
Message-Id: <slrn9pm604.dnm.tim@vegeta.ath.cx>
Me parece que Benjamin Goldberg <goldbb2@earthlink.net> dijo:
> Tim Hammerquist wrote:
> >
> > Me parece que Benjamin Goldberg <goldbb2@earthlink.net> dijo:
> > > I forget where I saw it, but this makes me think of a quote that was
> > > something like "Real Programmers edit using 'cat'" :)
> >
> > http://ars.userfriendly.org/cartoons/?id=19990508
> >
> > It's actually DOS, but who couldn't have a similar argument about
> > unix?
> >
> > s/edit/pico/g;
> > s/edlin/ex/g;
> > s/copy con/cat/g;
>
> Hmm, now that I think about it, I think the quote had been more like,
> Real Programers program using DEBUG. [was it DEBUG.EXE or DEBUG.COM ?]
On my Win98 partition, it's an exe. I could check on earlier versions
of DOS, but my box doesn't have the 5 1/4" floppy drives for me to
browse the MS-DOS 5.0 diskettes. =)
--
Destinations are often a surprise to the destined.
-- Thessaly, The Sandman
------------------------------
Date: Sat, 08 Sep 2001 23:58:00 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How can I find the PID's of my children?
Message-Id: <3B9AE8C8.9E84FE9F@earthlink.net>
Stan Brown wrote:
>
> I'm writing a perlTK script, which will spawn at least one child task
> to do some long runing processing.
>
> However, I'm going to leave the user the option of canceling from an
> "exit" button on the main window. So I need to be able to send a
> kill() signal to my children.
>
> Short of making these PID's global variables, when they are spwned,
> how can I detrmine what children, my runing perl process is the parent
> of?
If I had that problem, I would cheat and do:
sub END {
kill "EXIT" => -$$;
}
killing the negation of a pid, will, on some systems, sends the kill
signal to that process and all it's descendants. Neat huh?
If I wanted to do solve the problem for real...
A few solutions:
1) assuming you've got pipes connecting the children to the parent,
then when the parent exits, the pipes get closed at the parent's end.
When the child detects this, it knows it's parent has died, and should
clean up and die itself.
2) every so often, each child should call kill(0, getppid()), and see
if it succeeds. If not, then the parent has died.
3) create a package named PID. bless a reference to each forked pid
into class "PID", and define sub PID::DESTROY to kill "EXIT", $$self.
Stuff the object into one of Tk's data structures [somewhere that you're
allowed to hang user-data]. When the program exits, the object will get
cleaned up, calling it's DESTROY method.
A combination of 1, 2, and 3 might be best.
Also, if you use packages and namespaces and encapsulation, it's easy to
add globals without cluttering up package "main"'s namespace. After
all, this isn't C, where there's essentially only one namespace.
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
Date: Sun, 09 Sep 2001 05:55:50 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How can I find the PID's of my children?
Message-Id: <3B9B3CA6.B08CBA5@earthlink.net>
Stan Brown wrote:
>
> I'm writing a perlTK script, which will spawn at least one child task
> to do some long runing processing.
>
> However, I'm going to leave the user the option of canceling from an
> "exit" button on the main window. So I need to be able to send a
> kill() signal to my children.
Here's another solution, which I should have thought of before.
When you create the child put something like this on the following line:
eval qq[END: { kill "EXIT", $pid }];
Or whatever cleanup code you want to do.
> Short of making these PID's global variables, when they are spwned,
> how can I detrmine what children, my runing perl process is the parent
> of?
To reiterate the various methods of learning your process's children:
1) store them in a global variable.
2) use your system's "ps" program
3) attach them to a piece of data which is global
4) Don't store them, just kill( EXIT => -$$ ) as cleanup.
5) Don't store them, let them clean up after themselves.
6) Don't store them, eval an END block when the proc is created, which
will do whatever cleanup is necessary.
7) [which I just thought of], write an XS function which mimics "ps".
--
"I think not," said Descartes, and promptly disappeared.
------------------------------
Date: Sun, 9 Sep 2001 19:09:16 +1000
From: "nathan" <michealo@ozemail.com.au>
Subject: Re: newbe problem with Perl
Message-Id: <PjGm7.2205$iH4.162217@ozemail.com.au>
are you moving this script from a win32 system to a linux system ?
you may have forgot to include.
print "content-type:text/html\n\n";
with in your scirpt
Tom Folkes <tomfolkes@hotmail.com> wrote in message
news:7ee7b25f.0108300849.7d74878f@posting.google.com...
> I am moving a working Perl code from one machine to another. In
> theory they are the same.
>
> I get the following error message.
>
> (program name) did not produce a valid header (program terminated
> without a valid CGI header. Check for core dump or other abnormal
> termination)
>
> Any help would be appreciated. -Tom
------------------------------
Date: 8 Sep 2001 19:39:23 -0700
From: genericax@hotmail.com (Sara)
Subject: Perl is TOO much fun
Message-Id: <776e0325.0109081839.55041721@posting.google.com>
I dunno why - coding this just makes me giggle! Ya gotta love this language..
-WQ
my @p=<*.jpg>;
my %p;
@p{@p}=@p;
------------------------------
Date: Sun, 09 Sep 2001 03:41:36 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl is TOO much fun
Message-Id: <x766atf2ta.fsf@home.sysarch.com>
>>>>> "S" == Sara <genericax@hotmail.com> writes:
S> I dunno why - coding this just makes me giggle! Ya gotta love this
S> language.. -WQ
then join the fun with perl list (see lists.perl.org).
S> my @p=<*.jpg>;
S> my %p;
S> @p{@p}=@p;
you shouldn't be using single letter var names and having a hash and an
array with the same name is fun but not good solid coding.
and if you like hash slices, see my tutorial at:
http://tlc.perlarchive.com/articles/perl/ug0001.shtml
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs -------------------------- http://jobs.perl.org
------------------------------
Date: 9 Sep 2001 00:44:30 -0700
From: mirvine@compsoc.com (mirvine555)
Subject: Re: Perl objects problems
Message-Id: <9ef8bd6b.0109082344.6d6158eb@posting.google.com>
Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> wrote in message news:<3B9AB3DD.8020807@post.rwth-aachen.de>...
> > sub new {
> > my $classname = shift; # What class are we constructing?
> > my $self = $classname->SUPER::new(@_);
> ^^^^^
> Why SUPER here? I don't see any base-classes.
>
> More to that, you do not bless anything:
> my $self = bless {}, $classname;
>
> Tassilo
The base Class is Critter. So SUPER refers to Critter::new. I bless in
Critter::new, I don't need to bless twice, do I?!
package Critter;
use strict;
sub new {
my $classname = shift; # What class are we constructing?
my $self = {}; # Allocate new memory
bless($self, $classname); # Mark it of the right type
$self->_init(@_); # Call _init with remaining args
return $self;
}
...etc.
package Insect;
use strict;
use vars qw(@ISA);
use lib qw(./);
use Critter;
@ISA=('Critter');
sub new {
my $classname = shift; # What class are we constructing?
my $self = $classname->SUPER::new(@_);
$self->_initialize(@_);
return $self; # And give it back
}
...etc.
Thanks,
Mark Irvine
------------------------------
Date: Sun, 09 Sep 2001 10:02:30 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Perl objects problems
Message-Id: <3B9B2216.8080505@post.rwth-aachen.de>
mirvine555 wrote:
>>Why SUPER here? I don't see any base-classes.
>>
>>More to that, you do not bless anything:
>> my $self = bless {}, $classname;
>>
>>
>
>>Tassilo
>>
>
> The base Class is Critter. So SUPER refers to Critter::new. I bless in
> Critter::new, I don't need to bless twice, do I?!
Ah, sorry, I overread this @ISA('Critter') bit. You indeed only bless
once, that's ok.
But the rest of what I said still stands: You have to add this one line
to Insect->_initialize as I pointed out in the previous post. You had
been assigning the wrong argument to $self->{NAME}.
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: 9 Sep 2001 09:25:23 GMT
From: mirvine@compsoc.com
Subject: Re: Perl objects problems
Message-Id: <9nfci3$2jd$1@news.netmar.com>
In article <3B9B2216.8080505@post.rwth-aachen.de>, Tassilo von Parseval
<Tassilo.Parseval@post.rwth-aachen.de> writes:
>But the rest of what I said still stands: You have to add this one line
>to Insect->_initialize as I pointed out in the previous post. You had
>been assigning the wrong argument to $self->{NAME}.
Ok, I think i get it now, but from the point of view of building a properly
inherited/inheritable class, should I just completely over-ride
Critter->_init method with Insect->_init, as below. It works this way, is
there any thing wrong with this?
package Insect;
use strict;
use vars qw(@ISA);
use lib qw(./);
use Critter;
@ISA=('Critter');
sub new {
my $classname = shift; # What class are we constructing?
my $self = $classname->SUPER::new(@_);
$self->_init(@_);
return $self; # And give it back
}
#!!!-->changed name from _initialize to _init, over-rides Critter->_init
sub _init {
# print "insect init, @_\n";
my $self = shift;
$self->{START} = time();
$self->{AGE} = shift;
$self->{NAME} = shift;
}
Thanks,
Mark
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: Sun, 09 Sep 2001 07:13:41 GMT
From: Alex Hart <news@althepal#nospam#.com>
Subject: recognize MS Windows with perl
Message-Id: <FEEm7.3542$uf3.910506@typhoon1.gnilink.net>
What is the best way to determine whether my program is being run on a
MS Windows box? Is there a sure fire way?
- Alex
------------------------------
Date: Sun, 09 Sep 2001 07:46:54 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: recognize MS Windows with perl
Message-Id: <O7Fm7.82748$hT4.21388324@news1.rdc1.md.home.com>
"Alex Hart" <news@althepal#nospam#.com> wrote in message
news:FEEm7.3542$uf3.910506@typhoon1.gnilink.net...
> What is the best way to determine whether my program is being run on a
> MS Windows box? Is there a sure fire way?
>
> - Alex
perldoc perlvar, and look for $^O. This should point you in the right
direction.
perldoc -q operating
"How do I find out which operating system I'm running under?"
David Hilsee
------------------------------
Date: Sun, 09 Sep 2001 07:48:02 GMT
From: "Martin" <kyros.ironforge@yahoo.com>
Subject: Re: recognize MS Windows with perl
Message-Id: <S8Fm7.144017$7h.26868052@news2.rdc1.bc.home.com>
The system variable $^O is what you are looking for.
Martin
"Alex Hart" <news@althepal#nospam#.com> wrote in message
news:FEEm7.3542$uf3.910506@typhoon1.gnilink.net...
> What is the best way to determine whether my program is being run on a
> MS Windows box? Is there a sure fire way?
>
> - Alex
------------------------------
Date: Sun, 9 Sep 2001 19:48:15 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: recognize MS Windows with perl
Message-Id: <1000065121.971094@clover.origin.net.au>
"Alex Hart" <news@althepal#nospam#.com> wrote in message
news:FEEm7.3542$uf3.910506@typhoon1.gnilink.net...
> What is the best way to determine whether my program is being run on a
> MS Windows box? Is there a sure fire way?
>
> - Alex
print $^O, "\n";
See perldoc perlvar.
Cheers,
Rob
------------------------------
Date: Sun, 09 Sep 2001 02:35:08 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: Recommendations for a PERL editor
Message-Id: <slrn9plm24.dhp.tim@vegeta.ath.cx>
Me parece que Jonadab the Unsightly One <jonadab@bright.net> dijo:
> helgi@NOSPAMdecode.is (Helgi Briem) wrote:
>
> > UltraEdit is very good and I heartily recommend it.
> > Believe it or not, I also recommend MS Word.
>
> The college I went to had Word, and I used it there and
> liked it, for producing paper copies, like things to hand
> in to profs. It's good, excellent, even, if your goal is
> to produce paper copies. Handles that nicely.
So far I've found LaTeX to be a quite acceptable substitute/replacement
for word. You have the benefit of finer granular control of appearance,
greater customization of elements, beautiful dvi/ps output, and (this is
the kicker) I can use whatever editor I choose.
(Ok, so the fact that there was no paper clip with eyes was a depressing
shortcoming and I'm still mourning the loss.... Ok, done mourning.)
Tim
--
But the price of getting what you want
is getting what you once wanted.
-- Morpheus, The Sandman
------------------------------
Date: Sun, 9 Sep 2001 19:34:14 +1000
From: "nathan" <michealo@ozemail.com.au>
Subject: Re: Recommendations for a PERL editor
Message-Id: <fHGm7.2212$iH4.160450@ozemail.com.au>
i use editpad, it's very good. you can find it at download.com
Jonadab the Unsightly One <jonadab@bright.net> wrote in message
news:3b9a8abe.24458797@news.bright.net...
> helgi@NOSPAMdecode.is (Helgi Briem) wrote:
>
> > W9x crashes frequently, but it does not BSOD.
>
> Oh, yes, it most certainly does.
>
> Not, however, as frequently as it crashes in other ways.
> When NT crashes, it's usually a BSOD that you get (or so
> I am told, not that I would know from personal experience;
> I don't have any NT here). With 9x, it's usually either
> something less elegant (like a bizarre clicking sound any
> time you move the mouse, and no response at all to the
> keyboard) or something a little less thoroughgoing (like
> Explorer suddenly just stops responding, which is fairly
> recoverable if you happen to have a command prompt up
> (MCL is handy for that), although it is highly advisable
> to reboot shortly). But you do get a BSOD on occasion,
> complete with meaningless white hex numbers. If you've
> never seen a BSOD, you haven't pushed Windows very hard.
>
> The feature is certainly not unique to NT; Win3 used to
> BSOD quite often, as I recall.
>
> - jonadab
------------------------------
Date: Sun, 09 Sep 2001 01:57:23 GMT
From: "chengkai liang" <chengkail@home.com>
Subject: Re: Simple regexp
Message-Id: <70Am7.54310$MK5.30516301@news1.sttln1.wa.home.com>
If you know awk, then Perl actually can do what awk does it for you. Suppose
the records you list is in a file called data.dat, then this will give you
the first column data,
perl -F -anle 'print $F[0]' data.dat
-F is used to provide a column seperate as what awk with -F do. -a will use
the column seperate provided by -F and generated an array @F, -l is used to
chomp off the newline and finally -e will execute the command quoted in a
pair of single quote.
Note -e must be the last option in the command line; if you put it in
different position then no output will be generated.
"Scott" <scotty99@earthlink.net> wrote in message
news:3B9A1E74.140509FC@earthlink.net...
> Hi,
>
> Being a newbie to regexps, I find even the simplest of tasks extremely
> daunting. Anyways imagine if you will the following code snippet:
>
> we have the following output piped in from a unix program:
> 12312 /home/this
> 3234 /home/that
> 12213 /var/horses
>
> while(FD){
> #I need an expression here that will make $_ just the first number
> field
> #ie the first time around in this case would be 12312
> }
>
> I know this is probably simple. In awk I'd just do {print $1}
> In perl I'm sure I can use a substitution pattern like s /something
> here/ /
> but I don't know what.
>
> Thanks,
> Scott
>
>
>
------------------------------
Date: 8 Sep 2001 21:28:14 -0700
From: youradmirer@onebox.com (Newbie)
Subject: strange Win32 IO behavior!
Message-Id: <582bc82b.0109082028.6dbf079e@posting.google.com>
Hi,
While playing with dupping filehandles, I was puzzled by strange win32
io behavior. The following few lines work fine on Linux as intended
(captured STDOUT & STDERR and send the output to a file), but not on
Win32. The output of a "dir" command was sent directly the screen
which shouldn't be expected. Could anyone with Win32 experience
explain? Thanks.
#!/usr/bin/perl -w
use strict;
open(FH, ">foo.txt") || die "trouble: $!\n";
my $oldfh = select(STDOUT); $| = 1;
select(STDERR); $| = 1;
select($oldfh);
defined(my $pid = fork()) || die "fork: $!\n";
if ($pid == 0) {
close STDOUT;
close STDERR;
open(STDOUT, ">&FH") || die "stdout dup: $!\n";
open(STDERR, ">&FH") || die "stderr dup: $!\n";
close FH;
my @args = ('dir', '\w');
exec(@args) || exit 1;
close STDOUT;
close STDERR;
exit 0;
}
waitpid($pid, 0);
print ($? >> 8), "\n";
close FH;
------------------------------
Date: Sun, 9 Sep 2001 16:31:04 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Why doesn't this regex work?
Message-Id: <slrn9pm358.b0q.mgjv@martien.heliotrope.home>
On Wed, 05 Sep 2001 08:06:34 GMT,
Bart Lateur <bart.lateur@skynet.be> wrote:
> Martien Verbruggen wrote:
>
>>And this:
>>
>>$data = sprintf "%.20", $data;
This should be "%.20s", as someone else pointed out as well :)
>>or
>>
>>$data = pack "a20", $data;
>
> What, no substr()?
Too obvious.
$data = join '', (split //, $data1)[0..19];
Martien
--
Martien Verbruggen |
Interactive Media Division | We are born naked, wet and hungry.
Commercial Dynamics Pty. Ltd. | Then things get worse.
NSW, Australia |
------------------------------
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 1717
***************************************