Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
EVGA Longoria
Dec 25, 2005

Let's go exploring!

homercles posted:

Line 1: global typeglobs, is he for real? this isn't 1995

Line 3: ok use a slurp lib, File::Slurp or Perl6::Slurp

Line 8: there's 2 things wrong with this line. You really want to be splitting on all whitespace, so C<split ' ', $_> is the preferred form. This is a SPECIAL form of split, it splits out multiple whitespace and fucks off the newline at the end rendering the chomp at line 7 superfluous. The form you want though is just plain C<split>, that uses $_ and splits on the special ' ' pattern (perldoc split, read it). Also, why the unnecessary brackets? This isn't lisp, you're kirk coding with all this unnecessarily punctuation (just made that term up)

Line 11: Not a good approach, most performant is to useuse substr+index. If you don't want to and prefer to be lazy, you're still critically wrong. If $_ contained special regex patterns (like '(') your program would die. If you really want to do that, use the form C<s/\Q$_\E/Grog/> or more simply C<s/\Q$_/Grog/>. Furthermore you're compiling new regexes with every iteration so if you care about performance (oh wait it's perl no-one cares) one would be using substr with index

Line 12: what's with your 8tab whitespace fetish, you could compress that to C<s/\Q$_/Grog/, last if 4 == length;>

Line 8-15: This entire block can be replaced with a regex. C<s/ \b \S{4} \b /Grok/x>

There's more, the entire file is quite broken. You're programming Perl like it was C. You need to learn more Perl!

is file::slurp in a standard perl install now?

Adbot
ADBOT LOVES YOU

EVGA Longoria
Dec 25, 2005

Let's go exploring!

oh i guess you had a last in there that's one thing the map can't do but it's so much nicer and "Grok of the Grok" is superior.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

rotor posted:

everyone needs to learn more perl imho

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

EVGA Longoria posted:

is file::slurp in a standard perl install now?

imo the audrey tang style slurp is idiomatic and i would never bitch if i saw it in someone else's code regardless whether file::slurp is in the main distro

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp
map's cool, i like map tricks.

EVGA Longoria
Dec 25, 2005

Let's go exploring!

Jonny 290 posted:

map's cool, i like map tricks.

map {} grep {} supremacy

Deacon of Delicious
Aug 20, 2007

I bet the twist ending is Dracula's dick-babies
[quote="syntaxrigger" post="""]
now tho this kind of poo poo motivates me, I just wish I could keep that motivation until I can actually ACT on it, a la after work
[/quote]

man, this is the worst. it seems like the only time i feel like doing things is when i'm already doing something else

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome
never do a golf

JawnV6
Jul 4, 2004

So hot ...
oh no?

Jonny 290 posted:

code:
open MOVIES,"<","movies.txt" or die;
while(<MOVIES>){
	$_ =~ s/\b\S{4}\b/Grok/;
	push(@finishedflicks, $_);
}
foreach (@finishedflicks) {
next unless ($_ =~ m/grok/i);
s/\..*$//;
print "$_\n";
}

:smug:

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome
no.

JawnV6
Jul 4, 2004

So hot ...
wow <TAB> in a [code] block will actually put a tab and won't change the focus


... idk how i feel about that

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome
this new guy just owns

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp
code:
open MOVIES,"<","movies.txt" or die;
while (<MOVIES>) {
        if (s/\b\S{4}\b/Grok/) {print}
}

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

yo anal volcano im in a similar boat as u but i don't post about it, instead i just bang my head against the android framework every once in a while. its frustrating but otoh im actually learning stuff that will help ace some buzzword bingo in an interview / look good on mah resume. Basically quit whining and :getin:

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror

Jonny 290 posted:

:supaburn: oh god he didnt use strict and warnings!!!!! :supaburn:

strict: for people who want more bugs in their code

Serenade
Nov 5, 2011

"I should really learn to fucking read"

Tiny Bug Child posted:

strict: for people who want more bugs in their code

the actual unironic reason i use strict

Jonny 290
May 5, 2005



[ASK] me about OS/2 Warp

Jonny 290 posted:

code:
open MOVIES,"<","movies.txt" or die;
while (<MOVIES>) {
        if (s/\b\S{4}\b/Grok/) {print}
}

a little tighter

code:
open MOVIES,"<","movies.txt" or die;
print map{s/\b\S{4}\b/Grok/&&$_} <MOVIES>

tef
May 30, 2004

-> some l-system crap ->
perl -pe 's/\b\S{4}\b/Grok/' < movies.txt | grep Grok :v:

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

tef posted:

perl -pe 's/\b\S{4}\b/Grok/' < movies.txt | grep Grok :v:

gently caress yeah use that shell

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
sometimes, when im really loving lazy, i'll write little utilities by embedding python or ruby in heredoc in bash scripts and just running that via ruby -e or python -c usually in a pipeline

Opinion Haver
Apr 9, 2007

rotor posted:

graph traversal algorithms are not even a little bit hard to write, please stop complaining that you had to write one

i'm not complaining it was the easiest thing in the world, i'm just saying that it's a good reason to know how it's actually implemented

salted hash browns
Mar 26, 2007
ykrop
i use 2 languages mostly
java for stuff that matters
python for stuff that doesn't

works 4 me

Hellsworn Barn
Apr 11, 2008

hi
i use c#

Hellsworn Barn
Apr 11, 2008

hi
does anyone else use c#

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

Hellsworn Barn posted:

does anyone else use c#

haha windows

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Tiny Bug Child posted:

strict: for people who want more bugs in their code

i want to pinch your cheeks

CamH
Apr 11, 2008

CamH
Apr 11, 2008

today i did a lot of javascript though

X-BUM-RAIDER-X
May 7, 2008

Paracetamol Boy posted:

does anyone here actually enjoy working with libboost for the sake of working with libboost

boost owns and if you don't use it then you're an idiot who should not be a c++ programmer

X-BUM-RAIDER-X
May 7, 2008
C++11 owns and i'm so pissed we won't have it in our company for a while yet

X-BUM-RAIDER-X
May 7, 2008

rotor posted:

everyone needs to learn more perl imho

Cold on a Cob
Feb 6, 2006

i've seen so much, i'm going blind
and i'm brain dead virtually

College Slice

Hellsworn Barn posted:

does anyone else use c#
yep I like it

Bird Priest
Jun 22, 2009

I have free will to do what I want but I choose to oscillate.

OBAMA BIN LAUGHIN posted:

boost owns and if you don't use it then you're an idiot who should not be a c++ programmer

boost is useful but there is this guy who uses boost for stuff that he can code natively in fewer lines than it takes to code the thing using boost

i do not understand this mentality

OBAMA BIN LAUGHIN posted:

C++11 owns and i'm so pissed we won't have it in our company for a while yet

C++11 multithreading & raii is p cool

Shaggar
Apr 26, 2006

Hellsworn Barn posted:

does anyone else use c#

yeah c# is great. also java

Shaggar
Apr 26, 2006

CamH posted:

today i did a lot of javascript though

sorry for your lot

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Hellsworn Barn posted:

does anyone else use c#

yes but mostly for linq

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

EVGA Longoria posted:

modern::perl

oxymoron.pm

JawnV6
Jul 4, 2004

So hot ...

tef posted:

sed 's/\b\S{4}\b/Grok/' movies.txt | grep Grok :v:

:smaug:

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
i'm Hype for the hobbit (the second trailer was Neato)

Adbot
ADBOT LOVES YOU

homercles
Feb 14, 2010

when i ask myself what could be added to java to make it a less awful language to code in, i start listing all the stuff in c# that isn't legacy

it's as though i've discovered this other restaurant that only has maggots in its food, lacking the ever present cockroaches dropping from the ceiling and i'm using this discovery as the benchmark that all things should be judged against

meanwhile there's this old but ever present prostitute efficiently working her way through customers, always oblivious to the shitfight inside called Pearl (or something like that)

(I could never code in C# professionally its standard library is unfun and I don't like xaml how the hell is it suited to mvcc??)

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply