Joel wrote:

> If I was using one specific group of commands, Could I put them inside a
> variable, then just use the variable when I needed the commands instead of
> copying and pasting them?

Yes.  You could do that.  It would be a step backward, though.  Variables are
for storing data or information.  Storing programming structures in them tends
to confuse matters.

> i.e.
> print "Hello world";
> if ($i == 50) {
>     goto MAIN;

Don't do this.  For some perverse reason, goto was included in the Perl
language.  This may have been to support legacy programs.  No new code should
ever be written with such structures.  They have been long since deprecated.
Name the procedure you wish to undertake, then define it in a subroutine.  You
can then call the subroutine by name, without any gotos:

For instance:


sub launch_viewer {
  my $for_path = shift;
  $message_viewer = create_main_viewer_window();
  add_main_menu($message_viewer);
  add_header_list($message_viewer, $for_path);
  add_message_area($message_viewer);
  print get_viewer_option('Files|References'), "\n";
  MainLoop;
}

sub create_main_viewer_window {
  our $message_viewer = MainWindow->new(
  -title => get_viewer_option('source file'));
  $message_viewer->geometry('780x540+0+0');
  return $message_viewer;
}

sub add_main_menu {
  my $message_viewer = shift;

  our $menu_bar = $message_viewer->Menu(-type => 'menubar');
  $message_viewer->configure(-menu => $menu_bar);
  create_view_menu();
  create_find_menu();
}

You notice something about the  launch_viewer method?  It does nothing technical
at all, yet guides the entire process, and does so in plain language.
Programming languages have eveolved to well support plain-language styles, and
they help to minimize errors by minimize the distractions of detail.  The
details of each action specified can be fleshed out in the individual mthod
definitions, without cluttering the main description of the process.

It is a whole new world in programming.

Joseph



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to