Sponsored Content
Full Discussion: Reading values in perl
Top Forums Shell Programming and Scripting Reading values in perl Post 302394290 by pludi on Thursday 11th of February 2010 04:25:52 AM
Old 02-11-2010
Something like this:
Code:
$ cat data.pl
#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;

my %conf = map {
    chomp;
    my @a = split / = /;
    $a[1] =~ s/['"]//g;
    $a[0] => $a[1];
} <DATA>;
print Data::Dumper->Dump( [ \%conf ], [qw/conf/] );

__DATA__
name = varun
ip = '23.43.123.2'
address = "asd, blah blah blah ..... @#!$%$#%"

$ perl data.pl
$conf = {
          'ip' => '23.43.123.2',
          'name' => 'varun',
          'address' => 'asd, blah blah blah ..... @#!$%$#%'
        };

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Reading from a file and assigning values

HI I have something like this in a file ABC = 1 DEF = 2 GHI = 3 JKL = 4 MNO = 5 QRS = 6 TUV = 7 I need to assign ABC to V_abc (that is to a variable) GHI to V_ghi (that is to another variable) TUV to say V_tuv ... (6 Replies)
Discussion started by: ssuresh1999
6 Replies

2. Shell Programming and Scripting

reading values into an array

I have this portion of a script and it works: base_config="A B C D E" for field in $base_config do var=`echo $field` ((i=$i+1)) done I get an array of var=A, var=B, and so on. What if I have this example with white space and want to put it into an array while... (1 Reply)
Discussion started by: djehresmann
1 Replies

3. UNIX and Linux Applications

Reading values from the command line

Hi I want to give the user the choice of whether or not they want to include a certain option when they run the script. This is my getops: while getopts " s: d: r f: e h " option do case $option in f ) dsxfile="$OPTARG";; d ) dbname="$OPTARG";; s ) dsn="$OPTARG";; r )... (0 Replies)
Discussion started by: ladyAnne
0 Replies

4. Shell Programming and Scripting

Reading values from a file

Hi I have a file in the following format AFUE 0. AOXI 0. VFUE 100.0 VOXI 274.601 TFUE 298. TOXI 2229.544 TMAX 2400. What I want to do is write a bash script, that use either perl/awk or sed to read the number after VFUE and VOXI (which is 100.0 and... (1 Reply)
Discussion started by: lost.identity
1 Replies

5. Shell Programming and Scripting

reading a script and summing some values

I need help reading and summing some values in a file that looks like the following. This is an Oracle trace file. Oracle has as utility to do this,but it doesn't work properly unless my sql statement is done. I want to read the file and sum up some values to let me know how the query/job is... (0 Replies)
Discussion started by: guessingo
0 Replies

6. Shell Programming and Scripting

Reading multiple values in while loop

I'm having trouble with a simple piece of code. IFS=, echo "1,2,3,4,5,6,7,8" | while read x y do echo "x=$x" echo "y=$y" done I'm hoping for x=1 y=2 x=3 y=4 . . . but I'm getting x=1 (3 Replies)
Discussion started by: sabbata
3 Replies

7. Shell Programming and Scripting

Reading values from sql query

I have sql query in shell script. select distinct account_no from adj order by account_no; This query returns account number daily.Sometimes it may return 90 rows sometime it may return 1 row only and someday it may return 0 rows I am storing the output of this query in sql_output.txt. ... (5 Replies)
Discussion started by: rafa_fed2
5 Replies

8. Shell Programming and Scripting

Perl :: reading values from Data Dumper reference in Perl

Hi all, I have written a perl code and stored the data into Data structure using Data::Dumper module. But not sure how to retreive the data from the Data::Dumper. Eg. Based on the key value( Here CRYPTO-6-IKMP_MODE_FAILURE I should be able to access the internal hash elements(keys) ... (1 Reply)
Discussion started by: scriptscript
1 Replies

9. Shell Programming and Scripting

Reading off values from a large file

Hi, I have a large output file (star.log), with many lines of the following type *** T vavg unburnt: 723.187 / burnt: 2662.000 What I would like to do is pick the values 723.187 and 2662.000 and What I've got so far is awk '/unburnt:.*burnt:/{Tu=$6;Tb=$NF}END{print Tu, Tb}'... (6 Replies)
Discussion started by: lost.identity
6 Replies

10. Shell Programming and Scripting

Reading and Comparing values of file

Hi gurus.. Am reading a file, counting number of lines and storing it in a variable. Then am passing that variable into If loop for comparision, if the number of lines are greater than 1000 it should split a file if not it should send the file name to archive folder.. but when i execute the... (4 Replies)
Discussion started by: azherkn3
4 Replies
fileutil::magic::cfront(n)					  file utilities					fileutil::magic::cfront(n)

__________________________________________________________________________________________________________________________________________________

NAME
fileutil::magic::cfront - Generator core for compiler of magic(5) files SYNOPSIS
package require Tcl 8.4 package require fileutil::magic::cfront ?1.0? package require fileutil::magic::cgen ?1.0? package require fileutil::magic::rt ?1.0? package require struct::list package require fileutil ::fileutil::magic::cfront::compile path... ::fileutil::magic::cfront::procdef procname path... ::fileutil::magic::cfront::install path... _________________________________________________________________ DESCRIPTION
This package provides the frontend of a compiler of magic(5) files into recognizers based on the fileutil::magic::rt recognizer runtime package. For the generator backed used by this compiler see the package fileutil::magic::cgen. COMMANDS
::fileutil::magic::cfront::compile path... This command takes the paths of one or more files and directories and compiles all the files, and the files in all the directories into a single recognizer for all the file types specified in these files. All the files have to be in the format specified by magic(5). The result of the command is a Tcl script containing the generated recognizer. ::fileutil::magic::cfront::procdef procname path... This command behaves like ::fileutil::magic::cfront::compile with regard to the specified path arguments, then wraps the resulting recognizer script into a procedure named procname, puts code setting up the namespace of procname in front, and returns the result- ing script. ::fileutil::magic::cfront::install path... This command uses ::fileutil::magic::cfront::procdef to compile each of the paths into a recognizer procedure and installs the result in the current interpreter. The name of each new procedure is derived from the name of the file/directory used in its creation, with file/directory "FOO" caus- ing the creation of procedure ::fileutil::magic::/FOO::run. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category fileutil :: magic of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. SEE ALSO
file(1), fileutil, magic(5) KEYWORDS
file recognition, file type, file utilities, mime, type CATEGORY
Programming tools fumagic 1.0 fileutil::magic::cfront(n)
All times are GMT -4. The time now is 08:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy