[8652] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2269 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 7 17:07:36 1998

Date: Tue, 7 Apr 98 14:01:39 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 7 Apr 1998     Volume: 8 Number: 2269

Today's topics:
    Re: perl linux database program? (Maurice Aubrey)
        please help with script (John Q. Public)
    Re: please help with script (Greg Bacon)
    Re: Porting HTML into CGI Perl routine with variables. (Maurice Aubrey)
        Quickly deciding which netblock an IP belongs too? (Lars Marowsky-Bree)
    Re: Trimming blank lines from end of file? (David Oswald)
    Re: Trimming blank lines from end of file? <ludlow@us.ibm.com>
    Re: Variable interpolation problems <cmargoli@world.northgrum.com>
    Re: Variable interpolation problems (RonaldWS)
    Re: Wanted: Amoo to stop my sysadmin from whining (brian moore)
    Re: Wanted: Amoo to stop my sysadmin from whining <cmargoli@world.northgrum.com>
    Re: Web spider/crawler script (Kevin B Cohen)
        Why doesn't this work right? <poohba@io.com>
    Re: Why doesn't this work right? <lr@hpl.hp.com>
    Re: Why doesn't this work right? (Greg Bacon)
    Re: Why doesn't this work right? (Matthew Cravit)
        WWW gamma dilemmas (Neil Kandalgaonkar)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 7 Apr 1998 18:40:46 GMT
From: maurice@localhost.localdomain (Maurice Aubrey)
Subject: Re: perl linux database program?
Message-Id: <slrn6iksqc.g0o.maurice@localhost.localdomain>

