[22047] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4269 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 16 11:05:40 2002

Date: Mon, 16 Dec 2002 08:05:11 -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           Mon, 16 Dec 2002     Volume: 10 Number: 4269

Today's topics:
    Re: chained maps and greps <bart.lateur@pandora.be>
    Re: editing files (Tad McClellan)
        extract dir name from file path <N.Hirani@hgmp.mrc.ac.uk>
    Re: extract dir name from file path (Tad McClellan)
    Re: Getting the week day from a previous date. <bart.lateur@pandora.be>
    Re: hash efficiency and key/value/array reading file (Tad McClellan)
    Re: hash efficiency and key/value/array reading file (Tad McClellan)
    Re: HELP: MYSQL, IMAGES and PERL <pkent77tea@yahoo.com.tea>
        In place edit with $^I and multiple files, keeping SOME (qanda)
        Is it possible to change windows background via Perl? <jpagnew@vcu.edu>
        Is there a better way of doing this? (Jimbo)
    Re: Is there a better way of doing this? <simon.oliver@umist.ac.uk>
    Re: Is there a better way of doing this? <bernard.el-hagin@DODGE_THISlido-tech.net>
        Obtaining a ref to a hash using an element of the hash <richard@zync.co.uk>
    Re: Obtaining a ref to a hash using an element of the h <bart.lateur@pandora.be>
    Re: Obtaining a ref to a hash using an element of the h <richard@zync.co.uk>
    Re: OT: Re: Get current date / time? <pkent77tea@yahoo.com.tea>
    Re: OT: Re: Get current date / time? (Helgi Briem)
    Re: OT: Re: Get current date / time? (=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=)
        PErl and CSS (ToxicFungi)
    Re: Perl timeout without killing script? (Anno Siegel)
    Re: Piping HTML tags (total newbie question) <me@privacy.net>
    Re: Piping HTML tags (total newbie question) <ashfaaq.usman@bt.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 16 Dec 2002 11:25:06 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: chained maps and greps
Message-Id: <jmdrvugtht88tta6t44n8ivho4h5i0jalj@4ax.com>

<foobear@nospam.doom.net> wrote:

>#one liner attempt, doesn't work, but shows what I have in mind
>return map { my $s = $_; grep { $s->id eq $_ } @ids } $self->sessions if @ids;

It doesn't work? It looks about right to me. I've done things like this
in the past, so it should be possible to make it work.

You don't need the if(), the grep will return nothing with an empty
array. You could also reverse the order:

 return map { my $s = $_; grep { $_->id eq $s } $self->sessions } @ids;

I can't test it, buit it looks about right.

Hmm... you appear to be wanting the intersection of two lists. There's a
FAQ entry about that (perlfaq8, IIRC). Stuff one list in a hash, and
verify using the other list?

	my %exist; @exist{@id} = (1) x @id;
	return grep $exist{$_->id}, $self->sessions;

-- 
	Bart.


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

Date: Mon, 16 Dec 2002 09:21:00 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: editing files
Message-Id: <slrnavrrqs.dvc.tadmc@magna.augustmail.com>

Richard Cross <richard.cross@NOPSPAM.freeserve.com> wrote:

> for the PC 


   perldoc -f binmode


> I found out 

> that one of the binary config files (jedi.cfg) can be edited in a hex 
> editor (I used UltraEdit), if you replace the bytes at certain offset 
> values with the desired keyboard codes

> Now I want to write something in Perl to make this easier for anyone else 
> to accomplish.  Is there an easy way of being able to read a file in Perl 
> such that each line is exactly 16 bytes long and can easily be separated 
> into bytes' hex values.  


The concept of "lines" is only applicable to text files.

Binary files do not have "lines", so you must have meant "records"
or some such.

   perldoc -f read


> I also need each line of the file to be number in 
> hex too.


To convert from a hexidecimal representation to the number
that it represents:

   perldoc -f hex

To convert from a number to its hexidecimal representation:

   perldoc -f sprintf         # %x or %X


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


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

Date: Mon, 16 Dec 2002 15:01:28 +0000
From: Naran Hirani <N.Hirani@hgmp.mrc.ac.uk>
Subject: extract dir name from file path
Message-Id: <3DFDEAC7.509B14AA@hgmp.mrc.ac.uk>

Hi,

I'm sure there is a very simple solutions to this but I can't seem to
work it out :-)
I have a fully qualified path name to a file which may or may not have
an extension
- all I would like to do is strip away the file name so I am left with
just the dir path to
this file.  What is the simplest RE that will achieve this for me?

