C
ccc31807
I've been writing software for about ten years, mostly Perl but also
Java, C, Python, some Lisp, Javascript, and the assorted stuff we all
pick up (SQL, HTML, XML, etc.) I've never worked on a big project, my
scripts typically running between several hundred and several thousand
LOC. I've written in a number of different styles, evolving over the
years. After reviewing some of the work I've done in the past couple
of years, rewriting a lot and revising a lot (due to changing data
requirements), I've noticed that I use a particular style.
In the past, the technology I've used seems to influence the style.
For example, at one time I was writing in C, and my Perl code
consisted of modules that acted the same as header files. When I was
writing some Lisp, my Perl code conformed a lot more to a functional
style.
Now, I don't know what I do. I've copied the guts of a program below,
and would like comments from those who might have a lot more
experience than I do.
Essentially, what I do is declare all my variables as global
variables, write the subroutines that manipulate the data, and call
the subroutines one after another. The problem domain consists of data
munging, slicing and dicing data files and preparing reports of one
kind or another.
Thoughts?
Thanks, CC.
---------------------sample of
script-----------------------------------
#declare necessary variables
my ($global1, $global2, $global3, $global4, $global5, $global6);
my (@global1, @global2, @global3);
my (%global1, %global2, %global3, %global4);
#run subroutines
&get_student_info;
&get_letter_info;
&check_site_exists;
&test_hashes;
&make_new_dir;
&create_letters;
#email to sites
my $answer = 'n';
print "Do you want to email the letters to the sites? [y|n] ";
$answer = <STDIN>;
&email_letters if $answer =~ /y/i;
exit(0);
#construct user defined functions
sub get_student_info { ...}
sub get_letter_info {... }
#etc .
Java, C, Python, some Lisp, Javascript, and the assorted stuff we all
pick up (SQL, HTML, XML, etc.) I've never worked on a big project, my
scripts typically running between several hundred and several thousand
LOC. I've written in a number of different styles, evolving over the
years. After reviewing some of the work I've done in the past couple
of years, rewriting a lot and revising a lot (due to changing data
requirements), I've noticed that I use a particular style.
In the past, the technology I've used seems to influence the style.
For example, at one time I was writing in C, and my Perl code
consisted of modules that acted the same as header files. When I was
writing some Lisp, my Perl code conformed a lot more to a functional
style.
Now, I don't know what I do. I've copied the guts of a program below,
and would like comments from those who might have a lot more
experience than I do.
Essentially, what I do is declare all my variables as global
variables, write the subroutines that manipulate the data, and call
the subroutines one after another. The problem domain consists of data
munging, slicing and dicing data files and preparing reports of one
kind or another.
Thoughts?
Thanks, CC.
---------------------sample of
script-----------------------------------
#declare necessary variables
my ($global1, $global2, $global3, $global4, $global5, $global6);
my (@global1, @global2, @global3);
my (%global1, %global2, %global3, %global4);
#run subroutines
&get_student_info;
&get_letter_info;
&check_site_exists;
&test_hashes;
&make_new_dir;
&create_letters;
#email to sites
my $answer = 'n';
print "Do you want to email the letters to the sites? [y|n] ";
$answer = <STDIN>;
&email_letters if $answer =~ /y/i;
exit(0);
#construct user defined functions
sub get_student_info { ...}
sub get_letter_info {... }
#etc .