[18841] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1009 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 29 06:06:46 2001

Date: Tue, 29 May 2001 03:05:10 -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: <991130710-v10-i1009@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 29 May 2001     Volume: 10 Number: 1009

Today's topics:
    Re: <> operator problem <risto.vaarandi@eyp.ee>
    Re: [Q] count number of emails (Guillaume Durr)
    Re: Comparing objects (Graq)
    Re: convert letters to numbers (Eric Bohlman)
    Re: convert letters to numbers (Abigail)
        Creating a file based on a template with scalar value (Michael)
    Re: Creating a file based on a template with scalar val <krahnj@acm.org>
    Re: END{} and tempfiles <ilya@math.ohio-state.edu>
    Re: exec script w/require & headers (David Efflandt)
        HASH of ARRAY of HASHES <glodalec@yahoo.com>
    Re: HASH of ARRAY of HASHES (Bernard El-Hagin)
    Re: HASH of ARRAY of HASHES (Anno Siegel)
    Re: HASH of ARRAY of HASHES (Bernard El-Hagin)
    Re: HASH of ARRAY of HASHES (Anno Siegel)
        How can I migirate installed&configured activeperl5.6 t <mn_eric@email.com>
        How to express carriage return? (DrDave)
    Re: How to express carriage return? <krahnj@acm.org>
    Re: How would have solved this problem? (Eric Bohlman)
        passing parameters <"relaxedrob@optushome.com.au">
    Re: printing contents of a file to html (Eric Bohlman)
    Re: printing contents of a file to html <pne-news-20010529@newton.digitalspace.net>
    Re: printing contents of a file to html <bart.lateur@skynet.be>
    Re: printing contents of a file to html <"relaxedrob@optushome.com.au">
    Re: re-sizing GIF images on the fly <bart.lateur@skynet.be>
        Regular Expression question  <softcomp@home.com>
    Re: Regular Expression question  <wyzelli@yahoo.com>
    Re: Regular Expression question  <wyzelli@yahoo.com>
    Re: Regular Expression question  (Mark Jason Dominus)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 29 May 2001 11:58:09 +0200
From: Risto Vaarandi <risto.vaarandi@eyp.ee>
Subject: Re: <> operator problem
Message-Id: <3B1372B1.CC6621A@eyp.ee>

Risto Vaarandi wrote:
> 

hi,

thanks to anyone who have answered so far!
What I would like to understand, however, is WHY this is happening?

best regards,
risto

> hello,
> 
> I am trying to tail a file with a perl program. The program just opens
> the file without any specific options (ordinary blocking open), and the
> uses <> operator to get new bytes. If <> returns undef, then the program
> uses select for sleeping, and the tries again.
> The program works fine on Linux, but on Solaris <> occasionally starts
> to loop strangely, going back to lines it has already seen in the past
> and returning them, then going back again and returning the same lines
> all over again, etc.
> 
> Here is the code fragment - what could be wrong here?
> 
> for (;;) {
>       $line = <INPUT>;
>       if (!defined($line))  { select(undef, undef, undef,
> $poll_timeout); }
>         else { print $line; }
> }
> 
> I haven't seen this problem on Linux and HPUX, but on Solaris8 and
> Solaris2.6.
> Perl version is 5.6.0.
> 
> Does anyone have any clue - is this happening because of a bug in
> Solaris?
> 
> best regards,
> risto


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

Date: Tue, 29 May 2001 08:54:04 +0200
From: g.durr@free.fr (Guillaume Durr)
Subject: Re: [Q] count number of emails
Message-Id: <1eu5v4h.9vuv51wurha8N%g.durr@free.fr>

Clinton A. Pierce <clintp@geeksalad.org> wrote:

> [Posted and mailed]
> 
> In article <1eu53hv.659bvl17zn7oqN%g.durr@free.fr>,
>       g.durr@free.fr (Guillaume Durr) writes:
> > hi, 
> > I am a newbie to perl, and I have the following problems
> > I want to count the number of email in a file
> > I tried : 
> 
> A proper Unix mbox file should have:
>       
>       /^From\s/
> 
> Mark the beginning of every e-mail message.  This string will not occur
> in the body of a mail message.  So if you just want to count them:
> 
>       while(<>) {
>               $heads++ if /^From\s/;
>       }

