On Sep 6, Mike Singleton said:
>1. replace all spaces with commas
$str =~ s/\s/,/g;
or
$str =~ tr/\n\r\t\f /,/;
>2. strip all information before the date
You probably want something like
($keep) = $str =~ /(\w{3} \w{3} .*)/;
This assumes the date is going to be the first occurrence of "NNN NNN...",
where "NNN" represents a three-letter word (like "Sun" and "Mon", and
"Jun" and "Aug").
> / ssjobhnd ('$)/g; # Postmatch all after 'ssjobhnd'
I don't think you understand this regex yourself -- first of all, the
postmatch variable, $' (not '$), is not defined until after the regex, and
you don't assign to it, Perl does. If you had done
/ ssjobhnd (.*)/
then $' would be set to the rest of the string (after 'ssjobhnd'). But
using $`, $&, and $' is icky, so don't use them. Also, there's no reason
for a /g modifier on that regex. Perhaps you want
($_) = / ssjobhnd (.*)/;
That will work (for the text string you showed us).
> ~ s/ /,/g; # Convert all spaces to commas
What's that extra '~' in there for? It's not doing anything. Perhaps
you're confused about the =~ operator, which binds a variable to a pattern
match or substitution or transliteration:
/foo/; # like $_ =~ /foo/
s/foo/bar/; # like $_ =~ s/foo/bar/
tr/a-j/0-9/; # like $_ =~ tr/a-j/0-9/
$x =~ /foo/;
$x =~ s/foo/bar/;
$x =~ tr/a-j/0-9/;
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]