[22241] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4462 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 24 14:06:50 2003

Date: Fri, 24 Jan 2003 11:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 24 Jan 2003     Volume: 10 Number: 4462

Today's topics:
        Accessing disk and volume information <yashgt@yahoo.com>
    Re: Changing the context of a code block <eric.anderson@cordata.net>
    Re: Changing the context of a code block <nobull@mail.com>
    Re: Checking IP Ranges in one line <abigail@abigail.nl>
    Re: consolidating some regex's <abigail@abigail.nl>
    Re: Converting a string to a valid date.. <no_spam@fromyou.thanks-anyways.com>
    Re: Converting a string to a valid date.. <glex_nospam@qwest.net>
    Re: Dynamically Declaring Variables <bkennedy@hmsonline.com>
        IO::Socket - timeout not working zen13097@zen.co.uk.invalid
    Re: Is there a better way to check to see  if a date li (Ben Morrow)
    Re: Is there a better way to check to see  if a date li <mothra@nowhereatall.com>
    Re: Is there a better way to check to see  if a date li <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
    Re: newbie question on reference ?? (Sara)
    Re: newbie question on reference ?? <uri@stemsystems.com>
    Re: newbie question on reference ?? (Tad McClellan)
    Re: OT: TOFU, jeopardy and spoilers <abigail@abigail.nl>
    Re: OT: TOFU, jeopardy and spoilers <krahnj@acm.org>
    Re: Perl & CGI Security <GPatnude@adelphia.net>
    Re: Perl & CGI Security <nobull@mail.com>
    Re: Perl Thread Tk Web Server problem (Michael)
    Re: Reading French-Accented Data (Ben Morrow)
    Re: Reading French-Accented Data (Dave Fraleigh)
        reflected form of $/ ctcgag@hotmail.com
    Re: Reverse Inheritance? <abigail@abigail.nl>
    Re: slow grep ctcgag@hotmail.com
        Term::ReadKey non-blocking non-working in RH8.0 (Roy Souther)
    Re: unlink() <krahnj@acm.org>
    Re: What does this header mean? <bbsouth@bellsouth.net>
    Re: win32 tieregistry html <nobull@mail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 24 Jan 2003 19:30:58 +0530
From: "Yash" <yashgt@yahoo.com>
Subject: Accessing disk and volume information
Message-Id: <b0rgf0$8mm$1@news.vsnl.net.in>

Hi,
Can someone point me the package that I should use to query the system to
access the information about physical disks and volume groups. I am using
perl 5.6.1 on HP-UX 11.

Thanks
Yash




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

Date: Thu, 23 Jan 2003 20:32:53 -0500
From: "Eric Anderson" <eric.anderson@cordata.net>
Subject: Re: Changing the context of a code block
Message-Id: <pan.2003.01.24.01.32.51.158676@cordata.net>

On Fri, 24 Jan 2003 03:01:25 +0000, Uri Guttman wrote:
> __PACKAGE__ is replaced with the current package name which is MyPackage.
> 
> if you say package AnotherPackage before it, it will print that package
> name.

Is there anyway I can use a variable with the package statement. Such as:

my $package_name = 'AnotherPackage';
package $package_name;
 
> to get the dynamic package name use the caller() function.

I'm not quite sure I understand what you are saying here? I tried the
following, but got the same results.

my $my_code = sub {
   print((caller())[0], "\n" );
};

--
Eric Anderson


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

Date: 24 Jan 2003 17:25:30 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Changing the context of a code block
Message-Id: <u9r8b21mut.fsf@wcl-l.bham.ac.uk>

"Eric Anderson" <eric.anderson@cordata.net> writes:

> On Fri, 24 Jan 2003 03:01:25 +0000, Uri Guttman wrote:
> > __PACKAGE__ is replaced with the current package name which is MyPackage.
> > 
> > if you say package AnotherPackage before it, it will print that package
> > name.
> 
> Is there anyway I can use a variable with the package statement. Such as:
> 
> my $package_name = 'AnotherPackage';
> package $package_name;

package is a compile-time directive.  Even if package() could use a
variable it wouldn't help you since you'd have to have already set the
variable at compile time.

You may need to use eval(STRING) but I suspect this is XY.

What is your X?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 24 Jan 2003 15:38:38 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Checking IP Ranges in one line
Message-Id: <slrnb32nfu.dce.abigail@alexandra.abigail.nl>

