473,465 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Want to remove an unwanted charachter from scalar

2 New Member
I am reading in a file that has a list that of items. The items I place into a scalar for print but when i do, there is an extra unwanted charachter that shows up at the end of each item. It looks to be some hex charachter. It does not exist in the original file. Is this some sort of charachter set and can I remove it with a substition routine?

I have tried

$item =~ s/\x+$//g;

and

$item =~ s/[\n+\r+\f+\e+\t+]//g;

but they do not help.



Any help would be great in identifying and removing this. Thanks. -ljs
Apr 21 '08 #1
4 1565
KevinADC
4,059 Recognized Expert Specialist
are you using chomp()? If so the file was probably created on a different operating system and the line endings are differnt than the operating sytem the script is running on. You can try:

$item =~ s/[\r\n]?$//;

see if that helps.
Apr 21 '08 #2
ljsmith91
2 New Member
KevinADC,

Thanks. However, it didn't make a difference.

I think the extra charachter is a <160> or char set for &nbsp. However, even knowing that, I can't seem to get rid of it.

Any ideas that might help?

Thanks.
Apr 22 '08 #3
KevinADC
4,059 Recognized Expert Specialist
is $item a multiline scalar? In other words, does it have embedded records seperators like newlines in it? If so you can try this:

$item =~ s/[\r\n]?$//m;

If not, I am not sure what else to suggest.
Apr 22 '08 #4
Ganon11
3,652 Recognized Expert Specialist
You could try getting the item (weird character and all), then capturing the legible portion:

Expand|Select|Wrap|Line Numbers
  1. $item =~ /([A-Za-z]+)/;
  2. $item = $1;
If the item could be multiple words, add spaces - if the item includes numbers, inclue 0-9, etc. etc.
Apr 22 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: roger | last post by:
I'm having difficulties invoking a user defined table function, when passing to it a parameter that is the result of another user defined function. My functions are defined like so: drop...
11
by: Tony Johansson | last post by:
Hello! I have some problem with STL function remove I have two classes called Handle which is a template class and Integer which is not a template class. The Integer class is just a wrapper...
5
by: Bob Stearns | last post by:
When I run the following query with the two sections commented out, the response time is between 1 an 2 seconds; with the first indicated section enabled, the response goes up to 15 seconds even...
3
by: Danny Yeadon | last post by:
Hi I need to remove unwanted characters from phone numbers from my phone bill to analyse the data. Some examples are 02 48222222 i need to remove the space +61266667656 ...
10
by: pamelafluente | last post by:
Hi I have a sorted list with several thousands items. In my case, but this is not important, objects are stored only in Keys, Values are all Nothing. Several of the stored objects (might be a...
4
by: Magnus Warker | last post by:
Hello group, I am producing a form within a table: <table> <tr> <td> <form> ... </form>
0
by: Michel Esber | last post by:
Hello, Linux RedHat AS4 running DB2 V8 FP15. I have very large tables (100 Million+ rows), and I only need to keep 6 months of data online/available. The tables have a timestamp field. I...
3
by: Barkingmadscot | last post by:
I am stuck, i can workout how to remove lines from an array I have loading a text file (a Log), I know which lines a need, but the logs can be upto 30K sometimes bigger. I found trying to...
6
by: ashish1985s | last post by:
Hello friends.. i have made on window service which is hourly update the rss news data.. but some rss comes with some ads and logos and unwanted scripts i wanted to completly remove that all...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.