![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Remove parenthesis character (Perl) | aristegui | Shell Programming and Scripting | 4 | 10-28-2008 02:53 PM |
| How to remove the specific lines from file using perl | dipakg | Shell Programming and Scripting | 4 | 06-11-2008 03:45 AM |
| Perl RegExp to remove last character from strings | ospreyeagle | Shell Programming and Scripting | 2 | 04-03-2008 03:55 PM |
| remove specific lines from flat file using perl | meghana | Shell Programming and Scripting | 12 | 02-12-2008 09:50 PM |
| perl split funciton - special character "/" | deepakwins | UNIX for Dummies Questions & Answers | 5 | 02-08-2008 12:19 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Perl use split and remove specific character
i want to split the input by a space and remove specific characters like full stop, comma...... etc. and then save each word in an array.
i got something below, but it didn't work. can anyone please help me? Thank you Code:
#!/usr/bin/perl -w
while (<>)
{
$line = <>;
@word = split(' ', $line);
$line =~ s/[^\w]/ /g;
@lowerword = map {lc($_)}@word;
print(@lowerword);
}
Output: hello how are you |
|
||||
|
Quote:
|
|
||||
|
Quote:
i have try yours, it is working, but mine is not working.... Code:
#!/usr/bin/perl -w
while (<>)
{
$line = $_;
$line =~ s/[[:punct:]]//g;
$line = lc($line);
@word = split(' ', $line);
print (@word);
}
Output : hellohowareyou i don't know why my output is sticking together? i want it to separate.... can anyone help? Thank you |
|
||||
|
Quote:
Code:
print (@word); Code:
print "@word"; |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|