[13865] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1275 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 4 06:07:50 1999

Date: Thu, 4 Nov 1999 03:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <941713512-v9-i1275@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 4 Nov 1999     Volume: 9 Number: 1275

Today's topics:
    Re: -w <spyder@pikesville.net>
        assembler & portprogramming <CLN@DMT.Sonofon.DK>
    Re: assembler & portprogramming <rhomberg@ife.ee.ethz.ch>
    Re: core dump - perl, me or server? <rhardicr@mail.ford.com>
    Re: Creating Hashes? (Abigail)
    Re: DBI error: ORA-06401: NETCMN: invalid driver design <chris.beels@riskmetrics.com>
        duplicates in an array <sumengen@iplab.ece.ucsb.edu>
    Re: duplicates in an array <Joachim.Pimiskern@de.bosch.com>
    Re: FAQ 3.9: Is there an IDE or Windows Perl Editor? <Eric.Gibson@geac.com>
    Re: FAQ 3.9: Is there an IDE or Windows Perl Editor? <tim.westlakeNOtiSPAM@myremarq.com.invalid>
    Re: Hex output help (Abigail)
    Re: How can I set reg. expresion to anchor at the end o (Neko)
    Re: How can I set reg. expresion to anchor at the end o (Abigail)
        Lost in Splitting....... <mattking@techie.com>
    Re: mirror command <tex@off.org>
        Netscape URI values... Newbie daniel_simser@my-deja.com
    Re: Netscape URI values... Newbie <daniel@allfilms.com>
    Re: Newbie help <montuori@acs.neu.edu>
        Perl / NIS+ <asd@ds.aw>
    Re: Perl and commonsense part 2 (brian d foy)
    Re: Perl and Excel Charting <skilchen@swissonline.ch>
    Re: proposed "??" operator causing ambiguous syntax (Philip 'Yes, that's my address' Newton)
    Re: replace " " with &nbsp; (Kragen Sitaker)
    Re: replace " " with &nbsp; (Kragen Sitaker)
    Re: replace " " with &nbsp; <slanning@bu.edu>
    Re: Who is worse: Cops or Criminals (Nik Smiğr Warrensson)
    Re: Year 2000 date problem (Abigail)
    Re: Year 2000 date problem (Philip 'Yes, that's my address' Newton)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 04 Nov 1999 07:04:12 GMT
From: "V.B." <spyder@pikesville.net>
Subject: Re: -w
Message-Id: <38212ED0.B27A3102@pikesville.net>


thankyou
ill give it a shot!
BTW

the version of V.B. is
Vince Brammer
till next time!

Bart Lateur wrote:

> V.B. wrote:
>
> >hi all
> >im back again.
>
> What version of VB are you?
>
> >im writing several scripts, all that work together. i am using "require"
> >to include nessecary scripts.. i would like to use the -w command for
> >perl, but if i leave an ending "return1;" -w gives me an error. any ways
> >to work around this?
>
> Just a
>
>         1;
>
> will do.
>
> You can use anything other that will leave a true value, such as (per
> TomC):
>
>         "Because I say so";
>
> Even if this generates a warning if you test syntax on this file, it
> doesn't when the file is "required", and it works.
>
> --
>         Bart.



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

Date: Thu, 04 Nov 1999 07:19:36 GMT
From: "CLN" <CLN@DMT.Sonofon.DK>
Subject: assembler & portprogramming
Message-Id: <01bf2694$f2056b80$386f10ac@pc2579>

Hi there
 
Can someone help me with my problems:
How do I insert assembler code into a perlscript?
and
How do I program a hardware address at a PC. Forexample port 378H
(LPT-port) ?
 
Claus Nielsen
 



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

Date: Thu, 04 Nov 1999 10:50:06 +0100
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: assembler & portprogramming
Message-Id: <382156CE.875E8ADE@ife.ee.ethz.ch>

CLN wrote:
> 
> Hi there
> 
> Can someone help me with my problems:
> How do I insert assembler code into a perlscript?
> and
> How do I program a hardware address at a PC. Forexample port 378H
> (LPT-port) ?

IMHO best done via C and xs:
- Make sure you have enough time
- print out the xs and xstut manpages or buy a book
- Write a C function that acesses your port
- follow the advice in the manpages

- Alex


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

Date: Thu, 04 Nov 1999 10:14:38 +0000
From: Richard H <rhardicr@mail.ford.com>
Subject: Re: core dump - perl, me or server?
Message-Id: <38215C8E.E8B81DFE@mail.ford.com>

Ala Qumsieh wrote:
> 
> I can not reproduce your problem.
> 
> % perl -v
> This is perl, version 5.005_03 built for sun4-solaris
> 
> What does the Page module look like?

nothing special at all: 

package Page;

    use vars qw($AUTOLOAD);
    use CGI qw(:standard);

    my %fields = (
        DATABASE => undef,              # Database object reference    
    );
etc...............

Your use of perl -v made me have a look at the perl I was using :

>This is perl, version 5.003 with EMBED
>        built under solaris at May  4 1997 13:48:18
>        + suidperl security patch

which gave Segmentation Fault (core dumped) or 
Bus Error (core dumped) with another module!

So I upped the level of Perl to 5.004 and dont get the same problem,
though I'm still confused as to why I don't get a core dump in online
code using the eval(use x) construct and 5.003,

Thanks for the pointer,

Richard H


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

Date: 4 Nov 1999 04:16:03 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Creating Hashes?
Message-Id: <slrn822ne5.dk.abigail@alexandra.delanet.com>

David Cassell (cassell@mail.cor.epa.gov) wrote on MMCCLVI September
MCMXCIII in <URL:news:3820D99B.977765E8@mail.cor.epa.gov>:
\\ Shon Stephens wrote:
\\ > 
\\ >  I want to read a multline file, each line containing comma separated
\\ > values. Then I want to take the 1st and 2nd fields (dumping the rest)
\\ > and put them into a hash with the 1st field being the key and second
\\ > being the value. (I think thats generally how hashes work?) So that
\\ > input lines like:
\\ > 
\\ > line1 1,2,3
\\ > line2 a,b,c
\\ > 
\\ > Would yield:
\\ > 
\\ > keys(%hash) = (1,a)
\\ > and
\\ > values(%hash) = (2,b)
\\ 
\\ Okay, here's a short program which illustrates one way to do this.
\\ No claims that this is the fastest.
\\ 
\\ #!/usr/bin/perl -w
\\ use strict;
\\ 
\\ my %hash;
\\ 
\\ while (<DATA>) {
\\     $hash{$1} = $2 if /^([^,]+),([^,]+)/;
\\     }


%hash = map {(split /,/) [0, 1]} <DATA>;



Abigail
-- 
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 3 Nov 1999 18:47:59 -0500
From: "Chris Beels" <chris.beels@riskmetrics.com>
Subject: Re: DBI error: ORA-06401: NETCMN: invalid driver designator
Message-Id: <1%9U3.24$%33.92@news.ais.net>

Alright, turns out it was the connection string after all, the correct one
being

$dbh = DBI->connect("dbi:Oracle:$dbname", $user, $passwd);

Thanks,
Chris


Chris Beels <chris.beels@riskmetrics.com> wrote in message
news:fzET3.2$vC1.50@news.ais.net...
> Hi,
>
> I'm trying to connect to an Oracle DB using DBI (Solaris) and am receiving
> the error mentioned above.  I've tried both of the following connection
> strings:
> $dbh = DBI->connect('dbi:Oracle:','$username@T:$host:$sid','$password')
> and
> $dbh = DBI->connect("DBI:Oracle:host=$host:sid=$sid", $username,
$password)
>
> with the same results.  I've seen this problem referred to a couple of
> places on the net,
> e.g. http://www.xray.mpe.mpg.de/mailing-lists/dbi/1998-11/msg00152.html
and
> http://www.minivend.com/minivend/minivend-list/1999/msg01785.html
>
> but no solutions were posted and the people who posted the problem have
> failed to respond.  Oracle describes the error rather unhelpfully at
> http://www.oracle.com/support/bulletins/o8/nt/html/8002.html as follows:
> ORA-06401:  "NETCMN: invalid driver designator"
> // *Cause:  The login (connect) string contains an invalid
>             driver designator.
> // *Action: Correct the string and resubmit.
>
> but I'm not sure what that has to do with DBI.
>
> I appreciate your help.
>
> Thanks,
>
> Chris Beels
> RMG Web Services
> riskmetrics.com
>
>




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

Date: Thu, 4 Nov 1999 02:40:10 -0800
From: "Baris Sumengen" <sumengen@iplab.ece.ucsb.edu>
Subject: duplicates in an array
Message-Id: <7vrn88$5cc@yuggoth.ucsb.edu>

Hi,
Do you know an easy way to remove duplicates from an array.(If multiple
entries are identicle just keep one copy of it).
Thanks,
Baris.




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

Date: Thu, 4 Nov 1999 11:52:32 +0100
From: "Joachim Pimiskern" <Joachim.Pimiskern@de.bosch.com>
Subject: Re: duplicates in an array
Message-Id: <7vrohf$fhe$1@proxy2.fe.internet.bosch.de>

Baris,

>Do you know an easy way to remove duplicates from an array.(If multiple
>entries are identicle just keep one copy of it).


Take a hash to determine whether an element has already
been added to the result array. It goes like this:

@a = (1,2,3,1,2, 5 ,6);

sub uniqueArray
{
 my %h = ();
 my @result = ();
 my $i;
 foreach $i (@_)
   {
    if (not defined $h{$i})
       {
        push(@result,$i);
        $h{$i} = 1;
       }
   }
 return @result;
}

print uniqueArray(@a);

Regards,
Joachim
(Joachim.Pimiskern@de.bosch.com)





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

Date: Wed, 03 Nov 1999 14:45:01 -0500
From: Eric Gibson <Eric.Gibson@geac.com>
Subject: Re: FAQ 3.9: Is there an IDE or Windows Perl Editor?
Message-Id: <382090BD.D6A302F7@geac.com>

Scott Lanning wrote:
> 
> "Lee Sharp" <lee@insync.net> writes:
> > Tim Lewis wrote in message <7vabs4$sv7$1@news.gte.com>...
> > |ed has those wimpy visual editors beat hands down!
> > |ed is the standard text editor!!!!
> >
> >    You kids today have it easy.  I remember when we had to write
> > programs with an ice pick and index cards.
> 
> You got an ice pick?!?
> Why we had to use a cigarette lighter...in a blizzard!

Punch cards were nuthin, it was even more difficult to read/write to
magnetic platters with a 9 volt battery and a safety pin!


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

Date: Thu, 04 Nov 1999 02:36:37 -0800
From: Tim Westlake <tim.westlakeNOtiSPAM@myremarq.com.invalid>
Subject: Re: FAQ 3.9: Is there an IDE or Windows Perl Editor?
Message-Id: <1415c574.d56ebebd@usw-ex0101-007.remarq.com>

In article <7vd0dj$3ea$1@gellyfish.btinternet.com>, Jonathan Stowe
<gellyfish@gellyfish.com> wrote:

> No I dont think that we will -

You might not, however the rest of the world doesnt just program in C,
C++, PERL and Java. Being able to tailor an editor to support a
different and not widely used language as well as the more popular ones
is something that I spent a while trying to find.

Tim



* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: 4 Nov 1999 01:01:54 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Hex output help
Message-Id: <slrn822c24.dk.abigail@alexandra.delanet.com>

David Cassell (cassell@mail.cor.epa.gov) wrote on MMCCLVI September
MCMXCIII in <URL:news:3820D268.46FA1999@mail.cor.epa.gov>:
\\ Alan Curry wrote:
\\ > 
\\ > In article <7vq4s9$bv4$1@nnrp1.deja.com>,  <nite_eagle@hotmail.com> wrote:
\\ > >I tried printf "0x%x" , $data; but that just output 0x0
\\ > >How do I get perl to output what DBI gave me as a hex string?
\\ > 
\\ > for (split //, $yourvar) {
\\ >   printf "%02x", ord $_;
\\ 
\\ Or even:
\\ 
\\ map {printf "%02x", ord $_} split //, $yourvar;


{local($_,@&)=($var,0..9,A..F);s[.][$&[ord($&)/0x10]$&[ord($&)%0x10]]gs;print}



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 03 Nov 1999 22:27:33 -0800
From: tgy@chocobo.org (Neko)
Subject: Re: How can I set reg. expresion to anchor at the end of a string?
Message-Id: <YAohOLPr=b7dzeqptlJB3qNWgLO2@4ax.com>

On 4 Nov 1999 01:57:12 GMT, lt lindley <ltl@rgsun40.viasystems.com> wrote:

>Neko <tgy@chocobo.org> wrote:
>
>:>My first try was also quadratic.  Actually, it was just "going to do a whole
>:>lot of work to get each match", but after seeing Abigail's code/comment and
>:>thinking about it some, I've decided to just call it "quadratic" as well. :)
>
>:>    my @a = /.+?(?=(?:....)*\z)/gs;
>
>:>My second try is less quadratic:
>
>Only less quadratic by the last iteration (though I guess
>you could arguue that 1 less is less :-).  I don't think the
>definition of quadratic works that way.  This solution would
>continue to increase in cost quadratically as the length
>of the string increased.  If I am wrong about that, somebody
>explain it to me please. 
>
>:>    my @a = /(?!^)....|.+?(?=(?:....)*\z)/gs;

The first match will match the second alternative, which searches the entire
string of N characters.  However, the second and subsequent matches will each
only need to search the next 4 characters to match the first alternative, for
a total of between N and (N - 4) characters.  So that's (2 * N - 4) or just
(2 * N), which is linear.

Hope I got that right.  Just in case though:

#!/usr/bin/perl -w

use Benchmark;
$|++;

for (1, 2, 4, 8, 16) {
    my $str = '1234567890' x $_;
    print "N=", length $str, "\n";
    timethese 20000, {
        Neko1   => sub { my @a = $str =~ /.+?(?=(?:....)*\z)/gs },
        Neko2   => sub { my @a = $str =~ /(?!^)....|.+?(?=(?:....)*\z)/gs },
    };
    print "\n";
}

__END__
N=10
Benchmark: timing 20000 iterations of Neko1, Neko2...
     Neko1:  0 wallclock secs ( 0.77 usr +  0.00 sys =  0.77 CPU)
     Neko2: -1 wallclock secs ( 0.61 usr +  0.00 sys =  0.61 CPU)

N=20
Benchmark: timing 20000 iterations of Neko1, Neko2...
     Neko1:  2 wallclock secs ( 1.48 usr +  0.00 sys =  1.48 CPU)
     Neko2:  1 wallclock secs ( 0.99 usr +  0.00 sys =  0.99 CPU)

N=40
Benchmark: timing 20000 iterations of Neko1, Neko2...
     Neko1:  3 wallclock secs ( 3.46 usr +  0.00 sys =  3.46 CPU)
     Neko2:  2 wallclock secs ( 1.48 usr +  0.00 sys =  1.48 CPU)

N=80
Benchmark: timing 20000 iterations of Neko1, Neko2...
     Neko1:  9 wallclock secs ( 9.66 usr +  0.00 sys =  9.66 CPU)
     Neko2:  3 wallclock secs ( 2.46 usr +  0.00 sys =  2.46 CPU)

N=160
Benchmark: timing 20000 iterations of Neko1, Neko2...
     Neko1: 32 wallclock secs (32.35 usr +  0.00 sys = 32.35 CPU)
     Neko2:  5 wallclock secs ( 4.55 usr +  0.00 sys =  4.55 CPU)


-- 
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=


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

Date: 4 Nov 1999 00:44:22 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: How can I set reg. expresion to anchor at the end of a string?
Message-Id: <slrn822b18.dk.abigail@alexandra.delanet.com>

lt lindley (ltl@rgsun40.viasystems.com) wrote on MMCCLVI September
MCMXCIII in <URL:news:7vqp5o$44f$1@rguxd.viasystems.com>:
<> 
<> I think this is one of those times where a less Perlish solution is
<> in order.  I kept thinking "this would be so easy in C".
<> 
<> $_ = '1234245678';
<> my @x;
<> for (my $curpos = length($_) - 4;; $curpos -= 4) {
<> 	if ($curpos < 0) {
<> 		unshift @x, substr($_, 0, 4 + $curpos);
<> 		last;
<> 	} 
<> 	unshift @x, substr($_, $curpos, 4);
<> }
<> print "@x\n";

No reverses, no unshifts, and no conditionals in a loop:

@x = do {local $_ = $str;    
        (length ($_) % 4 ? substr $_ => 0, length ($_) % 4, "" : ()) => /..../gs
     };    

Or, if you don't want to copy the string:

@x = ((length ($str) % 4 ? substr $str => 0, length ($str) % 4 : ()),
      (substr  $str => length ($str) % 4) =~ /..../gs);


Too bad substr STR, OFFSET, 0 doesn't return the empty list in list context.


Abigail
-- 
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
 |perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
 |perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
 |perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Thu, 4 Nov 1999 11:58:28 +0100
From: "Matt King" <mattking@techie.com>
Subject: Lost in Splitting.......
Message-Id: <7vrort$71c$1@news.uk.ibm.com>

I have a question that will sound  real basic for you pro's. I'm trying to
read in a files contence and display it in a table. First off the script
needs to creat the table 'headder' based on the first line of the plain text
file. The first line looks like this:
 ITEM 1/1   ITEM 2/2           DESCRIPTION
This is not tab delmitated and the file has some 60000 lines in it so
changing the format would be just to much work. I'm trying to read in and
split the above like this:
 ...
  foreach $line(@LINES) {
  ($item1,$item2,$item3) = ($line =~  m{
                 \s*
                (\S*(\s*)\S*)\s*
                (\S*(\s*)\S*)\s*
                (.*)\s*}x);
 ...

Then I print the output to make sure I got what I want with this (for now,
later in a table format):
print "($item1)($item2)($item3)\n";

The output looks like this:
(ITEM 1/1)()( ITEM)

What is wrong with this split? I have been trying different 'formats', but I
can't find the one that will give me the output that looks like this, which
is the one I need:
(ITEM 1/1)(ITEM 2/2)(DESCRIPTION)

Can someone please point out where my eror is and what I need to change to
make this work. Note there there is a space in the first two items and and
the third item needs all remaining items even if there is a space.

Thanks for your help.
Matt




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

Date: Thu, 04 Nov 1999 01:29:39 -0800
From: Please deposit 35 cents <tex@off.org>
Subject: Re: mirror command
Message-Id: <38215203.2EE0@off.org>

bruce wrote:
> 
> > > that it can't find LWP/simple.pm,
> >
> > Have you seen what perldiag has to say about the "massage" that you're
> > getting?
> 
> (so much for spell checkers)
> 
> here's the message:
>     Can't locate LWP/simple.pm in @inc
> 
> which I've attempted to solve using use LIB /mydir
> and loading simple.pm to mydir.
> 
> thanks.

	All published packages (with one notable exception) capitalize
the first letter in each part of the package name. Perhaps you wanted
to try:

use LWP::Simple;

	Austin


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

Date: Thu, 04 Nov 1999 05:20:58 GMT
From: daniel_simser@my-deja.com
Subject: Netscape URI values... Newbie
Message-Id: <7vr53o$3hn$1@nnrp1.deja.com>

I am sending a querystring to a cgi script and need to grab the
variables from the string and use them later. When I use
IE the URI looks like: script.cgi?name=dan%20image=one%20...
Netscape looks like: script.cgi?name=dan$image=one two  three...

How can I get netscape to look like ie?

Thanks


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 04 Nov 1999 07:05:38 GMT
From: "Daniel Simser" <daniel@allfilms.com>
Subject: Re: Netscape URI values... Newbie
Message-Id: <6faU3.1295$sa5.44863@dfiatx1-snr1.gtei.net>

figured this simple one out...

use URI::Escape;
my $q_string = "name=     fooo&blah=fhh   .., ";

# one way
uri_escape($q_string);

# another
print "<a href=\"http://$ENV{SERVER_NAME}/cgi-bin/slour.cgi?".uri_escape("
abunch of crap")."\">blah</a>";

daniel_simser@my-deja.com wrote in message <7vr53o$3hn$1@nnrp1.deja.com>...
>I am sending a querystring to a cgi script and need to grab the
>variables from the string and use them later. When I use
>IE the URI looks like: script.cgi?name=dan%20image=one%20...
>Netscape looks like: script.cgi?name=dan$image=one two  three...
>
>How can I get netscape to look like ie?
>
>Thanks
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.




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

Date: 01 Nov 1999 16:24:11 -0500
From: kevin montuori <montuori@acs.neu.edu>
Subject: Re: Newbie help
Message-Id: <ygewvs16h38.fsf@spot.acs.neu.edu>

>>> kb9nvh  writes:
  ts> The code below prints the $i variable and then the text "+1".  I
  ts> want 1 to be added to $i and the sum printed.  What do I do
  ts> Please?  Any help is appreciated...  Todd Snyder

among other possibilities:


my $i = 5;

print <<"EOF";
this is the number @{[ $i + 1 ]}
EOF



cheers,
k.

-- 

kevin montuori            



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

Date: Thu, 4 Nov 1999 12:00:29 +0100
From: "Jakob" <asd@ds.aw>
Subject: Perl / NIS+
Message-Id: <7vrpll$qgu@sdaw04.seinf.abb.se>

Hi all.

I need to run nispasswd (or equvivalent) from within a Perl script. This
because oure users are running X-clients (Reflection) and it's not possible
to
configure Ref* for unforseen circumstances such as pw changing.

I've tried using filehandles but that doesnt seem to work ...

Help ?




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

Date: Thu, 04 Nov 1999 02:03:04 -0500
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Perl and commonsense part 2
Message-Id: <brian-0411990203040001@40.new-york-68-69rs.ny.dial-access.att.net>

In article <vl7U3.26391$23.1387141@typ11.nn.bcandid.com>, kragen@dnaco.net (Kragen Sitaker) wrote:

>In article <If3U3.86$KN4.1769@nsw.nnrp.telstra.net>,
>Martien Verbruggen <mgjv@comdyn.com.au> wrote:


>>Comparing JavaScript to Perl is of course nonsensical, but that's
>>another issue.
>
>I don't think it's nonsensical at all.  Anything that can be done in
>one language can be done in the other. 

that's not really true, especially since Javascript is a sandboxed
langauge (meaning that it is intentionally crippled as part of its
security model).

but of course, there are things that you can't do in Perl that you
can do in C, like access memory addresses, because Perl doesn't
let you do that.

and in FORTRAN you can't ...

and the list goes on and on.  langauges have design limits - some
intentional and some not.  not all langauges are the same, and not 
all of them have the same capabilities.

-- 
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ 
  <URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>



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

Date: Thu, 04 Nov 1999 10:24:07 GMT
From: Samuel Kilchenmann <skilchen@swissonline.ch>
Subject: Re: Perl and Excel Charting
Message-Id: <7vrms6$fdv$1@nnrp1.deja.com>

In article <38207945.A6C12195@bellatlantic.net>,
  James Tolley <jtolley@bellatlantic.net> wrote:
> Kragen Sitaker wrote:
>
> > >Hope this helps, and thanks for any help anyone might have on this
> > >SaveAs("filename:=whatever.xls")?!? issue,
> >
> > 'filename' => 'whatever.xls', perhaps?
>
> Thanks, but it doesn't seem to work.
>
From perldoc Win32::OLE:
  Named parameters can be specified in a reference to a
  hash as the last parameter to a method call.
In the SYNOPSIS of Win32::OLE you find this example:
   $ex->Dmethod($RequiredArg1,
                {NamedArg1 => $Value1,
                 NamedArg2 => $Value2});

Your AddNew procedure in Perl:
sub AddNew {
  my $newBook = $app->Workbooks->Add();
  $newBook->{Title} = "1995 Sales";
  $newBook->{Subject} = "Sales";
  $newBook->SaveAs({Filename => "95Sales.xls"});
  return undef;
}


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 04 Nov 1999 07:35:34 GMT
From: nospam.newton@gmx.li (Philip 'Yes, that's my address' Newton)
Subject: Re: proposed "??" operator causing ambiguous syntax
Message-Id: <382133ce.253127203@news.nikoma.de>

On Wed, 3 Nov 1999 14:49:59 -0800, Tom Phoenix <rootbeer@redcat.com>
wrote:

>Having said that, I see that we don't complain that these are potentially
>ambiguous if whitespace is removed:
>
>    $fred =~ $barney;
>
>    $fred = ~ $barney;

Or pathological stuff like

    $a - -+5

    $a-- + 5

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>


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

Date: Thu, 04 Nov 1999 05:47:48 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: replace " " with &nbsp;
Message-Id: <869U3.26546$23.1410082@typ11.nn.bcandid.com>

In article <7vqsed$6am$1@fir.prod.itd.earthlink.net>,
Blair Heuer <ab@cd.com> wrote:
>I need a line, or lines, of code that will take each element in a list,
>check for any leading spaces, and change those into non-breaking spaces
>(&nbsp;).

s/^( +)/'&nbsp;' x length $1/e for @list, I think.

>But I have no clue how to tell it to change all " " to "&nbsp;" until there
>is not a " " then stop and go to the next.
>Basically if i had the line (without quotes) "   Hello World!" I would want
>the code to change it to "&nbsp;&nbsp;&nbsp;Hello World!"
>
>I hope that the non-breaking spaces were not interpreted as merely " " so
>you can see what i was writing.
>
>Just so you know, this is for a message board script, so if people indent
>their paragraphs, it will come out that way in the browser.

I would be so much happier if you would just use <blockquote>.  I hate
nbsp and I hate people who use it.  (Well, maybe not quite.) Here's a
somewhat ugly example; perhaps somene can come up with a simpler way to
do this.

Basically, @prefixes contains a list of all the chunks of whitespace
found at the beginnings of lines of @list; %prefixes is there just to
uniquify them; @prefixlens contains the sorted lengths of the
whitespace prefixes; and %prefixlens maps the lengths back to their
ranks in @prefixlens.  The ranks are what we're interested in; they are
the depths of nesting of quotes.

#!/usr/bin/perl -w
use strict;
my @list = map {"$_\n"} split /\n/, <<eot;
     Here is some text.
     It is good text.
   More text.
     Yet more text.
 No ugly nbsp's here.  No no no.
eot
 
my @prefixes = map {/^(\s*)/} @list, '';
my %prefixes = map {$_ => 1} @prefixes;
my @prefixlens = sort {$a<=>$b} map {length} keys %prefixes;
# print "prefixlens: @prefixlens\n";
my %prefixlens = map {$prefixlens[$_] => $_} 0..$#prefixlens;
my $oldprefix = 0;
push @list, '';
for (@list) {
	s/^(\s*)//;
	my $prefix = length $1;
	my $indent = $prefixlens{$prefix} - $prefixlens{$oldprefix};
	# print "indent is $indent; prefix is $prefix\n";
	if ($indent > 0) {
		$_ = ('<blockquote>' x $indent) . $_ . '<br>';
	} elsif ($indent < 0) {
		$_ = ('</blockquote>' x -$indent) . $_ . '<br>';
	} else {
		$_ .= '<br>';
	}
	$oldprefix = $prefix;
}
print @list, "\n";
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Nov 02 1999
6 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 04 Nov 1999 05:49:58 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: replace " " with &nbsp;
Message-Id: <a89U3.26549$23.1410449@typ11.nn.bcandid.com>

In article <slrn822449.2r5.efflandt@efflandt.xnet.com>,
David Efflandt <efflandt@xnet.com> wrote:
>Perhaps you should start by typing 'perldoc perlre' (without quotes) on a
>system with Perl on it.  This is a simple search and replace:
>
>foreach (@list) { s/ /&nbsp;/g; }

It's not *that* simple.  He wants *leading* spaces changed.

I think it's a terrible idea.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Nov 02 1999
6 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: 04 Nov 1999 01:15:48 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: replace " " with &nbsp;
Message-Id: <kusvh7ibx4b.fsf@charm.bu.edu>

"Blair Heuer" <ab@cd.com> writes:
> I need a line, or lines, of code that will take each element in
> a list, check for any leading spaces, and change those into
> non-breaking spaces (&nbsp;).

This works. Dunno if it's optimal..

#!/usr/local/bin/perl -w
use strict;
my @foo = ("   hi", " bye", "die   ", "  rye  ", " sky high ");
for(@foo){
    s{^( +)(.+)}{'&nbsp;' x length($1) . $2}e;
    print $_, "|\n";
}

yields

&nbsp;&nbsp;&nbsp;hi|
&nbsp;bye|
die   |
&nbsp;&nbsp;rye  |
&nbsp;sky high |

How it works:

1) the for(@foo) loop, iterates in turn over each element of
@foo, assigning the current element to the variable $_.
2) in general the substitution operator looks like
$foo =~ s/bar/baz/, but if there's no $foo part, it
operates on the $_ variable.
3) instead of s///, you can use either a) any non-alphanumeric
character in place of '/', or b) naturally paired delimiters
like '{}' or '()'; the pattern and replacement parts can even
be different as in s{}(), where {} delimit the pattern and
() delimit the replacement.
4) a caret '^' at the beginning of the pattern in s///
"anchors" the match to the beginning of the string
5) /^( +)(.+)/ means: match only at the beginning of $_,
followed by one or more spaces followed by one or more
of any characters (indicated by a dot '.').
6) the parentheses above mean to group one or more spaces
and save it into the variable $1 and group one or more
of any characters and save it into $2.
7) like I said in part 4, the second half
8) the 'e' modifier to s/// causes the replacement part
to be evaluated like Perl code rather than a double-quoted
string.
9) length($1) returns the length of $1, in this case the
number of spaces at the beginning of $_
10) the dot '.' on the replacement side means to concatenate
its two operands into one string
11) the 'x' operator expands the string to its left as many
times as the operand on the right. For example, 'foo' x 3
expands to 'foofoofoo'.
12) then I print what's left in $_, followed by a pipe '|'
to indicate that some spaces remain at the end

Again, this might not be optimal, but it works, as I hope
you can see..

-- 
"It showed a lady, with a fur cap on and a fur stole, sitting upright
and holding out to the spectator a huge fur muff into which the whole
of her forearm had vanished!" --From Franz Kafka's Metamorphosis


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

Date: Thu, 04 Nov 1999 06:12:21 GMT
From: nik@removethis.sinesurf.co.nz (Nik Smiğr Warrensson)
Subject: Re: Who is worse: Cops or Criminals
Message-Id: <38212281.255067181@news.xtra.co.nz>

>> > >By the way-- would you believe there are countries in this world where cops
>> > >rarely carry side arms?  New Zealand is a good example.  The cops there don't
>> > >
>> > >carry guns unless they need them.. They don't train with the Special Forces
>> > >tol earn how to best attack a house.

Learn about what you're talking about before you engage your mouth.
I've spent just short of 7 years in the New Zealand Army and I saw
Police training at the same time as I was doing my specialist Corp
training. They do indeed train with the Special Forces.


>> > Funny you should choose New Zealand.

Amusing indeed in your ignorance.

>>  I have a cousin who is one of those cops you seem to admire so much, he is a Sergeant and a prosecutor(The cops perform
>> > that function down there).  I mentioned to him  that it was probably an
>> > interesting job, and he replied, " Not really, everyone here pleads guilty."
>> > He went on to compare the CITIZENS of New Zealand to Americans (This means
>> > YOU).  The fundamental urge to scream"I didn't do it" while holding the smoking
>> > gun is not a common occurrance, like it is here. In this country, everyone is
>> > innocent and the cops are always wrong (according to WAY too many people).
>> > In addition, the New Zealand citizenry are not armed as it is here,

New Zealand has the highest rate of legal Rifle ownership in the world
- kinda shoots down your argument. Fully 10% of the population has a
firearms license and the average rate of ownership is two firearms for
license.

> and the homicide rate of the country is less than most precincts in the US, thus the
>> > need to carry is not as important.  It is typical that these facts eluded you
>> > as you spouted that idiot logic.

Look who's talking. New Zealand has a worse record for non-weapon
violence than America.

My father used to be a Prison Chaplain. I can remember my 9 year old
sister sitting between the "Top Dog" of Paparua Prison and Ronald
Jorgensen famous for his Machine Gun murders in the late 60's.

>> > >They don't cruise the streets like predators looking for some prey..

Yes they do. I know this all too well.

>> > Thats exactly what cops are paid to do.
>> > Moron.

Who's the moron here?

>> >  I know it pains you to hear it, but whatever you think of cops, the citizens
>> > that they protect, in general, are worse.
>> >
>> Shoot the horse. You can't lead the Rev. to water. His misinformed
>> statement was made to suit his purpose. We see many who use half-facts
>> such as his to prove their unpopular viewpoints on Usenet.
>
>I prove whatever half-facts I want, fuckhead.  But did I tell you you could get 
>your tongue out of my asshole and speak?  GET BACK TO WORK YOU LITTLE SHIT.
>
>This is your last warning.

