On Tue, 19 Sep 2006 11:34:26 +0100, McGlinchy, Alistair wrote:
I've managed to get it down to just a comma and
a dollar.
print readline open print, $0
There's the
open FOO
trick which means the same as
open FOO, $FOO
with FOO and $FOO global.
So I can reduce this
On Fri, 8 Sep 2006 08:19:21 -0700 (PDT), John Douglas Porter wrote:
If you really want to test the ref type, do so
robustly using the methods in Scalar::Util.
I'm not convinced that is indeed the best approach. So Uri expects
either a plain string, or a scalar ref to a string.
What if instead
On Thu, 07 Sep 2006 03:29:02 -0400, Uri Guttman wrote:
this line of my code grew to its present form which i find amusing.
@{$self-{templates}}{ keys %{$tmpls} } =
map ref $_ eq 'SCALAR' ? \${$_} : \$_, values %{$tmpls} ;
discuss amongst yourselves. topics include: what
On Thu, 13 Jul 2006 04:29:38 -0400, Chasecreek Systemhouse wrote:
On 7/7/06, Jerrad Pierce [EMAIL PROTECTED] wrote:
perl -le 'print @{[time]}'
What the advantage the above over this:
perl -le 'print time'
Oh come on, you asked how to use @{[]}. Well, its main purpose is a way
to embed
On Thu, 23 Feb 2006 13:02:32 -0500, Uri Guttman 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 be fine there.
That reminds me, only earlier today I looked at the word
On Tue, 1 Feb 2005 11:49:57 +, José Castro wrote:can
anyone tell me about other secret operators?
I just produced this in my own code, I think it would qualify. Take this
expression in list context:
cond ? foo : ()
I'm talking about the 3 characters at the end: : (). I'd call it a
On Wed, 5 May 2004 02:04:54 +0100, Allen, Greg wrote:
But if we were golfing... Well I suppose it's still pretty ugly.
I do find the
($transformed = $package) =~ s,::,/,g;
construction pretty unreadable though. People expect flow of control to be
left to right, while data flow in assignments is
On Thu, 22 Jan 2004 07:16:11 -, Pense, Joachim wrote:
So I'd rather write $VERBOSE and $STOP_ON_ERROR, living with the minor
risk that I might inadvertently change the values.
You can reduce the risk by making them pseudo-constants (globals only):
*VERBOSE = \1;
print
On Wed, 30 Jul 2003 21:36:46 -0500, James E. Tilley wrote:
Does
if (/^BEGIN$/ .. (/^\s*$/ .. /^END$/) =~ /E/)
do what you want?
s/BEGIN/START/ to plug it in the skeleton.
And yes, that's perfect. Quite elegant too. Very much so.
Here's my own solution:
my $pre;
What I would want is to match lines in a loop, one line at a time, say,
between a line cotnaining just START and a line containing just END,
but where the latter condition is only looked at, after an intermediate
condition has been met first. In particular, I have to have seen a blank
line first.
Can someone come up with a (nice) regex that matches only Roman
numerals?
I'm trying to include proper case conversion to title case in a script,
and it should turn a movie title like HALLOWEEN II into Halloween
II, not Halloween Ii.
--
Bart.
On Tue, 15 Oct 2002 18:08:57 +0200, Bart Lateur wrote:
You mean with the same amount of whitespace as before? None of the
solutions I've seen does that.
Oops. Some do.
--
Bart.
On Tue, 15 Oct 2002 17:14:39 +0100, Jasper McCrea wrote:
Why not just:
s/(\s+\S+){4}\s*$//;
$1 for the chopped stuff.
$1 contains the last word and preceding whitespace. For every match,
the captured value overwrites the previous one. You need parens around
it all to capture the lot.
On Mon, 14 Oct 2002 17:34:19 +0100, Simon Cozens wrote:
This is what the flip-flop operator is for.
Which bring s up a good question. The OP talked about 50 or so lines.
Shall we take this literally? I know the flip-flow operator returns the
number of times it was succesful in a row, already,
On Mon, 14 Oct 2002 16:35:21 -0400, Bernie Cosell wrote:
I think they're referring to the '..' operator in scalar context:
In scalar context, .. returns a boolean value. The operator is
bistable, like a flip-flop, and emulates the line-range (comma)
operator of sed, awk, and
On Mon, 30 Sep 2002 16:27:58 +0100, [EMAIL PROTECTED] wrote:
Would it include binmode() ?
Most definitely.
--
Bart.
When thinking of a user-friendly interface to let a user define a table
of words and their hyphenated forms, I stumbled across this cute
problem. It's simple enough to be a fun puzzle, yet not too hard to be
labour. It might even be a fun task for Perl Golf.
The problem is this: given two
On Thu, 05 Sep 2002 15:04:30 +0200, Bart Lateur wrote:
The problem is this: given two versions of a word, one without, and one
with hyphenation, determine which hyphens are soft hyphens (optional
breakpoints), and which ones are hard hyphens? For example:
hypo-allergeen hy-po-al-ler
On Thu, 11 Jul 2002 11:40:47 +0100, [EMAIL PROTECTED] wrote:
$_=reverse qw' r e k c a h x l r e P x r e h t o n a x t s u J ' t n i r
p;y y xyzz y;eval;
Question: does anybody know how to include the comma, without any
warnings under -w?
--
Bart.
On Mon, 01 Jul 2002 14:57:36 +, sara starre wrote:
Unfortunately I can't get your solution to work:
DB1
main::r2(./x.pl:66): $_ [0] %= {$_ [1]};
DB1
Modification of a read-only value attempted at ./x.pl line 66.
Seems it doesn't like you trying to modify $_ [0] ?
Then make a
On Fri, 14 Jun 2002 00:21:16 -0400, Michael G Schwern wrote:
The history is someone noticed that since this:
my $foo; $foo = $foo . 42
Use of uninitialized value at -e line 1.
and this:
my $foo; $foo .= 42
are logically the same, the former shouldn't warn.
Perhaps... (I
On Fri, 14 Jun 2002 11:27:33 -0400 (EDT), Jeff 'japhy' Pinyan wrote:
On Fri, 14 Jun 2002 00:21:16 -0400, Michael G Schwern wrote:
The history is someone noticed that since this:
my $foo; $foo = $foo . 42
Use of uninitialized value at -e line 1.
and this:
my $foo; $foo .=
On Fri, 14 Jun 2002 16:33:57 -0500, Chris Dolan wrote:
Sorry for the newbie-ish question, but can someone explain why op=
does not warn? Is it because (quoting perlop)
$a += 2; is equivalent to $a = $a + 2; although without
duplicating any side effects that dereferencing the lvalue
On Wed, 22 May 2002 13:04:53 -0600, Scott Wiersdorf wrote:
What is the shortest way to test a variable for truth and then set its
value to false such that the truth test still succeeds?
For example, I have a global variable $a (given) that is somehow set
to true. I want to test it for truth and
On Wed, 17 Apr 2002 15:01:50 -0400, Michael G Schwern wrote:
On Wed, Apr 17, 2002 at 02:34:20PM -0400, Bill -Sx- Jones wrote:
Actually, the input data looks more like
[SNEEX]
[ADMIN]
[END]
# setup %Dispatch as before, then...
while( $vData =~ /\[([A-Z])\]/g ) {
On Fri, 12 Apr 2002 12:00:54 +0100 (BST), Jonathan E. Paton wrote:
Many perl features are core, that don't need to be...
e.g. networking/unix permissions stuff. Removing these makes a far cleaner
language.
Amen to that. For example, I find it pretty amazing that fcntl() is part
of the
On Mon, 1 Apr 2002 15:16:47 +0100 (BST), Jonathan E. Paton wrote:
and the only compression module I could find:
http://search.cpan.org/search?module=Compress::LZV1
Heh? What about Compress::Zlib, which is based on the zlib library, and
is used both by Archive::Tar and Archive::Zip?
It doesn't
On Mon, 25 Mar 2002 12:36:50 +1100, [EMAIL PROTECTED] wrote:
Searching amazon on Perl Golf reveals that Eugene has already
written a book on Perl Golf under the pseudonym of Eugenia Perl:
Understanding Golf Games, a guide for all skill levels
by Eugenia Perl
On Fri, 15 Mar 2002 13:09:04 +1100, [EMAIL PROTECTED] wrote:
En op 14 maart 2002 sprak Bart Lateur:
Don't say you've never heard of cookies.
cookie. US, a small sweet biscuit.
biscuit. Brit, a small unleavened cake.
I apologize for my ignorance, but when I installed Windows,
I asked
On Thu, 14 Mar 2002 11:23:47 +1100, [EMAIL PROTECTED] wrote:
I like that use.perl.org. You log in with your username and
password. But it seems to remember where you did that from
because I have gone for days without going to the bother of
re logging in, yet every time I go to that site it
On Thu, 14 Mar 2002 10:38:29 -0500, Ted Zlatanov wrote:
Has anyone developed an implementation of the well-known bitstring
algorithm? Basically you convert your data strings to bitstrings, AND
the two, and look for the longest match.
Maybe it's just me, but that doesn't feel right. If you AND
On Wed, 6 Mar 2002 17:57:07 -0500, Uri Guttman wrote:
how often will you need to interpolate a hash?
A whole hash: quite rarely. A hash item: a LOT. Don't forget that
$foo{BAR} will now become %foo{BAR}
--
Bart.
On Sat, 16 Feb 2002 11:05:14 -0800, Vicki Brown wrote:
It took me a while to find the problem... when I did I was somewhat amused
if (...) {
my @item_parts = split(/\n/, $item);
printf ORDER (\n%4d %-50s %3.2f %3.2f\n,
On Sat, 16 Feb 2002 11:10:17 +0100, F. Xavier Noria wrote:
: What an anti-climax. Utterly boring.
Maybe being a mathematician I am a bit formalist, but the challenge was
to use as few strokes as possible, if you didn't use strtol you lost. If
you didn't want to use strtol as an option you are
On Fri, 15 Feb 2002 08:53:45 -0600, Dave Hoover wrote:
Here is the winning solution:
#!perl -l
use POSIX;print~~strtol pop,36
Boo, boo!
What an anti-climax. Utterly boring.
--
Bart.
On Fri, 8 Feb 2002 18:35:06 +1100 , [EMAIL PROTECTED] wrote:
Jerome Quelin wrote:
I think the arbiter program could (should?) be a module, but not
the client part.
Agreed. We should make things as easy as possible for the customer.
No modules to install. Just download and run the test
On Fri, 08 Feb 2002 14:00:48 +0100, Bart Lateur wrote:
At least, this appears to be working:
#! perl -l
open STDERR, errors.txt;
warn This goes to the file, date = .localtime
print Result: . `perl otherscript.pl`;
But only (as intended) with a semicolon right after
On Fri, 08 Feb 2002 09:06:03 -0500, Morbus Iff wrote:
Not sure what you mean, here. I've been using this code in the
crossplatform AmphetaDesk [1], and it's been working fine (collecting
thousands of warnings from a Win32::GUI, IO:: kills, etc.):
# open our log file, turn on autoflush,
On Wed, 6 Feb 2002 00:29:53 -0500, Uri Guttman wrote:
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.
On Wed, 6 Feb 2002 01:02:27 -0500 (EST), Brett W. McCoy wrote:
On Wed, 6 Feb 2002 00:05:12 -0500, Bill -OSX- Jones wrote:
What does cabal really mean, in a Perl perspective?
I know the dictionary/definition:
ca·bal
n.
1. A conspiratorial group of plotters or intriguers: Espionage is
quite precisely ita cabal of powerful men, working secretly
On Sat, 2 Feb 2002 12:35:13 -0800 , Pradeep Sethi wrote:
and I want to use regexp , without using sprinf.
!?!?!!
WTF is wrong with sprintf()? It's a proper tool for this job. Next
you'll want to replace 13.57831 by 13.58 without using sprintf().
Which is doing things the hard way.
Also want
On Thu, 31 Jan 2002 22:10:03 -0500, Michael G Schwern wrote:
$date =~ s{(.*)}{sprintf '%02d/%02d/%d', split '/', $1}e;
$date =~ s{(\d+)/(\d+)/(\d+)}{sprintf '%02d/%02d/%d', $1, $2, $3}e;
--
Bart.
On Fri, 1 Feb 2002 12:37:40 +0100, Jérôme Quelin wrote:
I mean, what the heck could a beginner do to improve Eugene's
solution?
What the heck can *anybody* do to improve Eugene's solution?
When paricipating in Perl golf, he's virtually always in the lead.
--
Bart.
On Wed, 30 Jan 2002 14:17:01 +1100, [EMAIL PROTECTED] wrote:
but then I remembered a post by Perl Monk tilly (something
about a color chart) where he used glob in a most perverse way.
I had never done this myself, however, so I started with a small
program:
@a = glob('|y|{a,e,i,o,u,y,}||c');
On Sun, 27 Jan 2002 12:34:55 -0500, Bill -OSX- Jones wrote:
Isn't there another var that is the same as STDERR ?
And can't you set $! directly, and when printed - goed to STDERR ???
I'll tell ya -- after the game closes. Which should be... in 14 hours?
--
Bart.
On Mon, 28 Jan 2002 10:19:56 +0100, Bart Lateur wrote:
On Sun, 27 Jan 2002 12:34:55 -0500, Bill -OSX- Jones wrote:
Isn't there another var that is the same as STDERR ?
And can't you set $! directly, and when printed - goed to STDERR ???
I'll tell ya -- after the game closes. Which should
On Sat, 19 Jan 2002 23:26:16 -0500, Michel Lambert wrote:
Here's something which generates a regex that matches most shrinkable
strings.
print join|,map{$_.*[^$_-z]}('a'..'z')
which prints out:
a.*[^a-z]|b.*[^b-z]|c.*[^c-z]|d.*[^d-z]|e.*[^e-z]|f.*[^f-z]|g.*[^g-z]|h.*[^h
On Sat, 19 Jan 2002 14:42:11 +, Robin Houston wrote:
On London.pm we're wondering what this Perl 6 operator is called.
Suggestions so far: topcat, firework, rat, squirrel.
Any thoughts?
Horseback. The top of the head and tail are there, too.
--
Bart.
On Mon, 31 Dec 2001 16:15:39 -0800, Paul Makepeace wrote:
I couldn't figure out a Perl-ish way of parsing it, resorting to putting
it all in a big 2D array and scurrying around it.
I still have no clue what it's all about (it's no fun being left all in
the dark), but can't you use vec()? If
On Thu, 20 Dec 2001 19:00:30 +0100, Philip Newton wrote:
On Thu, 13 Dec 2001 10:50:11 -0500, [EMAIL PROTECTED]
(Ronald J Kimball) wrote:
(y/a-zA-Z// 2) (y/0-9// 1)
Each numeric comparison will return either 1 or 0.
In my experience, 1 or , rather than 1 or 0. Or is FALSE (PL_NO?) a
On Thu, 13 Dec 2001 08:10:44 -0500, Yanick wrote:
The following is not very clever obfuscation, and it's not the
most palatable ASCII drawing ever drawn, but I suppose it's good enough
to elicit a few chuckles and/or groans.
On day 3, a bug becomes visible: the final line And a
On 5 Dec 2001 16:25:16 -, Lars Henrik Mathiesen wrote:
[EMAIL PROTECTED] (Bernie Cosell) writes:
On 5 Dec 2001, at 11:34, [EMAIL PROTECTED] wrote:
But Bart said he wanted to test for 0. The test above, and several of
the other proposals don't distinguish between 0 and the empty string.
On Thu, 6 Dec 2001 02:56:58 -0500, Uri Guttman wrote:
so the main boolean test is ref!
Thank goodness that ref() doesn't generate a warning when used with
undef as a parameter.
--
Bart.
On Wed, 5 Dec 2001 07:44:00 -0400, Bernie Cosell wrote:
but from what he said, I'd think that bumming off of concluding It is not
undef and not true implies it must have been zero is legit within the
parameters of the challenge, no??
Yes. The values to test for are true, false (but not
On Tue, 11 Sep 2001 08:56:54 +1000, [EMAIL PROTECTED] wrote:
Just to clarify, the JAPH starts with the line:
'%'=~
not with:
open 0;
Your leading junk looks suspiciously like the original ASCII
program from which the JAPH was generated (with a leading
#! perl -w added). If you delete
On Fri, 7 Sep 2001 10:52:04 +0200 , Newton, Philip wrote:
export PROMPT_COMMAND=pwd|perl -pe
'chop;s#^.*(/.+/.+)\$#...\1#;\$_=qq(\e]0;\$_\a)'
^
(ouch)
You should be able to get rid of '^.*' since you're not capturing that bit
-- *every*
On Wed, 1 Aug 2001 00:24:50 +0200, Abigail wrote:
There's more than one block in do {{EXPR; last}}.
Argh!
Pretty obfuscated, that is.
--
Bart.
57 matches
Mail list logo