The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-24-2009
silkiechicken silkiechicken is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 21
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!
  #2 (permalink)  
Old 02-24-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,944
The empty read function ('<>') is implicitly STDIN. If you want to read a file instead, take a look at perldoc -f open
  #3 (permalink)  
Old 02-24-2009
silkiechicken silkiechicken is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 21
Thanks, I'll see if I can't find "perldoc -f open" and figure it out.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0