ithelp commented: Thanks. +3
Lets see your current code.
OK, but the code you posted is not loading any modules so I thought you were trying to do it all by hand. As far as Windows/Solaris goes the open() command works on both. You can prepend to a file but it is much easier to append to a file. To prepend you can use perls inplace editor or open a new file and add the new data, then open the old file and add the old file data to the new file, then delete the old file and rename the new file to the old file.
There are a lot of SNMP modules already written that you should probably take a look at:
Yes, I guess. I put the A and B modules in the same directory as the script, not sure if the directory the script is in is found first by @INC or if there is in fact any standard order for @INC at all.
Good point Bob but it's interesting to note it does work for me as-is. ActiveState Perl 5.8.8 which does include perls 'B' module.
try changing these lines:
if ($genome_seq =~ $srna_seq){
my $align = lc$1;
$genome_seq =~ s/$1/$align/;
print $genome_seq, "\n";
}
to:
if ($genome_seq =~ /($srna_seq)/){
my $align = lc $1;
$genome_seq =~ s/$1/$align/;
print $genome_seq, "\n";
}
or:
if ($genome_seq =~ s/($srna_seq)/lc $1/e){
print $genome_seq, "\n";
}
and see if it helps.
hmmm...not sure what the problem is, your code works fine for me. Are you sure the B.pm file you posted is the file your main script is accessing?
\014 looks to be octal for a carraige return or newline. so /\014/ is a regexp looking for that pattern in $_. Probably it's counting lines, not sure why it does it like that though. Perl has a variable that tells you how many lines are in a file: '$.'
Sorry, I'm lost, I don't think I can help you.
Not sure I understand what your question is. Why doesn't it work with the xml file?
why are you spamming so many forums with your pointless questions?
what have you tried so far?
I see I may have misunderstood your question. If all the radio buttons have the same name and the same value, whats the point anyway? There would be no way to know which one was checked because they all have the same name and the same value. That is just the wrong premise to begin with. That is what your original question asked even though the code does not create the same value $i for each radio button. But maybe you just made a mistake in how you asked the question.
But if the radio buttons had the same name and different values you can get the values but they are all associated with the one name. That is called a multi-value form field: one name but many values.
Or if they have a different name and the same values you can get the radio buttons that were checked because they are no longer a group. Those are just single name single value form fields.
It should, you must have done something wrong.
Use the CGI module and it will automatically get multi-valued form fields into your CGI script for you if you call the multi-valued form field in list context, for example:
use CGI qw/:standard/;
print header;
my @first = param('first');#<-- your radio buttons: name='first'
print "$_<br>\n" for @first;
See the CGI module documentation for all the gory details. It s a big module and has lots of functions, takes a while to learn to use well but is a must for CGI coding with perl.
I mean use the CGI module. To get you started:
use CGI;
my $query = CGI->new;
my %data = $query->Vars;#gets 'post' or 'get' data in name/value pairs
print $query->header();
foreach my $param (keys %data) {
print "$param = $data{$param}\n";
}
should work, but really you should use the CGI module to get post and get (and other) data into your perl based CGI scripts. Trying to do it like you are is not secure, could lead to problems.
It looks like Activeperl 5.10 comes with Tkx instead of Tk. Activeperl 5.8 comes with Tk and Tkx (I think).
http://aspn.activestate.com/ASPN/docs/ActivePerl/5.10/lib/Tkx.html
So install perl 5.8 if you want to use Tk instead of Tkx.
You need perl and the Tk modules installed. I would be surprised if they are not included with the distribution of perl you are using.
Open the activestate folder and open the documentation folder (or however it is structured with Active perl 5.10). You should see a list of all the Tk modules that came with your distribution.
Tk is a sort of niche when it comes to coding perl programs, you don't find a lot of perl programmers that are familiar with Tk applications.
I suggest you post on the perl forum at www.tek-tips.com as I know there is one member there that has a lot of Tk experience.
may as well use "do" instead of eval.
try using wperl.exe instead of the regular perl.exe
Get the latest edition of "Perl BookShelf References" (on CD). 5 or 6 books on the CD, including "Learning Perl" and "Advanced Perl Programming" (at least last ime I checked they were included).
You can download (or simply read) a few perl books for free from this site:
http://www.perl.org/books/library.html
They are getting a little old but are still relevant for the most part.
"Data Munging" by Dave Cross is also excellent.
is this school work? If you are entering integers sort() will not work properly. That is a lexical sort in ASCII order, not numeric order. To properly sort numbers use: <=>
@sorted = sort {$a <=> $b} @unsorted;
I really don't know, sorry. Find a forum or newsgroup that specializes in bioperl and you may find someone that has experienced this problem and can help.
Good luck.
You are using math, there are several places in the script that use math operators:
==
<=
maybe more. I do not know if that is where you problems are occuring. Erros/Warnings generally have a line number associated with them that can help pin point where a error/warning is occuring. Run your program and see if a line number and a program/module name gets displayed along with the message.
If you are using Windows you will want to look into the Win32 class of modules and see if there is one written to communicate with the com port, I suspect there is. Or you can possibly open a pipe to the com port. Where are you stuck? Do you know any perl?
Well, I had the code pasted into my perl IDE so making some assumptions I adjusted the code. It is of course untested and I am not sure it does what you want, but I guess you can try it:
#!/usr/local/bin/perl
use strict;
use warnings;
open (INPUT, "phastCons_200_chr6.txt") or die "Can't open phastCons: $!\n";
open (INPUT2, "refFlat.txt") or die "Can't open refFlat.txt: $!";
open (OUT, ">>phastCons_noex_chr6.txt") or die "Can't open phastCons_noex: $!\n";
print "phastCons and phastCons_noex and refFlat.txt are all open\n";
OUTTER: while (my $line_ph = <INPUT>) {
my @fields_ph = split (/\s+/, $line_ph);
INNER: while (my $line = <INPUT2>) {
my @fields = split (/\s+/, $line);
if ($fields_ph[1] eq $fields[2] && $fields_ph[2] < $fields[5] && $fields_ph[3] > $fields[4]) {
my @ex_start = split (/,/, $fields[9]);
my @ex_end = split (/,/, $fields[10]);
for my $i (0 .. $fields[8]-1) {
if ($fields_ph[2] < $ex_end[$i] && $fields_ph[3] > $ex_start[$i]) {
print OUT $line_ph;
seek INPUT2, 0,0; # return to beginning of file INPUT2 - see note below
next OUTTER; # go to next line in INPUT
}
}
}
}
}
close INPUT;
close OUT;
close INPUT2;
Note: this may not work on some systems
After looking at the code I need some explanations. You are using a binary flag, $overlap, to control some behavior of the script.
You open the first file and read in the first line and $overlap is false (0).
You open the second file and check if $overlap is true (1) and if it is you go to the next iteration (the next line) of the second file.
Now if $overlap is true (1) all the code does is loop through all the lines of the second file without ever doing anything else. If this is a big file that will waste lots of time.
So now the script reads all the lines of the second file and gets back to the second line of the first file. $overlap is once again set to false.
Then it does the same thing again like I described above. It loops through the lines of the second file until $overlap is set to true. Then it loops through all the rest of the lines in the second file again. Then it gets back to the third line of the first file.
That is most likely what is causing the scripts runtime to be so long.
Do you really need to check all the lines of the second file against all the lines of the first file?
How big are the files? Can I see some of the data? Are you reading this thread anymore?
Your FTP program, or a control panel that the host lets you use are the two most common ways. You can also shell into the account with telnet and set permissions but the host has to allow telnet connections. Using your ftp program is very easy. See it's help files for chmod.
Can we see some of the data the script is porcessing? Does it just print just one line of data to the output file?
The code can be written more efficiently. I do not have the time right now to look at it in detail but I will check back later today.
if you have php questions ask them in the php forum, but I am sure a php script can run a perl program. But if you are at a total loss as to how to even start your project, I really have no idea what to suggest.
extracting data from a pdf file could be difficult. I have seen many questions posted on forums over the years dealing with pdf files and it seems the perl modules there are for reading pdf files may leave something to be desired. The rest should be relatively easy but probably not for a beginner.
OK, you may be new, but have you tried anything yet? Please post the code you have written so far so I can see where you need help.
Image::Magick is sort of a beast all it's own seperate from general perl issues. I recommend you post your concerns on the Image Magick forum:
http://www.imagemagick.org/discourse-server/
Hopefully someone there will be able to help you out. Or wait and see if you get some replies here. I never use it so can't help.
Hard to say, you have not given enough information. Can you be more specific?
Personally, I can not understand the specifications of what the program is supposed to do. Posting partial code is not much help, there is no place in the code posted that even prints anything so there is no way to tell why it's not working properly. And you say you have a csv file but you are using tabs in the regexp to pull the data fields out of the lines.
You have to do better at explaining your program specs and please start using code tags around your perl code.
I will be glad to help, but I don't know where to start. All you have done so far is post a very general and somewhat vague idea of what you want to do. If you can be more specific maybe I can help.
Do you know any perl at all?
That modules documentation appears to support upto PPM 3.x, and I also have no idea how to mass add repositories to PPM.
He has this posted on another forum where it has a number of replies and so far nothing has worked, his input file appears to not be tab delimited. He was told to use \s+ instead of \t , which did not work either.
ahh, that will be a good thing to remember for future reference.
just for sanity sake I would add in some error handling for any sytem functions, like these:
if (!(-d "$path/"))
{
mkdir("$path/", 0777) or some error handling here;
}
if(-f "$path/$filename")
{
unlink("$path/$filename") or some error handling here;
}
make sure everything else is working so you can for sure track it down to the read() function being the real source of the problem, or at least the point where the problem occurs. Why the filehandle is closed is a mystery at this point. It worked, nothing got changed, now it does not work.... thats possible but leads to more fundamental questions, like is the server/computer going bad? Was new software installed or ugraded? It does not sound like a perl problem though.
Another piece of important information is that while both the program that failed and then worked and this current program are programs to upload files, they are completely different versions of code that work differently. They don't even share any custom libraries in common.
Almost sounds like someone is hitting the "stop" button on the browser while uploading a file. Maybe someone else will have an idea to help you, but I am baffled by the problem you have described.
Ok :)
I hope I did not offend you by quoting the manual, but it explains it very well.
this is a bit of perl magic:
@ARGV = (list of files);
while (<>){
Quoted from perlvar:
# ARGV
The special filehandle that iterates over command-line filenames in @ARGV . Usually written as the null filehandle in the angle operator <> . Note that currently ARGV only has its magical effect within the <> operator; elsewhere it is just a plain filehandle corresponding to the last file opened by <> . In particular, passing \*ARGV as a parameter to a function that expects a filehandle may not cause your function to automatically read the contents of all the files in @ARGV .
# $ARGV
contains the name of the current file when reading from <>.
# @ARGV
The array @ARGV contains the command-line arguments intended for the script. $#ARGV is generally the number of arguments minus one, because $ARGV[0] is the first argument, not the program's command name itself. See $0 for the command name.
# ARGVOUT
The special filehandle that points to the currently open output file when doing edit-in-place processing with -i. Useful when you have to do a lot of inserting and don't want to keep modifying $_. See perlrun for the -i switch.
/end quote/
The "if" condition probably should be written like this:
if(/^pageoncall:) {
print "pageoncall: $num\@pager.com\n";
}