I hope you enjoy my comments about New Zealand.

Nik


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

Date: 4 Nov 1999 01:09:46 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Year 2000 date problem
Message-Id: <slrn822cgr.dk.abigail@alexandra.delanet.com>

Craig Berry (cberry@cinenet.net) wrote on MMCCLV September MCMXCIII in
<URL:news:s21bfjog24218@corp.supernews.com>:
<> 
<> For future ref, the above can be more legibly written
<> 
<>   @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec);
<>   @days   = qw(Sun Mon Tue Wed Thur Fri Sat);
<> 
<> By the way, is it intentional that September and Thursday don't follow the
<> 3-character-abbreviation patten?  Looks weird to me.

Thursday is 4 days after the weekend, but not late enough to be just
before a weekend. And well, September never ends.

So, September is the longest month, and Thursday the longest day. That
of couse has to be signalled.



Abigail
-- 
               split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_)  {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Thu, 04 Nov 1999 07:34:53 GMT
From: nospam.newton@gmx.li (Philip 'Yes, that's my address' Newton)
Subject: Re: Year 2000 date problem
Message-Id: <382131ea.252643353@news.nikoma.de>

On Wed, 03 Nov 1999 16:36:29 +0100, Frederic TYNDIUK
<tyndiuk@ftls.org> wrote:

>	Sorry I have forgotten the NOT, It's NOT "modulus" operation (1999 %
>100) what is the reason why $yr="20year"; doesn't work...

Even if the year *were* modulo 100, having $yr be "201" ('20' . 1) in
the year 2001 is not much better.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 1275
**************************************


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