Sponsored Content
Top Forums Shell Programming and Scripting perl : splitting the data into 2 different variables Post 302706341 by rangarasan on Wednesday 26th of September 2012 01:46:33 PM
Old 09-26-2012
perl

Hi,
Try this one,

Code:
if($var =~ /^(\d+)%.*(\d +)%$/) {
   my ($part1, $part2)=($1,$2);
}

Cheers,
Ranga:-)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Splitting data file

Hello, I'm trying to split a file by lines. I know that I can use the split command to do this, but the one problem I'm having is, each file created, the first line needs to be a header. I can use the split command the create another file with the header, then append the new split file to... (4 Replies)
Discussion started by: ctcuser
4 Replies

2. Shell Programming and Scripting

Splitting the data and storing it into 2 variables

Hi, I have a file in the given format: |aaa |hhh |fat hat chat |make sure I need to get store in a variable,say 'error' the value of the string 'fat hat chat' In short, echo $error should give the result fat hat chat Is this possible using awk? Also, can this be split.For... (10 Replies)
Discussion started by: jisha
10 Replies

3. Shell Programming and Scripting

Data Splitting into two files from one file

I have a file as: I/P File: Ground Car 2009 Lib 2008 Lib 2003 Ground Car 2009 Ground Car 2003 Car 2005 Car 2003 Car 2005 Sita 2900 2006 Car 2007 I have to split the file into two: - one for names and second for years. O/p1 (Names): Ground Car (3 Replies)
Discussion started by: karumudi7
3 Replies

4. UNIX for Dummies Questions & Answers

Splitting Data in File

I have a file with the below Data 1,nj@ny@pa@caa 2,ct 3,ca@vaa@txI want the output to be 1,nj 1,ny 1,pa 1,caa 2,ct 3,ca 3,vaa 3,tx I need to split the second column based on @ as delimiter The number of delimiters is unknown (4 Replies)
Discussion started by: traininfa
4 Replies

5. Shell Programming and Scripting

Splitting the data in a column into several columns

Hi, I have the following input file 32895901-d17f-414c-ac93-3e7e0f5ec240 AND @GDF_INPUT 73b129e1-1fa9-4c0d-b95b-4682e5389612 AUS @GDF_INPUT 40f82e88-d1ff-4ce2-9b8e-d827ddb39447 BEL @GDF_INPUT 36e9c3f1-042a-43a4-a80e-4a3bc2513d01 BGR @GDF_INPUT I want to split column 3 into two columns:... (1 Reply)
Discussion started by: ramky79
1 Replies

6. UNIX for Dummies Questions & Answers

Splitting data into new records

Hi, My file is seperated with ";" delimiter, after 13 delimiter i want to put the data in new line... eg: My current file:- a;b;c;d;e;f;g;h;e;f;h;s;t;a;i;o;q;t;q;r;yu;f;sz;f;t;r........... i want o/p as:- a;b;c;d;e;f;g;h;e;f;h;s;t a;i;o;q;t;q;r;yu;f;sz;f;t;r How to achieve ths,... (2 Replies)
Discussion started by: gnnsprapa
2 Replies

7. Shell Programming and Scripting

Splitting the Data using awk

Hello All, I have a comma delimiter file with 10 columns. I took the desired data but from $4 I need to split into two columns as 3+7 bytes. awk -F"," -v OFS=',' '{print $2,$3,$4}' foo.txt 42366,11/10/2014,5012418769 42366,11/10/2014,2046955672 42366,11/10/2014,2076802951 ... (3 Replies)
Discussion started by: karumudi7
3 Replies

8. Shell Programming and Scripting

Splitting a line in two variables

Hello. The file /etc/fstab contains UUID=957c3295-9944-1593-82e2-2b90dede4312 / ext4 acl,user_xattr 1 1I fill a variable SOME_LINE=$( cat /etc/fstab | grep \/\..*ext4 )I want PART1=>>>>>UUID=957c3295-9944-1593-82e2-2b90dede4312 / ext4 ... (2 Replies)
Discussion started by: jcdole
2 Replies

9. Shell Programming and Scripting

Splitting CSV into variables then to XML file

I have a text file that looks like this: FIELD1, FIELD2, THIS IS FIELD3, FIELD4 FIELD1, FIELD2, THIS IS FIELD3, FIELD4 FIELD1, FIELD2, THIS IS FIELD3, FIELD4 I need it to turn it into an XML file to run against a custom application. My ultimate goal is for it to look like... (15 Replies)
Discussion started by: jeffs42885
15 Replies

10. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies
Config::File(3pm)					User Contributed Perl Documentation					 Config::File(3pm)

NAME
Config::File - Parse a simple configuration file SYNOPSIS
use Config::File; my $config_hash = Config::File::read_config_file($configuration_file); DESCRIPTION
"read_config_file" parses a simple configuration file and stores its values in an anonymous hash reference. The syntax of the configuration file is as follows: # This is a comment VALUE_ONE = foo VALUE_TWO = $VALUE_ONE/bar VALUE_THREE = The value contains a # (hash). # This is a comment. Options can be clustered when creating groups: CLUSTER_ONE[data] = data cluster one CLUSTER_ONE[value] = value cluster one CLUSTER_TWO[data] = data cluster two CLUSTER_TWO[value] = value cluster two Then values can be fetched using this syntax: $hash_config->{CLUSTER_ONE}{data}; There can be as many sub-options in a cluster as needed. BIG_CLUSTER[part1][part2][part3] = data is fetched by: $hash_config->{BIG_CLUSTER}{part1}{part2}{part3}; There are a couple of restrictions as for the names of the keys. First of all, all the characters should be alphabetic, numeric, underscores or hyphens, with square brackets allowed for the clustering. That is, the keys should conform to /^[A-Za-z0-9_-]+$/ This means also that no space is allowed in the key part of the line. CLUSTER_ONE[data] = data cluster one # Right CLUSTER_ONE[ data ] = data cluster one # Wrong Function ";read_config_file" Syntax Config::File::read_config_file($file); Arguments $file is the configuration file. Return value This function returns a hash reference. Each key of the hash is a value defined in the configuration file. Description "read_config_file" parses a configuration file a sets up some values in a hash reference. NOTES
Function not exported by default In versions up to 1.0, the function read_config_file was exported to the calling program's namespace - Starting in version 1.1, nothing is exported by default. You can either fully qualify read_config_file or explicitly import it into your namespace: Fully qualifying read_config_file use Config::File; my $config_hash = Config::File::read_config_file($configuration_file); Explicitly importing read_config_file use Config::File qw(read_config_file); my $config_hash = read_config_file($configuration_file); Migrated away from ConfigFile into Config::File As of version 1.4, in order to include this module in the CPAN, I decided to move away from the highly unstandard name of ConfigFile and rename the module to Config::File. A small redirecting module is put in place, so current code using this module does not break, but the ConfigFile namespace usage is deprecated (and will thus issue a warning). Please update your code! AUTHOR
Development was started by Sebastien J. Gross <seb@sjgross.org>, and since 2003 it is maintained by Gunnar Wolf <gwolf@gwolf.org>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GPL. VERSION
Version 1.4 Copyright (c) 2002 Sebastien J. Gross. All rights reserved. Copyright (c) 2003-2009 Gunnar Wolf. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GPL v2 (or later, at your choice). perl v5.10.0 2009-02-20 Config::File(3pm)
All times are GMT -4. The time now is 05:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy