Sponsored Content
Top Forums Shell Programming and Scripting perl : regular expression to replace the strings Post 302702383 by elixir_sinari on Tuesday 18th of September 2012 08:22:58 AM
Old 09-18-2012
Code:
$ cat testfile
xyz.net-Multilink1,BW: 1.07 M,,,,,,,,,,,,,,,,,,,,,,,
Hrly Avg (IN / OUT),0:00,1:00,2:00,3:0041148,,,,,,,,,,,,,,,,,,,,,,,,
41149,,,,,,,,,,,,,,,,,,,,,,,,
41150,,,,,,,,,,,,,,,,,,,,,,,,
41151,,,,,,,,,,,,,,,,,,,,,,,,
41152,,,,,,,,,,,,,,,,,,,,,,,,

$ perl -wne 'print if /\A[0-9]+/' testfile
41149,,,,,,,,,,,,,,,,,,,,,,,,
41150,,,,,,,,,,,,,,,,,,,,,,,,
41151,,,,,,,,,,,,,,,,,,,,,,,,
41152,,,,,,,,,,,,,,,,,,,,,,,,

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl regular expression

letz say that my file has 7 records with only one field. So my file has: 11111111 000000000000000 1111 aaaabbbccc 1111111222000000 aaaaaaaa zz All i need is: 1. when the field has a repetition of the same instance(a-z or 0-9), i would consideer it to be invalid.... (1 Reply)
Discussion started by: helengoldman
1 Replies

2. UNIX for Dummies Questions & Answers

Regular Expression - Replace if x contains y except if...

Hi all, I have a file which contains 1000s of lines of text. I need to delete all lines with the words "Red" EXCEPT if the line also contains the word "GREEN"... For example: ThisIs some random text that should be red deleted ThisIs some random text that should NOT be red deleted green ... (4 Replies)
Discussion started by: not4google
4 Replies

3. Shell Programming and Scripting

regular expression in perl

hi, i want to extract the sessionID from this line. QnA Session Id : here the output should be-- QnA_SessionID=128589 Thanks NT (3 Replies)
Discussion started by: namishtiwari
3 Replies

4. UNIX for Dummies Questions & Answers

replace words in sed using regular expression

hi, I need to replace all these lines from my text file 123end 234end 324end 234end 989end 258end 924end At the moment I know how to replace "end". But I want to replace the numbers before end as well. How can I do this ? sed s/end/newWord/ myfile.txt newFile.txt thanks (3 Replies)
Discussion started by: aneuryzma
3 Replies

5. Shell Programming and Scripting

PERL regular expression

Hello all, I need to match the red expressions in the following lines : MACRO_P+P-_scrambledServices_REM_PRC30.xml MACRO_P+P-_scrambledServices_REM_RS636.xml MACRO_P+P-_scrambledServices_REM_RS535.xml and so on... Can anyone give me a PERL regular expression to match those characters ? ... (5 Replies)
Discussion started by: lsaas
5 Replies

6. Shell Programming and Scripting

perl regular expression

Dear all, I have a simple issue on a perl regular expression. I want to get the characters in red from the next lines : POWER_key LEFT_key RIGHT_key OK_key DOWN_key and so on... Thanks in advance for reply. Ludo (1 Reply)
Discussion started by: lsaas
1 Replies

7. Shell Programming and Scripting

Perl regular expression and %

Could you help me with this please. This regular expression seems to match for the wrong input #!/usr/bin/perl my $inputtext = "W1a$%XXX"; if($inputtext =~ m/+X+/) { print "matches\n"; } The problem seems to be %. if inputtext is W1a$XXX, the regex doesnot match.... (5 Replies)
Discussion started by: suppandi7
5 Replies

8. Shell Programming and Scripting

Hidden Characters in Regular Expression Matching Perl - Perl Newbie

I am completely new to perl programming. My father is helping me learn said programming language. However, I am stuck on one of the assignments he has given me, and I can't find very much help with it via google, either because I have a tiny attention span, or because I can be very very dense. ... (4 Replies)
Discussion started by: kittyluva2
4 Replies

9. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

10. Shell Programming and Scripting

Perl regular expression

Hi , I have the below array my @actionText = ("delivered to governor on 21/23/3345" , "deliver jllj" , "ram 2345/43"); When i am trying to grep the contents of array and if mathced substituting with the digitis or some date format from the element like below my @action = grep { $_ =~... (7 Replies)
Discussion started by: ragilla
7 Replies
Mail::Mailer(3) 					User Contributed Perl Documentation					   Mail::Mailer(3)

NAME
Mail::Mailer - Simple interface to electronic mailing mechanisms INHERITANCE
Mail::Mailer is a IO::Handle SYNOPSIS
use Mail::Mailer; use Mail::Mailer qw(mail); # specifies default mailer $mailer = Mail::Mailer->new; $mailer = Mail::Mailer->new($type, @args); $mailer->open(\%headers); print $mailer $body; $mailer->close or die "couldn't send whole message: $! "; DESCRIPTION
Sends mail using any of the built-in methods. As TYPE argument to new(), you can specify any of "sendmail" Use the "sendmail" program to deliver the mail. "smtp" Use the "smtp" protocol via Net::SMTP to deliver the mail. The server to use can be specified in @args with $mailer = Mail::Mailer->new('smtp', Server => $server); The smtp mailer does not handle "Cc" and "Bcc" lines, neither their "Resent-*" fellows. The "Debug" options enables debugging output from "Net::SMTP". You may also use the "Auth => [ $user, $password ]" option for SASL authentication. To make this work, you have to install the Authen::SASL distribution yourself: it is not automatically installed. "smtps" Use the smtp over ssl protocol via Net::SMTP::SSL to deliver the mail. Usage is identical to "smtp". $mailer = Mail::Mailer->new('smtps', Server => $server); "qmail" Use qmail's qmail-inject program to deliver the mail. "testfile" Used for debugging, this displays the data to the file named in $Mail::Mailer::testfile::config{outfile} which defaults to a file named "mailer.testfile". No mail is ever sent. "Mail::Mailer" will search for executables in the above order. The default mailer will be the first one found. METHODS
Constructors Mail::Mailer->new(TYPE, ARGS) The TYPE is one of the back-end sender implementations, as described in the DESCRIPTION chapter of this manual page. The ARGS are passed to that back-end. $obj->open(HASH) The HASH consists of key and value pairs, the key being the name of the header field (eg, "To"), and the value being the corresponding contents of the header field. The value can either be a scalar (eg, "gnat@frii.com") or a reference to an array of scalars ("eg, ['gnat@frii.com', 'Tim.Bunce@ig.co.uk']"). DETAILS
ENVIRONMENT VARIABLES PERL_MAILERS Augments/override the build in choice for binary used to send out our mail messages. Format: "type1:mailbinary1;mailbinary2;...:type2:mailbinaryX;...:..." Example: assume you want you use private sendmail binary instead of mailx, one could set "PERL_MAILERS" to: "mail:/does/not/exists:sendmail:$HOME/test/bin/sendmail" On systems which may include ":" in file names, use "|" as separator between type-groups. "mail:c:/does/not/exists|sendmail:$HOME/test/bin/sendmail" BUGS Mail::Mailer does not help with folding, and does not protect against various web-script hacker attacks, for instance where a new-line is inserted in the content of the field. SEE ALSO
This module is part of the MailTools distribution, http://perl.overmeer.net/mailtools/. AUTHORS
The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development. Mail::Cap by Gisle Aas <aas@oslonett.no>. Mail::Field::AddrList by Peter Orbaek <poe@cit.dk>. Mail::Mailer and Mail::Send by Tim Bunce <Tim.Bunce@ig.co.uk>. For other contributors see ChangeLog. LICENSE
Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2007 Mark Overmeer <perl@overmeer.net>. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.12.1 2010-01-26 Mail::Mailer(3)
All times are GMT -4. The time now is 03:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy