![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Search text from a file and print text and one previous line too | kamranjalal | Shell Programming and Scripting | 6 | 01-06-2009 03:27 AM |
| Need help in storing command line argument argv[2] to a variable of int type | frozensmilz | High Level Programming | 3 | 12-12-2008 11:11 AM |
| Need help on installing an EASY to use and easy to install command line text editor | EugeneG | UNIX for Dummies Questions & Answers | 4 | 07-16-2007 12:53 PM |
| argv command in awk | emil2006 | UNIX for Dummies Questions & Answers | 1 | 02-17-2007 03:34 PM |
| replace text in a file from the command line... | dudboy | UNIX for Dummies Questions & Answers | 1 | 09-04-2001 03:31 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Using ARGV, acepting text from command line
I want to be able to call in my file and make it do it's magic by basically giving it: FileNAME.pl searchTerm fileToSearch It runs, and gives me the answers I want, however, it gives me an error: Code:
Can't open GAATTC: No such file or directory at .//restriction_map_better.pl
line 15 (#1)
(S inplace) The implicit opening of a file through use of the <>
filehandle, either implicitly under the -n or -p command-line
switches, or explicitly, failed for the indicated reason. Usually this
is because you don't have read permission for a file which you named on
the command line.
This is what I have in my code, and was wondering if there was a way to bypass the error and some how just have it read from the command line the "searchTerm" without trying to use it for a search in itself, since it doesn't really exist. Or maybe if there was a way to specify the code in red so it specifically searches only the 3rd entry. Code:
$line = "";
@sequence = "";
$int = "";
$length = 0;
$search = $ARGV[0]; # Assign with the input from command line ie THE
while ($line = <>){
chomp($line);
@sequence = split /\t/, $line;
if ($sequence[1] =~ /$search/){
$int = $`;
$length = length($int) + 1; # +1 to give loc of found word
}
print $sequence[0] . "\t" . "$length\n";
}
Thanks a bunch! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|