getting error in my perl script


 
Thread Tools Search this Thread
Top Forums Programming getting error in my perl script
# 1  
Old 08-01-2012
getting error in my perl script

hi
Here is my code written to identify the particular position which is after a string (chr*). my input file looks some thing like this
Code:
aaanbb:anhn:iuopl:12345 chr1 12345 asnmkol * # kjiiii.....anmkij:lpolk:lopll:abnnj chr5 123222 polko * dddfgg ....

aaanbb:anhn:iuopl:aanjuj chr2 44345 asnmkol * # kjiiii.....anmkij:lpolk:lopll:abnnj chr7 567222 polko * dddfgg ..

i wanted to get the @pos as the immediate occurance after chr* as there are 2 such occurances in each line the first occrance has to be stored in pos[0] and second in pos[1] for pos[0] pattern search has to be made wih in pos[0]+6 characters and same vs for pos[1] but backwards

Code:
use strict;
use warnings;
open (my $fhConditions, "<1.txt"); 
my $l=6;
open (my $read, "<2.txt");
my @e = <$read>;
my $d = join('', @e );
$d =~ s/\s+//g;
while (my $line = <$fhConditions>) {
chomp $line;
my @pos = $line[$i] =~/chr*\s+(.+?)\s/g;
if($pos[0] =/[0-9]/)
{
my $match = substr($d,$pos[0],$l)
print "$line" if $match =~m/AAGCTT/;
}
if($pos[1] =/[0-9]/)
{
my $a = $pos[0]-$l;
my $match = substr($d,$a,$l);
print "$line" if $match =~m/AAGCTT/;
}
}

# 2  
Old 08-01-2012
You say you're getting an error -- which error?

You haven't shown the output you want, either.

Please do not leave people guessing. Show a representative sample of input, desired output, attempts at a solution and specify what OS and versions being used, or this thread will be closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Slight error with my perl script that I could use some help on

So I have a perl script that prompts the user to enter either q or Q to exit the program or c to continue said program. If the user inputs anything other than those three keys they will be prompted again and again for an appropriate input. My script works for the most part except for one small... (6 Replies)
Discussion started by: Eric1
6 Replies

2. Homework & Coursework Questions

A2p, error in the perl script?

1. The problem statement, all variables and given/known data: filename = awkdata Part 1: Write an awk program that removes the first field and prints only those lines where the third field is greater than 15 million. Part 2: Do the same command above, but with perl instead of awk.... (0 Replies)
Discussion started by: AZbase10
0 Replies

3. Shell Programming and Scripting

Error in executing Perl script

Hello All I am facing an issue The unix script is running fine in unix environment which uses ssh connection but when I try to run the same in informatica environment (same server where I was running the unix script manually successfully) its showing the below error command-line line 0:... (11 Replies)
Discussion started by: Pratik4891
11 Replies

4. Shell Programming and Scripting

Perl : Error in calling script

I am getting a strange error with perl's inbuilt script flush.pl. I am callling this script in my other script but it kept throwing error: flush.pl did not return a true value at ./abc.pl line 1 abc.pl has: require 'flush.pl'; Not sure why this error is coming. Can someone pls throw... (4 Replies)
Discussion started by: abhisharma23
4 Replies

5. Shell Programming and Scripting

perl script processing error

open(IN,"input_file") or die "Can't open Input file.\n"; while (<IN>) { chomp; $line = $_; if($line != '') { print "\nprocessing $line\n"; $size = 0; $hrid = $line; @project_id_array = null; $size = @project_id_array;... (3 Replies)
Discussion started by: vishwakar
3 Replies

6. Shell Programming and Scripting

Perl script to rename file,error

#!/usr/bin/perl $FL="ch.txt"; $CFL="mytext.txt"; print "This script will rename textfiles."; mv $FL $CFL; print "Done."; perl file.pl Error: Can't locate object method "mv" via package "ch.txt" (perhaps you forgot to load "ch.txt"?) at file.pl line 7. (5 Replies)
Discussion started by: cola
5 Replies

7. Shell Programming and Scripting

Need help understanding perl script error

I solicited this site earlier this week and got a good answer for a perl Script so I made this script from what understood from the answers But now I have a bug and I'm stump. It doesn't parse correctly the Output it stays on the first line My $f2 and reprints in a endless loop I'm sure there... (3 Replies)
Discussion started by: Ex-Capsa
3 Replies

8. Shell Programming and Scripting

error in output of perl script

Hi, This is my piece of code. my $logFile = $ARGV; die "usage: $0 <logFile>" unless $logFile; die "Logfile $logFile doesn't exist" unless -f "$logFile"; open(my $log, "<", $logFile) or die "Can't open $logFile for reading."; print "Processing file $logFile...\n"; #my $authenticates... (2 Replies)
Discussion started by: namishtiwari
2 Replies

9. UNIX for Dummies Questions & Answers

Perl Error with ftptail script

Hello everyone, I'm a starting website admin who 2 days ago decided to make the move from shared hosting to a vps on a linux (ubuntu 8.04) platform. This opened a whole new world for me, since I never worked with the console, SSH, linux,... before. I managed to get LAMP setup after a day of... (2 Replies)
Discussion started by: Cooki3s!
2 Replies

10. Shell Programming and Scripting

Perl script error

Hi all I keep getting a segmentation fault error while running the script below. #!/usr/bin/perl -w use CGI ':standard'; use GD::Graph::pie; use strict; use warnings; sub trim($) { my $string = shift; $string =~ s/^\s+//; $string =~ s/\s+$//; ... (4 Replies)
Discussion started by: pietie
4 Replies
Login or Register to Ask a Question