TIA
Naran.




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

Date: Mon, 16 Dec 2002 09:51:53 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: extract dir name from file path
Message-Id: <slrnavrtkp.e8f.tadmc@magna.augustmail.com>

Naran Hirani <N.Hirani@hgmp.mrc.ac.uk> wrote:

> I'm sure there is a very simple solutions to this but I can't seem to
> work it out :-)

> I have a fully qualified path name to a file which may or may not have
> an extension
> - all I would like to do is strip away the file name so I am left with
> just the dir path to
> this file.  


   use File::Basename;
   $dirname = dirname($fullname);


> What is the simplest RE that will achieve this for me?


A regex is not always the Right Tool.

The answer depends on what your directory separator is, the above
is the portable way to do it.

If slash is your dir separator:

   $fullname =~ s#(.*)/.*#$1#s;
or
   $fullname =~ s#/[^/]*$##;


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


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

Date: Mon, 16 Dec 2002 13:59:25 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Getting the week day from a previous date.
Message-Id: <9fmrvuka9gink25g00rh85rc1dms4s6vhn@4ax.com>

rob.buxton@wcc.spam.govt.nz wrote:

>I thought I should be able to load the variables into the
>localtime(EXPR) function and use that to retrieve the details for an
>earlier date.
>
>Alas, all attempts give me a date of Jan 1, 1970.
>Is there a way to achieve this?

Yes. With Time::Local, a standard modules (meaning you should have it),
you can turn a date into a time() value, with timelocal() (= localtime()
reversed). From this, with localtime(), you can get the weekday number.

Actually IMO it might be safer, with regards to summer time, to use
timegm() and gmtime(), not timelocal() and localtime(). Eh, no, in this
case, you're safe, as you don't actually do any calculations with this
date. Oh well, it doesn't hurt. It's safer, in general, to use GMT for
such calculations.

Note that the month number is zero based, and for the year, you can
either use the common 4 digit year, or the year minus 1900.

	use Time::Local;
	my $time = timelocal(0, 0, 12, 16, 11, 2002);  # noon
	my $wday = (localtime($time))[6];
	print "This post was written on a weekday #$wday.\n";

-- 
	Bart.


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

Date: Mon, 16 Dec 2002 08:15:50 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: hash efficiency and key/value/array reading file
Message-Id: <slrnavro0m.dvc.tadmc@magna.augustmail.com>

qanda <fumail@freeuk.com> wrote:

> #!/usr/bin/perl -w

> use warnings;


Enabling warnings twice won't help much.  :-)

Lexical warnings are "better", so lose the -w switch.


> sub get_config {
> 	my $frc = 0;			# Function return code, default to fail.
> 	my %config_keys;		# Keys required.
> 	my %config_values;		# Values of keys.
> 
> 	@config_keys{ qw(
> 		KEY2
> 		KEY5
> 	)} = ();
> 
> 	# Load keys required.
> 	while( <DATA> ) {
> 		chomp;


No point in removing the newline here when the next statement
will also remove it.


> 		# Remove blank lines and comments.
> 		s/\s+|#.*$//g;


The comment is misleading, it removes more than what you've mentioned.

It removes spaces on non-blank, non-comment lines too.

If it was a blank line, it is now the empty string. No point in
further processing it if that is the case.

    next unless /\S/;   # skip blank lines
   

> 		# Only keep keys with values.
> 		if (/(\S+)=(\S+)/) {
> 			next if ! exists $config_keys{ $1 };
> 			$config_values{ $1 } = $2;
> 		}


You can do it in one statement:

   $config_values{ $1 } = $2 if exists $config_keys{ $1 };


> 		$frc = 1; # Set to success here?


Not if "success" means: found all the keys in %config_keys.

The way it is, you declare success if _any one_ of the keys is found,
though you "take it back" in the loop below.


> 	}
> 
> 	# HELP - Want to wrap this test into above loop.
> 	foreach my $key( keys %config_keys ) {	
> 		if( ! exists $config_values{$key} ) {
> 			print "$key not found!\n";
> 			$frc = 0;
> 		}	


If you want to test that you've found them all, you can move
it into the loop (see below).

If you want to test that none are missing, then you can't
move it into the loop. You have to examine them all before
you can declare failure. :-)


> 	}
> 	return $frc;
> }
> 
> __DATA__


> KEY2 = # key2_value # comment on key/value line with value
         ^                                        ^^^^^^^^^^
         ^ start of a comment

But that line does _not_ have a value, only a comment.

