Sponsored Content
Full Discussion: Perl command help needed
Top Forums Shell Programming and Scripting Perl command help needed Post 302445899 by linuxkid on Tuesday 17th of August 2010 06:37:11 AM
Old 08-17-2010
Quote:
Originally Posted by pravin27
Try this,

Code:
perl -nle 's/(date|time|ref)(.+?)\s(.*)/$1$2/g; print;' infile


my apologies as I probably didn't explain this problem the best that I should have. The input file may have many other words on the line, both after and before before the keyword, so the $1$2 would not be too useful in this problem!

Code:
some stuff date-01/01/01 hello
stuff time-2110 hello how are you today
ref/0001 hello happy birthday
this should remain
this should remain

 

10 More Discussions You Might Find Interesting

1. AIX

Perl.rte needed..

Hello I was installing ssh in Aix 4.3 but found that "perl.rte and rpm.rte" was not installed. but to my bad luck i was not able to find these packages for Aix 4.3. Ibm site just has these packages only for 5L. Can anyone help me in finding these packages. Bala (1 Reply)
Discussion started by: balaji_prk
1 Replies

2. Shell Programming and Scripting

Perl - help needed

Hi all, I'm a rookie in Perl scripting, and I have a task to do. Generally it's something like that: I have a reference file consisting of a number and name, tab-separated. One entry in one line, about 99 lines in file. The other file is an XML log file, where in one specific branch, eg.... (8 Replies)
Discussion started by: tklich
8 Replies

3. Shell Programming and Scripting

Help Needed Perl

Hi, I need your help on this script wherein I am matching up the input phone numbers for a partical pattern (xxx-xxxx). However in this I want to have null output where first value of input is null. ( For Example: $record = " ,111-5555") . Ideally I would expect to recieve input in this format... (6 Replies)
Discussion started by: john_prince
6 Replies

4. Shell Programming and Scripting

Perl Script Help Needed

I need this script to be able to check both IPs that are given to it and exit with an OK... if one of those expected IPs is returned. The script is run like this: /bin/dns_checker.pl -s 69.34.55.66 -q htt.jababa.com -e 69.44.56.33,45.47.43.55 Right now, the script is failing, but when I... (4 Replies)
Discussion started by: SkySmart
4 Replies

5. Shell Programming and Scripting

Perl script help needed..

Hi, I am new to perl scripting. Can anybody help me in solving the below problem. I have file, which is called map_file. According to map_file's last column data, i need a output file, which has repeats as like the map_file's last column name. Thank you in advance Vasanth (5 Replies)
Discussion started by: vasanth.vadalur
5 Replies

6. Shell Programming and Scripting

Perl script needed

For the following command I need a perl script equivalent with a couple of more things - cat /tmp/mail |grep Appname > /tmp/mail1;cat /tmp/mail >> /tmp/mail1; mail -s "mail subject here" allan@mail.com < /tmp/mail1; >/tmp/mail ; >/tmp/mail1 ================== cat /tmp/mail ***** Alert *****... (4 Replies)
Discussion started by: jacki
4 Replies

7. Shell Programming and Scripting

Help needed with Perl Script

i have the following script: #!/usr/local/bin/perl use STUN::Client; use Data::Dumper; use strict; my $stun_client = STUN::Client->new; $stun_client->stun_server('10.59.29.14'); my $r = $stun_client->get; my $ip = $r->{ma_address}; print "IP: $ip\n\nResult (hash):... (5 Replies)
Discussion started by: SkySmart
5 Replies

8. Shell Programming and Scripting

fgrep command: Perl programming help needed..Kindly advise

Hi, I am novice in PERL enviornment. I have a text files withso many entries in rows and columns. I have to pick up entries named as "Uniprot ID" in the file and create a new text file with list of particular Uniprot ID entries. Can anybody guide regarding this.. I came to know abut fgrep... (1 Reply)
Discussion started by: manigrover
1 Replies

9. Shell Programming and Scripting

perl regex help needed

Hi, I want to validate strings in perl, the string may contains characters from a-zA-Z0-9 and symbols +-_.:/\ To validate such a string I computed a regex if ($string =~ m/^/) { print "valid"; } else { print "invalid"; } but this regex also validates strings that contain... (8 Replies)
Discussion started by: zing_foru
8 Replies

10. Shell Programming and Scripting

PERL help needed

Hi, I will be asking a series of major newbie questions, and you help is greatly appreciated in advance!! I have to write a script that will parse a logfile in a directory, the directory name changes daily. So far I have: #!/usr/bin/perl open LOGFILE,">logfile.txt"; ($day, $month,... (3 Replies)
Discussion started by: BG_JrAdmin
3 Replies
MKDoc::XML::Dumper(3pm) 				User Contributed Perl Documentation				   MKDoc::XML::Dumper(3pm)

NAME
MKDoc::XML::Dumper - Same as Data::Dumper, but with XML SYNOPSIS
use MKDoc::XML::Dumper; use Test::More 'no_plan'; my $stuff = [ qw /foo bar baz/, [], { hello => 'world', yo => \'boo' } ]; my $xml = MKDoc::XML::Dumper->perl2xml ($stuff); my $stuff2 = MKDoc::XML::Dumper->xml2perl ($xml); is_deeply ($stuff, $stuff2); # prints 'ok' SUMMARY
MKDoc::XML::Dumper provides functionality equivalent to Data::Dumper except that rather than serializing structures into a Perl string, it serializes them into a generic XML file format. Of course since XML cannot be evaled, it also provides a mechanism for undumping the xml back into a perl structure. MKDoc::XML::Dumper supports scalar references, hash references, array references, reference references, and litterals. It also supports circular structures and back references to avoid creating unwanted extra copies of the same object. That's all there is to it! API
my $xml = MKDoc::XML::Dumper->perl2xml ($perl); Turns $perl into an XML string. For instance: my $perl = [ qw /foo bar baz/, { adam => 'apple', bruno => 'berry', chris => 'cherry' } ]; print MKDoc::XML::Dumper->perl2xml ($perl);' Will print something like: <array id="135338912"> <item key="0"> <litteral>foo</litteral> </item> <item key="1"> <litteral>bar</litteral> </item> <item key="2"> <litteral>baz</litteral> </item> <item key="3"> <hash id="135338708"> <item key="bruno"> <litteral>berry</litteral> </item> <item key="adam"> <litteral>apple</litteral> </item> <item key="chris"> <litteral>cherry</litteral> </item> </hash> </item> </array> As you can see, every object has an id. This allows for backreferencing, so: my $perl = undef; $perl = $perl; print MKDoc::XML::Dumper->perl2xml ($perl);' Prints something like: <ref id="135338888"> <backref id="135338888" /> </ref> For the curious, these identifiers are computed using some perl black magic: my $id = 0 + $reference; my $perl = MKDoc::XML::Dumper->perl2xml ($xml); Does the exact reverse operation as xml2perl(). AUTHOR
Copyright 2003 - MKDoc Holdings Ltd. Author: Jean-Michel Hiver This module is free software and is distributed under the same license as Perl itself. Use it at your own risk. SEE ALSO
MKDoc::XML::Decode MKDoc::XML::Encode perl v5.10.1 2004-10-06 MKDoc::XML::Dumper(3pm)
All times are GMT -4. The time now is 02:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy