![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| perl -write values in a file to @array in perl | meghana | Shell Programming and Scripting | 27 | 06-07-2009 06:05 PM |
| Help me to write the script | gyana_cboy | Shell Programming and Scripting | 5 | 10-05-2007 03:19 AM |
| how to write perl substitute command in shell scripts | param_it | UNIX for Dummies Questions & Answers | 3 | 07-03-2007 05:09 AM |
| need help to write perl code | getdpg | Shell Programming and Scripting | 0 | 09-20-2006 10:24 AM |
| Help! Need to write my first script | fundidor | Shell Programming and Scripting | 5 | 01-08-2004 10:20 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Need help to write a Perl script
Hello friends,
I am having a awk script which does my goal , but I want to learn perl , after learning the basics in perl now I am trying to convert my nawk script to perl . Please help me to do some task in perl that I ve already did in nawk. Like I am facing some problem in perl with $_, I think it is similar to $0 in nawk. part of my perl code as follows Code:
open(IN, $file)|| die("Could not open file");
while(<IN>) {
if($_ !~ /^"/){
if($_ =~ /^\*/){
}
else{
@fld = split(/,/, $_);
if( $fld[3] == 1 ){
print $_;
$binary1 = HexToBinary(substr($fld[0],0,2));
print $_;
}
}
}
}
sub HexToBinary{
my(%h)=( '0'=>'0000'
,'1'=>'0001'
,'2'=>'0010'
,'3'=>'0011'
,'4'=>'0100'
,'5'=>'0101'
,'6'=>'0110'
,'7'=>'0111'
,'8'=>'1000'
,'9'=>'1001'
,'A'=>'1010'
,'B'=>'1011'
,'C'=>'1100'
,'D'=>'1101'
,'E'=>'1110'
,'F'=>'1111'
);
$_=uc $_[0];
s/([0-9A-F])/$h{$1}/g;
return $_;
};
Code:
print $0 Regards, user_prady Last edited by user_prady; 03-21-2008 at 04:14 AM.. |
| Bookmarks |
| Tags |
| perl, perl shift, shift, shift perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|