Is is not a Unix mailbox, but a Eudora mailbox 
Is uses the <x-flowed> tag before and after the body message (see RFC
2646 for details), so that if there is a "From " in the message body,
the emailer don't add a ">" before the reserved keyword
-- 
«Pour voir le PC de demain, regardez le Macintosh d'aujourd'hui.»
                  BYTE, octobre 1995
Guillaume Durr                          g.durr@free.fr
ICQ N# 29417800                http://g.durr.free.fr


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

Date: 29 May 2001 01:00:47 -0700
From: graq@bigfoot.com (Graq)
Subject: Re: Comparing objects
Message-Id: <7f513e9c.0105290000.6ef668bd@posting.google.com>

nobull@mail.com wrote in message news:<u9u2294f9l.fsf@wcl-l.bham.ac.uk>...
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> 
> > According to Graq <graq@bigfoot.com>:
> > > I would like to know if comparing two objects is a valid thing to do.
> > 
> > Since Perl objects are references, the rules for references apply.

Thanks Anno.

> It is worth adding that this applies to objects of most but not all
> classes.  If the author of the class decides that comparison via ==
> should have some other semantics for objects of his class then (s)he
> can choose just about any semantics (s)he likes using the overload
> mechanism.

There are a mixture of objects and classes, but happily the classes
are simple in terms of Perl construction. Thank you for the info.

