On 11/09/2011 12:26 PM, Sandro CAZZANIGA wrote:
2011/11/9 Bennett Toddb...@rahul.net
I think this list may have fallen into disuse. I don't have any fresh
juicy bits to share, I'm sorry. I hope you inspire some contributions to
re-kindle the list.
The only cool perl trick I recall at this
spaces but it does work.
golf away!
uri
perl -le 'print join \n, map {tr/01/NY/; $_} map unpack( b5, chr), 0 .. 31'
--
Uri Guttman -- [EMAIL PROTECTED] http://www.sysarch.com --
- Perl Code Review , Architecture, Development, Training, Support --
- Free Perl
count 9 errors and 213 characters removed. Though, I can't
DC count, so that may be wrong. Did I miss anything?
i dunno. i can't figure it out either. that is why i posted it here! :)
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem
sub new{bless{0,@_},$_[0]}
my double reverse thing has the same flaw. but i don't think the extra
key/value is legit (being the judge of this contest :).
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture
that i would use lisp assoc lists! :)
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs http://jobs.perl.org
sub new [EMAIL PROTECTED],shift}
that is the same as my shorter golf answer. maybe i counted mine wrong.
MGS sub new {$a=shift;[EMAIL PROTECTED],$a}
MGS 21. And it's even strict clean. :)
that is nice. the other replies beat it though!
uri
--
Uri Guttman -- [EMAIL PROTECTED
to splice or shift.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs http://jobs.perl.org
MGS == Michael G Schwern [EMAIL PROTECTED] writes:
MGS Uri Guttman wrote:
is there any guarantee of evaluation order in arg lists? will the
bless/splice always be executed before the pop?
MGS I believe it is undefined, so it's not recommended that you do
MGS anything order dependent
it be fun to post more snippets and taunt
them with happy fun ball?
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs http
to my heart's content? :)
this is code for cpan. your requests are requirements for top quality
cpan code!
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs
there are plenty of small errors, typos, format
issues etc. i did these slides under time pressure and never fixed up
the plentiful bugs as they were not public.
thanx,
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems
://sysarch.com/computershare/hashes/index.html
yes, i know the sets slide is empty. i didn't have time to write it.
you can show these slides to others but attribute them to me, please. i
didn't even put copyright notices in the templates so don't rip me off
for my lifetime + 75 years!
uri
--
Uri Guttman
such as which are
really variations of each other. they are all hash variations when you
come down to that so the context and name of each use must be clearly
explained.
i will post here the url for these slides (with mistakes! :) when i get
them done. please be kind. :)
thanx,
uri
--
Uri Guttman
}
s ;-)
GACK!!!
and that assume knowledge of the internals of hashes. not a good thing
to teach! :)
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs
. and i am not talking obscure code,
just judicious use of statement modifiers, subs, logic order that
generally eliminates the need for else. others will use else as they
please.
thanx,
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem
DL == David Landgren [EMAIL PROTECTED] writes:
DL Uri Guttman writes:
AP == A Pagaltzis [EMAIL PROTECTED] writes:
AP * Jerrad Pierce [EMAIL PROTECTED] [2007-11-23 22:50]:
exists( $dispatch{$sub} ) ? $dispatch{$sub}-() :
warn Key $sub does not exist in the dispatch table;
AP
! :) and with outside input as in web you need to do this checking in
the server. if you know the data is clean then you can default on a
missing key but otherwise you need to check the key against the dispatch
table.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
,
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs http://jobs.perl.org
. this is not a hash issue but a detail about doing dispatch tables
cleanly. sometimes you want to predefine a default code ref in the
dispatch table and other times you want to handle the missing key when
you make the call through the dispatch table.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http
ugly in reality.
s/dispatch tables/inheritance/g ;
:)
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs http://jobs.perl.org
is
@[EMAIL PROTECTED] = () ;
and then use exists() to test instead of truth.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs
hi all,
i have released Template::Simple to cpan so get it from there and start
rendering!
thanx,
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs
-- http://en.wikipedia.org/wiki/Quine
and beyond that, reading and printing the source file of the script
isn't quining either. the goal is for a self-contained program to print
its source. so usually the quine source has to be generated on the fly
using some nasty tricks.
uri
--
Uri
$_ and so do the for loops. i wouldn't hazard a guess
as to what the code will do. i never run into that since i rarely use
$_. i use my vars on all loops and only use $_ where required
(map/grep/for modifier) or in one liners and such.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http
these
lists would be a good idea
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs http://jobs.perl.org
):
print map $_ = $unique{$_}\n, sort keys %unique;
i am curious how much faster it will run with all those changes. :)
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer
AY == Alan Young [EMAIL PROTECTED] writes:
AY Updated script at bottom.
AY On 2/23/06, Uri Guttman [EMAIL PROTECTED] wrote:
AY $text =~ s{(
AY (\b\w+(?:['-]+\w+)*\b)
why the multiple ['-] inside the words? could those chars ever begin or
end words? so just [\w'-]+ should
code review and heat
death will occur before i respond! :)
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs http://jobs.perl.org
AS == Aaron Sherman [EMAIL PROTECTED] writes:
AS On Mon, 2005-03-28 at 18:43, Uri Guttman wrote:
ZL == Zhuang Li [EMAIL PROTECTED] writes:
ZL Hi, given an array: @a = ('E1', 'E2', ..., 'En');
ZL Is there an easy way, hopefully one liner, to do the following without a
ZL loop
passed this problem to a top regex person and he sent me the
second one above (obviously untested! :).
so fame, glory and an acknowledgement in the new release all go to the
valiant warrior who solves this.
let the fl^Wgames begin!
uri
--
Uri Guttman -- [EMAIL PROTECTED] http
as that will slow it down.
as i said, it is trickier than meets the eye. that is why i settled on
the split with lookbehind as it works properly in all the corner cases.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems
fix that with another list reverse but that all will be too
slow IMO. i have another solution i think which i will test later today.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding
the () and . makes it look like about a wash golfwise
but top posting and full quoting should add penalty strokes :)
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl
# ...
XN }
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs http://jobs.perl.org
and no one found one of the faster methods:
my $padded = substr( $in . $c x $pad_len, 0, $pad_len ) ;
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs
such a construct would be legal. I'm not sure what it
K means.
you have it backwards from the string in the subject. replace that with
}{ and it works. see all the other responses.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development
/ }= (3, 5);print join ,, values %h'
5,3
where did you get the notion that hash slices won't work as an lvalue?
any list (of lvalues) can be an lvalue and a slice is just syntactic
sugar for the same list expanded out.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
. it was like coding
regexes in cobol. it was like having bush for a president.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs
and cleaner loop: untested
s/(#?\w{2,7});/fix_ent( $1 )/ge ;
sub fix_ent {
my $ent = shift ;
return $ent; if $ent =~ /^#\d{3}/ ||
$html_entities{ lc $ent } ;
return amp;$ent; ;
}
fix up to suit your taste.
uri
--
Uri Guttman
PBE == Peter B Ensch [EMAIL PROTECTED] writes:
PBE Uri Guttman wrote:
Y == Yanick [EMAIL PROTECTED] writes:
no one seems to have seen my earlier post on this so here it is again
and it is much shorter.
Y perl -pe'/\S/?($e=0):($e++and$_=)' filename
perl -0777pe's
interested.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
- Damian Conway Perl Classes -- July 1-3 -- http://stemsystems.com/class/ ---
- Stem and Perl Development, Systems Architecture, Design and Coding
Search or Offer Perl Jobs
. and advocacy has some stories i think. but a collection of
these stories would be great to have.
you can delete the cc if you wish. i know many are on two or more of
these lists.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
-- Stem is an Open Source Network Development
DC == Dave Cross [EMAIL PROTECTED] writes:
DC I'm having flashbacks to the 2000 OSCON Perl Golf Apocalypse,
DC which is something that I'm sure the organisers would like to
DC forget :)
MUST KILL ALL WHO KNOW!!
MUST KILL!!!
MUST KILL!!!
uri
--
Uri Guttman -- [EMAIL
a == abigail [EMAIL PROTECTED] writes:
a On Wed, Mar 06, 2002 at 11:15:30PM -0500, Uri Guttman wrote:
good point. $() can still wrap that but then there has to be a balance
between printf strings and double quoters. how about this wacky idea:
make a new type of string where
YS == Yitzchak Scott-Thoennes [EMAIL PROTECTED] writes:
YS Uri Guttman [EMAIL PROTECTED] wrote:
i disagree. but we shall see if larry is listening to this thread and
will back away from hash interpolation or take some of our suggestions
that make it work without killing format
alternatives. :-/
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
- Stem and Perl Development, Systems Architecture, Design and Coding
Search or Offer Perl Jobs
BD == Brent Dax [EMAIL PROTECTED] writes:
BD Uri Guttman:
BD # $prec = %hash{width} ;
BD # sprintf( qf%${prec}s, $string);
BD #
BD # sprintf( \%${prec}s, $string);
BD #
BD # is one of your alternatives. :-/
BD You forgot one.
BD sprintf('%'_%hash{width}_'s', $string
is $(%foo.string), $bar ;
no ambiguity and no confusion. how often will you need to interpolate a
hash? so make it more cumbersome as it is a rare thing. that is larry's
credo from way back. breaking % in a s/printf format is not good as that
is the very common thing to do.
uri
--
Uri Guttman
BD == Brent Dax [EMAIL PROTECTED] writes:
BD Uri Guttman:
BD # printf %d hash is $(%foo.string), $bar ;
BD #
BD # no ambiguity and no confusion. how often will you need to
BD # interpolate a
BD # hash?
BD As others have pointed out, %foo{BAR} has to work. But I have
;
printf ORDER (\n%4d %-50s %3.2f %3.2f\n,
$quantity, $p_item, $price, $ext);
that eliminates the brace issue, and the duplication of the printf
format (which is annoying to have to change in both places later).
better code is what i call fun. :)
uri
--
Uri Guttman
client a favor by simplifying the code down to his level. :)
and you should never write code for the client, you write code for the
maintainer (who may be you, the client, or anyone else!). but this is
getting off fun (even if vicki is involved :)
uri
--
Uri Guttman -- [EMAIL PROTECTED
the meaning of words can turn upside down so
BL completely.
the kabbalah is a collection of mystical and spiritual jewish teachings
and writings over the last two thousand years. it doesn't have anything
to do with the word cabal AFAIK.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http
MGS == Michael G Schwern [EMAIL PROTECTED] writes:
MGS perl.org mailing lists don't use Majordomo. They're... something
MGS else. ezlm? mailman?
definitely qmail/ezmlm.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
-- Stem is an Open Source
RF == Ryan Fischer [EMAIL PROTECTED] writes:
y/a-zA-Z//2y/0-9//1
RF That's not gonna do it. You'll kill $_. :(
you don't know y/// too well if you think that. it is a well known perl
golf trick.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
if it is not specified. that
is also a useful feature and documented.
i wouldn't call them counter intuitive as they are clearly documented
and make it more flexible than your single use approach would.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
-- Stem is an Open
and no software could
help. but i like the idea of the winner being the next judge and/or
puzzle maker.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
- Stem and Perl Development, Systems
PC == Piers Cawley [EMAIL PROTECTED] writes:
PC Uri Guttman [EMAIL PROTECTED] writes:
AS == Andrew Savige [EMAIL PROTECTED] writes:
AS 1. Timing
you started it just as i was leaving for LISA. :( i should be around
for the next one. just don't do one around the time
to golf. looks like a lot of fun i am
skipping.
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
- Stem and Perl Development, Systems Architecture, Design and Coding
Search or Offer
to solve this cutesy
problem. :) if someone patches it, i will apply it and upload a new
version. SEEK would be much harder and i am not sure it is warranted.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit
) in time. and it uses no more than 1
buffer (actually 2) of data which is O(1) in memory no matter the size
of the file. that assumes normal size lines and not enormous ones.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
-- Stem is an Open Source Network
function in O()
notation. it will eventually swamp out any lower growth function. both
the ST and GRT have a O(N) component but the O(Log N) of the actual sort
call is what counts.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
-- Stem is an Open Source Network
get sent out. i will need to automate this with
LWP and mail filters, etc.
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
- Stem and Perl Development, Systems Architecture, Design
)/)print'
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
- Stem and Perl Development, Systems Architecture, Design and Coding
Search or Offer Perl Jobs
-ne 'print
if/^#!.*perl/i..0and/\s*#\s*(include|define|(ifn?|un)def|else|elif|endif)/|/^\s*[^#]/'
3 more than ronald's
i also had the range idea independently.
i ran into the problem of binding tighter than scalar ..
but i have another idea up my sleeve. :)
uri
--
Uri Guttman -- [EMAIL
should be filtered out but isn't. you can only pass lines which start
with exact cpp command tokens
uri
--
Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
- Stem and Perl Development
IP == Ian Phillipps [EMAIL PROTECTED] writes:
IP On Thu, 18 Oct 2001 at 20:43:40 -0400, Uri Guttman wrote:
IP == Ian Phillipps [EMAIL PROTECTED] writes:
IP I feel sure this is a FAQ...
trust your feelings. i didn't answer because it IS an FAQ. FAQ's aren't
fun. :)
IP Oh, I
IP == Ian Phillipps [EMAIL PROTECTED] writes:
IP I feel sure this is a FAQ...
trust your feelings. i didn't answer because it IS an FAQ. FAQ's aren't
fun. :)
perldoc -q number
How do I determine whether a scalar is a
number/whole/integer/float?
uri
--
Uri Guttman
67 matches
Mail list logo