I had a bit of trouble going through the perldocs when I started on perl as it is all rather confusing at that stage. But it is definetly worth it. I was avoiding going back again and then noticed some links to the perltut posted by a distinguished monk, so I revisited them.
Having been writing some initiate level subroutines I was amazed at some of the basic syntax and structure practices I was failing to include in my code. The shear feeling of elation I have from just reading a few nicely laid out tutorials is beyond description. Send $40 dollars now and you may have the opportunity to become the next beautified initiate at perlmonks.org ... (joking)
Here's a small before and after - the differences are subtle but extremely satisfying.
sub adedtear{ open(my $prfore, "<", "../editsite2/preview.html") or die "couldn't o +pen preview for read in sub adedtear: $!\n"; while(my $line=<$prfore>){ if($line =~ m/<\!--texts001-->/){ $flag=1; } if($flag == 1){ if($line =~ m/<\!--text[s|e]/){ $line=$line; } else{ $line =~ s/<br\/>//; $linevalis .= $line; $line = ""; } } if($line =~ m/<\!--texte/){ $flag=2; } } close $prfore or die "couldn't close prfore: $!\n"; print $bar $foo->textarea({-id=>'t001', -name=>'none', -value=>"$linev +alis"}) or die "cant print linevalis into textarea cgi: $!\n";&n; }
sub adedtear{ open(my$prfore, "<", "../editsite2/preview.html") or die "couldn't op +en preview for read in sub adedtear: $!\n"; LINE: while(<$prfore>){ if(/<\!--text[se]\d{3}-->/){ $flag=1; next LINE; } if($flag){ unless(/<\!--texte/){ s/\D{5}\s+$/\n/; $linevalis .= $_; } else{$flag=0;} } } close $prfore or die "couldn't close prfore: $!\n"; print $bar $foo->textarea({-id=>'t001', -name=>'none', -value=>"\n$lin +evalis"}) or die "cant print linevalis into textarea cgi: $!\n";&n; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Another reason for perl beginners to read perldocs
by GrandFather (Saint) on Jul 02, 2011 at 23:20 UTC | |
by Anonymous Monk on Jul 02, 2011 at 23:33 UTC | |
by GrandFather (Saint) on Jul 03, 2011 at 00:12 UTC | |
by Jim (Curate) on Jul 03, 2011 at 18:41 UTC | |
|
Re: Another reason for perl beginners to read perldocs
by dcmertens (Scribe) on Jul 06, 2011 at 16:44 UTC | |
|
Re: Another reason for perl beginners to read perldocs
by thirdm (Sexton) on Jul 09, 2011 at 16:28 UTC | |
by Don Coyote (Hermit) on Jul 10, 2011 at 22:10 UTC |