On Tue, 07 Apr 1998 05:09:40 GMT, Paul Wilson <prw@vanitydomain.net> wrote:
>On Sat, 4 Apr 1998 07:34:47 -0500, "Greg Waters" <gwaters@dorsai.org>
>wrote:
>
>>Does anybody know resource information and help files on how to create perl
>>databases for linux? Did someone write a program?
>>
>
>Creating a perl database would be a pain. Why not just use mSQL
>(http://www.hughes.com.au) , get a copy of MSQL.pm, and you're all

Or MySQL (http://www.tcx.se/) which, in my opinion, is much better.

-- 
Maurice Aubrey <maurice@hevanet.com>

Beware of bugs in the above code; I have only proved it correct, 
not tried it. 

- Donald Knuth


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

Date: Tue, 07 Apr 1998 18:59:00 GMT
From: no@spam.ok (John Q. Public)
Subject: please help with script
Message-Id: <MPG.f9441285a5d4ff8989681@news.lightstream.net>

I am new to perl.  I could not perform a task using sed & awk so I read 
some perl books over the weekend...

The task is this: I downloaded a large (1.4M) text file that has 209 
Grimm's Fairy Tales (for history class) identified only by:

   Story 1

   Fairy Tale text
   blah blah blah...

   Story 209

   blah blah blah...

The titles to the stories are indexed on a web page like this:

<LI> <A HREF="001.txt">The Frog King, or Iron Henry</A>
<LI> <A HREF="002.txt">Our Lady's Child</A>
<LI> <A HREF="209.txt">The Golden Key</A>

(In case you are interested) http://www.ul.cs.cmu.edu/books/GrimmFairy/

sed stripped off all html tags and I have a text file with 209 titles.

I think what I need to do is figure out how to stuff each line from 
titles file into an array and do a (s/^Story \d/$_/g) for each element.

I'm sure it's a no-brainer but, I'm an EE student--not a programmer. So 
please don't flame me.

Thanks in advance,
{ew993#po,cwru,edu}


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

Date: 7 Apr 1998 20:13:21 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: please help with script
Message-Id: <6ge1d1$3qi$1@info.uah.edu>

In article <MPG.f9441285a5d4ff8989681@news.lightstream.net>,
	no@spam.ok (John Q. Public) writes:
: The task is this: I downloaded a large (1.4M) text file that has 209 
: Grimm's Fairy Tales (for history class) identified only by:
: 
:    Story 1
: 
:    Fairy Tale text
:    blah blah blah...
: 
:    Story 209
: 
:    blah blah blah...

    #! /usr/bin/perl -w

    use strict;

    $/ = "";  # we love paragraph mode

    while (<>) {
        next until /^Story\s+(\d+)$/m;

        my $file = sprintf "%03d.txt", $1;
        open STORY, ">$file" or die "$0: failed open >$file: $!";

        while (<>) {
            last if /^Story\s+(\d+)$/m;

            print STORY;
        }

        close STORY;

        last if eof();

        redo;
    }

Note that you're going to get blank lines at the ends of your stories,
but you can always cut out the blank lines before story titles before
you split the stories out.

: I'm sure it's a no-brainer but, I'm an EE student--not a programmer. So 
: please don't flame me.

:-)

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 7 Apr 1998 18:30:49 GMT
From: maurice@localhost.localdomain (Maurice Aubrey)
Subject: Re: Porting HTML into CGI Perl routine with variables.
Message-Id: <slrn6iks7m.g0o.maurice@localhost.localdomain>

>The principle is this: if you read from a text file that contains tokens
>like $this and $that, how can the Perl interpreter know that those are
>meant to be Perl variables rather than mere text? Of course it can't.
>
>But if you use this statement,
>s/\$this/$this/g;
>
>occurrences of $this will be replaced by the actual value of $this.
>
>Your job is now to come up with the proper regular expression that will
>catch things like "$form_data{'setup_file'}". Not easy, at first glance.

  Yes, not easy.  So check out YAWP at:

http://olympia2.adhost.com/~maurice/

  which will do this for you (without using weird variable delimiters).

-- 
Maurice Aubrey <maurice@hevanet.com>

I'm not good in groups. It's difficult to work in a group when 
you're omnipotent. 

- Q in ST:TNG


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

Date: 7 Apr 1998 19:35:10 GMT
From: lmb@pointer.teuto.de (Lars Marowsky-Bree)
Subject: Quickly deciding which netblock an IP belongs too?
Message-Id: <slrn6ikvvc.qkp.lmb@pointer.teuto.de>

Morning guys,

I am writing a network traffic accounting package. One of the tasks is to
quickly decide which netblock an IP belongs to.

ie: let A be an IP (like "127.0.0.1"). Now I have a set of netblocks Z_1 to
Z_n, with an associated name.

So, the task is:

Find out which Z_x includes A and get the associated name.

A hash mapping each netblock to the name and going through them via each is
the easiest, though pretty brute force approach. A single test is quite fast
with the binary IP representation ($IP & $netmask == $net), but how to
quickly find the right netblock to check?

How do I implement this most effectively in Perl? I have an idea how to do
it quite fast in C - sorting the netblocks and doing a binary search.

Is the same viable in Perl, should I try my hand at xs, or should I use an
entirely different approach?

Thanks in advance for all replies.

-- 
Lars Marowsky-Bree  :homepage email: \ geek, BOFH, psychopath, magician, /
 http://teuto.net/~lmb/ lmb@teuto.net \ killer, looney, genius, pervert /
pgp-key-id: 0x09e360c5 / ff 2a 82 e8 6b 85 79 23 9c da b5 81 d4 fc 29 e6


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

Date: Tue, 07 Apr 1998 18:37:29 GMT
From: doswald@xmission.com (David Oswald)
Subject: Re: Trimming blank lines from end of file?
Message-Id: <352a7061.43778940@news.xmission.com>

On Mon, 6 Apr 1998 10:06:27 -0400, David Lee Lambert
<lamber45@EGR.msu.edu> wrote:

>I've written a short bash/perl/find/diff script to automatically generate
>a patch from my personal ChangeLog and my working source tree.  As a side
>effect of working on it with Windows editors,  (like the Borland IDE),
>the files sometimes have the CR-LF convention instead of simple CR.  In
>addition,  they tend to acquire extra blank lines,  sometimes a screenful,
>at the end.   I've solved the first problem with
>
>	perl -p -i.~8~ -e 's/(\r\n|\n\r)/\n/' $N
>
>but not the second.  I want each file that's about to be diffed to have
>one and only one blank line at the end.  Does anyone have an idea of a
>perl program to do it? 

Go ahead and handle your first regex the same way, and then pass it
through a second regex as follows:

s/\n*$/\n/

This regex should take all or zero newlines anchored to the end of the
document, and substitute a single newline.  This s/// will begin with
the first \n that is followed only by \n's and will continue matching
all the way to the last \n in the document.  If there are no \n's at
the end, one will be added.  If there are one or more, they'll be
substituted for one.

Another alternative would be to substitute a single newline only if
one existed in the first place:

s/\n+$/\n/

If you wanted to permit \r\n or \n\r at the end to also trigger the
match, do it this way:

s/[\r\n]*$/\n/

This won't translate \r\n's found earlier in the document, but it will
eliminate any \r or any \n at the end of the document and leave a
single \n.

Good luck,

Dave


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

Date: Tue, 07 Apr 1998 15:25:35 -0500
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Trimming blank lines from end of file?
Message-Id: <352A8BBF.755D1DC0@us.ibm.com>

David Lee Lambert wrote:
> 
> I've written a short bash/perl/find/diff script to automatically generate
> a patch from my personal ChangeLog and my working source tree.  As a side
> effect of working on it with Windows editors,  (like the Borland IDE),
> the files sometimes have the CR-LF convention instead of simple CR.  In
> addition,  they tend to acquire extra blank lines,  sometimes a screenful,
> at the end.   I've solved the first problem with
> 
>         perl -p -i.~8~ -e 's/(\r\n|\n\r)/\n/' $N
> 
> but not the second.  I want each file that's about to be diffed to have
> one and only one blank line at the end.  Does anyone have an idea of a
> perl program to do it?

Unless your files are just huge and take up all of your RAM, this crude
little script should work.  It just reads the file into a string and
then uses a regex to get rid off all \n's appearing at the end.  Then
since you wanted just one blank line, it adds a \n to the end.

#!/usr/bin/perl -w

$infile = "slop.txt";
$outfile = "clean.txt";
open IN,"$infile" or die "Can't open $infile $!";
open OUT,">$outfile" or die "Can't open $outfile $!";

$text = "";
# Turn your text file into a string
while (<IN>) {
    $text .= $_;
}
$text =~ s/(.*)?\n+$/$1/;    # Remove any \n at end of string
$text .= "\n";               # Add the "one and only one" \n
print OUT $text;

close IN or die "Can't close $infile $!";
close OUT or die "Can't close $outfile $!";

-- 
James Ludlow (ludlow@us.ibm.com)
This isn't tech support, and all opinions are my own.


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

Date: Tue, 7 Apr 1998 19:24:54 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: Variable interpolation problems
Message-Id: <352A7D86.2623@world.northgrum.com>

Stas Bekman wrote:
>  
> I'm trying to make the following. But in vain...
> 
> $abc = 345;
> $a = 'This is $abc';
> $b = eval {$a};
> print $b,"\n";
> 
First, there are two kinds of eval:  the kind with a BLOCK surrounded
by {} is used to catch run-time errors, but inside the block  you
must have executable Perl code.  The kind that you want is coded as
eval EXPRESSION, in this case eval $a; so that eval receives a string
containing the code to be compiled during the main program's execution.

Second, the string to be eval'd must be a legal Perl expression, so
try putting double quotes around it (inside the single quotes that
surround the 'program' to be eval'd.

$abc = 345;
$a = '"This is $abc"';
$b = eval $a;
print $b,"\n";

should work better.
-- 
Charles G. Margolin                   DSSD Internal Information Services
cmargoli@world.northgrum.com          Northrop Grumman Corp. 0624/23
margolin@acm.org                      Hawthorne, California 90250-3277


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

Date: 7 Apr 1998 20:37:27 GMT
From: ronaldws@aol.com (RonaldWS)
Subject: Re: Variable interpolation problems
Message-Id: <1998040720372701.QAA17055@ladder03.news.aol.com>

In article <Pine.A41.3.96.980407194338.38434A-100000@ilx374.iil.intel.com>,
Stas Bekman <sbekman@ilx374.iil.intel.com> writes:

>Subject:	Variable interpolation problems
>From:	Stas Bekman <sbekman@ilx374.iil.intel.com>
>Date:	Tue, 7 Apr 1998 19:48:18 +0300
>
>Hi,
>
>I'm trying to make the following. But in vain...
>
>$abc = 345;
>$a = 'This is $abc';
>$b = eval {$a};

try - $b = eval qq/"$a"/;

>print $b,"\n";
>
>I want to get :
>This is 345
>but I get 
>This is $abc
>
>I tried many other ways: sprintf, eval and other but none of them seems to
>work...
>
>Any ideas, how do I take the one quote delimited string ans then get its
>internals interpolated?
>
>Thanks a lot!
>__

Ronald Schmidt



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

Date: 7 Apr 1998 18:42:09 GMT
From: bem@news.cmc.net (brian moore)
Subject: Re: Wanted: Amoo to stop my sysadmin from whining
Message-Id: <slrn6ikssk.elk.bem@thorin.cmc.net>

On Tue, 7 Apr 1998 13:42:29 -0400, 
 Andrew F. Lee <andrewf@cp.pathfinder.com> wrote:
> Hello,
> 
> We have Perl 5.002 (which has been around about 2 years) and very limited
> set of modules.  I am groaning to my sysadmin to UPGRADE, but no one wants
> to do anything unless the building is on fire.
> 
> I gave the following example as a Perl5.004 vs. Perl5.002 idiosyncracy:

Bah, forget that.  Show him:
    ftp://ftp.cert.org/pub/cert_advisories/CA-97.17.sperl

Or: http://www.rootshell.com/archive-dv7cnezqmiuciufxgsqrr7s9/199709/sperl.tgz

Or: http://www.rootshell.com/archive-dv7cnezqmiuciufxgsqrr7s9/199707/perl-ex.sh

Maybe you should run one of 'em, get root, and upgrade Perl yourself.
Though that might create some nasty politics. :)

-- 
Brian Moore                             Kill A Spammer For Jesus
Sysadmin, C/Perl Hacker, Usenet Vandal 


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

Date: Tue, 7 Apr 1998 19:31:55 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: Wanted: Amoo to stop my sysadmin from whining
Message-Id: <352A7F2B.64A5@world.northgrum.com>

Andrew F. Lee wrote:
> 
> Hello,
> 
> We have Perl 5.002 (which has been around about 2 years) and very limited
> set of modules.  I am groaning to my sysadmin to UPGRADE, but no one wants
> to do anything unless the building is on fire.
> 

The building IS on fire.  Remind your sysadmin that Perl 5.002 has
security holes which were the subject of CERT bulletins.
-- 
Charles G. Margolin                   DSSD Internal Information Services
cmargoli@world.northgrum.com          Northrop Grumman Corp. 0624/23
margolin@acm.org                      Hawthorne, California 90250-3277


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

Date: 7 Apr 1998 15:58:54 -0400
From: kcohen@julius.ling.ohio-state.edu (Kevin B Cohen)
Subject: Re: Web spider/crawler script
Message-Id: <6ge0hu$72u@julius.ling.ohio-state.edu>

In article <3529ca7c.70190361@loomi.telstra.net>,
Peter <delphiask@sale-net.com.au> wrote:
>Hi all. I am trying to find a spider or crawler type script I can use

you want to buy a copy of "perl5 for dummies", by paul e. hoffman.
pp. 241-250 will walk you thru creation of the script that you're
looking for.

>Please CC: to delphiask@sale-net.com.au as news is very slow.

actually, i find it to be very fast.

kevin

"If we suppose for the moment that a pizza is a syntactical
structure..." --Nigel Chapman, "Perl: the programmer's companion"



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

Date: Tue, 7 Apr 1998 14:19:37 -0500
From: Chocolate <poohba@io.com>
Subject: Why doesn't this work right?
Message-Id: <Pine.BSI.3.96.980407141650.6978A-100000@bermuda.io.com>

#!/usr/local/bin/perl

open (FILE, ".plan") || die "Can't open .plan:   $!\n";
@plans=<FILE>;
close(FILE);


for ($i=9; $i>=0; $i--) {
	print "\a";
	sleep(2);
	print "$i\b";
}
print "BBBBBB  YY    YY YYYYYYY\n";
print "BB   BB  YY  YY  YY\n";
print "BBBBBB    YYYY   YYYYY\n";
print "BB   BB    YY    YY\n";
print "BBBBBB     YY    YYYYYYY\n";
print "\n\n";

sleep(5);
system "exit";

For one the numbers don't print out in 2 sec intervals they wait until the
program is almost done and then it prints them out all at once.  And then
it doesn't exit after that.  Why is that?

  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

			_/_/_/		     _/     _/
		       _/  _/	            _/     _/		
  Web Page Designs    _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/_/_/ 
    Small Programs   _/     _/   / _/  _/ _/  _/ _/  _/ _/  _/  poohba@io.com
www.io.com/~poohba  _/	   _/_/_/ _/_/_/ _/  _/ _/_/_/ _/_/\_ 	(919)506-5883

  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/



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

Date: Tue, 07 Apr 1998 13:10:28 -0700
From: Larry Rosler <lr@hpl.hp.com>
To: Chocolate <poohba@io.com>
Subject: Re: Why doesn't this work right?
Message-Id: <352A8834.6CBBCC50@hpl.hp.com>

Chocolate wrote:
> 
> #!/usr/local/bin/perl
> 
> open (FILE, ".plan") || die "Can't open .plan:   $!\n";
> @plans=<FILE>;
> close(FILE);
> 
> for ($i=9; $i>=0; $i--) {
>         print "\a";
>         sleep(2);
>         print "$i\b";
> }
> print "BBBBBB  YY    YY YYYYYYY\n";
> print "BB   BB  YY  YY  YY\n";
> print "BBBBBB    YYYY   YYYYY\n";
> print "BB   BB    YY    YY\n";
> print "BBBBBB     YY    YYYYYYY\n";
> print "\n\n";
> 
> sleep(5);
> system "exit";
> 
> For one the numbers don't print out in 2 sec intervals they wait until the
> program is almost done and then it prints them out all at once.  And then
> it doesn't exit after that.  Why is that?
> 
<SNIP> (of overblown .sig)

Two problems:

To force flushing of stdout after each print statement, put at the top:

$| = 1;

Replace 'system "exit";' by just 'exit;' (or nothing at all).  You have
asked the program to spawn a command named "exit" which probably doesn't
exist.

HTH.

Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: 7 Apr 1998 20:24:30 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Why doesn't this work right?
Message-Id: <6ge21u$3qi$2@info.uah.edu>

In article <Pine.BSI.3.96.980407141650.6978A-100000@bermuda.io.com>,
	Chocolate <poohba@io.com> writes:
[snip dynamic .plan code]

: For one the numbers don't print out in 2 sec intervals they wait until the
: program is almost done and then it prints them out all at once.  And then
: it doesn't exit after that.  Why is that?

That's because the fingerd cats your ~/.plan to the user.  You have to
play games to get a program to run each time you're fingered.  If you
want to have an dynamic .plan, use something like this (if you want to
see it in action, `finger -lm gbacon@cs.uah.edu'):

    #! /usr/bin/perl

    # Copyright (c) 1997 Greg Bacon. All rights reserved.
    # This program is free software.  You may distribute it and/or
    # modify it under the same terms as Perl itself.

    use strict;

    my $DOT_PLAN = "$ENV{HOME}/.plan";

    sub create_dot_plan {
        unless (-p $DOT_PLAN) {
            unlink $DOT_PLAN;

            my $cmd = "mknod $DOT_PLAN p";

            die "Failed $cmd: $?\n" if system $cmd;
        }
    }

    ## main
    create_dot_plan;

    my $fingerings = 0;

    while (1) {
        open PLAN, ">$DOT_PLAN" or die "Failed open >$DOT_PLAN: $!\n";

        $fingerings++;

        my $s;
        my $m;
        my $h;
        my $timestr;

        ($s, $m, $h) = localtime time;
        $timestr = sprintf "%d:%02d:%02d", $h, $m, $s;

        my $fing_str = $fingerings == 1
                           ? "just once"
                           : "$fingerings times";

        print PLAN <<EOHeader;
    Current local time is $timestr.

    You have reached gbacon\@cs.uah.edu.  I've been fingered $fing_str, and
    boy am I tired! :-)

    ---
    EOHeader

        my $lwall = `lwall-quote`;
        print PLAN <<EORandomQuote;

    A random Larry Wall quote (try again, you'll see! :-)

    $lwall
    EORandomQuote

        print PLAN <<EOFooter;
    ---

    THE Larry Wall quote:
     
    The depths of idiocy are as yet unplumbed.
                  -- Larry Wall in <199612181938.LAA10214\@wall.org>
    EOFooter

        close PLAN or print PLAN "Failed close: $!\n";

        sleep 1;
    }

If you're curious, here's lwall-quote:

    #! /usr/bin/perl

    $0 =~ s!^.*/!!;
    $quotes = "$ENV{HOME}/doc/lwall-quotes.txt";

    unless (open QUOTES, $quotes) {
        print "$0: failed open $quotes: $!\n";
        exit 1;
    }

    $/ = undef;
    @quotes = split /^%%\n/m, <QUOTES>;
    close QUOTES;

    print $quotes[int rand @quotes];

You can get a list of Larry Wall quotes suitable for use by this program
from <URL:http://www.perl.com/CPAN-local/misc/lwall-quotes.txt.gz>.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 7 Apr 1998 13:46:35 -0700
From: mcravit@shell3.ba.best.com (Matthew Cravit)
Subject: Re: Why doesn't this work right?
Message-Id: <6ge3bb$5p0$1@shell3.ba.best.com>

In article <Pine.BSI.3.96.980407141650.6978A-100000@bermuda.io.com>,
Chocolate  <poohba@io.com> wrote:


>For one the numbers don't print out in 2 sec intervals they wait until the
>program is almost done and then it prints them out all at once.  And then

This is the normal behavior for Perl...output is "buffered", and so it prints
out in chunks. To change this behavior, add the following to the start of your
script:

    BEGIN {
       use IO::Handle;
 
       autoflush STDOUT 1;
       autoflush STDERR 1;
    }

>it doesn't exit after that.  Why is that?

Because you're doing:

>system "exit";

instead of:

exit;

The system command is spawning off a new shell, and that shell is exiting.
The net effect of the command is therefore basically zero. "exit" is a
built-in perl function, so you don't need to (and shouldn't) call it via
system.


Hope this helps.
/MC

-- 
Matthew Cravit, N9VWG               | Experience is what allows you to
E-mail: mcravit@best.com (home)     | recognize a mistake the second
        mcravit@net.com (work)      | time you make it.


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

Date: 7 Apr 1998 19:08:21 GMT
From: neil@domingo.concordia.ca (Neil Kandalgaonkar)
Subject: WWW gamma dilemmas
Message-Id: <6gdtj5$n0a$1@newsflash.concordia.ca>


When I build websites, the difference in monitor gamma between the PC and
Mac really annoys me. (Assume that you care about Mac users visiting the
site -- or, more likely, your artists all insist on working with Macs.)

If you try for a sophisticated, low-contrast color mix, it is guaranteed
to look horrific on one platform or the other. So, despite computers that
can generate far more colors than a human can even distinguish, we browse
sadly among bland, primary color, high-contrast cell blocks.* "Hey, it may
be ugly, but the contrast is so great that even a massive gamma shift
can't dent it!"

Certain color standards have been proposed to fix the problem, such as
Apple's ColorSync or the W3C's sRGB. However, they require massive
hardware AND software industry consensus. Likely we'll be stuck with the
system as it is for a good long while.

So, I would like to use Apache (and Perl?) to hack my way around this
problem, serving different content to different platforms. I haven't
decided on the best approach and I was hoping you all could help me out.

First, pretend that all Macs have similar gammas, likewise all PCs. It's a
vast oversimplification; that's why I call it a hack.

Now imagine a perl script to generate a "translation" of a whole site. For
example, say you told it that the site was tested on a PC, now produce a
mac version. For every foo.html and bar.gif it adjusts the colors and
saves the result as foo.mac.html or bar.mac.gif in the same directory.
Apache would then be config'ed to filter content by browser platform much
as it can by language.

Comments? Surely this has been done before?


* The so-called websafe 216-color palette is the other millstone around
our necks, but let's set that aside for now.



-- 
Neil Kandalgaonkar
njk@odyssee.net


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 2269
**************************************

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