The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Split Command in Perl rochitsharma UNIX for Advanced & Expert Users 9 03-09-2008 03:56 AM
split to array in perl jaganadh Shell Programming and Scripting 3 07-06-2007 05:29 AM
multiple pattern split in perl umen Shell Programming and Scripting 3 08-01-2006 02:43 AM
split question perl reggiej Shell Programming and Scripting 7 07-21-2006 04:18 PM
perl split function new2ss Shell Programming and Scripting 5 06-08-2006 10:17 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 12-17-2006
maheshsri maheshsri is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 31
Perl Split Command usage

Hi,

I am trying to use the split commad to seperate string reading from file. but it dosent give me a correct result. can some body tell me what is the wrong in following scritp.

Code:
#!/usr/bin/perl -w                                         
#use CGI qw(:standard);                                    
#use CGI::Carp qw(warningsToBrowser fatalsToBrowser);      
use strict;                                                
                                                           
open(FH,"bh_file.txt");                                    
                                                           
while (my $line = <FH>) {                                  
my @hash_array = split(/|/, $line);                        
print $hash_array[1] ;                                     
}         

close(FH);
Input file format as follows,

Code:
Banikoara_A1|0|2006-12-14 19:00|duration: 120 minute(s)| 0.24 0.13
Banikoara_B1|1|2006-12-14 19:00|duration: 120 minute(s)| 0.08 0.08

my expected output should be,

Banikoara_A1
Banikoara_B1

(print the 1st column)

current out put as follows,

aa
 

Bookmarks

Tags
delimited, perl split

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 01:05 PM.


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