By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,903 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,903 IT Pros & Developers. It's quick & easy.

Splice function

P: 1
Hi all,

I am a newbie and trying to use splice function to read data from text file.
It seems the data doesn't have line breaks but only separated by spaces. All I know is that each row has specific byte size. I am wondering if there is any way to splice data if I know byte size of each row. I have tried by array indexing but that doesn't work very well (basically, it doesn't splice data uniformly).

-Manish

Below is the code and piece of data

Expand|Select|Wrap|Line Numbers
  1. my @morenames = split(/\s+/, $data); 
  2.  
  3.  
  4. for ($i=0; $i< 10; $i++)
  5. {
  6. my @someNames= splice(@morenames, 0, 39); 
  7.  
  8. print $someNames[0]."**\t". $someNames[2]."***\n"; 
  9. }; 
  10. close (FM); 
  11.  
Expand|Select|Wrap|Line Numbers
  1. $data='WA2000-03   WA7WMU03BTRAABADYBTRWA737360161    37360161    14394306CA1  11200004272030050120000601   450000.00   447755.82 8.583  1050000.00  1050000.0020360 3.950 0.0 0.0 1   20000   42.86 0.0001125.080  2.500 0.000 0.000 7.500 0.00011.500 0.000  1 12  1  0  009   7751          0    0.000 0.000          0.00  0.00 42.86  0.00  0.00WA Mutl                       N/A                                                                                                                               WA2000-03   WA7WMU03BTRAAIFgMBTRWA733739236    33739236    14395138CA1  11200004132030050120000601   496000.00   491124.57 8.583   620000.00   620000.0020360 3.950 0.0 0.0 1   20000   80.00 0.0001125.080  2.500 0.000 0.000 7.500 0.00011.500 0.000  1 12  1  0  009   7141          0    0.000 0.000          0.00  0.00 80.00  0.00  0.00WA Mutl                       N/A                                                                                                                               WA2000-01   WA1WA001BTRAAPptBBTRWA118450317    18450317    13490277CA4  43199604102026040119960510   600000.00   577178.60 7.752        0.00   750000.0020360 4.450 0.0 0.01141  0000   80.00 0.0001  0.021  2.900 0.000 0.000 7.500 0.00011.750 3.000  1 12  3  0  0Z       1          1    0.000 0.000          0.00  0.00 80.00  0.00  0.00WA Mutl                       N/A                                                                                                                               WA2001-07   WMAWU107BTRAAQOoIBTRWMA39727615    39727615    14892061CA1  11200101042031010120010201   982000.00   986842.69 7.961  2200000.00  2200000.0020360 3.950 0.0 0.0 3   20000   44.63 1.0501125.080  2.250 0.000 0.000 7.500 0.00011.950 0.000  1 12  2 13  009   6901          1036 0.000 0.000          0.00  0.00  0.00  0.00  0.00                                                                                                                                                                WA2000-01   WA1WA001BTRAAQuNTBTRWA116367646    16367646    13490814CA1  11199311222023110119931220   380000.00   337349.51 7.052        0.00   480000.0020360 5.150 0.0 0.01341  0000   79.16 0.0001  0.021  2.200 0.000 0.000 7.500 0.00010.950 3.000  1 12  6  0  0Z       1          0    0.000 0.000          0.00  0.00 79.16  0.00  0.00WA Mutl                       N/A                                                                                                                               WA2001-07   WMAWU107BTRAAfYmwBTRWMA43981141    43981141    14892024CA1  11200104192031050120010601   419950.00   419950.00 3.950   524990.00   534000.0020360 3.950 0.0 0.0 1   20000   79.99 1.1501125.080  2.350 0.000 0.000 7.500 0.00011.950 0.000  1 12  2 13  009   7161          0    0.000 0.000          0.00  0.00  0.00  0.00  0.00                                                                                                                                                                WA2000-01   WA1WA001BTRAAmqMUBTRWA159714881    59714881    13492651CA2  11199703242027040119970501   800000.00   827209.58 7.552        0.00  1500000.0020360 3.950 0.0 0.01242 20000   53.33 0.0001125.021  2.700 0.000 0.000 7.500 0.00011.950 2.700  1 12  0  0  009   6601          1    0.000 0.000          0.00  0.00 53.33  0.00  0.00WA Mutl                       N/A                                                                                                                               WA2000-01   WA1WA001BTRAAsozsBTRWA156588026    56588026    13494402CA1  11199608202026090119961001   507500.00   471218.93 7.402        0.00   725000.0020360 4.750 0.0 0.0134Z  0000   70.00 0.0001110.021  2.550 0.000 0.000 7.500 0.00012.050 2.550  1 12  0  0  0Z       1          0    0.000 0.000          0.00  0.00 70.00  0.00  0.00WA Mutl                       N/A                                                                                                                               WA2000-01   WA1WA001BTRAAzLHaBTRWA126191338    26191338    13492663CA2  11199903302039040119990501   412500.00   421376.92 7.852        0.00   550000.0020480 3.950 0.0 0.01242 20000   75.00 0.0001125.021  3.000 0.000 0.000 7.500 0.00011.950 3.000  1 12  0  0  009   6951          1    0.000 0.000          0.00  0.00 75.00  0.00  0.00WA Mutl                       N/A  ' ;
  2.  
Sep 8 '08 #1
Share this Question
Share on Google+
1 Reply


KevinADC
Expert 2.5K+
P: 4,059
what it is you are trying to get out of the data?
Sep 8 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.