It is a well constructed group of objects and classes with good
use of accessors and database wrapping modules. However I have a
deadline to increase the scope of the system without the time for
the necessary re-write :( 
So a little tinkering with the objects in places that I'd prefer not
to do so is required.

Thank you both.


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

Date: 29 May 2001 04:54:28 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: convert letters to numbers
Message-Id: <9eva24$qec$2@bob.news.rcn.net>

Jim Cook <jcook@strobedata.com> wrote:
> I won't actually answer your question -- it's been done several times in
> this thread. However, this is exactly the type of situation where I know
> enough to think that you are trying to solve a problem the wrong way. In
> my job in tech support, i I were asked this type of question, I would
> get suspicious that you had a different problem, and were using this to
> try and solve it. I bet there's a better way, unless this was just a
> though experiment / homework problem.

We generally call something like that an "XY problem" here: someone wants 
to do X, they assume that Y is the way to accomplish it, and they ask for 
help with the difficulty they're having doing Y.  The canonical example is 
the CGI programmer who wants to avoid duplicate entries in his database 
(X) caused by resubmission of a form, decides that the solution is to 
disable the browser's back button (Y) and asks what his script needs to 
send to do that (there isn't any such thing).



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

Date: Tue, 29 May 2001 06:48:14 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: convert letters to numbers
Message-Id: <slrn9h6hhe.18l.abigail@tsathoggua.rlyeh.net>

Eric Bohlman (ebohlman@omsdev.com) wrote on MMDCCCXXVIII September
MCMXCIII in <URL:news:9eva24$qec$2@bob.news.rcn.net>:
``  Jim Cook <jcook@strobedata.com> wrote:
`` > I won't actually answer your question -- it's been done several times in
`` > this thread. However, this is exactly the type of situation where I know
`` > enough to think that you are trying to solve a problem the wrong way. In
`` > my job in tech support, i I were asked this type of question, I would
`` > get suspicious that you had a different problem, and were using this to
`` > try and solve it. I bet there's a better way, unless this was just a
`` > though experiment / homework problem.
``  
``  We generally call something like that an "XY problem" here: someone wants 
``  to do X, they assume that Y is the way to accomplish it, and they ask for 
``  help with the difficulty they're having doing Y.  The canonical example is 
``  the CGI programmer who wants to avoid duplicate entries in his database 
``  (X) caused by resubmission of a form, decides that the solution is to 
``  disable the browser's back button (Y) and asks what his script needs to 
``  send to do that (there isn't any such thing).


Exactly. And that while it's clear that the solution is to do an
"onSubmit: window.close()".



Abigail
-- 
use   lib sub {($\) = split /\./ => pop; print $"};
eval "use Just" || eval "use another" || eval "use Perl" || eval "use Hacker";


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

Date: Tue, 29 May 2001 06:58:46 GMT
From: usenet.spam@gunzel.net (Michael)
Subject: Creating a file based on a template with scalar value
Message-Id: <90B0AAEB3gunzelT333@203.50.2.80>

Hi all,

Hope this isn't covered in the FAQ, since I was unable to find it.. But I 
am having a problem where my script needs to send an email with a username 
in it, based on a text file, i.e. when creating a new user.

An example of the text file is:

----
Welcome. This is an email.

Your name is $name

Regards
Some script processing bot.
----

The section of the perl script that needs to work this is:

----
$user = "jbloggs";
$name = "JOE BLOGGS";

open(WELCRE,"</usr/local/userreg/text/welcome.txt");
@welcomemsg = <WELCRE>;
close (WELCRE);

$rand = rand(10000);
$tmpfile = "/tmp/welc.$rand";

open (WELCWRI,">".$tmpfile);
print WELCWRI @welcomemsg;
close WELCWRI;

system ("mail -s 'Welcome newuser $user' $user <$tmpfile");
----

The resultant body of the email, comes out exactly as the template 
(welcome.txt) file.

Any pointers would be greatly appreciated.

Regards
Michael


-- 
(To email me just remove ".spam" off my email address).

Whip me, Beat me, just don't Windows ME


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

Date: Tue, 29 May 2001 09:29:02 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Creating a file based on a template with scalar value
Message-Id: <3B136BDA.BB7FD406@acm.org>

Michael wrote:
> 
> Hi all,
> 
> Hope this isn't covered in the FAQ, since I was unable to find it.. But I
> am having a problem where my script needs to send an email with a username
> in it, based on a text file, i.e. when creating a new user.

Actually it is in the FAQ.

perldoc -q 'expand variables'



John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 29 May 2001 06:17:41 +0000 (UTC)
From: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: END{} and tempfiles
Message-Id: <9eveu5$j7t$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
buggs 
<buggs@geekmail.de>], who wrote in article <9ev4fa$94b$05$1@news.t-online.com>:
> Ilya Zakharevich wrote:

> > Will not work on most of the systems.

> Will just work fine on most UNIX systems.

Agreed.  Since it would not work anywhere else, it would not work on
most of the systems.

Ilya


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

Date: Tue, 29 May 2001 05:59:37 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: exec script w/require & headers
Message-Id: <slrn9h6em8.t9d.see-sig@typhoon.xnet.com>

On Mon, 28 May 2001, BUCK NAKED1 <dennis100@webtv.net> wrote:
> How do I get rid of the headers. When I use 
> 
> require "pcount.pl";
> 
> within another script, it executes "pcount.pl" as desired, but prints
> the content headers. FWIW, I have   require "pcount.pl"   right before
> my END block.

Think a little.  Modify pcount.pl to NOT print headers, or only when 
needed.  There is another newsgroup for CGI questions.

-- 
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Tue, 29 May 2001 09:12:30 +0200
From: Marvin <glodalec@yahoo.com>
Subject: HASH of ARRAY of HASHES
Message-Id: <MPG.157d5333e88e99f79896cd@news.siol.net>

Hi !

I need some help with a complex structure. Well, as it is seen, it is 
very simple:
I have a hash variable with two values, time and df. Time is a regular 
string while df is an array of hashes.
GetData collects data and returns main hash. Now, if I debug ENV after
the function call, I get the following:
pl:4): print "Time: ",$ENV{time},"\n";
  DB<1> x %ENV
0  'df'
1  ARRAY(0x80f29f8)
   0  HASH(0x80eee7c)
      'fs' => 'Filesystem'
      'used' => 'Used'
   1  HASH(0x81f5c1c)
      'fs' => '/dev/hda3'
      'used' => 959820
   2  HASH(0x8200838)
      'fs' => '/dev/hda1'
      'used' => 47329
2  'time'
3  'Tue May 29 07:23:31 CEST 2001'
  DB<2> x $ENV{df}
0  ARRAY(0x80f29f8)
   0  HASH(0x80eee7c)
      'fs' => 'Filesystem'
      'used' => 'Used'
   1  HASH(0x81f5c1c)
      'fs' => '/dev/hda3'
      'used' => 959820
   2  HASH(0x8200838)
      'fs' => '/dev/hda1'
      'used' => 47329
It looks, that $ENV{df} is an array. My question is, how to get number 
of elements (in this case 3) from that variable. $#ENV{df} won't work,
cause $# doesnt work on subscript. Also I would like to use foreach.. 
rather than for (...) statement.

#!/usr/local/bin/perl 

my %ENV=GetData();
print "Time: ",$ENV{time},"\n";

#These lines work, but I put 2 manually as a limit
print "1. DF:\n";
for (my $i=0;$i<=2;$i++)
{
   print $ENV{df}[$i]->{fs}," ",$ENV{df}[$i]->{used},"\n";
}

#These lines wont work
print "2. DF:\n";
foreach my $REC ($ENV{df})
{
   print $REC->{fs}," ",$REC->{used},"\n";
}
 
sub GetData
{
   my %DATA ;

   $DATA{time}=`date` ;
   my @TMPARRAY=();
   foreach my $LINE (`df -k`)
   {
      my @DF=split " ",$LINE ;
      push(@TMPARRAY,{fs=>$DF[0],used=>$DF[2]});
   }
   $DATA{df}=\@TMPARRAY;
   return %DATA ;
}



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

Date: Tue, 29 May 2001 07:43:58 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: HASH of ARRAY of HASHES
Message-Id: <slrn9h6k63.2s4.bernard.el-hagin@gdndev25.lido-tech>

On Tue, 29 May 2001 09:12:30 +0200, Marvin <glodalec@yahoo.com> wrote:
>Hi !
>

[snip]

>It looks, that $ENV{df} is an array. My question is, how to get number 
>of elements (in this case 3) from that variable. $#ENV{df} won't work,
>cause $# doesnt work on subscript.

If $hash{df} is a reference to an array you can get the index of the
last element of that array (not the number of elements, as you put it)
using:

$#{$hash{df}}

>Also I would like to use foreach..rather than for (...) statement.

Same principle:

foreach (@{$hash{df}}){
	#do some stuff
}

Cheers,
Bernard
--
perl -le '$#="Just another Perl hacker,"; print print;'


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

Date: 29 May 2001 08:36:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: HASH of ARRAY of HASHES
Message-Id: <9evn2c$i44$1@mamenchi.zrz.TU-Berlin.DE>

According to Marvin  <glodalec@yahoo.com>:

[...]

> It looks, that $ENV{df} is an array. My question is, how to get number 
> of elements (in this case 3) from that variable. $#ENV{df} won't work,
> cause $# doesnt work on subscript. Also I would like to use foreach.. 
> rather than for (...) statement.
> 
> #!/usr/local/bin/perl 
> 
> my %ENV=GetData();
> print "Time: ",$ENV{time},"\n";

[more code snipped]

Let me first note that the choice of %ENV for your hash is somewhat
unfortunate:  %ENV is a pre-defined hash in Perl (it reflects the
process environment).  While it is possible to have, as you do, a
lexical variable of the same name, this can only lead to confusion.

To your question:  $ENV{ df} is, of course, not an array, but a
reference to an array.  The actual array is @{ $ENV{ df}}, and using
that in scalar context gives you the number of elements, as with
any Perl array.  Similarly, @{ $ENV{ df}} can be used in a foreach
statement to loop over the elements.  To use the $#... construct, the
procedure is similar:  You replace the array name with an array ref
in {}, which leads to $#{ ENV{ df}}, the index to the last element in
@{ $ENV{ df}}.

Anno


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

Date: Tue, 29 May 2001 08:44:20 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: HASH of ARRAY of HASHES
Message-Id: <slrn9h6nn7.2s4.bernard.el-hagin@gdndev25.lido-tech>

On 29 May 2001 08:36:28 GMT, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
wrote:
>According to Marvin  <glodalec@yahoo.com>:
>
>[...]
>
>> It looks, that $ENV{df} is an array. My question is, how to get number 
>> of elements (in this case 3) from that variable. $#ENV{df} won't work,
>> cause $# doesnt work on subscript. Also I would like to use foreach.. 
>> rather than for (...) statement.
>> 
>> #!/usr/local/bin/perl 
>> 
>> my %ENV=GetData();
>> print "Time: ",$ENV{time},"\n";
>
>[more code snipped]
>
>Let me first note that the choice of %ENV for your hash is somewhat
>unfortunate:  %ENV is a pre-defined hash in Perl (it reflects the
>process environment).  While it is possible to have, as you do, a
>lexical variable of the same name, this can only lead to confusion.
>
>To your question:  $ENV{ df} is, of course, not an array, but a
>reference to an array.  The actual array is @{ $ENV{ df}}, and using
>that in scalar context gives you the number of elements, as with
>any Perl array.  Similarly, @{ $ENV{ df}} can be used in a foreach
>statement to loop over the elements.  To use the $#... construct, the
>procedure is similar:  You replace the array name with an array ref
>in {}, which leads to $#{ ENV{ df}}, the index to the last element in
                          ^
Note that there should be a $ there. :-)

Cheers,
Bernard
--
perl -le '$#="Just another Perl hacker,"; print print;'


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

Date: 29 May 2001 08:50:08 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: HASH of ARRAY of HASHES
Message-Id: <9evns0$i44$2@mamenchi.zrz.TU-Berlin.DE>

According to Bernard El-Hagin <bernard.el-hagin@lido-tech.net>:
> On 29 May 2001 08:36:28 GMT, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>

> >in {}, which leads to $#{ ENV{ df}}, the index to the last element in
>                           ^
> Note that there should be a $ there. :-)

Yes.  Sloppy me.

Anno


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

Date: Tue, 29 May 2001 12:33:10 +0800
From: "Kick" <mn_eric@email.com>
Subject: How can I migirate installed&configured activeperl5.6 to another machine
Message-Id: <9ev8hi$6mg$1@mail.cn99.com>

I have installed activeperl on my machine and use ppm installed perl/tk. Now
I want to migrate it to a machine in my office which can't connect to
internet. That means I can't install default activeperl distribution and
reinstall perl/tk again.

What can I do now?

Thanks for any help!

Eric




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

Date: 28 May 2001 22:40:21 -0700
From: drundeaddave@icqmail.com (DrDave)
Subject: How to express carriage return?
Message-Id: <43ca1c98.0105282140.559274ee@posting.google.com>

Hi guys,

I would like to do the following:

I use a pair of inverted brackets to read an html file to a variable

            $file = `lynx -source www.somesite.com`;

So the variable $file has a lot of lines ended with CR. I want to
split the variable to seperated lines. I would use split(), but how do
I express the CR as the delimiter in split()?

Thx!

DrDave


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

Date: Tue, 29 May 2001 05:53:15 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How to express carriage return?
Message-Id: <3B13394B.890FD0D3@acm.org>

DrDave wrote:
> 
> Hi guys,
> 
> I would like to do the following:
> 
> I use a pair of inverted brackets to read an html file to a variable
> 
>             $file = `lynx -source www.somesite.com`;
> 
> So the variable $file has a lot of lines ended with CR. I want to
> split the variable to seperated lines. I would use split(), but how do
> I express the CR as the delimiter in split()?

