Sponsored Content
Full Discussion: perl dot escaping issue
Top Forums Shell Programming and Scripting perl dot escaping issue Post 302698587 by pamu on Monday 10th of September 2012 09:56:15 AM
Old 09-10-2012
try this..Smilie

Code:
echo -n "hello.world" | perl -F/[.]/ -ane 'print "$F[1]\n"'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

splitting on dot in perl

I am trying to split input that looks like ,2005-09-12 01:45:00.000000,2005-09-12 01:48:18.000000, I want to split on the dot . What I am using is ($ev_time,$rol)=split(/\./),$inputfile; This does not recognize the dot as what I want to split on. (2 Replies)
Discussion started by: reggiej
2 Replies

2. Shell Programming and Scripting

perl issue ..

hi one perl issue i have xml file with 2 values and one condition b.w them <rule> <val1>12</val1> <cond>and</cond> <val2>13</val2> </rule> i read these values in hash in perl code $one{val1} = 12 $one{cond} = and $one{val2} = 13 now i want to form... (3 Replies)
Discussion started by: zedex
3 Replies

3. Shell Programming and Scripting

Perl Issue

Hi, I got this script from the web, this generates an LDAP report in CSV format. #!/usr/bin/perl # # Copyright (c) 2004 # Ali Onur Cinar &060;cinar&064;zdo.com&062; # # License: # # Permission to use, copy, modify, and distribute this software and its # documentation for... (23 Replies)
Discussion started by: raj001
23 Replies

4. UNIX for Advanced & Expert Users

Escaping special character stored in variables : perl

Hi just for regular use i m working on small module written in perl for getting date in specified format like i have to specify date format and then seperator to seperate date i am 95% done. now i m sure explanation i gave is not good enough so i am putting output here : C:\Documents and... (2 Replies)
Discussion started by: zedex
2 Replies

5. Shell Programming and Scripting

Perl issue - please help!

Hello. I've been writing some code in Perl to read in strings from html files and have been having issues. In the html file, each "paragraph" is a certain file on the website. I need to find every one of the files that is a certain type, in this case, having green color....therefore... (7 Replies)
Discussion started by: akreibich07
7 Replies

6. Shell Programming and Scripting

removing DOT by using perl

Hi Friends, I have a variable which has a number (e.g. 12.1234). I want to remove "." (dot) from that number i.e. 121234 I want to do this using perl. Can you please guide me Thank you Anushree (2 Replies)
Discussion started by: anushree.a
2 Replies

7. Programming

perl socket issue

Hi I am teaching myself perl and am writing a socket application to get experience. I am using Eclipse with the EPIC plugin to run the code in debug mode. I think that sometimes the script is not releasing the port if I terminate it in debug mode as I am occasionally getting the message: - ... (3 Replies)
Discussion started by: steadyonabix
3 Replies

8. Shell Programming and Scripting

GREP Issue in Perl

Im storing multiple functions in a varaible called $check... The variable check contains the following: a() b() c() ... ..etc now im checking individually which function is kept in which file using GREP if ( grep \$check \i, <FILE> ) The problem is im getting the output for the... (1 Reply)
Discussion started by: rajkrishna89
1 Replies

9. Shell Programming and Scripting

perl regex issue

Hi, I find it really strange while writing a simple regex to match and print the matched string, dibyajyo@fwtest:~ #perl -e '$x = "root@rashmi>"; print "matched string:$1\n" if ($x =~ /(root@rashmi)/);' matched string:root dibyajyo@fwtest:~ #perl -e '$x = "root@rashmi>"; print... (1 Reply)
Discussion started by: rrd1986
1 Replies

10. Shell Programming and Scripting

Replace dot with semicolon in PERL

Hi, I have a file in PERL in the following pattern filename| 06-Dec-11 03.04.14.000000 PM filename1| 06-Dec-11 05.05.14.000000 PM I need to replace .(dot) with :(semicolon) in the timestamp value of the file How can this be done. Any help will be appreciated Thanks in advance (5 Replies)
Discussion started by: irudayaraj
5 Replies
Hash::Flatten(3pm)					User Contributed Perl Documentation					Hash::Flatten(3pm)

