[16547] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3959 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 9 03:10:23 2000

Date: Wed, 9 Aug 2000 00:10:14 -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: <965805014-v9-i3959@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 9 Aug 2000     Volume: 9 Number: 3959

Today's topics:
    Re: Programming Ethics (Soren Andersen)
    Re: Programming Ethics (Tim Hammerquist)
    Re: reg expressions - protect html <stephenk@cc.gatech.edu>
    Re: Running other programs in background <bart.lateur@skynet.be>
    Re: Searching for errant modules (Soren Andersen)
        sh: lst2: Generated or received a file descriptor numbe <mahesha@nital.stpp.soft.net>
    Re: Simple reg expression question <kennylim@techie.net>
    Re: Simple regular Expression Question <kennylim@techie.com>
    Re: What to do with 1A(hex) in a file? <UlleAckermann@t-online.de>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 9 Aug 2000 04:35:14 GMT
From: soren@spmfoiler.removethat.wonderstorm.com (Soren Andersen)
Subject: Re: Programming Ethics
Message-Id: <8mqn22$ttf$1@slb0.atl.mindspring.net>

jmaggard@va.mediaone.net (Jason Maggard) wrote in 
<398D1351.D8A14436@va.mediaone.net>:

>If you hadn't programmed this someone else would have.
>If someone else wouldn't have they could buy one.

This is the utterly amoral argument. It is a worthless argument, it is the 
argument of those who have no ultimate values at all, nor much imagination.

Philosophy is not the strong point of many individuals in modern society. It is 
a very good thing that this thread is taking place here. Ordinary people, "even 
programmers," need to *not* leave this sort of question up to the "experts." It 
is too important to leave up egomaniac talking heads and pundits.

There is such a thing as being asleep as one moves through life. When one is 
awake, one realizes, senses, sees that every single day brings ethical, 
spiritual challenges.

"Ethics" is not an "inferior" area to "programming." Just far less comfortable. 
Comfort != rightness | logic | clear thinking. Comfort is just that: 
stagnation, stasis, dullness, decay. Hostility and cynicism when ethical 
questions are raised or replied to in public discussions is a self-defense 
mechanism engaged in by those who have the inner maturity and self-confidence 
of young children and furthermore doubt their own capacity or potential for 
growth in that area.

Life is change. Growth comes whether we want it or not. Sooner or later. 
Embracing it as much as we can and choosing (at least sometimes) a harder road 
over the easiest road is a sign of imagination, courage and true intellect, and 
is a more graceful or 'cool' way of living -- because that way, one gets to be 
the protagonist rather than merely the eventual 'victim.' It's not "stupidity" 
to be concerned about ethical issues.

Too many "clever" programmers apparently have an extremely narrow and distorted 
understanding of the overall model of how life works -- the Big Picture. It 
works based on profound cause-and-effect (not simple-minded childish naive 
notions of same) and it shows at times fearsome stringency, strictness. The 
minds of human beings today seem like leaky sieves -- we forget memorable 
instances of life's strictness 5 minutes after we perceive them -- we go 'back 
to sleep' -- and in that condition even deny that cause-and-effect is the 
principle that life operates on when another (with compassionate intention) 
points it out.


   soren andersen

-- 
Using PNG-format images as Web BACKGROUNDs without
"breaking your Site" for silly older browsers:
http://www.wonderstorm.com/techstuff/
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Wed, 09 Aug 2000 04:41:03 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: Programming Ethics
Message-Id: <slrn8p1oq3.2sq.tim@degree.ath.cx>

Soren Andersen wrote:
> Ordinary people, "even
> programmers," need to *not* leave this sort of question up to the
> "experts." It is too important to leave up egomaniac talking heads
> and pundits.

Doesn't that disqualify us en masse?

-- 
-Tim Hammerquist <timmy@cpan.org>
For every problem, there is one solution
which is simple, neat and wrong.
	-- H. L. Mencken


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

Date: Wed, 09 Aug 2000 00:55:55 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: reg expressions - protect html
Message-Id: <3990E45B.F4ED6A3E@cc.gatech.edu>

indiziert wrote:

> hi
>
> hm well
>
> i wrote a script that replaces certain characters by numbers e.g Hello -
> H3ll0
>
> i was figuring out how to translate html pages with it. but the script
> translated even the html tags, so that there were no html code.
> if i translate a html page you can see:
> <H7M1> instead of <HTML> because a T is translated to 7 and an L to 1.
> so how can i protect html tags from being translated ?
>
> i need someting that keeps html tags but still changes characters
>

I've noticed that many here advocate using a(n?) HTML moule to parse this.
But it can be done without one, without getting too ugly:

open IN, $infname or die "can't open input file: $!";
open OUT, ">$outfname" or die "can't open input file: $!";
local $/ = undef;    #slurp mode (or just 'undef $/' if you're in the main
procedure)
my @lines = split /(<.*?>)/,<IN>; #split on tag, but include
foreach(@lines) {
  unless (/^</) {    #skip tag contents
  #do transformations here
  }
  print OUT;
}
close IN or die "can't close input file: $!";
close OUT or die "can't close output file: $!";

If file size is a problem wrt memory, there is also this way (a little
odder, but not too big):
open IN, $infname or die "can't open input file: $!";
open OUT, ">$outfname" or die "can't open input file: $!";
local $/='>';  #read until end of tag
while(<IN>) {
  ($text,$tag)=split '<'; #line is "text <tag>"
  # do transformation to $text here
  print OUT $text,'<',$tag; #reconstruct line
}
close IN or die "can't close input file: $!";
close OUT or die "can't close output file: $!";

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Wed, 09 Aug 2000 06:57:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Running other programs in background
Message-Id: <bsv1ps4jpq8utebl5868bnl6s4flstggk6@4ax.com>

wutang_warrior@my-deja.com wrote:

>How do I capture the output of the program (cmdline utility) to a $var
>or do it like above?

Well, the usual trick is to shell a command line, by launching your
shell with a special option indication "just this line", and the command
following it.

