Removing the 1st character of the word in perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Removing the 1st character of the word in perl
# 1  
Old 11-09-2010
Tools Removing the 1st character of the word in perl

Hi All,

In one of the sections in my perl script, I need to remove the 1st character of a word and store in an array.The details are ,

The original script was ,
Code:
if ( ! defined $inq{$node}{"dmx"} ) {
      print "INFO: Collecting inq disk information for DMX array on $node.\n";
      $command="/opt/admin/bin/inq -sym_wwn -nodots |grep dsk";
      my @clarinq;
      ($rcode, @clarinq) = execute_command($node, $command, "root");
      #print Dumper @clarinq;
      my ($ldev, $disk, $diskdevice, $line);
      foreach $line (@clarinq)  {
         ($diskdevice, $junk, $ldev, $junk) = split (/\s+/, $line);
         ($junk, $junk, $junk, $disk) = split (/\//, $diskdevice);
         #print "disk is $disk, ldev is $ldev\n";
         $inq{$node}{"dmx"}{$disk}=$ldev;
      }
   }

The o/p of /opt/admin/bin/inq -sym_wwn -nodots |grep dsk is in the format,
Code:
# /opt/admin/bin/inq -sym_wwn -nodots |grep dsk
/dev/rdsk/c25t0d0   000290103691   1C4D      60060480000290103691533031433444

The 3rd column is storing to "ldev".

In the new servers, the above command is not workin.We have the new command and the o/p of that command is in the format is,
Code:
$ pbrun /opt/admin/bin/inq.HPUXIA64 -sym_wwn -nodots|grep disk|grep -v HP |more
/dev/rdisk/disk8     000290103691   0237A     60060480000290103691533032333741

The 3rd column is of 5 digit and I want to remvoe the 1st character so that it will be in the same format as that of old servers.

I have tried this way.....
Code:
if ( ! defined $inq{$node}{"dmx"} ) {
      print "INFO: Collecting inq disk information for DMX array on $node.\n";
      $command="/opt/admin/bin/inq.HPUXIA64 -sym_wwn -nodots|grep disk|grep -v HP";
      my @clarinq;
      ($rcode, @clarinq) = execute_command($node, $command, "root");
      #print Dumper @clarinq;
      my ($ldev, $disk, $ldev1, $diskdevice, $line);
      foreach $line (@clarinq)  {
         ($diskdevice, $junk, $ldev1, $junk) = split (/\s+/, $line);
         ($junk, $junk, $junk, $disk) = split (/\//, $diskdevice);
         ($junk, $ldev, $ldev, $ldev, $ldev) =split (/c/, $ldev1);=> This is not taking
         #print "disk is $disk, ldev is $ldev\n";
         $inq{$node}{"dmx"}{$disk}=$ldev;
      }
   }

Please could any one help me .

Ahilash

Last edited by Scott; 11-09-2010 at 02:00 PM.. Reason: Please use code tags
# 2  
Old 11-09-2010
Easy in ksh:
Code:
 
${ldev1#0}

# 3  
Old 11-09-2010
Hello,

Please could you paste the modified script with the line you suggested.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl lwp find word and print next word :)

hi all, I'm new there, I'm just playing with perl and lwp and I just successfully created a script for log in to a web site with post. I have a response but I would like to have something like this: I have in my response lines like: <div class="sender">mimi020</div> <some html code.....>... (3 Replies)
Discussion started by: vogueestylee
3 Replies

2. Shell Programming and Scripting

removing newlines after a certain word.

Hello! This is my first post here. I have a file with text like: A</title> B C</title> D I need to format it to: AB CD I am trying to use sed: sed 's/<//title>\n/ /g' file > newfile to delete </title> and the newline character, but the file is unchanged because there are... (3 Replies)
Discussion started by: DaytonCPS
3 Replies

3. UNIX for Dummies Questions & Answers

Need help removing last character of every line if certain character

I need help removing the last character of every line if it is a certain character. For example I need to get rid of a % character if it is in the last position. Input: aaa% %bbb ccc d%dd% Output should be: aaa %bbb ccc d%dd I tried this but it gets rid of all of the % characters.... (5 Replies)
Discussion started by: raptor25
5 Replies

4. Shell Programming and Scripting

extract whole thing in word, leaving behind last word. - perl

Hi, i've a string /u/user/DTE/T_LOGS/20110622_011532_TEST_11_HD_120/HD/TESi T_11_HD_120/hd-12 i need to get string, like /u/user/DTE/T_LOGS/20110622_011532_TEST_11_HD_120/HD the words from HD should get deleted, i need only a string till HD, i dont want to use any built in... (4 Replies)
Discussion started by: asak
4 Replies

5. Shell Programming and Scripting

Need some help removing a character from name

I have a file like this: DDD_ABCDE2AB2_1104081408.104480 I need to remove the 1 after the . in the file name so that it reads: DDD_ABCDE2AB2_1104081408.04480 Having some difficulty getting the command to work. I tried using cut -d 26 but that just doesn't work. (3 Replies)
Discussion started by: bbbngowc
3 Replies

6. Shell Programming and Scripting

Perl Cutting character(s) from a word

Hello, How to cut a char(s) for a word using perl?? I want to cut the number(s) from these sample words: Port-channel24 Po78 Po99 Port-channel34 $word = "Port-channel24"; I want to put only the number in a varible. Appreaciate using simple way in order to use it... (3 Replies)
Discussion started by: ahmed_zaher
3 Replies

7. Shell Programming and Scripting

perl (word by word check if a hash key)

Hi, Now i work in a code that 1-get data stored in the database in the form of hash table with a key field which is the " Name" 2-in the same time i open a txt file and loop through it word by word 3- which i have a problem in is that : I need to loop word by word and check if it is a... (0 Replies)
Discussion started by: eng_shimaa
0 Replies

8. Shell Programming and Scripting

Command to parse a word character by character

Hi All, Can anyone help me please, I have a word like below. 6,76 I want to read this word and check if it has "," (comma) and if yes then i want to replace it with "." (dot). That means i want to be changed to 6.76 If the word doesnot contain "," then its should not be changed. Eg. ... (6 Replies)
Discussion started by: girish.raos
6 Replies

9. Shell Programming and Scripting

Vi - removing last word

Hi All, I want to remove last word from a line using Vi. Do we have any vi command for that. line : ss dd ff gg i have to run some vi command which can delete gg from the line Thanks, Ravi Sadani (4 Replies)
Discussion started by: ravi.sadani19
4 Replies

10. Programming

removing first bit from the word

Hello, I have a code like this : pstSimPOIInfo.ppcName = realloc(pstSimPOIInfo.ppcName, (usLen+strlen(CountryName)+4)); memset(pstSimPOIInfo.ppcName, 0, (usLen+strlen(CountryName)+4)); strncpy((char *)pstSimPOIInfo.ppcName, CityName, strlen(CityName)) strcat(pstSimPOIInfo.ppcName, ",");... (3 Replies)
Discussion started by: jazz
3 Replies
Login or Register to Ask a Question