(unless you use an unusual definition for what is a comment)


> This is fine for the data given however very inefficient with a large
> data set.  It there a way I can check in the loop that the requied
> keys have a value?


I think you want to exit the loop if you've already found them all?

   last if keys %config_keys == keys %config_values;

or, better:

   return 1 if keys %config_keys == keys %config_values;


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


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

Date: Mon, 16 Dec 2002 08:40:37 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: hash efficiency and key/value/array reading file
Message-Id: <slrnavrpf5.dvc.tadmc@magna.augustmail.com>

qanda <fumail@freeuk.com> wrote:

> Thanks for the help, I've now ended up with this ...

> sub get_config {


I'd do it this way:

-------------------------------------
sub get_config {
        my %config_keys;                # Keys required.
        my %config_values;              # Values of keys.

        @config_keys{ qw(
                KEY2
                KEY5
        )} = ();

        while( <DATA> ) {
                s/#.*//;            # strip comments
                next unless /\S/;   # skip blank lines
                s/\s+//g;           # delete whitespace

                # Only keep keys with values.
                if (/^(\S+)=(\S+)$/) {
                   $config_values{ $1 } = $2 if exists $config_keys{ $1 };
                }

                # finished if we've already found them all
                return 1 if keys %config_keys == keys %config_values;
        }

        # failed if we got this far
        foreach my $key ( keys %config_keys ) {
                print "$key not found!\n" unless exists $config_values{$key};
        }
        return 0;
}
-------------------------------------


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


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

Date: Mon, 16 Dec 2002 13:30:38 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: HELP: MYSQL, IMAGES and PERL
Message-Id: <pkent77tea-0F93A6.13303816122002@news-text.blueyonder.co.uk>

In article <atf9tg$vci$1@lacerta.tiscalinet.it>,
 "Federico Bari" <fede72bari@tiscali.it> wrote:

> <img src="/cgi-bin/show_image_n.pl=876">
> 
> where the show_image_n.pl take the binary code of image 876 from a mysql
> database and "print" it. I tried but i doesn't work. Somebody could help me?

This isn't necessarily your problem, but when I call a URL such as:
http://webserver/cgi-bin/env.pl=2112

I get a 404 response (using Apache) whereas 'env.pl' by itself is fine. 
Perhaps you should use path info or a query string.

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: 16 Dec 2002 05:56:38 -0800
From: fumail@freeuk.com (qanda)
Subject: In place edit with $^I and multiple files, keeping SOME originals.
Message-Id: <62b4710f.0212160556.68032f54@posting.google.com>

Hi all, in line with previous posts I have this ...

#!/usr/bin/perl -w

use diagnostics -verbose;
use warnings;
use strict;

extract_recs();

sub extract_recs {
	open( RECA, ">reca.out" ) or die "Can't open reca.\n";
	open( RECB, ">recb.out" ) or die "Can't open recb.\n";

	# In place edit by <> construct.
	local $^I = '.orig';
	local @ARGV = glob("abc*.dat");

	# For each file.
	while ( <> )
	{
		# Ingore blank lines.
		next if /^\s+$/;

		# Split records into fields.
		my @type = split( /,/, $_, -1 );

		# Save valid type A records.
		if( $type[2] eq 'A' && $type[5] ) {
			print RECA;
		}
		# Save valid type B records.
		elsif( $type[2] eq 'B' && $type[5] ) {
			print RECB;
		}
		else {
			print;
		}

		# Check something else in current file
		# if OK do_action_1 then delete orig file
		# else do_action_2 then keep orig file
	}
}
Example data in files ...

1,2,D,4,5,d_val,7

1,2,A,4,5,a_val,7
1,2,A,4,5,,7
1,2,B,4,5,b_val,7
1,2,C,4,5,c_val,7

1,2,D,4,5,,7
1,2,B,4,5,,7

1,2,C,4,5,,7

First note I used a comma as the separator so it could be seen here,
in fact it is a backspace or delete character.

I would like to test some condition within each file and depending on
the result either remove or keep the original.  The above seems to
work OK however I don't know how to reference the individual files.

One other query, since discovering the wonderful __DATA__ idea I use
this for example data, can we replicate MULTIPLE files using this?

Thanks.


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

Date: Mon, 16 Dec 2002 10:29:06 -0500
From: Jim Agnew <jpagnew@vcu.edu>
Subject: Is it possible to change windows background via Perl?
Message-Id: <3DFDF142.A1E1E9BC@vcu.edu>

i have a website (http://www.ssec.wisc.edu/data/east/latest_eastvis.gif)
that the image I'd then take and make it my background, haveing a live
satellite map of the eastern us on my desktop... (one of my few toys).

I could automate this on vax/vms using xv from a subprocess (or child
process)

is it possible to automate this using Perl?  Any pointers to how to do
the windows background would be helpfull, and i already have most of the
other stuff like ftp'ing the image down, the timing, etc..  

Thanks!!!


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

Date: Mon, 16 Dec 2002 13:21:39 GMT
From: nobody@nobody.com (Jimbo)
Subject: Is there a better way of doing this?
Message-Id: <DrkL9.458$gt3.24670@amsnews02.chello.com>

Hi I have an array and I want to make it a hash like this:

my @array = (999, 'john','smith','elmstreet','9');

my %nameinfo = ( id             => $array[0],
                              firstname => $array[1],
                              lastname => $array[2],
                              street       => $array[3],
                              nr             => $array[4] );









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

Date: Mon, 16 Dec 2002 13:53:09 +0000
From: Simon Oliver <simon.oliver@umist.ac.uk>
To: Jimbo <nobody@nobody.com>
Subject: Re: Is there a better way of doing this?
Message-Id: <3DFDDAC5.9090503@umist.ac.uk>

Jimbo wrote:
> Hi I have an array and I want to make it a hash like this:
> 
> my @array = (999, 'john','smith','elmstreet','9');
> 
> my %nameinfo = ( id             => $array[0],
>                               firstname => $array[1],
>                               lastname => $array[2],
>                               street       => $array[3],
>                               nr             => $array[4] );

Depends what you want to do?

Do you mean something like this?

my @array;
my %hash;

@array = (999, 'john','smith','elmstreet','9');
@hash{qw(id firstname lastname street nr)} = @array;



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

Date: Mon, 16 Dec 2002 14:16:04 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Is there a better way of doing this?
Message-Id: <slrnavrnrb.14n.bernard.el-hagin@gdndev25.lido-tech>

In article <DrkL9.458$gt3.24670@amsnews02.chello.com>, Jimbo wrote:
> Hi I have an array and I want to make it a hash like this:
> 
> my @array = (999, 'john','smith','elmstreet','9');
> 
> my %nameinfo = ( id             => $array[0],
>                               firstname => $array[1],
>                               lastname => $array[2],
>                               street       => $array[3],
>                               nr             => $array[4] );


my @array = qw(999 john smith elmstreet 9);
my @keys  = qw(id firstname lastname street nr);

my %nameinfo;
@nameinfo{@keys} = @array;


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Mon, 16 Dec 2002 14:54:05 +0000
From: "Richard Gration" <richard@zync.co.uk>
Subject: Obtaining a ref to a hash using an element of the hash
Message-Id: <20021216.145404.937370163.997@richg.zync>

Hi all,

I have the following circular reference situation and am looking at ways
to resolve it.

I have a hash %i (the "input" hash) and this is used to hold just about
every useful datum my program uses. This is passed to every sub I use, it
holds inputs, options, return values etc. One value of this hash is an
object ( ie another hash ref). Some of the object methods need to use the
%i input hash, so I store a ref to it in one of the object's properties.
This is blatantly a circular reference.

$i->{qn} = new MyPackage::Qn(\%i);

# This is actually done in the object constructor code
$i->{qn}->[i} = $i;	<--- Aaargh! Can't see a way to avoid it ...

 ... unless I can somehow recover a reference to %i from $i->{qn}
(available as $self in the object methods). Is this possible ??

ATM, the circular reference is not really a problem because this is a
suite of CGIs. But I might turn it all into Apache modules, so then
I'll have GC issues.

Can anyone see through the trees to glimpse the wood??

Rich


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Mon, 16 Dec 2002 15:56:02 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Obtaining a ref to a hash using an element of the hash
Message-Id: <4htrvu023b8cp65v2b1ta3r36kqami75gf@4ax.com>

Richard Gration wrote:

>$i->{qn} = new MyPackage::Qn(\%i);
>
># This is actually done in the object constructor code
>$i->{qn}->[i} = $i;	<--- Aaargh! Can't see a way to avoid it ...
>
>... unless I can somehow recover a reference to %i from $i->{qn}
>(available as $self in the object methods). Is this possible ??

I think not.

>ATM, the circular reference is not really a problem because this is a
>suite of CGIs. But I might turn it all into Apache modules, so then
>I'll have GC issues.

That can be solved, by storing a weakened reference to the hash. This
means that it is an actual normal reference to the hash, but not one
that will keep the hash alive. Thus, if there's no other remaining
reference to this hash, it will disappear.

"weaken" used to be in a module of its own, but it has been assimilated
into a possibly more common module, namely Scalar::Util. You might even
have it on your system.

-- 
	Bart.


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

Date: Mon, 16 Dec 2002 16:04:37 +0000
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: Obtaining a ref to a hash using an element of the hash
Message-Id: <20021216.160437.1070575321.997@richg.zync>

In article <4htrvu023b8cp65v2b1ta3r36kqami75gf@4ax.com>, "Bart Lateur"
<bart.lateur@pandora.be> wrote:
<SNIP>
> That can be solved, by storing a weakened reference to the hash. This
> means that it is an actual normal reference to the hash, but not one
> that will keep the hash alive. Thus, if there's no other remaining
> reference to this hash, it will disappear.  "weaken" used to be in a
> module of its own, but it has been assimilated into a possibly more
> common module, namely Scalar::Util. You might even have it on your
> system.

Splendid :-)

Thank you for the reply
Rich


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Mon, 16 Dec 2002 14:04:12 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: OT: Re: Get current date / time?
Message-Id: <pkent77tea-0C4B61.14041116122002@news-text.blueyonder.co.uk>

In article 
<Pine.LNX.4.40.0212141513200.25180-100000@lxplus071.cern.ch>,
 "Alan J. Flavell" <flavell@mail.cern.ch> wrote:

> "standard" and "in everyday use"?  The introduction of metric units
> into everyday life in various parts of the former British Empire has
> been relatively recent (and the British themselves are still hovering
> on the brink, as they have been doing for 30 years or more...)

Oi! CERN-boy! :-) Some British (well, maybe "a lot" of British) people 
are still, in whole or in part, using Imperial measure, but it's wrong 
to say the entire country is hovering on the brink of using Metric 
measure in everyday life - it's already there and people use it plenty 
TYVM.

