Find string ending with %



Hi,

Need some help with a regex please.

I need to search a file for every instance of a string that ends with %.
Think output from the df command. I need the 1, 2 or 3 digits before the %
passed into the array.

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

my $outfile2 = "XXX.dat";
open(DATA2, "< $outfile2") || die "Can't open $outfile2: $!\n";
while(<DATA2>) {
my @oput2 = /\b([0-9]+)%/;
print "XXX @oput2 XXX\n";
}
close(DATA2);

It is kind of working but I pick up stuff I don't want e.g:

Input data(XXX.dat):
head
123 123 111% 123
456 22% 456 456 456
789
tail

Output data:
XXX XXX
XXX 111 XXX
XXX 22 XXX
XXX XXX
XXX XXX

How do I tell it not to process every line in the file, just the lines that
contain the relevant string?

Thanks,
Greg Keenan
Lucent Technologies *
Level 1, 68 Waterloo Road
North Ryde NSW 2113
Australia
* +61 2 9491 6898
* gjkeenan@xxxxxxxxxx




Relevant Pages

  • Help in French|Spanish|German translation.
    ... I am also an author of User-defined string functions. ... WORDTRANEX (cSearched, cArExpressionSought | cExpressionSough, ... each string of the array is searched ... If the parameter nArStartOccurrence is -1 or omitted, the replacement starts ...
    (microsoft.public.fox.helpwanted)
  • Re: passing a string to a dll
    ... Joe, I really appreciate you taking the time to demonstrate this. ... sure how I would implement indexing it for random alphanumeric codes. ... I might handle the array. ... I actually have been wondering if I could use a second string ...
    (microsoft.public.vc.mfc)
  • Re: passing a string to a dll
    ... I might handle the array. ... I actually have been wondering if I could use a second string ... look at insertion cost, organization cost, and search cost. ...
    (microsoft.public.vc.mfc)
  • RE: Structure conversion from C++ to VB-2008?
    ... One of the most important structures is AmiVar structure. ... point number, the array of floating point numbers, a string or IDispatch ... Dim 13012679 as Integer ...
    (microsoft.public.dotnet.languages.vb)
  • Structure conversion from C++ to VB-2008?
    ... One of the most important structures is AmiVar structure. ... point number, the array of floating point numbers, a string or IDispatch ... Dim 13012679 as Integer ...
    (microsoft.public.dotnet.languages.vb)