You mean something like:

my @lines = `lynx -source www.somesite.com`;



John
-- 
use Perl;
program
fulfillment


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

Date: 29 May 2001 05:01:30 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: How would have solved this problem?
Message-Id: <9evafa$qec$3@bob.news.rcn.net>

Robert Nicholson <steffi@shell8.ba.best.com> wrote:
> Fair enough point...

> The point I wanted to make about TokeParser was that if I read
> a token and then put it back ie. unget it and read the next
> token from the parser. It's not the one I just put back.

When you read the token, are you using get_token() or get_tag()?  Remember 
that the latter returns a "stripped" token where the type entry has been 
deleted and where the element name begins with a "/" if the token was an 
end tag.  unget_token() isn't smart enough to recognize stripped tokens, 
so if you try to push one back things get all messed up, since the next 
call to get_token() (which is what get_tag() and get_text() use 
internally) is going to expect the first entry in the token to be the type 
entry.

Note that the current version of XML::TokeParser, which I wrote, also 
suffers from this limitation, though it will be fixed in the next version.  
I think it would be useful if Gisle would do the same thing to 
HTML::TokeParser.



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

Date: Tue, 29 May 2001 09:21:33 GMT
From: "Rob" <"relaxedrob@optushome.com.au">
Subject: passing parameters
Message-Id: <xSJQ6.4857$25.17594@news1.eburwd1.vic.optushome.com.au>

Howdy all!

Is it possible to use a CGI object to preserve state across multiple html
pages without using forms?

