for file in @frack!

Ovid on 2008-12-12T10:17:53

If I write for my $file in (@files) { ... } one more time, I'm gonna scream. That's all.

IT'S STUCK IN MY FINGERS. MY FINGERS ARE SCREAMING!

Do you have any "non-perlisms" that you can't help but type?


iterators?

dagolden on 2008-12-12T11:39:07

Somehow, and surprisingly, none of the iterator type modules I saw in a quick CPAN seach do the trick with less finger pain. But there's always the option of $_ if you don't need the lexical:

for ( @files ) {
  # stuff
}

For small scopes, I find I often revert to single letters.

for my $f in ( @files ) {
  ...
}

--dagolden

Re:iterators?

bart on 2008-12-13T11:20:38

You said "in". *giggle*

Re:iterators?

dagolden on 2008-12-13T12:54:28

Yeah. :-(

I "got it" after I posted my reply and didn't even see it in my copy/paste.

-- dagolden

Sigils...

nxadm on 2008-12-12T12:04:17

After doing some java coding, I often get compilation errors in perl because I forget the $ in front of a variable :).

Nothing that a few wtf's can fix...

Culture shock

ziggy on 2008-12-12T15:56:19

I can't think of any non-perlisms leaking into my Perl, but I find myself typing this all the time in C# :

  public ovid foo() {
    // ...
  }

:-)

Re:Culture shock

Ovid on 2008-12-12T16:19:40

Ovid's foo should be private, thank you.

Re:Culture shock

ziggy on 2008-12-12T17:40:17

I think you misread that. Anyone can ask foo() for an ovid. :-)

Re:Culture shock

chromatic on 2008-12-12T19:45:03

What does it return in ovid context?

Re:Culture shock

ziggy on 2008-12-12T20:24:26

What does it return in ovid context?

It always returns ovid in an ovid context. In a strongly typed language, the compiler will never allow you to call it from a non-ovid context. I suppose you could overload foo() to return a virgil, horace, or even homer in other contexts, but I've never needed to do that.

Re:Culture shock

chromatic on 2008-12-12T20:42:58

If any dead Greek poet were polymorphic, I would have thought ovid!

Re:Culture shock

Ovid on 2008-12-13T12:16:45

He was considered a Roman poet, actually. Had Roman citizenship until he died, though he was never permitted to return to Rome after he was relegated (a form of exile).

ok, but how to fix this?

notbenh on 2008-12-12T21:15:59

I think that my most common 'non-perl-ism' would be 'elseif', easily fixable but still annoying, though that said I think that perl is a flexible enough base that we ~could~ address most of these (though ~should~ is a very different point).

So, whats the next step? Do we write a bunch of editor hacks that clean up our fingers output? Do we start writing modules that allow for such errors to become valid?

Me too...

jrockway on 2008-12-12T23:53:04

I have started adding the "in" also.
I also wrote this once:

    my @list = for $i in @source when $i > 42 collect "OH, $i";

It turns out that Perl can't parse that :)