Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > Perl
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Perl section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 3rd, 2007, 10:03 AM
Registered User
 
Join Date: Apr 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to nmnm
Default delete the duplicated sentencs without considering

i have this type of following sentences in a file.i want to delete the duplicated sentencs without considering the space difference.for eg: in the following sentences i want to delete both first and 3rd sentences starting with bs5019 because they are the same .i am only a starter in perl so pls help i tried it a lot but it considers that space also.expecting your reply.



bs5019 error: The document contains 68 carriage return characters
rol50141 error: The of element intra-ref is not correctly formatted.
bs5019 error: The document contains 68 carriage return characters


thank you


 
Old August 30th, 2007, 07:33 AM
Friend of Wrox
 
Join Date: Dec 2003
Posts: 488
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Quote:
quote:i want to delete both first and 3rd sentences starting with bs5019 because they are the same
I think this is what you're after - this works on a *nix box.

Code:
charlie@maui $ cat b
bs5019 error: The document contains 68 carriage return characters
rol50141 error: The of element intra-ref is not correctly formatted.
bs5019 error: The document contains 68 carriage return characters

charlie@maui $ cat filt.pl

#!/usr/bin/perl
use warnings;
use strict;

my %hash;

while (<>){
  next if ($hash{$_});
  $hash{$_}=1;
  print;
}

charlie@maui $ cat b | ./filt.pl
bs5019 error: The document contains 68 carriage return characters
rol50141 error: The of element intra-ref is not correctly formatted.
charlie@maui $
--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk





Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I prevent duplicated rows in a subtotal lsouza Crystal Reports 2 May 8th, 2007 11:23 AM
Duplicated assemblies in setup project eelisMX VS.NET 2002/2003 1 July 31st, 2006 08:05 AM
Finding values from duplicated nodes swwallace XSLT 1 March 2nd, 2006 05:21 AM
Need Help on Filtering duplicated data fanyin XSLT 2 November 4th, 2004 08:06 PM
How to suppress the duplicated fields? (formula) winnie1778 Crystal Reports 0 October 18th, 2003 05:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.