The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-22-2008
jyoung jyoung is offline
Registered User
  
 

Join Date: Nov 2001
Location: Flint, MI
Posts: 228
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.
  #2 (permalink)  
Old 04-22-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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.
  #3 (permalink)  
Old 04-22-2008
jyoung jyoung is offline
Registered User
  
 

Join Date: Nov 2001
Location: Flint, MI
Posts: 228
Hi era,
You are correct. Once I removed that the problem was solved. Thank you for your response and the tip.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0