Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

(crazyinsomniac) Re: diary.pl

by crazyinsomniac (Prior)
on Feb 07, 2002 at 08:12 UTC ( #143814=note: print w/ replies, xml ) Need Help??


in reply to diary.pl

I took a quick look at this, and I see a lot of familiar technique (you remind me of me) which I wouldn't employ now ;)

I will now ask you a few similar questions, and hopefully get you thinking about what I mean.

Why do you include use CGI qw/:all/;?
What do you think the above code does?

Why do you include my $q = new CGI;?

Why do you include $q->param ?
Why do you include print <<END_FORM;?

Do you see a conflict of technique yet?

I also see print("<center>"); and while it is understandable that you can't always say print center('stuff in here');, there is always print start_center,'stuff',end_center; (that trick only available if you're aware of use CGI qw/*center/;

Some might argue performance when choosing between print("<center>"); and print start_center;, but my point is, either use the CGI.pm functional or OO interface, but don't mix. Also, if you do bother to 'import' :all the CGI functions, use them. Also, either stick to heredocs, or stick to CGI functions for generating html, don't mix.

And probably the least important of my comments if (!($Found)) { if fine, but why did you choose to write it that way (probably cause it looks a lot like Java or c/c++ or something)? You are programming in perl now, and while some might argue that keeping things familiar helps you keep things straight, beginning to think in terms perlsyn helps you think of new solutions ( if (! $Found) { or if (not $Found) { or unless ($Found) { ).

Consider this, if you wanted to iterate over an @array, how often would you write for(my $i=0;$i<90;$i++) {print $array[$i].$jerky."\n";}?

for my $i(@array) { print $i.$jerky."\n" } print $_.$jerky."\n" for @array; print shift(@array).$jerky."\n" while @array; print map $_.$jerky."\n", @array; print map { "${_}${jerky}\n" } @array;
Think about it (but don't worry too much, after all, you at least have -wT -Mstrict in there ) :)

However, you also might wanna look into CGI's escape, unescape, and escapeHTML functions, especially for this line -href=>"diary.pl?user=$user_key&diary_key=$ref->{'diary_key'}"

Happy Coding!

update:

# Another minor comment, sql statemends end in ; # so I try to end all mine in ;, and I always reccomend # others do as well (;) my $SQLText = qq[ UPDATE diary SET diary_title = ( ? ), diary_entry = ( ? ), fk_user_key = ( ? ) WHERE diary_key = ( ? );];
and this one is almost ridiculous, but $entry =~ s/\n/<P>/g; i feel might be more appropriately written as
$entry =~ s/\n\n/<P>/g; $entry =~ s/\n/<br>/g;
(yeah, I know, *almost*, who am I kidding ;D)

 
______crazyinsomniac_____________________________
Of all the things I've lost, I miss my mind the most.
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"


Comment on (crazyinsomniac) Re: diary.pl
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://143814]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (9)
As of 2014-09-22 20:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (200 votes), past polls