in reply to MySQL Table adding with Perl

so please don't flame

Are you sure about that? Its cold outside, how will you keep warm?

use strict/warnings to cut your development time in half! strict and warnings have also been called "training wheels" but they're more like "sanity checks" or seatbelts , professionals use them long after they've learned to ride a bike

See Re: DBD::mysql trouble

See ExtUtils::MakeMaker::prompt, you could write

use ExtUtils::MakeMaker qw' prompt '; ... if( prompt('Are you new?', 'n') =~ /y/ ){ my $username = prompt('Your name is?','John Smith'); $username =~ s/\s+$//; ... } else { my $username = prompt('Who are you','John Smith'); $username =~ s/\s+$//; ... }

Or even

if( prompt('Are you new?', 'n') =~ /y/ ){ CreateNewUser(); } else { ActivateOldUser(); }

where CreateNewUser and ActivateOldUser do all that prompt/DBI stuff from before

Replies are listed 'Best First'.
Re^2: MySQL Table adding with Perl
by Anonymous Monk on Mar 07, 2013 at 13:48 UTC

    Making users isn't my issue. The DBI stuff is. You should read the topic before commenting.

    use Strict; use Warnings;

    Was not copied from my script, but are above the  use DBI; code. I didn't add them in because its a standard for nearly all perl scripts. Thanks... I guess.

      Making users isn't my issue. The DBI stuff is.

      I think Corion covered that well, which is why I chose to comment on other aspects

      I didn't add them in because its a standard for nearly all perl scripts. Thanks... I guess.

      Sure, you're welcome, but :)

      If you take the time to clean up the code you post and make sure it compiles and runs , then someone might focus on answering the real question instead of pointing out the typos and such

      You should read the topic before commenting.

      Sure, that is a reasonable practice, although its not a requirement :) However, surely you're aware I must have read the topic to notice issues in your code, and offer some suggestions?

      What did you think of my suggestions, have you heard about the programming rule of three?

      You repeat (or copy/paste)  print/<STDIN>/chomp and according to the rule of three, this means you should turn it into a function/sub/procedure ...

      Good luck