![]() |
|
|
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 |
| Perl Search and replace entire line | insania | Shell Programming and Scripting | 1 | 05-22-2008 07:45 PM |
| Perl: Global Search and replace | epi8 | Shell Programming and Scripting | 3 | 05-06-2008 04:18 PM |
| search & replace password perl script | shellscript22 | Shell Programming and Scripting | 4 | 03-25-2008 03:17 PM |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 10:24 AM |
| perl search and replace pairs | umen | Shell Programming and Scripting | 1 | 07-30-2006 12:37 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Search and replace in Perl
Hello, I have a Perl script that reads in an Excel spread sheet and formats the values into a text file. I am having trouble with one column that can have numbers or letters. Excel left justifies the values that start with a letter and right justifies the values that contain only a number(s). I thought this bit of code would get rid of spaces, but it is not working: Code:
my $hrbc_empdoe=uc(@$ref_array[2]); my $hrbc_empdoe =~ s/\s//gi; print "$hrbc_empdoe \n"; It prints nothing. When I did a test with the code below it printed the value "92" without the spaces in front. Code:
$s1 = " 92"; $s1 =~ s/\s+//; print "$s1\n"; Not sure what to do with this. Is it possible that there are not spaces in the value but some other un-readable characters? If so what would be the correct code? I am using Active State Perl on a Windows 2000 machine. Thank you. |
|
||||
|
The problem would seem to be the repeated my declaration -- you are creating a new temporary variable which masks the previous value (... I guess).
Lesson: use strict; use warnings; -- always. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|