NAME
Hash::Flatten - flatten/unflatten complex data hashes SYNOPSIS
# Exported functions use Hash::Flatten qw(:all); $flat_hash = flatten($nested_hash); $nested_hash = unflatten($flat_hash); # OO interface my $o = new Hash::Flatten({ HashDelimiter => '->', ArrayDelimiter => '=>', OnRefScalar => 'warn', }); $flat_hash = $o->flatten($nested_hash); $nested_hash = $o->unflatten($flat_hash); DESCRIPTION
Converts back and forth between a nested hash structure and a flat hash of delimited key-value pairs. Useful for protocols that only support key-value pairs (such as CGI and DBMs). Functional interface $flat_hash = flatten($nested_hash, \%options) Reduces a nested data-structure to key-value form. The top-level container must be hashref. For example: $nested = { 'x' => 1, 'y' => { 'a' => 2, 'b' => 3 }, 'z' => [ 'a', 'b', 'c' ] } $flat = flatten($nested); use Data::Dumper; print Dumper($flat); $VAR1 = { 'y.a' => 2, 'x' => 1, 'y.b' => 3, 'z:0' => 'a', 'z:1' => 'b', 'z:2' => 'c' }; The "\%options" hashref can be used to override the default behaviour (see "OPTIONS"). $nested_hash = unflatten($flat_hash, \%options) The unflatten() routine takes the flattened hash and returns the original nested hash (see "CAVEATS" though). OO interface $o = new Hash::Flatten(\%options) Options can be squirreled away in an object (see "OPTIONS") $flat = $o->flatten($nested) Flatten the structure using the options stored in the object. $nested = $o->unflatten($flat) Unflatten the structure using the options stored in the object. OPTIONS
HashDelimiter and ArrayDelimiter By default, hash dereferences are denoted by a dot, and array dereferences are denoted by a colon. However you may change these characters to any string you want, because you don't want there to be any confusion as to which part of a string is the 'key' and which is the 'delimiter'. You may use multicharacter strings if you prefer. OnRefScalar and OnRefRef and OnRefGlob Behaviour if a reference of this type is encountered during flattening. Possible values are 'die', 'warn' (default behaviour but warns) or a coderef which is passed the reference and should return the flattened value. By default references to references, and references to scalars, are followed silently. EscapeSequence This is the character or sequence of characters that will be used to escape the hash and array delimiters. The default escape sequence is '\'. The escaping strategy is to place the escape sequence in front of delimiter sequences; the escape sequence itself is escaped by replacing it with two instances. DisableEscapes Stop the escaping from happening. No escape sequences will be added to flattened output, nor interpreted on the way back. WARNING: If your structure has keys that contain the delimiter characters, it will not be possible to unflatten the structure correctly. CAVEATS
Any blessings will be discarded during flattening, so that if you flatten an object you must re-bless() it on unflattening. Note that there is no delimiter for scalar references, or references to references. If your structure to be flattened contains scalar, or reference, references these will be followed by default, i.e. "'foo' => \\\$foo" will be collapsed to "'foo' => $foo". You can override this behaviour using the OnRefScalar and OnRefRef constructor option. Recursive structures are detected and cause a fatal error. SEE ALSO
The perlmonks site has a helpful introduction to when and why you might want to flatten a hash: http://www.perlmonks.org/index.pl?node_id=234186 CGI::Expand Unflattens hashes using "." as a delimiter, similar to Template::Toolkit's behaviour. Tie::MultiDim This provides a tie interface to unflattening a data structure if you specify a "template" for the structure of the data. MLDBM This also provides a tie interface but reduces a nested structure to key-value form by serialising the values below the top level. VERSION
$Id: Flatten.pm,v 1.19 2009/05/09 12:42:02 jamiel Exp $ AUTHOR
John Alden & P Kent <cpan _at_ bbc _dot_ co _dot_ uk> COPYRIGHT
(c) BBC 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL. See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt perl v5.10.1 2010-09-24 Hash::Flatten(3pm)
All times are GMT -4. The time now is 04:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy