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

2003-02-07 Thread John Douglas Porter
and shortest. -- John Douglas Porter __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com

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

2003-02-07 Thread John Douglas Porter
A. Pagaltzis [EMAIL PROTECTED] wrote: * John Douglas Porter [EMAIL PROTECTED] [2003-02-07 14:15]: @lines = split /\n/, $x, -1; pop @lines; $/ can be different from \n though. Yes, but his example data was text in a here document. But you can always do split m,$/, $x, -1

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

2003-02-07 Thread John Douglas Porter
A. Pagaltzis [EMAIL PROTECTED] wrote: John Douglas Porter [EMAIL PROTECTED]: Yes, but his example data was text in a here document. Then add a note about the caveat. Sorry, I thought (and still do) that the OP's caveat was understood to still be in effect. join \n, @lines, $tail

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

2003-02-09 Thread John Douglas Porter
@lines = length($x) ? $x=~/^(.*)$/mg : (); -- John Douglas Porter __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com

Re: merlyn smeared by Python Johnnies' description of Schwartzian transform

2003-07-16 Thread John Douglas Porter
, arrays don't sort meaningfully with Perl's default sort. However, the Python default sort knows how to compare arrays. So to a Python programmer, the ST can be achieved using the default sort. But that still doesn't make it a GRT. -- John Douglas Porter __ Do you

Re: Comparing items from multiple files

2003-11-21 Thread John Douglas Porter
my %data; @[EMAIL PROTECTED] = (); /$regex/ $data{$ARGV}{$1}++ while ; print map { my $this = $_; map { my $that = $_; map { In $this but not $that $_\n } grep { not exists $data{$that}{$_} } keys %{$data{$this}} } grep { not $_ eq $this } keys %data } keys %data; -- John Douglas Porter

Re: Comparing items from multiple files

2003-11-21 Thread John Douglas Porter
Maybe it would be easier to invert the levels of the hash: my $re = shift; my @f = @ARGV; my %h; /$re/ and $h{$1}{$ARGV}++ while ; for my $s ( keys %h ) { print '$s' in (@{[ keys %{$h{$s}} ]}),, not (@{[ grep { not exists $h{$s}{$_} } @f ]})\n; } -- John Douglas Porter

Re: TRUE

2004-01-21 Thread John Douglas Porter
Honza Pazdziora [EMAIL PROTECTED] wrote: But 8.2 is not TRUE value. If returns_a_true_value is supposed to return a true true value, it should end with return TRUE; shouldn't it? Well, no. If it is supposed to return a true value, then it could return any true value, and 8.2 falls

Re: TRUE

2004-01-21 Thread John Douglas Porter
Steven W. Orr [EMAIL PROTECTED] wrote: Umm, I think what you were trying for was . . . Thank you, but I wrote exactly what I meant to. -- John D. Porter __ Do you Yahoo!? Yahoo! Hotjobs: Enter the Signing Bonus Sweepstakes

Re: fractional cents

2004-04-20 Thread John Douglas Porter
... printf $fractional_cents ? '%7.3f' : '%7.sf', $amt; irrespective of the value of $amt. Why is this not right? -- John Douglas Porter __ Do you Yahoo!? Yahoo! Photos: High-quality 4x6 digital prints for 25¢ http://photos.yahoo.com

Re: fractional cents

2004-04-23 Thread John Douglas Porter
that simple? $s = sprintf %7.3f, $amt; $s =~ s/(\.\d\d)0/$1/; No? (Sorry I'm la[tm]e, if this has already been covered.) -- John Douglas Porter __ Do you Yahoo!? Yahoo! Photos: High-quality 4x6 digital prints for 25¢ http

Re: unhead

2004-09-24 Thread John Douglas Porter
I think we'd like to avoid solutions that involve loading entire file into an array, agreed? Here's how I'd do it: sed -n '5,$p' -- John Douglas Porter Josh Goldberg [EMAIL PROTECTED] wrote: Here's a little oneliner to skip the first 5 lines of the file 'foo': perl -i5 -e '@_=STDIN

Re: A curious logic

2005-03-08 Thread John Douglas Porter
as Perl Diety (sic) or Mister Perl doesn't understand how parentheses work. -- John Douglas Porter __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

Re: code line of the day

2006-09-08 Thread John Douglas Porter
$_ ? \$$_ : \$_ for values %copy; @{$self-{templates}}{ keys %copy } = values %copy; Three statements vs 1, and a temporary variable... I'm not sure that's better either. Maybe clearer. -- John Douglas Porter __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best

Re: code line of the day

2006-09-08 Thread John Douglas Porter
. If you really want to test the ref type, do so robustly using the methods in Scalar::Util. -- John Douglas Porter __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

Re: Error puzzler

2006-09-15 Thread John Douglas Porter
problem with the technique; see http://perlmonks.org/?node_id=561931 -- John Douglas Porter __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

Re: fun with hashes!

2007-11-25 Thread John Douglas Porter
operations (including the *missing* operations, which have to be kludged in Perl), the set- related CPAN modules, and how all these things can be used. JMHO. Sorry if someone already made this point and I missed it. -- John Douglas Porter

Re: fun with hashes!

2007-11-25 Thread John Douglas Porter
Uri wrote: i still think isa is a (sic) concept that is important enough to cover on its own. sure it is a set but a very specific type with its own name. the names of these concepts are important (almost like design patterns which i despise :). If names are that important to you, then you

Re: Help with regex

2009-08-13 Thread John Douglas Porter
Maybe this is too obvious... and I know it's not regex... tr/A-Z/222333444555666888/; -- jdporter

Re: decimal - Binary

2011-11-16 Thread John Douglas Porter
What's the point? Seems to me the only purpose of this code beyond the obvious unpack(B*,pack(N, $arg)) line is to reformat the result into an odd, probably application-dependent format. --- On Wed, 11/16/11, Sandro CAZZANIGA cazzaniga.san...@gmail.com wrote: From: Sandro CAZZANIGA

Re: decimal - Binary

2011-11-16 Thread John Douglas Porter
Olof Johansson o...@ethup.se wrote: But why is that not greedy? Remember, the *first* match wins, even if it's shorter than a possible later match. ISTR that some have argued that's a bug. Well, too bad. It's too late. :-) -- john many jars porter

Re: The sperm secret operator: is it new?

2012-03-14 Thread John Douglas Porter
So is that the Perl 6 smart match operator? or something else? In any case... How does it work here? It looks like it's functionally equivalent to scalar()... but why? -- jdporter --- On Wed, 3/14/12, Philippe Bruhat (BooK) philippe.bru...@free.fr wrote: From: Philippe Bruhat (BooK)

Re: Secret operators: the documentation

2012-04-03 Thread John Douglas Porter
Philippe Bruhat (BooK) philippe.bru...@free.fr wrote: Andrew Savige wrote: I wonder if --$| and $|--, ... described by japhy as the magical flip flop variable qualifies as a secret operator? My rule has been to keep only the well-known operators, or the ones that had a nickname

Re: seeking golfing advice

2012-05-16 Thread John Douglas Porter
It's not clear whether you want every other element, beginning with the first or every numeric element with the property 'odd'. Your example doesn't clear that up at all. :-) If it's the latter you want: map { $_ 1 ? $_ : () } @l; --- On Wed, 5/16/12, damien krotkine dkrotk...@gmail.com

Re: seeking golfing advice

2012-05-16 Thread John Douglas Porter
And of course, use grep, as others have said. @list[ grep !$_%2, 0..$#list ]; that gets you every other element, beginning with the first. --- On Wed, 5/16/12, John Douglas Porter johndpor...@yahoo.com wrote: From: John Douglas Porter johndpor...@yahoo.com Subject: Re: seeking golfing

Re: seeking golfing advice

2012-05-18 Thread John Douglas Porter
From: Aristotle Pagaltzis pagalt...@gmx.de Subject: Re: seeking golfing advice To: fwp@perl.org Date: Friday, May 18, 2012, 5:29 AM * 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