For instance, I can do this on one html page and it works fine:
    my $q = new CGI;                        # create new CGI object
    $q->param(-name=>'basePage',-value=>'one.html');
    my $page = $q->param('basePage');
    print '<a href="$page">Go to base page</a>';

It dutifully produces a hyperlink to one.html..

But I want to be able to set basePage in one html document and then pick up
the value in the next one -without- using forms..

I assume that the form method="POST" conserves CGI object information from
page to page.. Is there no way do this without form method="POST"?

Can I do this?

Thanks for any help!

Rob




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

Date: 29 May 2001 05:08:42 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: printing contents of a file to html
Message-Id: <9evasq$qec$4@bob.news.rcn.net>

Rob <"relaxedrob@optushome.com.au"> wrote:
> Is there any way to avoid using an absolute file path in this case?

chdir() into the appropriate directory before trying to open files.



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

Date: Tue, 29 May 2001 09:42:20 +0200
From: Philip Newton <pne-news-20010529@newton.digitalspace.net>
Subject: Re: printing contents of a file to html
Message-Id: <qih6htke1srkt7lb2l1eqiv2telg9djva4@4ax.com>

[Please don't put your reply before the original text.
 Please trim your quoted material.
 Thanks.]

On Mon, 28 May 2001 12:25:15 GMT, "Rob" <"relaxedrob@optushome.com.au">
top-posted full-quoted:

> Is there any way to avoid using an absolute file path in this case?

FindBin may be able to help you, if the file is in the same directory as
the script. perldoc FindBin.

However, what's wrong with an absolute file path? (Don't you know where
you put your files? ;)

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Tue, 29 May 2001 08:59:31 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: printing contents of a file to html
Message-Id: <n9p6ht8gti0s8bgk8buq6mbot8h0k3dd1r@4ax.com>

Philip Newton wrote:

>However, what's wrong with an absolute file path? (Don't you know where
>you put your files? ;)

I think he's worried about moving the script to different servers.

-- 
	Bart.


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

Date: Tue, 29 May 2001 09:23:08 GMT
From: "Rob" <"relaxedrob@optushome.com.au">
Subject: Re: printing contents of a file to html
Message-Id: <0UJQ6.4858$25.17656@news1.eburwd1.vic.optushome.com.au>

> I think he's worried about moving the script to different servers.
Exactly..
Rob


"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:n9p6ht8gti0s8bgk8buq6mbot8h0k3dd1r@4ax.com...
> Philip Newton wrote:
>
> >However, what's wrong with an absolute file path? (Don't you know where
> >you put your files? ;)
>
> I think he's worried about moving the script to different servers.
>
> --
> Bart.




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

Date: Tue, 29 May 2001 08:58:20 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: re-sizing GIF images on the fly
Message-Id: <r1p6ht8cqu5ft8gekvkaiu14g4himq5dke@4ax.com>

Martien Verbruggen wrote (quoting):

>>>Another aspect is that you want to save the scaled version again as
>>>gif.  The gif format is limited to 256 color palettes.  But if you
>>>scale using interpolation the resulting image is likely to contain
>>>much greater number of colors than the original.  This causes your
>>>image to re-color quantized.  Meaning that the palette is regenerated.
>>
>> OK, I think I understand this.
>
>You are doing better than I do, then :)

Resampling might result in colours that are not in the original colour
pace. For example, if you have only red and yellow pixels, and you scale
down this pictures, ideally, a lot of intermediate oranges would have to
appear in the palette.

>ImageMagick can be told to stay within the current palette.

This will result in a less than optimal colour palette.

-- 
	Bart.


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

Date: Tue, 29 May 2001 05:49:13 GMT
From: "Jon" <softcomp@home.com>
Subject: Regular Expression question 
Message-Id: <tLGQ6.6919$yp2.1535274@news1.rdc1.az.home.com>

Hello all,

    Can someone help explain to me the difference between

    /(\w|\s)+/;

    versus

    /[\w\s]+/;

    If this question has been asked by someone before , where
can I find the answer ?.  perlfaq6.html does not seemed to address
the question above. Thanks.

    Jon




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

Date: Tue, 29 May 2001 15:57:59 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Regular Expression question 
Message-Id: <mhHQ6.32$NJ3.6640@vic.nntp.telstra.net>

