Oskym has asked for the wisdom of the Perl Monks concerning the following question:
Hi PerlMonkeys!
I'd made a simple script trying to get the final part from a line from the 4th space occurrence.
The Output should be like this:
"GetCertificate](3) Returning context. ID=PTWEBSERVER, Lang=ENG"
Instead of that I'm getting this:
"(6) 01/02/19 06:30:30 GetCertificate(3) Returning context. ID=PTWEBSERVER, Lang=ENG"
Can I ask for help to any expert?
Here is the code:
use strict; use warnings; my $line='PSAPPSRV.26476584 (6) 01/02/19 06:30:30 GetCertificate(3) Re +turning context. ID=PTWEBSERVER, Lang=ENG'; my $SpaceChar = ' '; my $offset = 0; my $result = substr $line,index($line, $SpaceChar, $offset); while ($offset < 4) { $result = substr $line,index($line, $SpaceChar, $offset); print "$result \n"; $offset++; print "offset: $offset \n"; }
Thanks for your help!!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: With substr, index the offset don't get proper start position
by hippo (Bishop) on Mar 21, 2019 at 10:55 UTC | |
Re: With substr, index the offset don't get proper start position
by talexb (Chancellor) on Mar 21, 2019 at 12:47 UTC | |
Re: With substr, index the offset don't get proper start position
by tybalt89 (Monsignor) on Mar 21, 2019 at 13:03 UTC | |
Re: With substr, index the offset don't get proper start position
by pgmer6809 (Sexton) on Mar 24, 2019 at 21:43 UTC |
Back to
Seekers of Perl Wisdom