Re: seeking golfing advice

2012-05-18 Thread Aristotle Pagaltzis
* Steve Fink sph...@gmail.com [2012-05-18 10:25]: On Thu, May 17, 2012 at 3:14 AM, Aristotle Pagaltzis pagalt...@gmx.de wrote: * Mike Erickson m...@quidquam.com [2012-05-16 15:45]: If you don't care about order, but just want those elements, you can also do: keys

Re: seeking golfing advice

2012-05-17 Thread Aristotle Pagaltzis
use `values` these problems go away… except that to get the odd- index elements from it you have to `reverse` the array, at which point a not-especially-golfed grep is shorter. -- *AUTOLOAD=*_;sub _{s/$/$/;s/(.*):://;wantarray//substr$_,-1,1,,$/;print;$1} Just-another-Perl-hack; #Aristotle Pagaltzis

Re: seeking golfing advice

2012-05-17 Thread Aristotle Pagaltzis
for doing half as much work. (For even elements, the map and grep solutions would yield exactly equally long code, with half-as-much-work still applying.) -- *AUTOLOAD=*_;sub _{s/$/$/;s/(.*):://;wantarray//substr$_,-1,1,,$/;print;$1} Just-another-Perl-hack; #Aristotle Pagaltzis // http

Re: decimal - Binary

2011-11-18 Thread Aristotle Pagaltzis
* Ronald J Kimball rjk-perl-...@tamias.net [2011-11-16 21:50]: It is greedy, but the important thing to remember is that the regular expression engine will find the longest *leftmost* match. To put that a third way: the engine will match at the first possible location, and will make the match

Re: regex of the month (decade?)

2008-01-12 Thread Aristotle Pagaltzis
] with an ISO-8859 charset) in the same document. [1]: Well, Modern Greek anyway. Regards, -- Aristotle Pagaltzis // http://plasmasturm.org/

Re: bad code to good golf

2007-12-10 Thread A. Pagaltzis
in either case, and which one is affected by the `shift`. -- *AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1} Just-another-Perl-hack; #Aristotle Pagaltzis // http://plasmasturm.org/

Re: bad code to good golf

2007-12-09 Thread A. Pagaltzis
to write delegative code: # ... $self-get_veeblefitzer()-frobnitz( @_ ); # ... -- *AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1} Just-another-Perl-hack; #Aristotle Pagaltzis // http://plasmasturm.org/

Re: fun with hashes!

2007-11-24 Thread A. Pagaltzis
* David Landgren [EMAIL PROTECTED] [2007-11-24 10:45]: 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

Re: fun with hashes!

2007-11-23 Thread A. Pagaltzis
the check for whether the default value is a CODE ref? Regards, -- Aristotle Pagaltzis // http://plasmasturm.org/

Re: fun with hashes!

2007-11-23 Thread A. Pagaltzis
wantarray]/e;$1} Just-another-Perl-hack; #Aristotle Pagaltzis // http://plasmasturm.org/

Re: Minimal DNS answer using Net::DNS

2006-11-26 Thread A. Pagaltzis
. You probably want to take this to Perlmonks. Regards, -- Aristotle Pagaltzis // http://plasmasturm.org/

Re: local vs. my (was Re: code line of the day)

2006-09-10 Thread A. Pagaltzis
to unwarranted grumpiness. Regards, -- Aristotle Pagaltzis // http://plasmasturm.org/

Re: code line of the day

2006-09-08 Thread A. Pagaltzis
. Matter of taste/style. Regards, -- Aristotle Pagaltzis // http://plasmasturm.org/

Re: code line of the day

2006-09-07 Thread A. Pagaltzis
Pagaltzis // http://plasmasturm.org/

Re: Super regexp to format numbers

2006-08-28 Thread A. Pagaltzis
* Alexandre Jousset [EMAIL PROTECTED] [2006-08-28 18:15]: For the moment I have a (too) complicated sub spacify and I would like to simplify it to a regexp. It doesn’t have to be complicated, even without a regexp. scalar reverse join ' ', unpack '(A3)*', reverse $num; Regards, --

Re: Including externally-defined constants

2006-07-20 Thread A. Pagaltzis
* Philippe BooK Bruhat [EMAIL PROTECTED] [2006-07-20 08:40]: Le jeudi 20 juillet 2006 à 02:41, A. Pagaltzis écrivait: * Philippe BooK Bruhat [EMAIL PROTECTED] [2006-07-19 22:10]: '=cut'; =pod [...snip...] =cut Damn, what a cool hack! That's exactly

Re: Naming the @{[]} operator

2006-07-13 Thread A. Pagaltzis
: 4 square: 9 In other words it’s also useful when you need to break aliasing to make sure you’re operating on a modifiable copied scalar. Regards, -- Aristotle Pagaltzis // http://plasmasturm.org/

Re: Naming the @{[]} operator

2006-07-11 Thread A. Pagaltzis
* Smylers [EMAIL PROTECTED] [2006-07-11 23:05]: babycart is 3 syllables; shopping trolley Plus I could see myself adopting the latter (reluctantly) if it became part of the vernacular, but I’d feel too silly using the former to pick it up. I still like “fat brackets” better though, in vague

Re: Converting dell tags to svc codes - itty-bitty golf, anyone?

2006-02-22 Thread A. Pagaltzis
* [EMAIL PROTECTED] [EMAIL PROTECTED] [2006-02-22 20:15]: map {$s+=(/\d/?$_:(ord()-55))*(36**$i++)} reverse(split(//,uc shift)); @v{ 0..9, A..Z } = 0..35; $s = $s * 36 + $v{ uc $_ } for /./g; Even readably spaced, the less clever solution is shorter. $s =~ s/(...)/$1-/g; print $s\n; print

Re: [ANNOUNCE] first release of PerlWar (and request for beta testers)

2005-10-17 Thread A. Pagaltzis
* Yanick Champoux [EMAIL PROTECTED] [2005-10-18 03:05]: Well, I'll be darned. Some people actually volunteered. :-) You might garner some more interest by posting this to rec.games.corewar – they’re always interested in hearing about variations on the game. Regards, -- #Aristotle

Re: Matching at least $x words out of @words

2005-05-09 Thread A. Pagaltzis
* A. Pagaltzis [EMAIL PROTECTED] [2005-05-09 12:10]: The problem with this and all the grep solutions is that you ^^ dont know whether you matched the same alternate multiple times, Err, that bit was non-sense, of course. I need some coffee

Re: Matching at least $x words out of @words

2005-05-05 Thread A. Pagaltzis
* Jos Castro [EMAIL PROTECTED] [2005-05-05 16:30]: So suppose you want a regular expression to match at least one of three words: /word1|word2|word3/ What solution would you use if you wanted at least _two_ of those three words? $alt = join '|', qw( word1 word2 word3 ); / ($alt)

Re: Load-Bearing Warnings

2004-08-03 Thread A. Pagaltzis
* Smylers [EMAIL PROTECTED] [2004-08-04 00:34]: [*0] It was cluttering up the error log with benign 'uninitialized' messages, which were obscuring the output (from some other script) that I wanted to see. Maybe you can try just disabling those? no warnings 'uninitialized';

Re: error handling in perl modules

2004-06-25 Thread A. Pagaltzis
* Babichev Dmitry [EMAIL PROTECTED] [2004-06-25 09:17]: Could anybody provide the best practices of implementation the error handling in perl modules? This is the fun with Perl list. Your inquiry is No Fun. You want to go to www.perlmonks.org or some such. Regards, -- Aristotle If you can't

Re: Golf challenge: Tangled Tale

2004-06-24 Thread A. Pagaltzis
* Tobias Gödderz [EMAIL PROTECTED] [2004-06-24 23:42]: Okay, I'm down to 148 now, and I think, I'm on my limit. I'll publish mine as soon as no one wants to compete anymore. I am working on a solution, but I don't think I'll manage to finish tonight, and tomorrow I'll be gone from home until

Re: Golf challenge: Tangled Tale

2004-06-23 Thread A. Pagaltzis
* Brad Greenlee [EMAIL PROTECTED] [2004-06-21 00:37]: Golf anyone? My opening shot is 288. * Tobias Gödderz [EMAIL PROTECTED] [2004-06-23 19:16]: We (a friend of mine and me) made it with 246 chars. Uh, you're supposed to publish your solutions when golfing. Regards, -- Aristotle If you

Re: Regular expression for years after a given one

2004-06-01 Thread A. Pagaltzis
* Jose Alves de Castro [EMAIL PROTECTED] [2004-06-01 11:59]: BTW: This was made so it would work with $year consisting of four digits... any care to make it generic? :-) sub rx_gt { local $_ = shift; return if /\D/; my @alt = ''; for(split //) {

Re: Regular expression for years after a given one

2004-06-01 Thread A. Pagaltzis
* Tobias Wolter [EMAIL PROTECTED] [2004-06-01 17:33]: On 2004-06-01T10:52:55+0100 (Tuesday), Jose Alves de Castro wrote: How can I say that I want every single year after the one I have? It's impossible... The operator works quite well for a four-digit year. Yeah, but that requires

Re: Reading X lines at a time

2004-05-09 Thread A. Pagaltzis
* Rick Delaney [EMAIL PROTECTED] [2004-05-03 15:23]: while (my @a = map { eof() ? () : scalar } 1 .. $n) { print @a; print SEPARATOR\n; } while (my @a = grep defined, map scalar , 1 .. $n) { print @a; print SEPARATOR\n; } -- Regards,

Re: Break the 65 chars :-)

2004-04-26 Thread A. Pagaltzis
* Jose Alves De Castro [EMAIL PROTECTED] [2004-04-26 18:36]: #!/usr/bin/perl -l0n /:/;$_{$'.$}.= $`,}{map{s/,$/ /;print}%_ Trivial improvement, for a gain of 5 chars: #!/usr/bin/perl -l0p /:/;$_{$'.$}.= $`,}for(%_){s/,$/ /; I've tried other clever things, but they all come out

Re: fractional cents

2004-04-25 Thread A. Pagaltzis
* Keith C. Ivey [EMAIL PROTECTED] [2004-04-22 14:48]: Math won't work, because floats aren't exact. Actually, that is a point I meant to make somewhere in this thread. When you're dealing with money, it's better to use cents (or tenths or hundredths of cents) as a unit, rather than dollars. You

Re: fractional cents

2004-04-21 Thread A. Pagaltzis
* John Douglas Porter [EMAIL PROTECTED] [2004-04-20 08:39]: It seems to me that the precision desired should depend on context, and nothing else. And that being the case... printf $fractional_cents ? '%7.3f' : '%7.sf', $amt; irrespective of the value of $amt. Why is this not right?

Re: fractional cents

2004-04-21 Thread A. Pagaltzis
* Bernie Cosell [EMAIL PROTECTED] [2004-04-22 00:02]: On 21 Apr 2004 at 22:55, A. Pagaltzis wrote: If you do this by looking at $amt, then your method must be mathematical, because chopping characters in the string representation of the unrounded $amt might occasionally lead to results

Re: fractional cents

2004-04-19 Thread A. Pagaltzis
* Bernie Cosell [EMAIL PROTECTED] [2004-04-19 17:37]: So: what I want is something to format money correctly, whther it is fractional or not. there's the fairly awful: sprintf ($amt =~ /\.\d\d\d/? %7.3f: %7.2f), $amt Right off the bat I thought of %g, but that doesn't really help:

Re: fractional cents

2004-04-19 Thread A. Pagaltzis
* Quantum Mechanic [EMAIL PROTECTED] [2004-04-19 23:09]: --- A. Pagaltzis [EMAIL PROTECTED] wrote: my $amt_str = sprintf %7.3f, $amt; for($amt_str) { chop if /\.\d\d0\z/ } Why would you do for..chop when you could do s///? You're using an re either way

Re: lvalue hash slice

2003-10-03 Thread A. Pagaltzis
* Gaal Yahas [EMAIL PROTECTED] [2003-10-03 11:24]: Two points about this. First, the lvalue ?: is kinda, uh, Perlish to the extreme. Yeah. It tends to be a powerful obfuscant too. I had to look thrice at your code (then went oh, duh!). For more than two or maybe three lvalues to switch between,

Re: lvalue hash slice

2003-09-30 Thread A. Pagaltzis
* Gaal Yahas [EMAIL PROTECTED] [2003-09-30 20:14]: Sadly, this doesn't work as an lvalue: @hash{ qw/aaa bbb ccc/ } = ($one, $two, $three); I use that *all* the time. The problem is not with Perl here.. -- Regards, Aristotle If you can't laugh at yourself, you don't take life seriously

Re: Semcarlbd letrtes sepur! (Scrambled letters super!)

2003-09-18 Thread A. Pagaltzis
* Etienne Grossmann [EMAIL PROTECTED] [2003-09-18 09:29]: I hared a sutdy has been dnoe on taht scjebut in an Eigslnh urtiivesny, but I coannt get hold of it. Any ionirmtfoan on that sceujbt is welomce. http://www.bisso.com/ujg_archives/000224.html perl -pe 'sub r{join,map chop,sort

Re: Semcarlbd letrtes sepur! (Scrambled letters super!)

2003-09-18 Thread A. Pagaltzis
* Kripa Sundar [EMAIL PROTECTED] [2003-09-18 15:41]: The following does guarantee re-ordering. How does it reorder loop? :-) -- Regards, Aristotle If you can't laugh at yourself, you don't take life seriously enough.

Re: Phalanx top 100 CPAN modules golf

2003-08-25 Thread A. Pagaltzis
* Andrew Savige [EMAIL PROTECTED] [2003-08-24 04:27]: the Klement Transform? Or should that read Klementian or even Klementine Transform? :-) Well, it's not called the Guttman-Roslerian Transform (or Guttmanian-Roslerian?) either. Schwartzian is really a red herring. -- Regards, Aristotle

Re: Fun - Each character at most once

2003-07-25 Thread A. Pagaltzis
* Adam Rice [EMAIL PROTECTED] [2003-07-22 16:02]: I wrote a program to generate these, but has an unfun tendency to take forever when the solution is non-trivial so I won't post it. If there was a better technique than brute force to find the answers that might be fun, but I just can't get my

Re: Fun - Each character at most once

2003-07-17 Thread A. Pagaltzis
* [EMAIL PROTECTED] [EMAIL PROTECTED] [2003-07-17 21:15]: What is the most interesting program that is restricted to use each ASCII character at most once? The definition I chose was to check if a program (from @ARGV) contains duplicate chars and printing a duplicate char iff it has one.

Re: Is this fun?

2003-07-15 Thread A. Pagaltzis
* Jon Bjornstad [EMAIL PROTECTED] [2003-07-15 00:00]: I don't often get to use the '.' operator or the 'x' operator and I thought this was pretty cool. Pretty standard fare for some people, though I guess the exact idea of fun is different for everyone. :) There are a few flaws with the above

Re: Is this fun?

2003-07-15 Thread A. Pagaltzis
* Keith C. Ivey [EMAIL PROTECTED] [2003-07-15 14:42]: which will be handled by the regex but may cause a parser to blow up (though some are more tolerant than others) Did you read what I said? You need a tolerant parser indeed. Did you take any look HTML::Parser at all? | That leaves input

