in reply to Re^2: extracting names between symbols
in thread extracting names between symbols
The solution from NetWallah looks fine to me.
I added a line to make it clear that the foreach() in my code does use an @variable. And I showed the idioms for deleting whitespace before and after a "line". Anyway, very happy that you can proceed further!
#!/usr/bin/perl -w use strict; my $line = "this- is-aline - one- two "; my @array = split (/-/,$line); foreach (@array) { s/\s+$//g; #throw away tailing whitespace s/^\s+//g; #throw away leading whitespace print "$_\n"; } __END__ PRINTS: this is aline one two
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: extracting names between symbols
by johngg (Canon) on Nov 18, 2009 at 14:10 UTC |