Forum: Perl Aug 1st, 2009 |
| Replies: 2 Views: 460 It aborts because you can't have nested quantifiers.
Your expectation of what the "g" modifier does is also wrong. Here is an excerpt from perlretut:
Global matching
The final two modifiers... |
Forum: Perl Jul 31st, 2009 |
| Replies: 4 Views: 637 You need parentheses for back references to capture patterns they find.
if (/($pattern)/) { |
Forum: Perl Jul 31st, 2009 |
| Replies: 1 Views: 570 hashes are not randomly ordered lists, they are lists that don't have any guaranteed ordered, but they should always be the same order on the same computer. So that bug report appears to be erroneous... |
Forum: Perl Jul 31st, 2009 |
| Replies: 4 Views: 637 What are you entering into $pattern? |
Forum: Perl May 30th, 2009 |
| Replies: 2 Views: 504 The perl documentation would have explained all of your errors. But I'll short-cut it for you.
First, $a and $b are variables used by perl for sorting and should not be used by you except for... |
Forum: Perl May 23rd, 2009 |
| Replies: 5 Views: 510 Yes there is something you can do. There are a few things actually. But I think this is the best suggestion. Instead of returning a list of scalars with some that you don't use, return a list slice... |
Forum: Perl May 20th, 2009 |
| Replies: 5 Views: 510 This line also needs to be changed:
$nucleotide_gi,$start_gene,$end_gene,$strand) = split('\t');
\t in single-quotes is a literal string, not a tab, so use forward slashes for the split()... |
Forum: Perl May 20th, 2009 |
| Replies: 5 Views: 510 I didn't look at all your code but this line:
$content = get('http://www.ncbi.nlm.nih.gov/sviewer/viewer.fcgi?db=protein&sendto=t&dopt=fasta&list_uids=$protacc_arr[$i]');
Needs... |
Forum: Perl May 14th, 2009 |
| Replies: 1 Views: 455 The code you posted will work to append the string to the end of whatever value $values[10] has. If its not working the problem is elsewhere. |
Forum: Perl May 13th, 2009 |
| Replies: 5 Views: 954 try:
my ($d) = $s =~ m/<head>(.*?)<\/head>/is; |
Forum: Perl Apr 19th, 2009 |
| Replies: 2 Views: 849 $decVal = <STDIN>;
chomp($decVal);#<--- you need this |
Forum: Perl Apr 18th, 2009 |
| Replies: 2 Views: 848 use split instead:
my $var = 'abcdefghijklmnop';
my @chars = split(//,$var);
foreach my $char (@chars) {
#do something with $char
} |
Forum: Perl Apr 9th, 2009 |
| Replies: 2 Views: 718 CGI::Pretty comes with perl. I leave it up to you to read the documentation. |
Forum: Perl Apr 6th, 2009 |
| Replies: 3 Views: 1,217 Its covered in the CGI modules documentation, you were pretty close actually:
use CGI;
my $cgi = CGI->new;
print $cgi->start_html(-title => 'Meta Test',
... |
Forum: Perl Apr 4th, 2009 |
| Replies: 4 Views: 657 I don't know, you can try www.perlmonks.com or ask on the dbi modules mailing list (see the DBI module for details) |
Forum: Perl Apr 2nd, 2009 |
| Replies: 3 Views: 585 #!/usr/local/bin/perl
use English;
$string = "This is my string this is it. I want to tie my string";
$count = 0;
while ($string =~ m/string/gi)
{
$count=$count+1; |
Forum: Perl Apr 2nd, 2009 |
| Replies: 3 Views: 585 If you literally want to find "string" you can't put it in square brackets. That makes a character class and order of the characters is ignored. |
Forum: Perl Mar 23rd, 2009 |
| Replies: 3 Views: 591 use the "g" option:
$string = 'abc 123 def 456 ghi 789';
@numbers = $string =~ /\d+/g;
print "$_\n" for @numbers;
Note I changed the quantifier * to + because * will match zero or more... |
Forum: Perl Mar 12th, 2009 |
| Replies: 3 Views: 817 Hes just not applying it correctly to this particular problem. |
Forum: Perl Mar 12th, 2009 |
| Replies: 3 Views: 817 The problem is you are generating a random number based on the length of the array, not the values of the elements of the array. Here is what you want to do:
my @numbers = (48..57, 65..90,... |
Forum: Perl Feb 10th, 2009 |
| Replies: 2 Views: 726 if($form_element{'email'} =~ m/^[a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-]+([.][a-zA-Z0-9_\-]+)+[a-zA-Z]{2,4}$/i){
$values = 0;
$mail = "Valid!";
} else {
$mail = "InValid!";
} |
Forum: Perl Jan 28th, 2009 |
| Replies: 7 Views: 1,006 just a guess, in this block of code:
#open (MLB2, ">> /data/local/GIS/WRKGIS.txt");
open (MLB2, ">> /awips/dev/localapps/kmltools/WRKGIS1.csv");
for ($i=1; $i<=$num1; ++$i){
if ($finline[$i]... |
Forum: Perl Jan 27th, 2009 |
| Replies: 12 Views: 2,067 see the other forum, I prefer to not duplicate my replies. |
Forum: Perl Jan 27th, 2009 |
| Replies: 12 Views: 2,067 I see you posted the same question on another forum and provided more detail. My suggestion above will not do what you want. |
Forum: Perl Jan 27th, 2009 |
| Replies: 12 Views: 2,067 csv files typically use quotes around fields that have text or non-digit data in them. If you don't want the quotes you can try this:
print (join ',' , "@dn", # row
map {get $entry, $_->[1],... |
Forum: Perl Jan 27th, 2009 |
| Replies: 1 Views: 525 PPM is not for running your perl programs. Its for installing modules and other tasks related to modules. On Windows the way I prefer to run a perl program is open a DOS (or Command) Window and type:... |
Forum: Perl Jan 27th, 2009 |
| Replies: 4 Views: 616 If you tried to run your code it will return a syntax error so I am suspicious you did not try it. In the other code the "while" loop has a condition:
while (1) {
why did you remove the... |
Forum: Perl Jan 26th, 2009 |
| Replies: 4 Views: 616 A students best cheat tool is a search engine or the search feature of a website or forum. You would have found a recent thread discussing the exact same assignment had you done just a little... |
Forum: Perl Jan 23rd, 2009 |
| Replies: 4 Views: 884 The Benchmark documentation says:
CAVEATS
Comparing eval'd strings with code references will give you inaccurate results: a code reference will show a slightly slower execution time than the... |
Forum: Perl Jan 23rd, 2009 |
| Replies: 4 Views: 884 You can try the Benchmark or Time::HiRes modules, they come with perl. Read the documentation and try a few things, if you get stuck post back. |
Forum: Perl Jan 22nd, 2009 |
| Replies: 12 Views: 2,067 Here is a simple test of the regexp I posted:
$row = [qq{this is\n a test},qq{this is\ranother test}];
s/[\r\n]// for @{$row};
print @{$row};
That appears to work fine. Why it causes your... |
Forum: Perl Jan 21st, 2009 |
| Replies: 14 Views: 1,800 this line is doing nothing (its useless):
($ch);
I am not sure what you think this does:
open(OUT, "<$file") || die "Cant open $file: $!";
for($line=0; <OUT>; $line++)
{
} |
Forum: Perl Jan 21st, 2009 |
| Replies: 14 Views: 1,800 Post you code again, the code that returns the warning you mention. "Useless use of variable" is generally something like:
$foo;
The above line does nothing, its useless. Thats a warning... |
Forum: Perl Jan 21st, 2009 |
| Replies: 12 Views: 2,067 Well, I don't know what the character is that is causing the problem but it appears you will need to remove it manually, something like:
my $row = $csv->getline ($fh);
s/[\r\n]// for @{$row}; |
Forum: Perl Jan 20th, 2009 |
| Replies: 12 Views: 2,067 RTM mate:
http://search.cpan.org/~hmbrand/Text-CSV_XS-0.58/CSV_XS.pm#Embedded_newlines |
Forum: Perl Jan 20th, 2009 |
| Replies: 8 Views: 984 Your code is quite close to getting it right, here is a way to do this type of looping guessing game:
use strict;
use warnings;
my $thinkingof = int(rand 10)+1;
while (1) {
print "Pick... |
Forum: Perl Jan 19th, 2009 |
| Replies: 14 Views: 1,800 inked,
add this line to your code:
use warnings;
and rerun it and list any warnings you get. |
Forum: Perl Jan 17th, 2009 |
| Replies: 14 Views: 1,800 A google search found this page:
http://en.literateprograms.org/Category:Programming_language:Perl
It shows a "word count" program listed but I have not read it to see how well written it is.
... |
Forum: Perl Jan 17th, 2009 |
| Replies: 14 Views: 1,800 The concept of sentences does not translate well to poetry or song liricks as they do not follow the same grammatical rules as formal writing. |
Forum: Perl Jan 17th, 2009 |
| Replies: 14 Views: 1,800 OK, when I run your code the count is 2. The problem appears to be that you are not chomping the input and you have "!" instead of "," in your conditional statement.
When "!" is changed to "," the... |