Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I appreciate the code, however some of the commands and methods used are a bit advanced for me.

My code currently stands as:
#!/usr/local/bin/perl use strict; use warnings; use DBI; use DBD::mysql; my $dbh = DBI->connect('DBI:mysql:e:xxx.xxx.xxx.xx', 'x.xxxxxxx', 'xxx +xxxxxx') or die "Couldn't connect to database: " . DBI->errstr; sub retrieve_ESLIM_codes { my $Multiple_lines = "Lines_string.txt"; my $lines_one_col = "List_of_lines_relating_to_particular_gene_kno +ckouts.txt"; my $sql_A = "SELECT DISTINCT parameter_id FROM e.measurement WHERE + parameter_id LIKE 'M-G-P%' OR parameter_id LIKE 'GMC%' OR parameter_ +id LIKE 'ESLIM%' AND parameter_id NOT LIKE '%_________8__' ORDER BY p +arameter_id;"; my $Output_A = "List_parameters_common_to_centers.txt"; # THIS D +OES NOT APPEAR TO BE USED. I NEED TO CHECK WHAT TO DO. open (OUTFILE_A, ">>$Output_A") || die "Error opening outfile.$!,s +topped"; my $sth_A = $dbh->prepare($sql_A) or die "Cannot prepare: " . $dbh +->errstr(); $sth_A->execute() or die "$sth_A->errstr\n"; my @row_A; my @parameters_A; my @record_A; while(@row_A = $sth_A->fetchrow_array()) { @record_A = @row_A; push(@parameters_A, @record_A); print OUTFILE_A "@record_A\n"; # at the moment this seems to be + only to creat a record. } $sth_A->finish(); my @sorted_parameters_A = sort { $a cmp $b } @parameters_A ; return (@sorted_parameters_A); # retrieve_ESLIM_codes returns @ +sorted_parameters_A but the return result is not used presently # I will at some point want to process this list to create associ +ations between the different pipelines that contain the same code. } sub look_through_file ($$) { # maybe I should remove ($$) my ($start_point, $continue_tag) = @_; # this variable is to pr +event line sets from being repeated. The starting point is the next +one up from the last to be processed my $entry_no_new = $start_point; # entry number new my @array_of_lines; my $Line_input = "List_of_lines_relating_to_particular_gene_knocko +uts.txt"; open (LINE_INPUT, "<$Line_input") || die "Error opening outfile.$! +,stopped"; print "I am here A\n"; LINE: while (<LINE_INPUT>){ print "I am here B\n"; chomp; my $entry_no_old = $entry_no_new; # a bit of a work around use +d here if ($_ =~ /^(\d{1,3})\t(\d{3,5})/){ next LINE if $1 < $start_point; print "I am here C\n"; $entry_no_new = $1; last LINE if ($entry_no_new > $entry_no_old); print "Entry no new: ".$entry_no_new."\n"; my $line = $2; push (@array_of_lines, $line); } else { $continue_tag = "FALSE"; } } print "@array_of_lines"; print "\n"; close (LINE_INPUT); return (@array_of_lines, $start_point, $entry_no_new, $continue_ta +g); # The array of lines is not used yet } sub create_output (\@$) { my ($arrayref_of_lines, $entry_no_new) = @_; # THIS DOES NOT WO +RK my @array_of_lines = @$arrayref_of_lines; print "Hi there\n"; print "@_"; print "@array_of_lines"; exit; print "\n\n$entry_no_new"; mkdir "Output"; my $Line_set_Output_A = 'Output/Line_set_Output_A_'.$entry_no_new. +'.txt'; # $entry_no_new should be from the stored procedure loo +k_through_file open (LINE_SET_OUTPUT_A, ">>$Line_set_Output_A") || die "Error ope +ning outfile.$!,stopped"; my $sql_command_A = "CREATE TEMPORARY TABLE Temp_Table ( Key_m INT + NOT NULL AUTO_INCREMENT, Value INT NOT NULL)"; my @insert_statements; print LINE_SET_OUTPUT_A @array_of_lines; print LINE_SET_OUTPUT_A "\n"; foreach (@array_of_lines){ my $element_line = $_; my $sql_command_B = 'INSERT INTO Temp_table (Line) VALUES ('.$elem +ent_line.');'; # uninitialized value $element_line ???????? print LINE_SET_OUTPUT_A "$sql_command_B\n"; } my $sql_command_C = "DROP TABLE Temp_table\n"; my $sql_command_D = "SELECT * from e.annotation WHERE Line IN (SEL +ECT Line FROM #Temporary_table) AND entity_name LIKE '_%' ORDER BY ev +idence_code;"; print LINE_SET_OUTPUT_A "$sql_command_D\n"; my $dbh = DBI->connect('DBI:mysql:e:xxx.xxx.xxx.xx', 'x.xxxxxxx', +'xxxxxxx') or die "Couldn't connect to database: " . DBI->errstr; my $sth_A = $dbh->prepare($sql_command_D) or die "Cannot prepare: +" . $dbh->errstr(); $sth_A->execute() or die "$sth_A->errstr\n"; while(my @row_A = $sth_A->fetchrow_array()) { print LINE_SET_OUTPUT_A @row_A; print LINE_SET_OUTPUT_A "\n"; my @record_A = @row_A; push(my @fields_A, @record_A); } $sth_A->finish(); } retrieve_ESLIM_codes(); my $starting_point = 0; my $continue_tag = "TRUE"; my @array_of_lines; my $entry_no_new; while ($continue_tag eq "TRUE"){ look_through_file ($starting_point, $continue_tag); create_output (@array_of_lines, $entry_no_new); }

In reply to Re^2: Calling a subroutine within a conditional by Freezer
in thread Calling a subroutine within a conditional by Freezer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-03-28 18:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found