OTOH I say this as a scientist, whose mum worked with metric measure 
professionally (pour encourager les autres), whose dad does a fair bit 
of DIY (everything in Homebase seems to have the metric measurements 
displayed more prominently, for example) and who lives in the more 
metropolitan end of the country.

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: Mon, 16 Dec 2002 14:54:18 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: OT: Re: Get current date / time?
Message-Id: <3dfde207.1016153121@news.cis.dfn.de>

On Sat, 14 Dec 2002 16:18:39 +0100, "Alan J. Flavell"
<flavell@mail.cern.ch> wrote:

>On Dec 13, Helgi Briem inscribed on the eternal scroll:
>
>> On Thu, 12 Dec 2002 19:26:16 +0100, "Alan J. Flavell"
>
>> >Y2K was a good moment to make a break with the past and do the same
>> >with date formats.  How about it?
>>
>> Why don't you tell them to convert over to the metric
>> system while they're at it?
>
>Insisting on coupling one relatively simple change to another much
>more radical change is a good way to ensure that neither of them will
>be successful!

My point was that apparently the metric system has
been to complex for them to adopt, so expecting them
to change their date format is an equally lost cause.

Americans made a mistake when they defined a billion,
but there's a lot of them, and they're influential, so 
eventually the rest of the world had to copy their 
dumb way and not the other way around.  

Power beats intelligence any day of the week.

>I found it quite amusing that both the Germans and the French still
>refer to a "pound" (Pfund, Livre) as a convenient unit of weight,
>albeit referring to 500g as a metric multiple. 

In Iceland we use pund (500g), mörk (250g), hálfpottur 
(0.5L) and peli (0.25L) as convenient everyday measures,
but they are fully metric.  
-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: 16 Dec 2002 16:03:41 +0100
From: mru@users.sourceforge.net (=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=)
Subject: Re: OT: Re: Get current date / time?
Message-Id: <yw1x1y4ihupe.fsf@lakritspipa.e.kth.se>

helgi@decode.is (Helgi Briem) writes:

> >> >Y2K was a good moment to make a break with the past and do the same
> >> >with date formats.  How about it?
> >>
> >> Why don't you tell them to convert over to the metric
> >> system while they're at it?
> >
> >Insisting on coupling one relatively simple change to another much
> >more radical change is a good way to ensure that neither of them will
> >be successful!
> 
> My point was that apparently the metric system has
> been to complex for them to adopt, so expecting them
> to change their date format is an equally lost cause.
> 
> Americans made a mistake when they defined a billion,
> but there's a lot of them, and they're influential, so 
> eventually the rest of the world had to copy their 
> dumb way and not the other way around.  