"Jon" <softcomp@home.com> wrote in message
news:tLGQ6.6919$yp2.1535274@news1.rdc1.az.home.com...
> Hello all,
>
>     Can someone help explain to me the difference between
>
>     /(\w|\s)+/;

This will match either a 'word character' or a 'space character' (perldoc
perlre for the specifics on those) and then the + modifies that to be 1 or
more of the previous match (word or space).

>     versus
>
>     /[\w\s]+/;

This  will match a 'word character' or a 'space character' and then the +
modifies it to one or more 'word or space' characters.

Since in any string which contains any word or space character will be
matched by either, it is difficult to see any practical difference between
them.

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
$d='$_$a$s$b$w';$e='$_$a$s$b';sub d{$h=shift;$h=~s/\$(\w+)/${$1}/g;return$h}
sub
e{return(shift!=1)?'s':''}for(reverse(1..100)){$s=e($_);$f=d($d);$g=d($e);
$c.="$f\n$g\n$t\n";$_--;$s=e($_);$e=d($d);$c.="$e\n\n";}print"$c*hic*";




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

Date: Tue, 29 May 2001 16:13:10 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Regular Expression question 
Message-Id: <BvHQ6.34$NJ3.6851@vic.nntp.telstra.net>

"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:mhHQ6.32$NJ3.6640@vic.nntp.telstra.net...
>
> Since in any string which contains any word or space character will be
> matched by either, it is difficult to see any practical difference between
> them.

I should add that the first will also store what was matched into $1 which
may be of some significance.

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";





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

Date: Tue, 29 May 2001 06:50:58 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Regular Expression question 
Message-Id: <3b1346c1.5c74$111@news.op.net>

In article <tLGQ6.6919$yp2.1535274@news1.rdc1.az.home.com>,
Jon <softcomp@home.com> wrote:
>    Can someone help explain to me the difference between
>
>    /(\w|\s)+/;
>
>    versus
>
>    /[\w\s]+/;

They match the same strings.  But [\w\s] will be more efficient in
general because it is compiled to a single opcode, whereas (\w|\s) is
compiled to several opcodes, with a branch, and the possibility of
backtracking to try \s if \w does not work.  (Also further, the (...)
causes part of the match to be captured in the $1 variable, which
slows down matching still more.)

For the string in this example, the [\w\s] version is about 5 times
faster.



$IT = 100000;
$s = 'The quick brown fox jumps over the lazy dog.';

print "NULL LOOP\n";
my ($u1, $s1) = times();
my $t1 = $u1 + $s1;
for ($i=0; $i<$IT; $i++) {
  1;
} 
my ($u2, $s2) = times();
my $t2 = $u2 + $s2;
my ($ue, $se, $te) = ($u2-$u1, $s2-$s1, $t2-$t1);
printf "Elapsed: %6.2fu %6.2fs %6.2ftotal\n", $ue, $se, $te;


print "Match with [\\w\\s]\n";
my ($u1, $s1) = times();
my $t1 = $u1 + $s1;
for ($i=0; $i<$IT; $i++) {
  $s =~ /[\w\s]+/
} 
my ($u2, $s2) = times();
my $t2 = $u2 + $s2;
my ($ue, $se, $te) = ($u2-$u1, $s2-$s1, $t2-$t1);
printf "Elapsed: %6.2fu %6.2fs %6.2ftotal\n", $ue, $se, $te;

print "Match with ([\\w\\s])\n";
my ($u1, $s1) = times();
my $t1 = $u1 + $s1;
for ($i=0; $i<$IT; $i++) {
  $s =~ /([\w\s])+/
} 
my ($u2, $s2) = times();
my $t2 = $u2 + $s2;
my ($ue, $se, $te) = ($u2-$u1, $s2-$s1, $t2-$t1);
printf "Elapsed: %6.2fu %6.2fs %6.2ftotal\n", $ue, $se, $te;

print "Match with (\\w|\\s)+\n";
my ($u1, $s1) = times();
my $t1 = $u1 + $s1;
for ($i=0; $i<$IT; $i++) {
  $s =~ /(\w|\s)+/
} 
my ($u2, $s2) = times();
my $t2 = $u2 + $s2;
my ($ue, $se, $te) = ($u2-$u1, $s2-$s1, $t2-$t1);
printf "Elapsed: %6.2fu %6.2fs %6.2ftotal\n", $ue, $se, $te;

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

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


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