Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Compilation error while using Fcntl

by cool (Scribe)
on Aug 19, 2006 at 11:40 UTC ( #568342=perlquestion: print w/replies, xml ) Need Help??

cool has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks!

While compiling this CGI script perl -c serve.pl it is showing errors,

Misplaced _ in number at serve.pl line 44. Misplaced _ in number at serve.pl line 44. Bareword found where operator expected at serve.pl line 44, near "0_CREAT" (Missing operator before CREAT?) syntax error at serve.pl line 44, near "0_CREAT " syntax error at serve.pl line 48, near "}" serve.pl had compilation errors.
all related to sysopen lines. I am not able to figure out the problem.

Any suggestions!! pl
#!/usr/bin/perl -w use strict; use CGI; use Fcntl qw(:DEFAULT :flock); #$query->cgi_errror and error($query, "Error transferring file: " . $q +uery->cgi_error ); #SUB error needs to be completed print "Content-type:text/html\n\n"; #Declaring constants use constant UPLOAD_DIR => "/usr/local"; use constant MAX_FILE_SIZE => 1_048_576; #Limit each upload to 1MB use constant MAX_OPEN_TRIES => 100; use constant BUFFER_SIZE => 16_384; # New object my $query = new CGI; my $file = $query->param('fname');#|| error ($query, "No file r +eceived."); my $fh = $query->upload("$file"); #y $buffer = ""; my $filename = ""; #y @annotation = ""; my @list = ""; $query->header(); $query->start_html(); $query->startform(); ################# IF file has been uploaded ########################## +### if($file) { $file =~ s/[^\w.-]/_/g; #Rectifying the string for name of the fil +e if($file=~ /^(\w[\w.-]*)/) { $file = $1; } else { error($query, "Invalid file name; file must start with a letter or n +umber."); } until (sysopen OUTPUT, UPLOAD_DIR . $file, 0_CREAT ) { $file =~ s/(\d*)(\.\w+)$/($1||0)+1 .$2/e; $1 >= MAX_OPEN_TRIES and error ($query, "Unable to save your file"); } while(read($fh, $buffer, BUFFER_SIZE)) #Write content to OUTPUT file { print OUTPUT $buffer; } close OUTPUT; $filename = $file.'.'.'fasta'; if($format eq "embl") { embl_fasta(); } elsif($format eq "genbank") { genbank_fasta(); } open(IN,"UPLOAD_DIR/$filename"); my $one = 0; my $header; my $prevhead; my $sequence; #reading the genome sequence my $x=1; while(<IN>) { my $seqline = $_; $seqline =~ s/\n//g; if($seqline =~ /^>/g) { if($one == 0) { $header = $seqline; $prevhead = $header; $sequence = ''; $one++; next; } else { $header = $seqline; $annotation[$x]=$prevhead; $list[$x]=$sequence; $x++; $prevhead = $header; $sequence = ''; next; } }#end if $seqline $sequence = $sequence.$seqline; $sequence =~ s/\s//g; }#end while<IN1> close(IN); $annotation[$x]=$prevhead; $list[$x]=$sequence; } # If Sequence has been uploaded ################# Opening of each sequence ########################### +#### my $z=0; for $name(@annotation) { my $sequence=""; $sequence = $list[$z]; print "$sequence"; $z++; print "<B> <center><h2>PROMOTER PREDICTION AT A SENSITIVITY LEVEL </h2 +></center><br><br>"; print " <body bgcolor=\"#E0E0E0 \">"; print "<B><em><font color=\"#800000\"> Sequence ID :</em></font> &nbsp +;&nbsp</B>$sequence<br>"; print "<br><BLINK><font color=\"#800000 \">RESULTS</font><br><br> </BL +INK></B>"; print "<hr>"; print "<h3><font color=\"#800000\">FORWARD STRAND</font></h3><br>"; print "<hr>"; } $query->endform(); $query->end_html();

Replies are listed 'Best First'.
Re: Compilation error while using Fcntl
by japhy (Canon) on Aug 19, 2006 at 12:09 UTC
    It's spelled O_CREAT, not 0_CREAT. The first character is a capital "o", not a zero.

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://568342]
Approved by Joost
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2020-02-25 18:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (113 votes). Check out past polls.

    Notices?