IMHO, the American number system is more logical.  It also has the
benefit of avoiding confusion with a fun game involving little balls
on a green table.

> Power beats intelligence any day of the week.

That is for sure.

-- 
Måns Rullgård
mru@users.sf.net


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

Date: 16 Dec 2002 07:40:18 -0800
From: toxicfungi@yahoo.com (ToxicFungi)
Subject: PErl and CSS
Message-Id: <a34dbdd.0212160740.3a032c28@posting.google.com>

Hi group,

I am trying to setup a message board for a website. This uses a perl
script. It is basically Matt's WWWBoard.

My website uses CSS, and the messageboard really looks sick, the way
it is.

I managed to make the default html forum page use CSS, but the problem
comes in, when the perl scripts creates new html code.

How can I modify the perl script to format any html code it spits out
to use CSS?

I am a vanilla perl/cgi personage.

any help would be appreciated.

feel fre to email me.

thanls
E


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

Date: 16 Dec 2002 12:03:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl timeout without killing script?
Message-Id: <atkfed$hc6$1@mamenchi.zrz.TU-Berlin.DE>

According to Tan D Nguyen <nospam@nospam.com>:
> 
> "Matt Oefinger" <oefinger@mit.edu> wrote in message
> news:e9b08c9f.0212131641.25a15a5e@posting.google.com...
> > I'm running a long loop of events, some of which are hanging. When an
> > event hangs it's NOT fatal, so I'm not happy with the default behavior
> > whereby Perl kills my script when the alarm event occurs. I'd instead
> > prefer that the alarm event just skips to the next foreach iteration.
> > Here's an example of my code...
> >
> > foreach(@)
> >   {
> >   eval {
> >        alarm 5;
> >        # code that occasionally hangs alarm 0;};
> >
> >        if ($@) {
> >        # timed out
> >                }
> >        else {
> >             # didn't
> >             }
> >   }
> >
> > As I've written it above, the alarm event will cause my script to die.
> > How can I fix it so that the alarm event merely spits out a print
> > statement then allows the loop to continue.
> >
> > Thanks in advance!
> 
> Put the if-else clause outside of eval.

It is (though the indentation may suggest otherwise).

To the OP:  The alarm signal, like other signals, can't directly be
trapped with "eval", they exit unconditionally.  You must catch the
signal in %SIG and die() there to make it catchable.  Add this early
to your code:

    $SIG{ ALRM} = sub { die 'timeout' };

Now eval will catch it.

Anno


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

Date: Mon, 16 Dec 2002 22:14:44 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Piping HTML tags (total newbie question)
Message-Id: <atkcj3$150nqk$1@ID-172104.news.dfncis.de>


"Ashfaaq Usman" <ashfaaq.usman@bt.com> wrote in message
news:3DFDB1EF.136FBB4C@bt.com...
>
> Hi,
>
> I am a total newbie and would appreciate any help with the following
> problem:
>
> What I want to do is run a function of some sort in Perl which I can
> provide a URL to, which will then suck the HTML tags from the requested
> URL and pipe this out to a text file on the client machine.
>
> Any idea how to do this....?

perl -MLWP::Simple -e 'getprint "http://www.example.com";' >somefile

or a longer form

#!/usr/bin/perl
use strict;
use warnings;

use LWP::Simple;
my $url = shift or die "Usage: $0 <url>\n";

 my $content = get($url);

if ($content) {
   open FILE, ">somefile" or die "Can not open somefile for writing $!\n";
   print FILE $content;
   close FILE;
}
else {
   print "No content retrieved from $url\n";
}






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

Date: Mon, 16 Dec 2002 11:54:16 +0000
From: Ashfaaq Usman <ashfaaq.usman@bt.com>
Subject: Re: Piping HTML tags (total newbie question)
Message-Id: <3DFDBEE8.C0A4A0E7@bt.com>

Tintin wrote:

> perl -MLWP::Simple -e 'getprint "http://www.example.com";' >somefile
>
> or a longer form
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> use LWP::Simple;
> my $url = shift or die "Usage: $0 <url>\n";
>
>  my $content = get($url);
>
> if ($content) {
>    open FILE, ">somefile" or die "Can not open somefile for writing $!\n";
>    print FILE $content;
>    close FILE;
> }
> else {
>    print "No content retrieved from $url\n";
> }

Thanks very much for this.... :-)


Ash




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

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


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