[21875] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4079 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 7 11:08:17 2002

Date: Thu, 7 Nov 2002 08:05:13 -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           Thu, 7 Nov 2002     Volume: 10 Number: 4079

Today's topics:
    Re: A vision for Parrot lvirden@yahoo.com
    Re: A vision for Parrot lvirden@yahoo.com
    Re: defaults in packages <garry@ifr.zvolve.net>
    Re: file order in opendir DH <chris.harris@cwfi.co.fk>
    Re: How to correctly use AUTOLOAD in derived class? <kevin@wx3.com>
    Re: How to locate Perl Interpreter <jurgenex@hotmail.com>
        Komodo Opinions <ihave@noemail.com>
    Re: Makefile.PL @INC PREFIX LIB [should be How do I kee <mothra@nowhereatall.com>
    Re: Makefile.PL @INC PREFIX LIB [should be How do I kee <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
    Re: Perfecting my Perl <jds@trumpetweb.co.uk>
    Re: Perfecting my Perl <tassilo.parseval@post.rwth-aachen.de>
    Re: Perfecting my Perl <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Perfecting my Perl <jurgenex@hotmail.com>
    Re: Perfecting my Perl (Tad McClellan)
    Re: Perfecting my Perl <tassilo.parseval@post.rwth-aachen.de>
        printf, sprintf help <ihave@noemail.com>
    Re: printf, sprintf help <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: printf, sprintf help <ihave@noemail.com>
    Re: printf, sprintf help <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: printf, sprintf help <ihave@noemail.com>
    Re: printf, sprintf help (Tad McClellan)
        Safety of Perl (Buck Turgidson)
    Re: Safety of Perl (Helgi Briem)
        seconds -> hours/min/secs <N.Hirani@hgmp.mrc.ac.uk>
    Re: seconds -> hours/min/secs (Helgi Briem)
    Re: seconds -> hours/min/secs <N.Hirani@hgmp.mrc.ac.uk>
    Re: seconds -> hours/min/secs <perl-dvd@ldschat.com>
    Re: seconds -> hours/min/secs (Helgi Briem)
    Re: setuid script <sheken@videotron.ca>
    Re: sh (bash) $1 equivalent <seppanen@chartermi.net>
    Re: Simple question - What is unicode? <flavell@mail.cern.ch>
    Re: Simple question - What is unicode? <flavell@mail.cern.ch>
    Re: Simple question - What is unicode? <tassilo.parseval@post.rwth-aachen.de>
    Re: Simple question - What is unicode? <flavell@mail.cern.ch>
    Re: Simple question - What is unicode? (Helgi Briem)
    Re: Simple question - What is unicode? <twhu@lucent.com>
    Re: Simple question - What is unicode? <flavell@mail.cern.ch>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 7 Nov 2002 13:25:21 GMT
From: lvirden@yahoo.com
Subject: Re: A vision for Parrot
Message-Id: <aqdpk1$5ur$2@srv38.cas.org>


According to Laotseu <bdesth@free.fr>:
:Frodo Morris <graham.lee@wadham.ox.ac.uk> wrote in message
:news:<aq8g9u$6c7$1@news.ox.ac.uk>...
:> that's what I call the conducting 
:> machine: "Apple" because it sends Jobs away, does nothing for a while 
:> then gets Jobs back :-) 

As long as your application is elegant, ergonometrically superior, and
technologically sexy, it will be an applicable name...
-- 
Tcl - The glue of a new generation.  <URL: http://wiki.tcl.tk/ >
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: mailto:lvirden@yahoo.com > <URL: http://www.purl.org/NET/lvirden/ >


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

Date: 7 Nov 2002 13:30:02 GMT
From: lvirden@yahoo.com
Subject: Re: A vision for Parrot
Message-Id: <aqdpsq$5ur$4@srv38.cas.org>


According to A.M. Kuchling <akuchlin@mems-exchange.org>:
:    Guile programmers?  If they're Guile programmers, they must like 
:    programming in Scheme.  Why would they work on translators for languages
:    they'll never use?

Perhaps a parallel example are the Java implementations of Python and
Tcl - these were written by Java programmers interested in having the
facilities of python / tcl in their java applications.

Perhaps Guile programmers never saw a need for the facilities of perl/tcl/
python.

-- 
Tcl - The glue of a new generation.  <URL: http://wiki.tcl.tk/ >
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: mailto:lvirden@yahoo.com > <URL: http://www.purl.org/NET/lvirden/ >


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

Date: Thu, 07 Nov 2002 15:38:22 GMT
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: defaults in packages
Message-Id: <slrnasl1u8.hls.garry@zfw.zvolve.net>

On Wed, 06 Nov 2002 16:17:05 +0100, Malte Ubl <ubl@schaffhausen.de> wrote:
> Garry Williams wrote:
> 
>> Perhaps a better style would be: 
>> 
>>     # set/get class attribute SOME_VAR
>>     sub SOME_VAR {
>>       $SOME_VAR = $_[1] if $_[1];
> 
> What if 0 or undef are valid values?

Oops.  

    $SOME_VAR = $_[1] if @_ > 1;

-- 
Garry Williams


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

Date: Thu, 7 Nov 2002 11:56:06 -0300
From: "Chris Harris" <chris.harris@cwfi.co.fk>
Subject: Re: file order in opendir DH
Message-Id: <aqdv09$93tvt$1@ID-134007.news.dfncis.de>

Thanks go everyone who replied. I have the anser now.

Last time I programmed anything was using C many years ago and there were no
handy sort routines then, you had to do it all yourself, I thought there
must have been something suitable in Perl, which seems to have everything
built in :-)

Chris

"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3DC9AD5F.F0270442@earthlink.net...
> Darren Dunham wrote:
> [snip]
> > > opendir DH, $dir or die "Cannot open $dir: $!";
> > > foreach $file (readdir DH) {
> >
> > Change that to
> >
> > my @sorted_files = sort (readdir DH);
> > foreach $file (@sorted_files) {
>
> There is no need to store data in a temporary array to sort it.
>
>    foreach my $file (sort readdir DH) {
>
> --
> my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
> ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]




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

Date: Thu, 07 Nov 2002 13:37:26 GMT
From: "Kevin Lin" <kevin@wx3.com>
Subject: Re: How to correctly use AUTOLOAD in derived class?
Message-Id: <q0uy9.23817$sP2.8284@sccrnsc02>

Thanks for the reply, I'll give that a go.
--
Kevin Lin
Wx3 Web Consulting
http://www.wx3.com/
Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in message
news:aqd4cl$7et$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach Kevin Lin:
>
> > I'm creating an application which uses a class I've derived from CGI.pm.
> > For convenience, I'm using AUTOLOAD to access the class's data members,
> > rather than create methods for all.
> >
> > My understanding is that perl will only call AUTOLOAD if the method is
not
> > found in either the object's class, or its parent class(es). But
AUTOLOAD
> > seems to be getting called for a "delete" method (I assume called by
CGI's
> > constructor or destructor, because I haven't defined one.)
> >
> > Here is the exception AUTOLOAD throws:
> > Uncaught exception: Can't access `delete' field in class Test at
> > F:/Gloc3/Development/Modules/Test.pm line 24.
>
> Subclassing CGI is probably a little trickier. CGI.pm keeps a lot of its
> methods as strings. Once a method is requested, the code for the method
> is compiled and executed. Afterwards, it shows up as an ordinary symbol
> in the symbol table. But not before.
>
> > Here is the code for Test.pm:
> > package Test;
> > use CGI;
> > use vars qw(@ISA);
> > use vars '$AUTOLOAD';
> > our @ISA = ("CGI");
>
> Try the following modification:
>
>     use CGI;
>     BEGIN { CGI->compile(':all') }
>     use vars qw(@ISA);
>     ...
>
> Tassilo
> --
> $_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
> pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
> $_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;




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

Date: Thu, 07 Nov 2002 14:01:49 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to locate Perl Interpreter
Message-Id: <hnuy9.43699$7W2.29895@nwrddc01.gnilink.net>

bansidhar wrote:
> Can anybody tel me how to locate Perl Interpreter (if installed the
> path) in a web server from a client.

The HyperTextTransferProtocol does not provide this functionality.

You could call "system('which perl');" in a Perl CGI script, but of course
there is no guarantee that the result of that query has anything to do with
the interpreter, that is actually called by the web server (or that 'which'
is even installed on the system or accessible from a CGI program).

What is your real question?

jue




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

Date: Thu, 07 Nov 2002 14:26:37 GMT
From: "TBN" <ihave@noemail.com>
Subject: Komodo Opinions
Message-Id: <xKuy9.2025$uwT2.36962367@news2.randori.com>

Does anyone have an opinion on what they like or dislike about Komodo as far
as using Perl with it?




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

Date: Thu, 7 Nov 2002 05:35:24 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Makefile.PL @INC PREFIX LIB [should be How do I keep my own module/library directory?]
Message-Id: <3dca6bd2$1@usenet.ugs.com>


"Koos Pol" <koos_pol@NO.nl.JUNK.compuware.MAIL.com> wrote in message
news:newscache$2q975h$bx$1@news.emea.compuware.com...
>
> I  have installed HTML::Tagset in a local directory:
>
>   perl Makefile.pl PREFIX=/some/local/dir
>   make
>   make test
>   make install
>
> This work beautifully. But if I then want to install HTML::Parser also in
> the local directory, it can't find HTML::Tagset
>
>
> Thanks,
>
> --
> KP

Take a look at perldoc -q module

  How do I keep my own module/library directory?

           When you build modules, use the PREFIX option when generating
           Makefiles:

               perl Makefile.PL PREFIX=/u/mydir/perl

           then either set the PERL5LIB environment variable before you run
           scripts that use the modules/libraries (see the perlrun manpage)
           or say

               use lib '/u/mydir/perl';

           This is almost the same as

               BEGIN {
                   unshift(@INC, '/u/mydir/perl');
               }

           except that the lib module checks for machine-dependent
           subdirectories. See Perl's the lib manpage for more information.

Mothra




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

Date: Thu, 07 Nov 2002 15:04:30 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: Makefile.PL @INC PREFIX LIB [should be How do I keep my own module/library directory?]
Message-Id: <newscache$irl75h$gz$1@news.emea.compuware.com>

Mothra wrote (Thursday 07 November 2002 14:35):

> 
> "Koos Pol" <koos_pol@NO.nl.JUNK.compuware.MAIL.com> wrote in message
> news:newscache$2q975h$bx$1@news.emea.compuware.com...
>>
>> I  have installed HTML::Tagset in a local directory:
>>
>>   perl Makefile.pl PREFIX=/some/local/dir
>>   make
>>   make test
>>   make install
>>
>> This work beautifully. But if I then want to install HTML::Parser also in
>> the local directory, it can't find HTML::Tagset
>>
>>
>> Thanks,
>>
>> --
>> KP
> 
> Take a look at perldoc -q module
> 
>   How do I keep my own module/library directory?
[snip] 
>            then either set the PERL5LIB environment variable before you
>            run scripts that use the modules/libraries (see the perlrun
>            manpage) or say
> 
>                use lib '/u/mydir/perl';



No. That's too easy. This only works for "normal" Perl programs. This 
doesn't work for subsequent modules you want to install in a local dir and 
that are dependent on modules also installed in a local dir. (Notice that 
in this scenario I only have a Makefile.PL and perl command line arguments 
to work with. And I am not lightly provoced to edit Makefile.PL.) Look at 
the result:

bash$ PERL5LIB=/some/local/dir perl Makefile.PL PREFIX=/some/local/dir

That'll throw me a:

Global symbol "%Config" requires explicit package name at 
/usr/lib/perl5/5.6.1/ExtUtils/MM_Unix.pm line 21.
BEGIN not safe after errors--compilation aborted at 
/usr/lib/perl5/5.6.1/ExtUtils/MM_Unix.pm line 243.
Compilation failed in require at /usr/lib/perl5/5.6.1/ExtUtils/MakeMaker.pm 
line 75.
Compilation failed in require at Makefile.PL line 3.
BEGIN failed--compilation aborted at Makefile.PL line 3.

Note secondly that despite "normal" programs, using PREFIX or LIB with "perl 
Makefile.PL" do NOT change @INC! Here is (again) the proof:

PREFIX=/some/local/dir perl Makefile.PL
Warning: prerequisite HTML::Tagset failed to load: Can't locate 
HTML/Tagset.pm in @INC (@INC contains: /usr/lib/perl5/5.6.1/i586-linux 
/usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i586-linux 
/usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl .) at (eval 4) line 
3.
Writing Makefile for HTML::Parser

What the core issue is I don't know. Maybe a MakeMaker problem.

So the problem remains:
How can I install HTML::Parse in /some/local/dir while it is dependent on 
HTML::Tagset also installed in a this local dir.


-- 
KP



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

Date: Thu, 7 Nov 2002 12:51:24 -0000
From: "Julia deSilva" <jds@trumpetweb.co.uk>
Subject: Re: Perfecting my Perl
Message-Id: <xjty9.34449$xF.1116@news-binary.blueyonder.co.uk>

> Does somebody have a more elegant solution?
>
> gtoomey

Try : "Get a Life !"




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

Date: 7 Nov 2002 13:29:39 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Perfecting my Perl
Message-Id: <aqdps3$ref$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Julia deSilva:

> Try : "Get a Life !"

Try my killfile.

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Thu, 7 Nov 2002 13:36:54 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Perfecting my Perl
Message-Id: <slrnaskne9.53f.bernard.el-hagin@gdndev25.lido-tech>

In article <xjty9.34449$xF.1116@news-binary.blueyonder.co.uk>, Julia
deSilva wrote:
>> Does somebody have a more elegant solution?
>>
>> gtoomey
> 
> Try : "Get a Life !"


Why? The OP is just trying to learn. What's wrong with that?


Anyhow, I have a nice, cozy place for you in my killfile.


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


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

Date: Thu, 07 Nov 2002 14:05:56 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perfecting my Perl
Message-Id: <8ruy9.43735$7W2.7237@nwrddc01.gnilink.net>

Gregory Toomey wrote:
> I'm helping a relative with some word puzzles but the solution I've
> come up with is rather ugly.
>
> Problem:
> Make as many words as possible with the letters a,a,c,c,e,i,n,t,v;
> each word must contain the letter c.
>
> My solution:
> Using the English language word list at www.wordlist.sourceforge.net/
> , I've come up with the following:
>
> while(<>) {
>         if (/^[aceintv]*$/ && /c/) {
>                 my %hash;
>                 foreach (split //) {$hash{$_}++};
>                 print "$_" if $hash{v}<=1 &&  $hash{c}<=2 &&
>  $hash{c}>=1 && $hash{i}<=1 && $hash{n}<=1  && $hash{t}<=1 &&
>          $hash{e}<=1; }
> }
>
> Does somebody have a more elegant solution?

Not sure which part you are trying to solve in your code snippet:
- creating all the permutation of the characters
- comparing them with the list of English words.

If it's about the permutations then you may want to check out "perldoc -q
permute" for some ideas.

jue




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

Date: Thu, 7 Nov 2002 09:00:21 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perfecting my Perl
Message-Id: <slrnasl005.2i3.tadmc@magna.augustmail.com>

Gregory Toomey <nobody@noplace.com> wrote:

> Problem:
> Make as many words as possible with the letters a,a,c,c,e,i,n,t,v; each
> word must contain the letter c.


> while(<>) {
>         if (/^[aceintv]*$/ && /c/) {
>                 my %hash;
>                 foreach (split //) {$hash{$_}++};
>                 print "$_" if $hash{v}<=1 &&  $hash{c}<=2 &&
                        ^  ^
                        ^  ^
Those quotes don't do anything (useful), so they should not be there.


>  $hash{c}>=1 && $hash{i}<=1 && $hash{n}<=1  && $hash{t}<=1 && $hash{e}<=1;
>          }
> }


Your code does not check for "a" characters...


> Does somebody have a more elegant solution?


This one seems to me to be easier to read and understand:


----------------------------------
while(<>) {
   next unless /^[aceintv]*c[aceintv]*$/;  # has disallowed character

   my $word = $_;
   chomp;
   foreach my $ch (qw/a a c c e i n t v/) {  # remove allowed characters
      s/$ch//;
   }
   print $word unless length;   # matched if no chars are left
}
----------------------------------


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


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

Date: 7 Nov 2002 16:00:36 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Perfecting my Perl
Message-Id: <aqe2n4$7eu$1@nets3.rz.RWTH-Aachen.DE>

The following posted on request sent in a personal mail from Cameron
Dorey (her newsservice appears to be down):

Gregory Toomey wrote:

 >
 > My solution:
 > Using the English language word list at www.wordlist.sourceforge.net/ ,


Is this the right URL? My computer cannot find it, and it looks like a good 
site to test some things I'm doing.

Oh, to your question. If it works, it's elegant. TIMTOWTDI, and, to a first 
approximation (okay, within an order of magnitude), they're all equally elegant.

Thanks,

Cameron

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu


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

Date: Thu, 07 Nov 2002 13:36:27 GMT
From: "TBN" <ihave@noemail.com>
Subject: printf, sprintf help
Message-Id: <v%ty9.2019$uwT2.31785138@news2.randori.com>

I've read through the documentation and see how Perl has commands to format
numbers, but what if I want to format a string?  I couldn't find anything on
that.

Basically, I'm trying to write information to a text file and I need each
"field" of the record to be fixed-spaced, so certain values will need some
space padding.  I also need to write out the date in a specific format such
as 2002/02/01 19:07:26

I know how to get the date and all that, but again and unable to figure out
how to format a string.




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

Date: Thu, 7 Nov 2002 13:41:29 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: printf, sprintf help
Message-Id: <slrnasknms.53f.bernard.el-hagin@gdndev25.lido-tech>

In article <v%ty9.2019$uwT2.31785138@news2.randori.com>, TBN wrote:
> I've read through the documentation and see how Perl has commands to format
> numbers, but what if I want to format a string?  I couldn't find anything on
> that.
> 
> Basically, I'm trying to write information to a text file and I need each
> "field" of the record to be fixed-spaced, so certain values will need some
> space padding.  I also need to write out the date in a specific format such
> as 2002/02/01 19:07:26
> 
> I know how to get the date and all that, but again and unable to figure out
> how to format a string.


perldoc perlform


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


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

Date: Thu, 07 Nov 2002 14:30:19 GMT
From: "TBN" <ihave@noemail.com>
Subject: Re: printf, sprintf help
Message-Id: <_Nuy9.2026$uwT2.19857591@news2.randori.com>

[snipped]
>
> perldoc perlform
>
>
> Cheers,
> Bernard
> --
> echo 42|perl -pe '$#="Just another Perl hacker,"'
>

Hmmm... when I enter perldoc perlform, I only get...
No documentation found for "perlform".

Could this be a Perl version problem?




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

Date: Thu, 7 Nov 2002 14:36:31 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: printf, sprintf help
Message-Id: <slrnaskqu3.53f.bernard.el-hagin@gdndev25.lido-tech>

In article <_Nuy9.2026$uwT2.19857591@news2.randori.com>, TBN wrote:
> [snipped]
>>
>> perldoc perlform
>
> 
> Hmmm... when I enter perldoc perlform, I only get...
> No documentation found for "perlform".
> 
> Could this be a Perl version problem?


I rather think it's a problem with your installation. Do you have the
Perl documentation installed? Does 'perldoc perl' produce the same
error?


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


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

Date: Thu, 07 Nov 2002 15:02:57 GMT
From: "TBN" <ihave@noemail.com>
Subject: Re: printf, sprintf help
Message-Id: <Agvy9.2027$uwT2.27721910@news2.randori.com>

"Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
message news:slrnaskqu3.53f.bernard.el-hagin@gdndev25.lido-tech...
> In article <_Nuy9.2026$uwT2.19857591@news2.randori.com>, TBN wrote:
> > [snipped]
> >>
> >> perldoc perlform
> >
> >
> > Hmmm... when I enter perldoc perlform, I only get...
> > No documentation found for "perlform".
> >
> > Could this be a Perl version problem?
>
>
> I rather think it's a problem with your installation. Do you have the
> Perl documentation installed? Does 'perldoc perl' produce the same
> error?
>
>
> Cheers,
> Bernard
> --
> echo 42|perl -pe '$#="Just another Perl hacker,"'

perldoc perldoc renders information, but perldoc perl rendered the same "No
documentation found..." message.




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

Date: Thu, 7 Nov 2002 09:28:24 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: printf, sprintf help
Message-Id: <slrnasl1ko.2u6.tadmc@magna.augustmail.com>

TBN <ihave@noemail.com> wrote:
> I've read through the documentation and see how Perl has commands to format
> numbers, but what if I want to format a string?  I couldn't find anything on
> that.


   perldoc -f sprintf

says:

   %s   a string


so you use the %s specifier to format a string. eg:

   my $str = sprintf "'%5s'\n", 'abc';  # leading space padding
   print $str;

   $str = sprintf "'%-5s'\n", 'abc';    # trailing space padding
   print $str;


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


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

Date: 7 Nov 2002 05:10:55 -0800
From: jc_va@hotmail.com (Buck Turgidson)
Subject: Safety of Perl
Message-Id: <f98999c8.0211070510.71ec6f77@posting.google.com>

I need to write a fairly simple date utility.  I was thinking of doing
it in C, but I am concerned about errors in the code bringing down our
production UNIX system.

Does Perl have built-in safeguards that will protect me from myself in
terms of over-writing memory, etc?  Perl seems to be able to do what I
want to do, and I am just wondering if it is also safer.


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

Date: Thu, 07 Nov 2002 13:30:29 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Safety of Perl
Message-Id: <3dca6956.1937614572@news.cis.dfn.de>

On 7 Nov 2002 05:10:55 -0800, jc_va@hotmail.com (Buck
Turgidson) wrote:

>I need to write a fairly simple date utility.  I was thinking of doing
>it in C, but I am concerned about errors in the code bringing down our
>production UNIX system.

Date utility?  What sort of date utility from hell are you
writing that your concerned with it bringing down your
system?  A computer dating system perhaps?  Perl has
a lot of library modules for dealing with dates.  They 
include, but are not limited to.

Date-Calc        (the standard)
Date-Chinese
Date-Christmas
Date-Convert-French_Rev
Date-Day
Date-DayOfWeek
Date-Decade
Date-Discordian
Date-Easter
Date-EzDate
Date-Gregorian
Date-Handler
Date-Horoscope
Date-ISO
Date-Japanese-Era
Date-Leapsecond
Date-Leapyear
Date-Lima
Date-Manip
Date-Ordinal
Date-Pcalc
Date-Range
Date-Simple
Date-SundayLetter
Date-Tie
DateConvert
DateManip
DateTime-Precise
Date_Maya

>Does Perl have built-in safeguards that will protect me from myself in
>terms of over-writing memory, etc?  Perl seems to be able to do what I
>want to do, and I am just wondering if it is also safer.

Perl does not have the problems C has with "over-writing
memory" and it has its own garbage collection.  However,
there is no problem with allocating more memory than you
have if that's what you want.  

Your requirement is an extremely arcane one.  
And there are always to prevent a program from
 "bringing down your system" if that is a real issue.

Test and troubleshoot it on a different system before
moving it to the critical one.
-- 
Regards, Helgi Briem
helgi AT decode DOT is

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


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

Date: Thu, 07 Nov 2002 13:46:15 +0000
From: Naran Hirani <N.Hirani@hgmp.mrc.ac.uk>
Subject: seconds -> hours/min/secs
Message-Id: <3DCA6EA7.5E9C04FA@hgmp.mrc.ac.uk>

Hi,

Is there some pre-built script that takes a large number of seconds and
converts it
into: hh:mh:sh format?

TIA, for your replies.

Naran.



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

Date: Thu, 07 Nov 2002 14:16:14 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: seconds -> hours/min/secs
Message-Id: <3dca6fba.1939251436@news.cis.dfn.de>

On Thu, 07 Nov 2002 13:46:15 +0000, Naran Hirani
<N.Hirani@hgmp.mrc.ac.uk> wrote:

>Is there some pre-built script that takes a large number of 
>seconds and converts it into: hh:mh:sh format?

Here's one way.  Doubtless there are more elegant ways
although I couldn't find anything in the Date::Calc module.

#!/perl
use strict;
use warnings;  # use -w on shebang for old Perls

my $num    = 45566;

my ($hh_mm_ss) = secs_to_hh_mm_ss($num);

print "$hh_mm_ss\n";

sub secs_to_hh_mm_ss
{
	my ($num_seconds) = @_;
	my $secs_per_min  = 60;
	my $secs_per_hour = 60*$secs_per_min;
	my $hours  = int ($num_seconds/$secs_per_hour);	
	my $remain = $num - ($hours*$secs_per_hour);
	my $mins   = int($remain/$secs_per_min);
	my $secs   = $remain - ($mins*60);  
	return "$hours:$mins:$secs";
}
-- 
Regards, Helgi Briem
helgi AT decode DOT is

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


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

Date: Thu, 07 Nov 2002 14:48:20 +0000
From: Naran Hirani <N.Hirani@hgmp.mrc.ac.uk>
Subject: Re: seconds -> hours/min/secs
Message-Id: <3DCA7D34.81E0FCA7@hgmp.mrc.ac.uk>

Thank you, Helgi.  I also came up with the same solution, but just wondered if

there was perhaps a slicker way of doing it.

Cheers.
Naran.

Helgi Briem wrote:

> On Thu, 07 Nov 2002 13:46:15 +0000, Naran Hirani
> <N.Hirani@hgmp.mrc.ac.uk> wrote:
>
> >Is there some pre-built script that takes a large number of
> >seconds and converts it into: hh:mh:sh format?
>
> Here's one way.  Doubtless there are more elegant ways
> although I couldn't find anything in the Date::Calc module.
>
> #!/perl
> use strict;
> use warnings;  # use -w on shebang for old Perls
>
> my $num    = 45566;
>
> my ($hh_mm_ss) = secs_to_hh_mm_ss($num);
>
> print "$hh_mm_ss\n";
>
> sub secs_to_hh_mm_ss
> {
>         my ($num_seconds) = @_;
>         my $secs_per_min  = 60;
>         my $secs_per_hour = 60*$secs_per_min;
>         my $hours  = int ($num_seconds/$secs_per_hour);
>         my $remain = $num - ($hours*$secs_per_hour);
>         my $mins   = int($remain/$secs_per_min);
>         my $secs   = $remain - ($mins*60);
>         return "$hours:$mins:$secs";
> }
> --
> Regards, Helgi Briem
> helgi AT decode DOT is
>
>                            A: Top posting
>                            Q: What is the most irritating thing on Usenet?
>                                            - "Gordon" on apihna



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

Date: Thu, 7 Nov 2002 07:56:51 -0700
From: "David" <perl-dvd@ldschat.com>
Subject: Re: seconds -> hours/min/secs
Message-Id: <Y3vy9.21741$46.8463@fe01>


"Naran Hirani" <N.Hirani@hgmp.mrc.ac.uk> wrote in message
news:3DCA7D34.81E0FCA7@hgmp.mrc.ac.uk...
> Thank you, Helgi.  I also came up with the same solution, but just
wondered if
>
> there was perhaps a slicker way of doing it.

Well, I don't know if its slicker or not, but it is using a
pre-existing package.  Observe:

##################################################
use Date::Manip;

my $expire_date = &ParseDateString("epoch $the_seconds");
$expire_date = UnixDate($expire_date, "%m/%d/%Y");
##################################################

Regards,
David





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

Date: Thu, 07 Nov 2002 15:40:56 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: seconds -> hours/min/secs
Message-Id: <3dca8951.1945802215@news.cis.dfn.de>

On Thu, 7 Nov 2002 07:56:51 -0700, "David"
<perl-dvd@ldschat.com> wrote:

>"Naran Hirani" <N.Hirani@hgmp.mrc.ac.uk> wrote in message
>news:3DCA7D34.81E0FCA7@hgmp.mrc.ac.uk...

>> Thank you, Helgi.  I also came up with the same solution, but just
>wondered if  there was perhaps a slicker way of doing it.
>
>Well, I don't know if its slicker or not, but it is using a
>pre-existing package.  Observe:
>
>use Date::Manip;
>
>my $expire_date = &ParseDateString("epoch $the_seconds");
>$expire_date = UnixDate($expire_date, "%m/%d/%Y");

Much better.  I knew there had to be a better way in
one of the Date modules.
-- 
Regards, Helgi Briem
helgi AT decode DOT is

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


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

Date: Thu, 7 Nov 2002 08:55:15 -0500
From: "George" <sheken@videotron.ca>
Subject: Re: setuid script
Message-Id: <3huy9.6056$RO1.14862@weber.videotron.net>

thanks a lot Sam.
it works flawlessly

I got that piece of C code from an older documentation :(

thanks again,
George
"Sam Holden" <sholden@flexal.cs.usyd.edu.au> wrote in message
news:slrnasjrgl.t9p.sholden@flexal.cs.usyd.edu.au...
> On Wed, 6 Nov 2002 23:23:42 -0500, George <sheken@videotron.ca> wrote:
> > Sam,
> >
> > I use this as C wrapper
> >
> > #include <stdlib.h>
> > void main() {
> >     system("/home/pulsar/public_html/cgi-bin/test.pl");
> >     }
> >
> > compiled, owned by root and with +s
> >
> > script still won't run as root
>
> Of course not, since that effectively does nothing.
>
> >
> > anything I am missing ?
>
> READ THE DOCUMENTATION!!!!
>
> perlsec has the C program you should use in it.
>
> It is not the same as your one above.
>
> Instead of guessing READ THE DOCUMENTATION!
>
> and yes I meant to yell.
>
> --
> Sam Holden
>




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

Date: Thu, 07 Nov 2002 06:24:46 -0500
From: Brian Seppanen <seppanen@chartermi.net>
Subject: Re: sh (bash) $1 equivalent
Message-Id: <3DCA4D7E.9030704@chartermi.net>

I am an idiot.   Each time I was trying to use $ARGV[0] I was doing the 
variable assignment incorrectly and basically assigning it a null value.

I apologize.   $ARGV[0] does work.
Thanks,

Brian Seppanen wrote:
> Is there an equivalent in perl, which I may have missed in my reading of 
> the documentation?   The documentation for perl indicates that $1 would 
> be the first regular expression match.   So I am left to assume that 
> perl cannot do this, but I was wondering if someone knew better.
> 
> Benjamin Goldberg wrote:
> 
>> Brian Seppanen wrote:
>>
>>> I'm trying to use perl to handle some snmptrap data.   One of the code
>>> examples I have is using bash and the $1 variable is used to pass some
>>> data to a handler script and is used as follows.
>>
>>
>> [snip]
>>
>> To learn about perl's special variables, including the ones that are
>> used to pass arguments from the command line to a script, read the
>> perlvar document that comes with perl.  To do this, run the command:
>>
>>    perldoc perlvar
>>
> 
> 


-- 
Brian E. Seppanen
seppanen@chartermi.net



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

Date: Thu, 7 Nov 2002 12:27:54 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Simple question - What is unicode?
Message-Id: <Pine.LNX.4.40.0211071212080.12812-100000@lxplus075.cern.ch>

On Nov 7, Helgi Briem inscribed on the eternal scroll:

> On Wed, 6 Nov 2002 20:39:15 +0100, "Alan J. Flavell"
> <flavell@mail.cern.ch> wrote:
>
> >> Helgi Briem <helgi@decode.is> wrote
> >> > Unicode is a scheme for encoding alphabets
>
> >Not exactly.  Unicode assigns numerical values to characters, but
> >there are numerous ways (several of which are in active use) of
> >actually encoding those numerical values to represent a character.
>
> Thanks for the clarification, Alan.

I'm afraid I expressed myself rather brusquely - that was unfair in
the circumstances.

Point was that I felt your phrase "Unicode is a scheme for encoding"
was too inaccurate to be left as it stood.  Under the general umbrella
of Unicode there are all of:

- One set of assignments of characters to small-ish integers, which
is maintained compatible with ISO-10646

- Rules and recommendations for usage of those characters

- Several schemes for actually encoding those small-ish integers
for network transmission and for storage.  (The unicode consortium
currently recommend utf-8, utf-16 and utf-32, although there are
others.)

> so I'm no expert and probably should not have stuck my nose in.

No offence intended, honestly.

> We Icelanders have fight long and hard to keep our
> special characters in the 256 character set, so have
> not needed extended Unicode yet.

I'm seeing iso-8859-15 (Latin-9) coding used extensively on the
mainland these days, although in the UK it hasn't made much impression
yet.

If you're involved in HTML or XML at all, though, you need to know
those Unicode small-ish integers (or at least know where to look them
up), because they're the numbers that you need to use in &#number;
representations, irrespective of the actual character coding that's in
use.  This seems to cause major confusion amongst non-specialists,
even though it's basically very simple and straightforward.  The
problem, in my interpretation, is that many people assume (wrongly)
that they already know what to do, and consequently don't realise that
there's anything different to be learned.  This is always the hardest
trap to get out of - the blissful belief that one is doing things
right and that there is no cause to reconsider.

cheers



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

Date: Thu, 7 Nov 2002 12:39:25 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Simple question - What is unicode?
Message-Id: <Pine.LNX.4.40.0211071230030.12812-100000@lxplus075.cern.ch>

On Nov 7, Bart Lateur inscribed on the eternal scroll:

> That's why there's a so-called BOM ("byte order mark") pseudo-character.

There is; but the use of a BOM isn't, in general, mandatory.

> It's a "zero width no-break space",

The specific bit-combination, if it occurs at the start of a file, is
always a BOM, whereas if it occurs anywhere else, it's a zero-width
no-break space.

> It usually appears only at the start of an Unicode text file.

As a BOM it can _only_ exist at the start of a file, although its use
isn't mandatory, as I say.

zwnbsp can certainly be used elsewhere in a file, but its semantics
are quite different from a BOM.  See FAQ24 at your cited URL.

> 	<http://www.unicode.org/unicode/faq/utf_bom.html#22>
> 	<http://www.unicode.org/unicode/faq/utf_bom.html#25>

Indeed.

best regards



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

Date: 7 Nov 2002 12:13:23 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Simple question - What is unicode?
Message-Id: <aqdld3$ms2$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Alan J. Flavell:

> I'm seeing iso-8859-15 (Latin-9) coding used extensively on the
> mainland these days, although in the UK it hasn't made much impression
> yet.

That's probably because the Britishers decided not to join the monetary
union yet. The introduction of the new currency was the point where I
replaced all occurances of latin1 with latin9 in my OS. Comparing these
two character sets, I think that the latter contains the more useful
characters.

Hadn't the Britons decided to use such an odd character for their
currency (£), they'd probably get on quite well with plain ascii. ;-)

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: Thu, 7 Nov 2002 13:55:41 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Simple question - What is unicode?
Message-Id: <Pine.LNX.4.40.0211071343350.12812-100000@lxplus075.cern.ch>

On Nov 7, Tassilo v. Parseval inscribed on the eternal scroll:

> Hadn't the Britons decided to use such an odd character for their
> currency (£), they'd probably get on quite well with plain ascii. ;-)

There used to be a UK-flavoured "ascii", just as there were other
national flavours within the scope of iso-646.  Has long since gone
out of use, except perhaps for some antique terminals which refuse to
die.  This is the origin of the term "national characters" for a
handful of the code positions in ascii.

I find it rather touching that someone went to the trouble of
numbering iso-10646 by analogy with that old iso-646.

Historical interest only: see "Domestic iso646 character tables"
at http://kanji.zinbun.kyoto-u.ac.jp/~yasuoka/CJK.html

(Apologies to anyone upset by the OT and >30-year-old digression)



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

Date: Thu, 07 Nov 2002 13:19:21 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Simple question - What is unicode?
Message-Id: <3dca67a2.1937178335@news.cis.dfn.de>

On Thu, 7 Nov 2002 12:27:54 +0100, "Alan J. Flavell"
<flavell@mail.cern.ch> wrote:

>I'm afraid I expressed myself rather brusquely - 
>that was unfair in the circumstances.

Not at all.  

>> so I'm no expert and probably should not have stuck my nose in.
>
>No offence intended, honestly.

Absolutely none taken.  I mean that. Don't worry.
I wasn't in the least bit offended.  

It is part and parcel of taking part in technical 
discussions that there are people who know better. 
Those who are not able to acknowledge that should 
not take part in technical discussions.
-- 
Regards, Helgi Briem
helgi AT decode DOT is

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


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

Date: Thu, 7 Nov 2002 09:06:48 -0500
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: Re: Simple question - What is unicode?
Message-Id: <aqds1t$s4e@netnews.proxy.lucent.com>

"Alan J. Flavell" <flavell@mail.cern.ch> wrote in
> Note that recent versions of Unicode have more characters than can be
> represented by a 16-bit number.  Which means that ucs-2 can no longer
> represent the full unicode range, and therefore utf-16 was introduced.

I'm reading some unicode information. I thought that ucs-2 is using 16 bits
and utf-16 is also using 16 bits. What's the differences between them?




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

Date: Thu, 7 Nov 2002 15:32:54 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Simple question - What is unicode?
Message-Id: <Pine.LNX.4.40.0211071526230.12812-100000@lxplus075.cern.ch>

On Nov 7, Tulan W. Hu inscribed on the eternal scroll:

> I'm reading some unicode information. I thought that ucs-2 is using 16 bits
> and utf-16 is also using 16 bits. What's the differences between them?

ucs-2 is a plain 16-bit representation of the unicode code points
0-65535 (the "basic multilingual plane" in iso-10646 terminology).

utf-16 specifies an extension mechanism for representing characters
outside of the BMP by means of pairs of 16-bit bit-patterns.  A
certain part of the 16-bit range is carved out for implementing this
mechanism (d800-dfff).

Google suggests
http://www.terena.nl/library/multiling/unicode/utf16.html



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

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


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