Re: split, no repeat- Regular expression
- From: Tad McClellan <tadmc@xxxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 06:52:05 -0500
Nina <tin_tint@xxxxxxxxxxx> wrote:
> what's the problem with this script?
>
> #!usr/bin/perl -w
You are missing a slash character there.
Please post _actual_ code!
> open (FILE, "$file") or die "Cannot open file.\n";
You should include the $! variable in your die() message.
You should not have quotes around a lone variable:
perldoc -q vars
What's wrong with always quoting "$vars"?
> foreach (@file) {s/\s+/\t+/g;}
That replaces _runs_ of whitespace characters (any of: line feed,
carriage return, tab, formfeed, space) with a tab and a plus sign.
The 2nd part of s/// is a *string*, not a regular expression.
To TRansliterate space characters to tab characters:
tr/ /\t/;
--
Tad McClellan SGML consulting
tadmc@xxxxxxxxxxxxxx Perl programming
Fort Worth, Texas
.
- References:
- split, no repeat- Regular expression
- From: Nina
- Re: split, no repeat- Regular expression
- From: William James
- Re: split, no repeat- Regular expression
- From: Nina
- split, no repeat- Regular expression
- Prev by Date: Class::DBI and fork
- Next by Date: INTERNAL SERVER ERROR (WIERD???)
- Previous by thread: Re: split, no repeat- Regular expression
- Next by thread: Class::DBI and fork
- Index(es):
Relevant Pages
|