in reply to Re^2: perl regex to match newline followed by number and text
in thread perl regex to match newline followed by number and text
poj#!/usr/bin/perl use strict; my $record; while (<DATA>){ s/\n/ /; if (/^\d+~/){ $record =~ s/ +$//; # trim trailing spaces printf "%s\n",$record if ($record); $record = $_; } else { $record .= $_; } } $record =~ s/ +$//; printf "%s\n",$record if ($record); __DATA__ 99~Arun~Kumar~Mobilenum: 1234-567 , from Earth Human 98~Mahesh~Babu~Mobilenum: 5678-901 , from Earth Human
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: perl regex to match newline followed by number and text
by arunkumarzz (Novice) on Jun 02, 2019 at 17:58 UTC |