Charles R. Thompson (charlest@indysoft.com) wrote on MMMCDXXXII September
MCMXCIII in <URL:news:v30h3b9igr2g90@corp.supernews.com>:
''  There is mention of this in various posts, and I even question it in a
''  recent post, but have broken it off here for clarity. Is it possible to
''  match a range of numbers located in a string with a one line regexp? Using
''  IPs as an example... keep in mind we aren't looking to see if this is a
''  valid IP, etc ad nauseum that's not what this thread should be about... How
''  might one go about checking a provided  IP to see if  set of numbers matches
''  a range?
''  
''  example...
''  
''  Given this regexp: ^64.(152|153|154|155|156|157|158|159).(.*?)$
''  -or-
''   if ($ipblock =~ /^64.(152|153|154|155|156|157|158|159).(.*?)$/) { # do
''  stuff }
''  
''  easily matches
''  64.152.0.0 through 64.159.255.255
''  
''  How can it be modified in the same one line regexp to do without the
''  excessive or'ing? Is this a job for backreferencing?


Untested code:

    $ipblock =~ /^64\.
                 (\d+)\.(?(?{152 <= $^N && $^N <= 159})|(?!X)X)
                 (\d+)\.(?(?{0 <= $^N && $^N <= 255})|(?!X)X)
                 (\d+)\.(?(?{0 <= $^N && $^N <= 255})|(?!X)X)
                 $/x;


Abigail
-- 
I'll put "ranges" to Regexp::Common's TODO list.


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

Date: 24 Jan 2003 15:53:37 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: consolidating some regex's
Message-Id: <slrnb32oc1.dce.abigail@alexandra.abigail.nl>

devrick (rick@shleprock.net) wrote on MMMCDXXXI September MCMXCIII in
<URL:news:X0BX9.785820$WL3.785169@rwcrnsc54>:
()  Could someone provide a way to consolidate the following:
()  
()  $_ =~ s/^\s+//gm;
()  next unless !/^\#/;
()  next unless !/^\%/;
()  next unless !/^\)/;
()  next unless /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
()  $_ =~ tr/\'\,//d;


I assume that the fifth line tries to match an IP address. In that
case, I'd write it as:

    use Regexp::Common qw /net/;

    s/^\s+//;          # No binding to $_ needed, nor the /g or /m.
    next if /^[#%)]/;  # Combine into a character class;
    tr /',//d if /$RE{net}{IPv4}/;
                       # Delete comma and quote, if the line contains
                       # an IPv4 address.


Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

Date: Fri, 24 Jan 2003 14:22:10 GMT
From: "Bullet" <no_spam@fromyou.thanks-anyways.com>
Subject: Re: Converting a string to a valid date..
Message-Id: <m_bY9.11896$zF1.3135424626@newssvr10.news.prodigy.com>

> There may be (s/may be/nearly always is/) a better way to get
> a speedup than rearranging the details of mere syntax.
>
> A better algorithm for instance.
>
> Or in your specific application, perhaps mod_perl which will speed
> up every program on your website in addition to the one you are
> working on right now.

True - however.. the reason its heavily taxed is because its
running about 50 different domains - all of which are run by different
individuals - and running all manner of web apps using a variety of
programming/database tools including -
coldfusion / tomcat / mod_perl / php / MySql

Unfortunately.. its not an enterprise situation where we can dictate
to the users what the best technology to use is.. (well we could LOL
but our customers probably wouldnt like that too much)

> Knuth says you should be interested 3% of the time, you say you are
> interested 100% of the time.
>
> Knuth is an Awfully Smart Guy.
>
> Perhaps you should reconsider your approach to optimization.  :-)
> (note he said "premature". Can't tell if that is applicable to
>  your case or not.
> )

well I have heard people say that I was wasting my time
optimising my code before.. I never have been called evil for it - LOL

There isnt any particular reason I need this chunk of code to run faster,
but I am just trying to get a feel for where optimisations are possible..

Mainly I am just curious as to what operations are faster/slower..
I figure the more I can figure out what types of code run a bit faster
the closer to that 3% of the time I can come.. without having to do
any tests later..

Besides.. I enjoy tinkering and doing tests.. I code because I like to
and I am working on this project as a volunteer.. so I can afford to
waste a bit of my time optimizing.. this way.. I take something away
from the project even though theres no tangible reward (ie a paycheck)




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

Date: Fri, 24 Jan 2003 11:09:55 -0600
From: Jeff D Gleixner <glex_nospam@qwest.net>
Subject: Re: Converting a string to a valid date..
Message-Id: <8qeY9.33$F84.29213@news.uswest.net>


> well I have heard people say that I was wasting my time
> optimising my code before.. I never have been called evil for it - LOL
> 
> There isnt any particular reason I need this chunk of code to run faster,
> but I am just trying to get a feel for where optimisations are possible..

When trying to make something run faster, I'd suggest that you start with the 
areas in your code which are taking up the most time. Use something like 
Devel::AutoProfiler, or Devel::Profiler to give you a good idea of where those 
areas are occuring.  To help you decide what code/algorithm is faster, use 
Benchmark and make sure you're testing for something specific and make sure the 
code produces the same results. Also, keep in mind that you or others may have 
to support/read your code some day and readibility goes a long way. :-)

> 
> Mainly I am just curious as to what operations are faster/slower..
> I figure the more I can figure out what types of code run a bit faster
> the closer to that 3% of the time I can come.. without having to do
> any tests later..

Many times testing is the only way to make sure.  In some cases
appending a string might be faster than a push() and a join(), for instance.

In short, don't sweat the petty things. :-)  In practice, once the code works 
well, is fast enough, well tested/bugfree, secure, and is documented, then 
optimization is done, if you have the time.

For fun, I found the following from "CGI Programming with Perl".  It's more for 
CGI scripts, however the tips are good practices for all scripts:

17.1. Basic Perl Tips, Top Ten

Here is a list of ten techniques you can use to improve the performance of your 
CGI scripts:

10. Benchmark your code.
9. Benchmark modules, too.
8. Localize variables with my.
7. Avoid slurping data from files.
6. Clear arrays with undef instead of ( ).
5. Use SelfLoader where applicable.
4. Use autouse where applicable.
3. Avoid the shell.
2. Find existing solutions for your problems.
1. Optimize your regular expressions.


There are many more practices, which you can find around the web.

Have fun



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

Date: Fri, 24 Jan 2003 12:37:38 -0500
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Dynamically Declaring Variables
Message-Id: <O52dnWxVHZGW56yjXTWcog@giganews.com>


"Dave Fraleigh" <dave@fraleigh.net> wrote in message
news:22f677f.0301231815.783e4097@posting.google.com...
> Thanks - ended up using a hash of arrays of hashes to store the
> variable and lookup table contents.
>
> eg:
>
> my @tempArry = (\{eval($theCreateLKHash)}, \{eval($theCreateDSHash)});
> $lookupTableHash{$theName} = \@tempArry;
>
> and then in the dereference, since I am just referencing one hash of
> the object,
> \%{$${\@{$lookupTableHash{$theLookupTable}}[1]}}

This is still looking quite complicated... if you want to store
configuration information as a Perl data structure, you could use the
standard 'Storable' module to handle all the serialization for you.  This
will allow you extend your configuration data structure pretty much
indefinitely as required, but at the expense of being able to edit the file
directly:

use Storable qw(store retrieve);

# name of configuration file
#
my $config_file = "my_conf_file";

# suppose this data structure has your config info
#
my $config_structure = {
    ConfigArea1 => [ qw(A B C) ],
    ConfigArea2 => { "A" => "foo",
       "B" => "bar"
       }
};

# sub that lets us view some contents of the config structure
#  - this will be called twice to verify that deserialization
#  worked
#
sub config_test {
  my $config_structure = shift;
  my @area_1 = @{$config_structure->{ConfigArea1}};
  print "* Config area 1: @area_1\n";
  my $val = $config_structure->{ConfigArea2}{A};
  print "* Value of ConfigArea2 -> A: $val\n";
}

# see what the data structure looks like
#
config_test($config_structure);

# now, store the config structure with Storable
#
store($config_structure, $config_file);

print "\nTime passes...\n\n";

# derialize file into a data structure
#
my $new_config_structure = retrieve $config_file;

# see if this thing worked!
#
config_test($new_config_structure);

# lets not leave a mess
#
unlink $config_file or die "Cannot unlink $config_file: $!";


Another option is using Data::Dumper + eval, which will at least let you
edit the config file if necessary.  Hope this helps--

--Ben Kennedy





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

Date: 24 Jan 2003 14:38:44 GMT
From: zen13097@zen.co.uk.invalid
Subject: IO::Socket - timeout not working
Message-Id: <slrnb32k6d.lk.davew@wormhole.homelinux.org>

I'm having problems geting timeouts working with IO::Socket.
Take the sample code below - run it, then telnet to port 9999 on the
same machine. The code prints a 'Connected' message, sets a 5 second 
timeout, and tries to read some data from the socket.

What's happening is that the timeout is being triggered (I'm seeing the
"[timeout]" message from the signal handler) but the recv() call isn't
exiting until it has received some data.

Am I doing something wrong?

(Perl V5.6.1, Linux)

------

#!/usr/bin/perl
use warnings;
use strict;
use IO::Socket;