Re: my if?

2003-07-02 Thread A. Pagaltzis
* Pense, Joachim [EMAIL PROTECTED] [2003-07-02 14:15]: You can write if ($some_condition) { do_this; do_that; do_something_else; } and you can write do_this if $some_condition; You need not write if ($some_condition) {do_this} You can also write do { do_this;

Re: my if?

2003-07-01 Thread A. Pagaltzis
* Bernie Cosell [EMAIL PROTECTED] [2003-07-01 18:39]: Perl is filled with multiple ways to do things and the simple argument that you can do something similar using some other mechanism is rarely determinative. ...but I hesitate to make ten ways to do it. -- Larry Wall -- Regards, Aristotle

Re: grep too slow

2003-02-24 Thread A. Pagaltzis
Still untested: * A. Pagaltzis [EMAIL PROTECTED] [2003-02-23 17:50]: @found3 = map pop @{$hash{$_}}, amatch('3456', @info); That should rather read @found3 = map shift @{$hash{$_}}, amatch('3456', @info); The point is that the order of identical items in the initial list is preserved

Re: grep too slow

2003-02-23 Thread A. Pagaltzis
Try this. Untested. $t-start('transforming2'); my $i; for(list) { $i = $_-{'info'}; push info, $i; push {$hash{$i}}, $_; } found3 = map pop {$hash{$_}}, amatch('3456', info); $t-stop; -- Regards, Aristotle

Re: Fun with RegExps

2003-02-17 Thread A. Pagaltzis
Alternatively it can be done with negative lookaheads. print ok if /^(?![a-z0-9]+$)(?![A-Z0-9]+$)(?![a-zA-Z]+$)[\w-]{6,14}$/; -- Regards, Aristotle

Re: When the Schwartzian Transform gets out of control...

2003-02-11 Thread A. Pagaltzis
Sorting 1000 items involves a _lot_ more than 1000 comparisons - which is really all you need. If you insist on your approach you should memoize vercmp() or use the orcish maneuver in your sort() callback. (Memoizing will accelerate it across all of your script, but the orcish maneuvre will

Re: When the Schwartzian Transform gets out of control...

2003-02-11 Thread A. Pagaltzis
* A. Pagaltzis [EMAIL PROTECTED] [2003-02-12 07:35]: and -1 == vercmp($2,$3, @{$installed{$_}}); That is, of course, and -1 == vercmp($2,$3, @{$installed{$1}}); -- Regards, Aristotle

Re: Converting a textfile-like string to an array and back

2003-02-10 Thread A. Pagaltzis
* Andrew Savige [EMAIL PROTECTED] [2003-02-10 17:54]: *whistle* *whistle* *red card* *disqualified* multiplying by length (x+length) will not give the desired result here; it must be boolean (0 or 1 only). Doh! Of course. I'm an idiot. *grmbl* -- Regards, Aristotle

Re: Converting a textfile-like string to an array and back

2003-02-10 Thread A. Pagaltzis
* Eugene van der Pijll [EMAIL PROTECTED] [2003-02-10 18:35]: Unfortunately, you had use strict in your first post, and neither of these are use-strict safe. Oh? What makes you say so? -- Regards, Aristotle

Re: Converting a textfile-like string to an array and back

2003-02-09 Thread A. Pagaltzis
* John W. Krahn [EMAIL PROTECTED] [2003-02-09 12:27]: You can also speed up j1 by using map without the braces. sub j1 { my @lines = map chomp $_, split /^/, $x, -1 } Which will promptly fail on a last line without a trailing record separator because chomp would return 0 and cause the to

Re: Converting a textfile-like string to an array and back

2003-02-09 Thread A. Pagaltzis
* Andrew Savige [EMAIL PROTECTED] [2003-02-10 07:28]: @lines = ($x=~/^.*/mg) x !!length($x); $_=$x;@lines=(/^.*/mg)x+length; -- Regards, Aristotle

Re: Converting a textfile-like string to an array and back

2003-02-07 Thread A. Pagaltzis
* Andrew Savige [EMAIL PROTECTED] [2003-02-07 13:47]: my @lines = split(/^/, $x, -1); chomp(@lines); # fastest? my @lines = split m[\Q$/], $x, -1; -- Regards, Aristotle

Re: Converting a textfile-like string to an array and back

2003-02-07 Thread A. Pagaltzis
* John Douglas Porter [EMAIL PROTECTED] [2003-02-07 14:15]: @lines = split /\n/, $x, -1; pop @lines; $/ can be different from \n though. And popping the last field is dangerous - you don't know if the file ends with a newline. Also, you now have no chance to reconstruct the exact equivalent

Re: Converting a textfile-like string to an array and back

2003-02-07 Thread A. Pagaltzis
* John Douglas Porter [EMAIL PROTECTED] [2003-02-07 14:50]: Yes, but his example data was text in a here document. Then add a note about the caveat. split m,$/, $x, -1; In bizarre cases, $/ might contain regex metacharacters. Don't forget the \Q. And popping the last field is dangerous -

Re: Converting a textfile-like string to an array and back

2003-02-07 Thread A. Pagaltzis
* Yitzchak Scott-Thoennes [EMAIL PROTECTED] [2003-02-07 20:51]: chomp(my $tmp=$x); my @lines=split /\n/,$tmp,-1 Very nice. -- Regards, Aristotle

Re: grep substitute

2002-12-14 Thread A. Pagaltzis
* Scott Wiersdorf [EMAIL PROTECTED] [2002-12-14 13:01]: perl -n0777 exit !(/pattern/) Necessary Improvements: - concisely get the pattern from the command-line (e.g., pattern as $ARGV[0] and the file as $ARGV[1]) such that the syntax is more like grep (e.g., grep 'pattern' filename =

Re: my in conditionals

2002-11-27 Thread A. Pagaltzis
* Paul Makepeace [EMAIL PROTECTED] [2002-11-27 08:53]: perl apparently doesn't consider $d exists by the second $d and issues an error. Can someone explain this? (Esp. in light of all this sequence point talk.) The entire statement ist compiled at a time; at this time, $d is undeclared. The

Re: Function parameter passing (was: Re: limit the list)

2002-11-20 Thread A. Pagaltzis
* Andrew Molyneux [EMAIL PROTECTED] [2002-11-20 12:47]: You're not the only one. I'd probably do: my ($max, $sep, $end) = @_; aolme too/aol but I'd love to know if Steven had a specific reason for doing it the other way. There doesn't seem to be any here. -- Regards, Aristotle

Re: Function parameter passing (was: Re: limit the list)

2002-11-20 Thread A. Pagaltzis
* Steven Lembark [EMAIL PROTECTED] [2002-11-20 17:35]: Yes, becuase if you did it this way you'd get $end equal to the integer coult of the number of list arguments passed plus one for the end value. Notice the usage: my $string = commify 90, ', ', 'etc...', @names; The other

Re: limit the list

2002-11-20 Thread A. Pagaltzis
* Steven Lembark [EMAIL PROTECTED] [2002-11-20 17:35]: Wasted work. Two comparisons per element and you don't bail once you've filled your available space. Two comparisons on a short list, at which point the remainder of them are a simple comparison to get a () out, which ends up as a

Re: limit the list

2002-11-20 Thread A. Pagaltzis
* Josh Goldberg [EMAIL PROTECTED] [2002-11-20 19:20]: map{$i++$lim?push @n,$_:$i!=$lim?{push @n,'etc.' and goto FOO}:''}@names; Sigh. map in void context and goto where a for would have done. And it doesn't even conform to the specs, you were asked to provide a string with less than 90

Re: Function parameter passing (was: Re: limit the list)

2002-11-20 Thread A. Pagaltzis
* Steven Lembark [EMAIL PROTECTED] [2002-11-20 20:51]: Look up what happens to arrays in a scalar context. my ( $a, $b, $c ) = qw( foo bar bletch blort bim bam blort ); what do yo get for $c? 'bletch' - and that's not an array there. -- Regards, Aristotle

Re: limit the list

2002-11-20 Thread A. Pagaltzis
* Jonathan E. Paton [EMAIL PROTECTED] [2002-11-20 20:51]: if (@array $bound) { $array[$bound-1] = , etc; # Set element at boundary $#array = $bound-1; # Shorten array to boundary } print join , , @array; Again, that's the same as: join ', ', @array[0 .. $bound], @array

Re: Function parameter passing (was: Re: limit the list)

2002-11-20 Thread A. Pagaltzis
* Andrew Molyneux [EMAIL PROTECTED] [2002-11-20 18:25]: A. Pagaltzis wrote: Enter splice. my ($max, $sep, $end) = splice @_, 0, 3; That has brevity, certainly, but for legibility, I think I prefer Steven's original (shift,shift,shift) Really? I find the splice version a lot easier

Re: limit the list

2002-11-20 Thread A. Pagaltzis
* Dave Arnold [EMAIL PROTECTED] [2002-11-21 02:45]: $str = join ', ', @names; if ( length($str) 90 ) { substr($str,rindex($str,,,90)) = , etc.; } Nice, and so obvious too - in retrospect, of course. The only thing I don't like about it is it still joins everything, even if it only needs

Re: limit the list

2002-11-19 Thread A. Pagaltzis
* Selector, Lev Y [EMAIL PROTECTED] [2002-11-20 00:55]: an array of names is converted into a comma-separated list. if the list gets to long - limit it and add , etc. at the end. $str = join ', ', @names; if (length($str)90) { ($str = substr($str,0,90)) =~ s/,[^,]*$/, etc./;

Re: limit the list

2002-11-19 Thread A. Pagaltzis
* A. Pagaltzis [EMAIL PROTECTED] [2002-11-20 02:00]: my ($i, $total); ($total += $_) 90 or last, $i++ for map length, @names; $str = join ',', @names[0 .. $i]; $str .= ', etc' if $i $#names; Sorry, that would of course be ($total += length) = 90 or last, $i++ for @names; The map was left

Re: limit the list

2002-11-19 Thread A. Pagaltzis
Ok, another attempt, this time with brain engaged and coffee consumed. $str = join ', ', @names; if (length($str)90) { ($str = substr($str,0,90)) =~ s/,[^,]*$/, etc./; } my ($i, $total); ($total += length) 90 ? $i++ : last for @ARGV; $str = join ', ', @ARGV[0 .. $i]; $str .= ', etc' if

Re: Perl Quiz of the Week

2002-10-14 Thread Aristoteles Pagaltzis
* Mark-Jason Dominus [EMAIL PROTECTED] [2002-10-13 17:48]: I am now back. If you want to get the quiz-of-the-week, send a note to [EMAIL PROTECTED] Please feel free to circulate this announcement to appropriate venues. I posted this (among others) to PerlMonks at

Re: Content-type:image/gif\n\n problem

2002-10-05 Thread Aristoteles Pagaltzis
* Adam Rice [EMAIL PROTECTED] [2002-10-05 23:26]: If I was writing this for work I would include error checking and read and write the file in 64k blocks, but there's no fun way to do that in Perl so I'll leave it out here. Yes there is. $/ = \(65536); See perldoc perlvar on $/ --

Re: removing extra empty lines

2002-09-30 Thread Aristoteles Pagaltzis
* Vladi Belperchinov-Shabanski [EMAIL PROTECTED] [2002-09-30 19:24]: $_='' if !/\S/ $e; # i.e. don't print if empty and last one was empty $e = !/\S/; # remember if last one is empty... Since you have already done $_='' in the first line, you don't need a regex in the