On WIN95/98, that command line shell is still command.exe, a legacy from
DOS (yes, it's the DOS prompt). Using the "/c" option, plus your actual
command line, you can run just one command line. (n.b. "/k" does the
same without closing the shell afterwards.)

Example: click on "Run" in the Start menu, and type:

	command /c perl -v >c:\perlversion.txt


Too bad that the shell's name is different on NT. ("cmd.exe", IIRC)

-- 
	Bart.


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

Date: 9 Aug 2000 04:45:38 GMT
From: soren@spmfoiler.removethat.wonderstorm.com (Soren Andersen)
Subject: Re: Searching for errant modules
Message-Id: <8mqnli$ttf$2@slb0.atl.mindspring.net>

flavell@mail.cern.ch (Alan J. Flavell) wrote in 
<Pine.GHP.4.21.0007251348570.19901-100000@hpplus03.cern.ch>:

>Nothing personal, but this kind of posting is completely infuriating.
>
>AFAICS, the worldwide perl community isn't in the least interested in
>whether you appreciated the help.  If you want to do nothing more than
>to personally thank the poster, then send them a mail, ferchrissake.

Flavell, you are such a complete idiot (nothing "personal" though). I have 
seen you flaming people in these groups for years. You don't speak for ME. 
I *liked it* that I got to see that the poster got an answer and 
appreciated it. That's closure.

You need to pull the plug on your box (I know the very idea shakes you to 
the core of your being) and get out and take a look at how human beings 
actually live. You have forgotten.

Welcome to my killfile, I have no idea why it took me so long to add you.

   soren andersen


-- 
Using PNG-format images as Web BACKGROUNDs without
"breaking your Site" for silly older browsers:
http://www.wonderstorm.com/techstuff/
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Wed, 09 Aug 2000 06:26:25 GMT
From: Mahesh Asolkar <mahesha@nital.stpp.soft.net>
Subject: sh: lst2: Generated or received a file descriptor number that is not valid
Message-Id: <8mqtig$4sj$1@nnrp1.deja.com>

Hi,

I have a couple of small perl scripts...

One is exec.pl ...

#!/usr/local/bin/perl -w

my $CmdStr1 = "my.pl > lst1";
my $CmdStr2 = "my.pl >& lst2";

system ("$CmdStr1");
system ("$CmdStr2");

 ... and other my.pl ...

#!/usr/local/bin/perl -w

print "An STDOUT String1\n";
print STDERR "An STDERR String2\n";
print "An STDOUT String3\n";
print STDERR "An STDERR String4\n";

Upon executing exec.pl, these are the responses that I get on two
versions of perl (on two different OSs).

On perl version 5.005_03 built for i386-linux, (Exactly the way I want)

An STDERR String2
An STDERR String4

(Lst1 has only the STDOUT messages & Lst2 has both STDERR & STDOUT
messages)

And on perl v5.6.0 built for 9000/777-hpux, (Error. Functionality, not
as desired)

An STDERR String2
An STDERR String4
sh: lst2: Generated or received a file descriptor number that is not
valid.

(Lst1 has only the STDOUT messages. Script exits before generating Lst2
due to an error)
------------------------------------------------------------------------

I think the problem lies in the '&' in $CmdStr2. If that is removed,
all's well - except the functionality - because I want all the STDERR
& STDOUT messages to go into the lst files. Is there any way I can get
response on v5.6.0 similar to the 5.005_03?

I have an idea that perl 5.6.0 treats file descriptors differently as
compared to its predecessors - as real variables. But I am not sure if
this problem is related to that fact.

- Mahesh


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 09 Aug 2000 06:53:56 GMT
From: "Kenny Lim" <kennylim@techie.net>
Subject: Re: Simple reg expression question
Message-Id: <8e7k5.30649$0W4.791143@newsread2.prod.itd.earthlink.net>


Hi Guys,

Thanks for the advice ! Most of the sample works perfectly fine
with exception to one particular problem which I failed to mention before
hand.

Since we are separating the major and minor version and increment the value
with a given value based on $1 as major version, $2 as minor version.

There will be a problem when we :

(a) Increment a value that is greater than 9 (ie. ETProj99)
(b) The total given value to be incremented exceeded 9.
(ie. $2 = 9, current value is ETProj99, the outcome result would be 918
where it should be 108)

#Addition should to be based on a 3 digit value.

More examples :

Increment by +1 on both major and minor version. (+1 major, +1 minor)

(a) ETProj99 will be ETProj1010 where it should be 200
(b) ETProj299 will be ETProj3100 where it should be 400
(b) ETProj999 will be ETProj10100 where it should be 2000

(See log below..)

Ultimately, we would like to maintain 3 digits as the project version
and leave the rest of the 5 for the project name. ie. ETProj29 or ETProj299

The problem is, both number being incremented are not coordinating
as the actual value. Is there a way to increment the value
at the sametime maintaining the actual value ?

Thanks All in advance and you have a pleasant evening.

Kenny-


Output :

Progid = ETProj99
12 pattern = <99>
New_Version = <1010>
Array value = <>
defined = 0
adding: ETProj99

12 pattern = <299>
New_Version = <3100>
Progid = ETProj299
Array value = <>
defined = 0
adding: ETProj299

12 pattern = <999>
New_Version = <10100>
Progid = ETProj999
Array value = <>
defined = 0
adding: ETProj999


"Kenny Lim" <kennylim@techie.net> wrote in message
news:_Lrj5.23818$0W4.563037@newsread2.prod.itd.earthlink.net...
>
> Hi Rafael,
>
> Thanks for the great pointers ! Your solution works just fine.
>
> I am just wondering if it's possible that we choose to "either"
> increment only the major or the minor point version.
>
> ie.
>
> ETThread226
>
> Major = 2 (ie. increment to 3)
>
> or
>
> Minor = 26 (ie. increment to 27)
>
>
> What I am trying to achieve is to provide the flexibily to upgrade the
> version based
> on the release type. (major or minor release)
>
> You have a pleasant evening Rafael.
>
> Kenny-
>
>
>
> "Rafael Garcia-Suarez" <rgarciasuarez@free.fr> wrote in message
> news:slrn8oiadh.3oh.rgarciasuarez@rafael.kazibao.net...
> > Kenny Lim wrote in comp.lang.perl.misc:
> > >
> > >Hi All,
> > >
> > >Given the followng project name and version, how do I get the current
> > >version and increment by one ? It would be nice to also keep track
> > >of the number increment, ie. from 99 to 100 instead of going back to 0.
> ie.
> > >90.
> > >
> > >ETThread226
> > >ETDB2UI52
> >
> > If I correcly understood your question:
> >
> > $project_name =~ s/(\d+)$/1+$1/e;
> >
> > See perlop, perlre.
> >
> > --
> > Rafael Garcia-Suarez
>
>
>




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

Date: Wed, 09 Aug 2000 04:56:43 GMT
From: "Kenny Lim" <kennylim@techie.com>
Subject: Re: Simple regular Expression Question
Message-Id: <fw5k5.30332$0W4.776859@newsread2.prod.itd.earthlink.net>


Hi Guys,

Thanks for the advice ! Most of the sample works perfectly fine
with exception to one particular problem which I failed to mention before
hand.

Since we are separating the major and minor version and increment the value
with a given value based on $1 as major version, $2 as minor version.

There will be a problem when we :

(a) Increment a value that is greater than 9 (ie. ETProj99)
(b) The total given value to be incremented exceeded 9.
(ie. $2 = 9, current value is ETProj99, the outcome result would be 918
where it should be 108)

#Addition should to be based on a 3 digit value.

More examples :

Increment by +1 on both major and minor version. (+1 major, +1 minor)

(a) ETProj99 will be ETProj1010 where it should be 200
(b) ETProj299 will be ETProj3100 where it should be 400
(b) ETProj999 will be ETProj10100 where it should be 2000

(See log below..)

Ultimately, we would like to maintain 3 digits as the project version
and leave the rest of the 5 for the project name. ie. ETProj299

The problem is, both number being incremented are not coordinating
as the actual value. Is there a way to increment the value
at the sametime maintaining the actual value ?

Thanks All in advance and you have a pleasant evening.

Kenny-


Output :

Progid = ETProj99
12 pattern = <99>
New_Version = <1010>
Array value = <>
defined = 0
adding: ETProj99

12 pattern = <299>
New_Version = <3100>
Progid = ETProj299
Array value = <>
defined = 0
adding: ETProj299

12 pattern = <999>
New_Version = <10100>
Progid = ETProj999
Array value = <>
defined = 0
adding: ETProj999

"Kenny Lim" <kennylim@techie.com> wrote in message
news:YpHj5.26736$0W4.628139@newsread2.prod.itd.earthlink.net...
> Hi All,
>
> I would like to know if it's possible that to increment
> on a "specific number" on a given project name.
>
> Example.
>
> ETThread226
>
> Major Version = 2 (ie. increment to 3)
>
> or
>
> Minor Version = 26 (ie. increment to 27)
>
>
> Results :
>
> To have either
>
> ETThread326
>
> or
>
> ETThread 227
>
> What I am trying to achieve is to provide the flexibily to upgrade the
> version based on the release type. (major or minor release)
>
> Any advise would be great. Thanks in advance.
>
> Kenny-
>
>
>
>
>
>










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

Date: Wed, 09 Aug 2000 07:30:53 +0200
From: Ulrich Ackermann <UlleAckermann@t-online.de>
Subject: Re: What to do with 1A(hex) in a file?
Message-Id: <3990EC8D.25D56D4A@t-online.de>

Hartmut Wind wrote:
> 
> I get a file from another computer (via ftp in ASCII mode). A perl
> script running through all of the
> 43200 lines to pick up some parts. Sometimes,  it happens that only the
> first part is processed,
> caused by an character, which is 1A(hex). perl assumes that the file is
> at the end (remaining
> appr. 8000 lines got ignored).
> Note: I use 'binmode(IN)' for the input stream, so that 0A(hex), 0D(hex)
> is not modified
> (Windows Environment)
> 
> I'd like to adapt the script to replace 1A by e.g. a space (20(hex)),
> but..
> how could I read the bytes after the 'last line', which contains the
> "abort character" 1A(hex)?
> 
> Regards
> Hartmut


Maybe 

undef $/; 

before reading the file might help. Just a thought, I
have not tested it.

Ulrich


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

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


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