my $listen = IO::Socket::INET->new(
        Proto       => 'tcp',
        LocalPort   => 9999,
        Listen      => 4,
        Reuse       => 1,
    ) or die "Can't create listen socket : $!\n";

my $socket = $listen->accept() or die "Accept failed : $!\n";

$socket->print( "Connected\n" );

my $timeout = 0;
$SIG{ALRM} = sub { $timeout = 1; warn "[timeout]\n" };
alarm(5);
$socket->recv( my $data, 1 ) or warn "recv failed : $!\n";
# my $data = <$socket>; # has same effect.
alarm(0);
print "Timeout!\n" if $timeout;
print "Got data : [$data]\n";

$socket->close();
__END__

-- 
Dave
zen13097<at>zen.co.uk


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

Date: Fri, 24 Jan 2003 14:09:56 +0000 (UTC)
From: mauzo@ux-ma160-13.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Is there a better way to check to see  if a date lies within a certain range of dates
Message-Id: <b0rhfk$2on$1@wisteria.csv.warwick.ac.uk>

"Mothra" <mothra@nowhereatall.com> wrote:
>Hi Koos Pol,
>
>> I missed the start of the thread, so excuse me if this is a bit off bow:
>> Date::Manip understands many date formats, including "sunday in 2 weeks".
>> So if you feed your dates to Date::Manip it will return you a simple date
>> string:
>>
>>     bash$ perl
>>     use Date::Manip;
>>     print ParseDate("sunday in 2 weeks"),"\n";
>>     ^D
>>
>>     2003020900:00:00
>>
>> Now you can apply Jurgen's comparison solution.
>
>Thanks for responding :-)
>
>I have tried that (before my orginal posted) and it generates warnings :-(
>Here is the script that I have tried:
>
>-----------Broken script ----------------
>#!/usr/bin/perl
>use Date::Manip;
>use strict;
>use warnings;
>
>my $start_date = 'jan 04 2001';
>my $end_date   ='mar 21 2001';
>
>while (<DATA>)   {
>
>
>my $test_date = ParseDate("$_");
>
>
>
>if ( ($test_date >= ParseDate("$start_date"))
                  ^^
                  ge

> &&
>   ($test_date <= ParseDate("$end_date")))
                ^^
                le
>  {
>      chop;
>      print "$_ is between!\n"
>  }
>
>}
>
>__DATA__
>04/09/2002
>05/10/2001
>02/25/2001
>02/01/2001
>01/02/2001
>--------output--------
>[ I removed some of the warnings to keep it short ]
>
>F:\scripts>date.pl
>Argument "2001022500:00:00" isn't numeric in numeric ge (>=) at
>F:\scripts\date.pl line 16, <DATA> line 3.
>Argument "2001032100:00:00" isn't numeric in numeric le (<=) at

as Perl was telling you. String compares should be done with eq, ne, gt, etc.
rather than ==, !=, >, etc.

>I guess it does work! however, whenever perl generates warnings it usally
>tells
>me that I am doing something wrong. This is the reason I did not use this
>method.

Ben


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

Date: Fri, 24 Jan 2003 06:21:31 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Is there a better way to check to see  if a date lies within a certain range of dates
Message-Id: <3e314b17$1@usenet.ugs.com>

Hi Ben,

> >if ( ($test_date >= ParseDate("$start_date"))
>                   ^^
>                   ge
>
> > &&
> >   ($test_date <= ParseDate("$end_date")))
>                 ^^
>                 le
[snipped]
> as Perl was telling you. String compares should be done with eq, ne, gt,
etc.
> rather than ==, !=, >, etc.

Good catch!! Thanks Ben.

Mothra




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

Date: Fri, 24 Jan 2003 15:20:16 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: Is there a better way to check to see  if a date lies within a certain range of dates
Message-Id: <newscache$sh289h$lye$1@news.emea.compuware.com>

Mothra wrote (Friday 24 January 2003 15:01):

> I have tried that (before my orginal posted) and it generates warnings :-(
> Here is the script that I have tried:

> if ( ($test_date >= ParseDate("$start_date"))

> Argument "2001022500:00:00" isn't numeric in numeric ge (>=) at


Why are you comparing strings with the >= operator?
What is unclear about "argument ... isn't numeric ..." ?
Please read "perldoc perlop" and read the part for "Relational Operators"


> I guess it does work! however, whenever perl generates warnings it usally
> tells
> me that I am doing something wrong. This is the reason I did not use this
> method.


Are you joking? The method is fine. It's usage needs revision.

-- 
KP



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

Date: 24 Jan 2003 06:17:43 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: newbie question on reference ??
Message-Id: <776e0325.0301240617.3e80ae28@posting.google.com>

Thens <thens@nospam.com> wrote in message news:<20030124114425.5fed5632.thens@nospam.com>...
> Hi,
>    I recently encountered this in one of the message in this group. What
> does this piece of code mean
> 
>  $row = +{};
> 
> It says this creates a new entry in the DS.
> 
> TIA for your help.
> 
> Thanks and Regards
> Thens.

Hi Thens. I just checked again in Camel- I don't see any discussion
about a "monadic + operator". I tried the example you gave and it
seems to work OK, creating a typical anon hashref. Why the compiler
doesn't complain about it? I'm not sure- I can't tell what it's
interpreting it as. Curiously,

  $row = -{};

worked fine as well. However *{} doesn't work, nor does /{}. The
latter two I think are being interpreted as a improperly formed blob,
and the opening of a regex respectively.

 However, the compiler is happy with this as well:

$row = +-+---+-++{};

Like an undersized pompano, interesting catch, but not particularly
useful. Toss it back!

Gx


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

Date: Fri, 24 Jan 2003 15:16:23 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: newbie question on reference ??
Message-Id: <x7el72mvcp.fsf@mail.sysarch.com>

>>>>> "S" == Sara  <genericax@hotmail.com> writes:

  S> Thens <thens@nospam.com> wrote in message news:<20030124114425.5fed5632.thens@nospam.com>...
  >> Hi,
  >> I recently encountered this in one of the message in this group. What
  >> does this piece of code mean
  >> 
  >> $row = +{};
  >> 
  >> It says this creates a new entry in the DS.
  >> 
  >> TIA for your help.
  >> 
  >> Thanks and Regards
  >> Thens.

  S> Hi Thens. I just checked again in Camel- I don't see any discussion
  S> about a "monadic + operator". I tried the example you gave and it
  S> seems to work OK, creating a typical anon hashref. Why the compiler
  S> doesn't complain about it? I'm not sure- I can't tell what it's
  S> interpreting it as. Curiously,

in perl they are called unary operators and they are fully
documented. in perldoc perlop you will see in the precedence table the
unary operators ! ~ \ and + and -. later you will find the section
Symbolic Unary Operators which covers unary + and its use as a syntactic
way to disambiguate values (as opposed to operators or blocks). the
above example is a very poor one as $x = {} is fine in all cases. but
when you are trying to return an anon hash and perl might think you have
a block instead, the unary + tells perl it is a value and therefore a hash.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


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

Date: Fri, 24 Jan 2003 09:24:47 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie question on reference ??
Message-Id: <slrnb32mlv.f1f.tadmc@magna.augustmail.com>

Sara <genericax@hotmail.com> wrote:
> Thens <thens@nospam.com> wrote in message news:<20030124114425.5fed5632.thens@nospam.com>...

>>    I recently encountered this in one of the message in this group. What
>> does this piece of code mean
>> 
>>  $row = +{};

> Hi Thens. I just checked again in Camel- I don't see any discussion
> about a "monadic + operator". 


Looking up "monadic" at www.dictionary.com yields:

   1. <programming> unary, when describing an operator or
      function. The term is part of the dyadic, niladic
      sequence.

So Thens was talking about what is more usually called a
"unary operator".

unary + is a "plus sign".

It is often used to disambiguate things for the perl parser, but
is not needed in the code above, because it is not ambiguous in
the first place.

For more discussion about helping the parser recognize the
semantics that you want it to recognize, see:

   Message-Id: <slrnatq036.2q2.tadmc@magna.augustmail.com>


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 24 Jan 2003 15:07:23 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: OT: TOFU, jeopardy and spoilers
Message-Id: <slrnb32llb.dce.abigail@alexandra.abigail.nl>

Steven Smolinski (steven.smolinski@sympatico.ca) wrote on MMMCDXXIX
September MCMXCIII in <URL:news:hI_W9.1494$VS6.275799@news20.bellglobal.com>:
==  Uri Guttman <uri@stemsystems.com> wrote:
== > 
== > the entire group enforces the rule that those posts have spoiler in
== > their subject and plenty of blank (or spoiler) lines before the actual
== > spoiler itself. 
==  
==  I dislike this, because of the scrolling.  My (and many other good)
==  newsreader(s) interpret anything after an ascii 0x0c (^L or FF) as a
==  spoiler, and mask the text as all asterisks.  When a special key is
==  pressed, the spoilers are revealed.  

Of course, long standing Usenet tradition (but who remembers them
nowadays) says you rot13 such spoilers. No need for scrolling (and thus
guessing the window size of the reader). No waste of transmitted bytes.


Abigail
-- 
I feel old


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

Date: Fri, 24 Jan 2003 15:42:43 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: OT: TOFU, jeopardy and spoilers
Message-Id: <3E315E99.B88AD012@acm.org>

Abigail wrote:
> 
> Abigail
> --
> I feel old

Your JAPH doesn't work.  :-(


John "I feel older then you do"
-- 
use Perl;
program
fulfillment


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

Date: Fri, 24 Jan 2003 15:05:10 GMT
From: "codeWarrior" <GPatnude@adelphia.net>
Subject: Re: Perl & CGI Security
Message-Id: <GCcY9.1169$ni5.718675@news1.news.adelphia.net>

Look into SSL....


"Alex Banks" <alex@alexbanks.com> wrote in message
news:3e3110c9$0$232$cc9e4d1f@news.dial.pipex.com...
> Would be grateful if someone could recommend an up-to-date security guide
> for CGI Perl.
>
> Thanks,
>
>
> Alex
>
>




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

Date: 24 Jan 2003 17:43:31 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Perl & CGI Security
Message-Id: <u9iswe1m0s.fsf@wcl-l.bham.ac.uk>

"codeWarrior" <GPatnude@adelphia.net> rudely and arrogantly top-posts
another nonsensical answer:

> "Alex Banks" <alex@alexbanks.com> wrote in message
> news:3e3110c9$0$232$cc9e4d1f@news.dial.pipex.com...
> > Would be grateful if someone could recommend an up-to-date security guide
> > for CGI Perl.
>
> Look into SSL....

Gee... this is getting surreal.

Is "codeWarrior" really "Ask Jeeves"?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\     
 ###LL  LL\\


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

Date: 24 Jan 2003 08:05:28 -0800
From: magic@tublet.freeserve.co.uk (Michael)
Subject: Re: Perl Thread Tk Web Server problem
Message-Id: <e4f7604c.0301240805.765f7fac@posting.google.com>

Thanks for the help Benjamin.

Michael


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

Date: Fri, 24 Jan 2003 14:06:40 +0000 (UTC)
From: mauzo@ux-ma160-13.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Reading French-Accented Data
Message-Id: <b0rh9g$2kl$1@wisteria.csv.warwick.ac.uk>

dave@fraleigh.net (Dave Fraleigh) wrote:
>> Which version of Perl are you using? 5.8 will need a
>> binmode FILEHANDLE, ":encoding(iso8859-1)"
>> or some such before Perl can correctly convert Latin-1 into Unicode.
>> Also, it's a bad idea to put top-bit-set characters directly in the source,
>> unless you know what you're doing. In 5.8 you can do it with the encoding
>> pragma, in 5.6.1 you can (I think) use latin1 by default or utf8 with the utf8
>> pragma.
>> 
>> Ben
>
>At present, I'm using 5.6.1 - how do you mean use latin1 by default?

Sorry: it wasn't terribly clear.

What I meant was that (when using Perl 5.6.1) any byte in the source with
the high-bit-set will be assumed to be encoded in ISO-8859-1 and will be
appropriately mapped to Unicode.

However, it seems that this isn't your problem: Alan Flavell's post is more
on the right track. You have your encodings in a mess.

Ben



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

Date: 24 Jan 2003 10:01:15 -0800
From: dave@fraleigh.net (Dave Fraleigh)
Subject: Re: Reading French-Accented Data
Message-Id: <22f677f.0301241001.46bea31b@posting.google.com>

So, I've established that the character Mappings are as follows, using
the link
http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT as:

my %charMap = ("c7"=>"80","fc"=>"81","e9"=>"82","e2"=>"83","e4"=>"84","e0"=>"85","e5"=>"86","e7"=>"87","ea"=>"88","eb"=>"89","e8"=>"8a","ef"=>"8b","ee"=>"8c","ec"=>"8d","c4"=>"8e","c5"=>"8f","c9"=>"90","e6"=>"91","c6"=>"92","f4"=>"93","f6"=>"94","f2"=>"95","fb"=>"96","f9"=>"97","ff"=>"98","d6"=>"99","dc"=>"9a");

This should, in theory, give me an appropriate mapping of the
characters (right?)

-the key/value pair in the above hash is a reference between the hex
value of the unicode character (key) and the hex value of the CP437
character (value)-

So, If I do the following:

my $fileName = 'afile.txt';
if (-e $fileName) {
    open (TEMPFILE,$fileName) || die ("No File found at $fileName\n");
    my $line = <TEMPFILE>;
    my $line2 = "";
    while (defined($line)) {
        $line2 = "";
        chomp($line);
        for (my $i=0; $i<=length($line); $i++) {
            my $decChar = ord(substr($line,$i,1));   
            my $hexChar = lc(sprintf("%X", $decChar));
            if (exists($charMap{$hexChar})) {
                $line2 = $line2 . chr(hex($charMap{$hexChar})) .
chr($decChar);
            } else {
                $line2 = $line2 . chr($decChar);
            }
        }
        print ("$line - [$line2]\n");
        
        $line = <TEMPFILE>;
    }
    close(TEMPFILE);
}

Then, in theory, the outputted text should be [original text] -
[original text], rather than [outputted text] - [garbled text]

here's the two-line file I'm testing it with.
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
ÇüéâäàåçêëèïîìÄÅÉæÆôöòû

BTW, I'm using ActiveState perl 5.6.1...

Thanks again :)
Dave


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

Date: 24 Jan 2003 16:20:10 GMT
From: ctcgag@hotmail.com
Subject: reflected form of $/
Message-Id: <20030124112010.680$wl@newsreader.com>

I was tempted to say the opposite of $/, but I figure that that would be
$\. So I will call this reflected rather than opposite.

I often have to process data that is a concatenation of a bunch of files.
The first line of each subfile is distinctive, but the last lines are
not.

I want a functionality similar to that given by $/, but having the
separator be at the front of the record, rather than the end.

I can do:

my @x=split /(?<=.)(?=\Q$recsep\E)/s, do {local $/; <STDIN> };

But that requires the whole thing to be slurped into memory
at once.  (or at twice, counting both @x and the anonymous scalar)

Or I could reverse the file, set $/= reverse $recsep, then reverse
the read lines both listly and scalarly, but that is more cute than
practical.

Or I could just run through the file myself, peeling off lines and
checking and/or storing them, then concatentating them to return
a scalar.  But that's just annoying.

I'm sure other people have to do this over and over again, so there
must be some perl tool/module for it.  But I haven't been able to find one,
probably because I don't know the words to search under.  Anyone have
a hint for me?

Thanks,

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: 24 Jan 2003 15:15:43 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Reverse Inheritance?
Message-Id: <slrnb32m4v.dce.abigail@alexandra.abigail.nl>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMCDXXX
September MCMXCIII in <URL:news:b0je3n$f96$4@mamenchi.zrz.TU-Berlin.DE>:
||  Malte Ubl  <ubl@schaffhausen.de> wrote in comp.lang.perl.misc:
|| > Anno Siegel wrote:
|| > > Ben Morrow <mauzo@mimosa.csv.warwick.ac.uk> wrote in comp.lang.perl.misc:
|| > >     
|| > > 
|| > >>    eval "require $backend";
|| > >>    $@ and die $@;
|| > > 
|| > > 
|| > > I'd rather avoid string eval here and write
|| > > 
|| > >     require "$backend.pm";
|| > 
|| > Just out of curiosity: Why?
||  
||  Well, string eval is a potentially dangerous operation and requires
||  careful checking of the string(s) involved.  So it's a stumbling block
||  in the way of anyone reading the program.

But since you create $backend yourself, without any user supplied code,
this isn't dangerous at all.

||  Also, it is huge overkill to start another interpreter run just
||  to load a module.

Come again? How do you think Perl knows what to do with the code
in "$backend.pm"? Divine mindsight? You already need an interpreter
to compile the content of the code in "$backend.pm".

BTW, note that 'require "$backend.pm"' is going to fail if $backend
contains 'Foo::Whatever'. You'd have to parse $backend, and substitute
the right path separator for '::'.

||                     While efficiency is no concern in this case,
||  it is good engineering to do things with as little expenditure
||  as possible.

You haven't convinced me your in Perl parsing for $backend outweights
the in C dealing with the eval.


Abigail
-- 
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
          q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'


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

Date: 24 Jan 2003 15:28:57 GMT
From: ctcgag@hotmail.com
Subject: Re: slow grep
Message-Id: <20030124102857.380$Te@newsreader.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>
> It's not grep-specific that {} slows things down.

<snip demo where extraneous braces slow things down>

That's rather impressive.  I figured {} that didn't do anything useful
would be ignored (i.e. compile down to the same op-tree).  Since redo,
last, and next are dynamic, pehaps it's just too difficult to verify which
braces are useless.

I've been using {} in greps and maps just because I like it stylistically
over the expression form.  Perhaps I should stop doing that.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: 24 Jan 2003 09:40:44 -0800
From: roy@SiliconTao.com (Roy Souther)
Subject: Term::ReadKey non-blocking non-working in RH8.0
Message-Id: <62e7caea.0301240940.1ec77c5@posting.google.com>

I just upgraded to RH8.0 and Term::ReadKey does not work in
non-blocking mode!
ReadMode(4);

I tried the same program on Mandrake 9.0, both have Perl 5.8 and it
works find on Mandrake 9.0. I think this is a kernel problem because
RH 8.0 is still using the 2.4.18 kernel. I did the Red Hat up2date and
now have the newest one from there but still the same problem.

Can someone confirm this for me or point me to a fix please.

Is there a site to get the new kenel 2.4.19 for RedHat 8.0?


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

Date: Fri, 24 Jan 2003 15:35:42 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: unlink()
Message-Id: <3E315CF3.FA0094ED@acm.org>

Koos Pol wrote:
> 
> Helgi Briem wrote (Friday 24 January 2003 13:48):
> >
> > I wonder about this.  Randal does the same.  Was all
> > the effort OS designers expended on buffering output
> > really that much of a waste?  You would have thought
> > they had some reason for doing it.
> 
> Can it have to do with the time that teletypes were used for STDOUT? I can
> imagine it is very expensive to handle teletype characters one at a time.

I remember using a teletype (an actual teletype, not a terminal) to
communicate between Vancouver and Toronto and the only buffer they had
was the paper tape reader/writer on the side.  :-)


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 24 Jan 2003 11:50:39 -0600
From: "Brett" <bbsouth@bellsouth.net>
Subject: Re: What does this header mean?
Message-Id: <dYeY9.4574$zt5.323@news.bellsouth.net>


<Andrew Lee> wrote in message
news:al623vclu61e9ccp9bkh3856ojem7adufa@4ax.com...
> On Thu, 23 Jan 2003 18:46:14 -0600, "Brett" <bbsouth@bellsouth.net>
> wrote:
>
> >I'm running a CGI script that has an .exe extension on Win2k Server.  The
> >.exe extension is linked to run Perl.  I get this message when I run the
> >script:
> >
> >CGI Error
> >The specified CGI application misbehaved by not returning a complete set
of
> >HTTP headers. The headers it did return are:
> >Can't open perl script "C:\Inetpub\domain.com\cgi-bin\Count.exe": No such
> >file or directory
> >
> >The directory is correct and file does exist.  Is this coming from the
> >script or Perl?  What does it mean exactly?
>
> Stop and think about it for a moment ... what component is printing the
> error message?
>
> Could it be the Web server?
>
> The Web server is telling you that instead of printing :
> "Content-type: text/html\n\n"
> (or whatever MIME type you want to send to browser), the cgi program is
> printing "Can't open perl script ... "  Which means exactly what it
> says.  You have a configuration snafu.  Consult your Web server's
> documentation and ask around in an appropriate newsgroup about "HTTP
> Headers" or "Server Configuration for /Apache|IIS|Other/."
>

The problem is I had .exe linked to run Perl.  I removed that link and it
works fine now.

Thanks,
Brett





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

Date: 24 Jan 2003 17:39:56 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: win32 tieregistry html
Message-Id: <u9n0lq1m6r.fsf@wcl-l.bham.ac.uk>

"Nuno Cancelo" <nac@advancecare.com> writes:

> Subject: win32 tieregistry html

HTML?  Where does HTML come into this?

> i'm making a perl script to  identify the current logged username in the
> system.
> this is the script
> #!c:\perl\bin\perl
> use Win32::TieRegistry;
> $username=$Registry->{"HKEY_CURRENT_USER\\Software\\Microsoft\\"
> . "Windows\\CurrentVersion\\Explorer\\\\Logon User Name"};

> Now the problem.
> 
> when i run it on dos prompt window, it gives what i whant, but
> 
> when i run it on Internet Explorer, nothing is shown, and i can't figure it
> out why.

You are allowing yourself to be confused by your own sloppy
terminology.

That's the third time I've said that in 24h.

I think this this must be an epidemic.

When you say "run it on Internet Explorer" you really mean "run it on
a web server (using IE as a client to that server)".

When you say it properly it becomes obvious that the user registry
that a script running on a web server sees is the one belonging to the
user as which the web server executes.  It cannot not be the one
belonging to the user who is running the web client that may, in
general, not even be in the same Computer/OS/continent.

This, of course, has nothing to do with Perl.

I believe that when using M$ proprietory web client/server software
within a M$ domain there may be ways to get scripts to be executed as
the user logged into the client.  But like I said, this has nothing to
do with Perl.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

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


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