[25780] in Perl-Users-Digest
Perl-Users Digest, Issue: 8019 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 27 06:05:25 2005
Date: Wed, 27 Apr 2005 03:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 27 Apr 2005 Volume: 10 Number: 8019
Today's topics:
Re: 10,20,30,40 <pilkowsk@informatik.uni-marburg.de>
Re: 10,20,30,40 <mdetomaso@bak.rr.com>
Re: 10,20,30,40 <see.sig@rochester.rr.com>
Re: 10,20,30,40 <mdetomaso@bak.rr.com>
Re: 10,20,30,40 <mdetomaso@bak.rr.com>
Re: A new scripting language Tao 0.9.0 beta released! (Fu Limin)
Nww Data types <guenther.sohler@newlogic.com>
Re: Nww Data types <tassilo.von.parseval@rwth-aachen.de>
print table inside while <hackeras@gmail.com>
Re: print table inside while <asoNOSPAMlkar@gmail.com>
Re: print table inside while <hackeras@gmail.com>
Re ANN: A new scripting language Tao 0.9.0 beta release (Fu Limin)
Re: Re ANN: A new scripting language Tao 0.9.0 beta rel <donal.k.fellows@manchester.ac.uk>
regex ip address exclusion <fsjfjs@nospma.net>
Re: regex ip address exclusion <someone@example.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 27 Apr 2005 03:06:35 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: 10,20,30,40
Message-Id: <3d86psF6plddoU1@individual.net>
* Steven Kuo schrieb:
> On Wed, 27 Apr 2005, Dan Jacobson wrote:
>
>> Is this how the pros would do this?
>> $ perl -we 'print join ",", map($_*10,(1..10))'
>> 10,20,30,40,50,60,70,80,90,100
>> Simpler ways would get an extra comma, or be meant for non gappy lists.
>
> If you're inquring about "perl golf", then the best I could do was:
>
> $ perl -e '$,="0,";print 1..10,"\b"'
Just because my windows shell doesn't like the deleting "\b" so much and
there is no need to print out more characters than really desired:
$ perl -e 'print+join("0,",1..10),0'
But I like your idea.
regards,
fabian
------------------------------
Date: Wed, 27 Apr 2005 01:17:59 GMT
From: "Michael De Tomaso" <mdetomaso@bak.rr.com>
Subject: Re: 10,20,30,40
Message-Id: <bLBbe.21288$JB.15364@tornado.socal.rr.com>
"Dan Jacobson" <jidanni@jidanni.org> wrote in message
news:877jip700r.fsf@jidanni.org...
> Is this how the pros would do this?
> $ perl -we 'print join ",", map($_*10,(1..10))'
> 10,20,30,40,50,60,70,80,90,100
> Simpler ways would get an extra comma, or be meant for non gappy lists.
Q:... when I tried to cut-n-paste it into my WIN: ActiveState I got the
following Error Message, & don't know why ???
D:\study\perl\WIP>perl -we 'print join ",", map($_*10,(1..10))'
Can't find string terminator "'" anywhere before EOF at -e line 1.
- thanks & take care M.D.
<aka>
_ _
| |_ ___ _ __ ___ __ _ | |_ ___ ___
| __| / _ \ | '_ ` _ \ / _` | | __| / _ \ / _ \
| |_ | (_) | | | | | | | | (_| | | |_ | (_) | | __/
\__| \___/ |_| |_| |_| \__,_| \__| \___/ \___|
------------------------------
Date: Wed, 27 Apr 2005 01:35:36 GMT
From: Bob Walton <see.sig@rochester.rr.com>
Subject: Re: 10,20,30,40
Message-Id: <I%Bbe.8721$Bc7.4997@twister.nyroc.rr.com>
Michael De Tomaso wrote:
> "Dan Jacobson" <jidanni@jidanni.org> wrote in message
> news:877jip700r.fsf@jidanni.org...
...
>>$ perl -we 'print join ",", map($_*10,(1..10))'
...
> Q:... when I tried to cut-n-paste it into my WIN: ActiveState I got the
> following Error Message, & don't know why ???
>
> D:\study\perl\WIP>perl -we 'print join ",", map($_*10,(1..10))'
> Can't find string terminator "'" anywhere before EOF at -e line 1.
That's because the Windoze command line processor doesn't
recognize ' as a quoting character, but does recognize ". Try:
perl -we "print join ',',map $_*10,1..10"
That is a Windoze issue, not a Perl issue, except for how it
botches up Perl one-liners.
> - thanks & take care M.D.
...
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Wed, 27 Apr 2005 04:57:32 GMT
From: "Michael De Tomaso" <mdetomaso@bak.rr.com>
Subject: Re: 10,20,30,40
Message-Id: <0ZEbe.21315$JB.4519@tornado.socal.rr.com>
"Bob Walton" <see.sig@rochester.rr.com> wrote in message
news:I%Bbe.8721$Bc7.4997@twister.nyroc.rr.com...
> Michael De Tomaso wrote:
>
>> "Dan Jacobson" <jidanni@jidanni.org> wrote in message
>> news:877jip700r.fsf@jidanni.org...
> ...
>>>$ perl -we 'print join ",", map($_*10,(1..10))'
> ...
>> Q:... when I tried to cut-n-paste it into my WIN: ActiveState I got the
>> following Error Message, & don't know why ???
>>
>> D:\study\perl\WIP>perl -we 'print join ",", map($_*10,(1..10))'
>> Can't find string terminator "'" anywhere before EOF at -e line 1.
>
> That's because the Windoze command line processor doesn't recognize ' as a
> quoting character, but does recognize ". Try:
>
> perl -we "print join ',',map $_*10,1..10"
>
> That is a Windoze issue, not a Perl issue, except for how it botches up
> Perl one-liners.
>
>> - thanks & take care M.D.
> ...
> --
> Bob Walton
> Email: http://bwalton.com/cgi-bin/emailbob.pl
Bob,
Thanks for your input, and setting me straight on Double Quotes .vs. Single
Quotes
in WINders, etc.
Seems like you even beat the Relay Chat folks too !!!
IRC - UnderNet - #perl
[18:08] < tomatoe > I was reading some of the comp.lang.perl.misc newsgroup
and came upon this line of code in a message:
[18:08] < tomatoe > perl -we 'print join ",", map($_*10,(1..10))'
[18:08] < tomatoe > but when I tried to cut-n-paste it into my WIN:
ActiveState I got the following Error Message, & don't know why ???
[18:08] < tomatoe > Can't find string terminator "'" anywhere before EOF
at -e line 1.
...
[19:37] < black-ice > tomatoe: on windows use " not ' for -e perl lines
[19:37] < black-ice > so, that means you will need to fix the "" inside the
oneliner as well.
[19:38] < black-ice > so perl -we "print join ',',map($_*10,(1..10))"
...
D:\study\perl\WIP>perl -we "print join ',',map($_*10,(1..10))"
10,20,30,40,50,60,70,80,90,100
[21:45] < tomatoe > ty black-ice, Quotes " on the outside, & singleQuote on
the inside ' worked
- take care M.D.
------------------------------
Date: Wed, 27 Apr 2005 05:17:05 GMT
From: "Michael De Tomaso" <mdetomaso@bak.rr.com>
Subject: Re: 10,20,30,40
Message-Id: <lfFbe.21332$JB.9742@tornado.socal.rr.com>
"Steven Kuo" <skuo@mtwhitney.nsc.com> wrote in message
news:Pine.GSO.4.21.0504261710090.27341-100000@mtwhitney.nsc.com...
> On Wed, 27 Apr 2005, Dan Jacobson wrote:
>
>> Is this how the pros would do this?
>> $ perl -we 'print join ",", map($_*10,(1..10))'
>> 10,20,30,40,50,60,70,80,90,100
>> Simpler ways would get an extra comma, or be meant for non gappy lists.
>
>
> If you're inquring about "perl golf", then the best I could do was:
>
> $ perl -e '$,="0,";print 1..10,"\b"'
>
> --
> Regards,
> Steven
>
Go get em Tiger :)
... U folks have some killer coding ways:
Generic perl golf rules: http://www.xs4all.nl/~thospel/golf/rules.html
very interesting.
- thanks & take care M.D.
<aka>
_ _
| |_ ___ _ __ ___ __ _ | |_ ___ ___
| __| / _ \ | '_ ` _ \ / _` | | __| / _ \ / _ \
| |_ | (_) | | | | | | | | (_| | | |_ | (_) | | __/
\__| \___/ |_| |_| |_| \__,_| \__| \___/ \___|
------------------------------
Date: 27 Apr 2005 00:37:16 -0700
From: fu.limin.tao@gmail.com (Fu Limin)
Subject: Re: A new scripting language Tao 0.9.0 beta released!
Message-Id: <b35444fb.0504262337.3fce3ab3@posting.google.com>
"Frank J. Lhota" (NOSPAM.Lhota.adarose@verizon.net) wrote:
> What! No backtracking and goal-driven evaluation?!
Currently no.
Don't be surprised if there is something missing in Tao, it's still quite new:-)
------------------------------
Date: Wed, 27 Apr 2005 08:56:33 +0200
From: Guenther Sohler <guenther.sohler@newlogic.com>
Subject: Nww Data types
Message-Id: <pan.2005.04.27.06.56.33.228698@newlogic.com>
Hallo Group,
Due to your great Help in the last Days I was able to
use embedded perl in c for my program. I was also able to
register my own c functions with my perl interpreter useing newXS.
Now I am wondering if its even possible to integrate my own
data type. At the moment I am calculating with integers and floats and
strings. and it works very well.
But due to the graphical nature of my prg it would be nice, if I could
add a new data type eg Point, which contains two floats(x and y)
or a list of Points, (or maybe a list of strings).
Is it possible ?
Maybe I would finally write
$pt=convert_point($x,$y);
How can I implement new data tyes ?
------------------------------
Date: Wed, 27 Apr 2005 10:56:38 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: Nww Data types
Message-Id: <slrnd6uku6.41e.tassilo.von.parseval@localhost.localdomain>
Also sprach Guenther Sohler:
> Hallo Group,
>
> Due to your great Help in the last Days I was able to
> use embedded perl in c for my program. I was also able to
> register my own c functions with my perl interpreter useing newXS.
> Now I am wondering if its even possible to integrate my own
> data type. At the moment I am calculating with integers and floats and
> strings. and it works very well.
> But due to the graphical nature of my prg it would be nice, if I could
> add a new data type eg Point, which contains two floats(x and y)
> or a list of Points, (or maybe a list of strings).
> Is it possible ?
> Maybe I would finally write
>
> $pt=convert_point($x,$y);
>
> How can I implement new data tyes ?
At this point you will probably need a class other than main to bless
the point object into. I'd suggest writing a class in XS for a point:
typedef struct {
float x, y;
} Point;
MODULE = Point PACKAGE = Point
Point*
new (char *CLASS, float x, float y)
CODE:
{
New(0, RETVAL, Point, 1);
RETVAL->x = x;
RETVAL->y = y;
}
OUTPUT:
RETVAL
float
x (Point *pt)
CODE:
{
RETVAL = pt->x;
}
OUTPUT:
RETVAL
# likewise for y and other methods
Plus, you will need a typemap file:
Point* POINT
OUTPUT
POINT
sv_setref_pv( $arg, CLASS, (void*)$var );
INPUT
POINT
if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) )
$var = ($type)SvIV((SV*)SvRV( $arg ));
else{
warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" );
XSRETURN_UNDEF;
}
As always, do a
xsubpp -typemap typemap_file Point.xs
and copy the generated functions into your C program and give it a name
of your choice with newXS. If you insist on main::convert_point($x, $y)
being the constructor, change the XSUB for Point::new to:
Point*
convert_point(float x, float y)
PREINIT:
char *CLASS = "Point";
CODE:
/* rest is unchanged */
The point object itself will still be blessed into the class 'Point',
though. But the programmer writing scripts for your program will usually
not notice this because all he will do is things like this:
my $pt = convert_point(1.0, 0.5);
print $pt->x;
Note that instance methods, such as x(), need to live in the Point::
namespace, so your newXS lines now should read:
newXS("main::convert_point", XS_Point__new, file);
newXS("Point::x", XS_Point__x, file);
...
Tassilo
--
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
------------------------------
Date: Wed, 27 Apr 2005 09:58:46 +0300
From: Nikos <hackeras@gmail.com>
Subject: print table inside while
Message-Id: <d4nd71$ja8$2@nic.grnet.gr>
ok the first part that loads the values is done, here it is :-)
#===============================================================================
my @row;
my $sth = $dbh->prepare( "INSERT INTO games( gamename, gamedesc,
gamecount) VALUES (?, ?, ?)" );
open (FILE, "<../data/games/perigrafes.txt") or die $!;
while (<FILE>) {
chomp;
@row = split /\t/;
push @row, 0;
$sth->execute( @row );
}
close FILE;
#===============================================================================
And the print out in games.pl is ok except that it does nto display the
table specification formatting:
Code:
my $row;
my $sth;
$sth = $dbh->prepare( "SELECT * FROM games" );
$sth->execute();
while ( $row = $sth->fetchrow_hashref ) {
print table( {class=>'games'},
Tr(
td( submit( -name=>'game', -value=>$row->{gamename} )),
td( $row->{gamedesc} ),
td( $row->{gamecount} )
)
)
}
How should i write it so for the snipper touse the classes and print out
the table and colort correctly. ths style.css file is ok but it is not
seek of using it.
Maybe the error is that the print table is display many times inside the
loop?
Please help.
------------------------------
Date: Wed, 27 Apr 2005 01:04:20 -0700
From: Mahesh Asolkar <asoNOSPAMlkar@gmail.com>
Subject: Re: print table inside while
Message-Id: <g5KdnRS4xKkZ2vLfRVn-3g@comcast.com>
Nikos wrote:
> while ( $row = $sth->fetchrow_hashref ) {
>
> print table( {class=>'games'},
> Tr(
> td( submit( -name=>'game', -value=>$row->{gamename} )),
> td( $row->{gamedesc} ),
> td( $row->{gamecount} )
> )
> )
> }
>
> How should i write it so for the snipper touse the classes and print out
> the table and colort correctly. ths style.css file is ok but it is not
> seek of using it.
> Maybe the error is that the print table is display many times inside the
> loop?
>
I am not entirely sure what you seek here. But I would write the above
loop using start_table and end_table, on the lines of:
--- sorry, untested code ---
print start_table ({class=>'games'});
while ( $row = $sth->fetchrow_hashref ) {
print Tr(
td( submit( -name=>'game', -value=>$row->{gamename} )),
td( $row->{gamedesc} ),
td( $row->{gamecount} )
)
}
print end_table;
------
This way there will be one table with a bunch of rows, as against a
bunch of tables with one row each.
More details at (section from CGI.pm documentation):
http://tinyurl.com/d7aa8
HTH,
Mahesh.
--
Mahesh Asolkar
asolkar-at-gmail-dot-com
------------------------------
Date: Wed, 27 Apr 2005 11:50:30 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: print table inside while
Message-Id: <d4njom$qku$1@nic.grnet.gr>
Mahesh Asolkar wrote:
> Nikos wrote:
>
>> while ( $row = $sth->fetchrow_hashref ) {
>>
>> print table( {class=>'games'},
>> Tr(
>> td( submit( -name=>'game', -value=>$row->{gamename} )),
>> td( $row->{gamedesc} ),
>> td( $row->{gamecount} )
>> )
>> )
>> }
>>
>> How should i write it so for the snipper touse the classes and print
>> out the table and colort correctly. ths style.css file is ok but it is
>> not seek of using it.
>> Maybe the error is that the print table is display many times inside
>> the loop?
>>
>
> I am not entirely sure what you seek here. But I would write the above
> loop using start_table and end_table, on the lines of:
>
> --- sorry, untested code ---
> print start_table ({class=>'games'});
> while ( $row = $sth->fetchrow_hashref ) {
> print Tr(
> td( submit( -name=>'game', -value=>$row->{gamename} )),
> td( $row->{gamedesc} ),
> td( $row->{gamecount} )
> )
> }
> print end_table;
> ------
>
> This way there will be one table with a bunch of rows, as against a
> bunch of tables with one row each.
Yes iam seekign that exatcly you describes but for some reason the table
formatting does not being applied although the path to the style.css
file is correct and the formatiing directives in the file is this:
#info games {
background-image : url(/data/images/blue.jpg);
width: 80%;
color: lime;
text-align: center;
font: 18px comic;
border: 8px ridge magenta;
border-collapse: : collapse;
}
I dont see neither alignment, neither colors, neither table borders,
neither backgrounds nothing at all.
I run your code but what i see is the rows one after another even
without a '\n' after each row.
------------------------------
Date: 27 Apr 2005 00:55:49 -0700
From: fu.limin.tao@gmail.com (Fu Limin)
Subject: Re ANN: A new scripting language Tao 0.9.0 beta released!
Message-Id: <b35444fb.0504262355.5083d3e3@posting.google.com>
"Kenneth Downs" (knode.wants.this@see.sigblock) wrote:
> In all sincerity, sounds like you described PHP. What does Tao have that
> would draw anyone away from PHP?
Honest saying, I didn't intend to draw people from other languages, I
was just trying
to implement a language in a way that I think it should be, and
provide people another
option. Of course, there will be some features in Tao will not be
available in
PHP, e.g., built-in types for numerical computation, as pointed out by
Ara.T.Howard.
Regards,
Limin
------------------------------
Date: Wed, 27 Apr 2005 10:41:03 +0100
From: "Donal K. Fellows" <donal.k.fellows@manchester.ac.uk>
Subject: Re: Re ANN: A new scripting language Tao 0.9.0 beta released!
Message-Id: <d4nmjp$2eb1$1@godfrey.mcc.ac.uk>
Fu Limin wrote:
> Honest saying, I didn't intend to draw people from other languages, I
> was just trying to implement a language in a way that I think it
> should be, and provide people another option. Of course, there will
> be some features in Tao will not be available in PHP, e.g., built-in
> types for numerical computation, as pointed out by Ara.T.Howard.
In what ways is your language distinctive? How does developing your own
language (as opposed to making stronger one of the languages whose
newsgroups you've posted to) make the sum of human experience richer?
And do any of these observations/questions below help you explain these
larger matters? :^)
Odd things I've noticed in a quick trawl through your docs:
* What no bit-ops? And why give ^ a non C/C++ meaning?
* What sort of characters are you using?
* How does passing by reference square with constant arguments?
* Your I/O interface has a /long/ way to go!
* The complex number and matrix stuff seems reasonable.
* It is probably a good idea to add something like a C/C++ switch; it
might only be syntactic sugar around if, but good syntax makes a
difference.
* Given that you are using mutable objects, do you have a way for
someone to force a duplicate of an arbitrary object? That would make
doing things like security separation much easier.
* The ~~ operator is neat.
* Do you have some kind of subtype operator?
* Are classes, namespaces and modules all objects? Can you introspect
on them to discover what exists and what you can do with them?
I think that's enough points to be going on with for now. :^)
Donal.
------------------------------
Date: Wed, 27 Apr 2005 13:48:27 +1000
From: "gooofoofs" <fsjfjs@nospma.net>
Subject: regex ip address exclusion
Message-Id: <d4n22c$bkt$1@news-01.bur.connect.com.au>
Im currently using the script below to find lines with valid IP addresses.
Now whats the best way to exclude any IP address in the 10.0.0.0 range.
#!/usr/bin/perl -w
open(FILE, "logfile.log");
foreach $string (<FILE>){
if($string =~ /(\d+)(\.\d+){3}/){
print $string }
}
close(FILE);
------------------------------
Date: Wed, 27 Apr 2005 05:43:02 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: regex ip address exclusion
Message-Id: <GDFbe.1508$0X6.1343@edtnps90>
gooofoofs wrote:
> Im currently using the script below to find lines with valid IP addresses.
> Now whats the best way to exclude any IP address in the 10.0.0.0 range.
>
>
> #!/usr/bin/perl -w
> open(FILE, "logfile.log");
>
> foreach $string (<FILE>){
>
>
> if($string =~ /(\d+)(\.\d+){3}/){
> print $string }
>
>
> }
>
> close(FILE);
$ perl -e'
use Socket;
for my $addr ( qw/ 1 10000 999999 abcd 1.2.3.4 zzzz 1.2.3.400 10.44.55.66 / ) {
eval { inet_ntoa inet_aton $addr };
if ( $@ ) {
print "$addr is NOT valid.\n";
}
else {
print "$addr is valid";
if ( ( inet_aton( $addr ) & "\xff\0\0\0" ) eq "\x0a\0\0\0" ) {
print " and is in range";
}
print ".\n";
}
}
'
1 is valid.
10000 is valid.
999999 is valid.
abcd is NOT valid.
1.2.3.4 is valid.
zzzz is NOT valid.
1.2.3.400 is NOT valid.
10.44.55.66 is valid and is in range.
John
--
use Perl;
program
fulfillment
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 8019
***************************************