http://www.perlmonks.org?node_id=1052539


in reply to extract the value before a particualr string

Hi nanban,
I am looking for extracting a number between in the below line
How would you that using Perl?
The best way to get help is to try something first, show such and help will then bring understanding.
I would advise that you check How do I post a question effectively?.
Seeing that you are new here, I could give you a head up that solves the this dataset you posted like so:

use warnings; use strict; while(<DATA>){ chomp; print $1,$/ if/\s+?(\d+?)\/total$/; } __DATA__ Apples Orances:5433 55552246:777449 Country 457852/total Apples Red:9987 green:777449 Public 74585/total
produces ..
457852 74585
But of what help is that, if your dataset changes or you have a different input files?
Hope this helps.

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me