- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- A little improvement to my webinput perl scripts
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2004 03:29 PM
тАО05-20-2004 03:29 PM
It works pretty well right now.
I strip out the line feeds as follows so I can put them in with print statements later:
chop ($filedata) if ($filedata =~/\n$/);
In the output file get the following results
this the data^M
This ^M is a single character and I'd like to strip it out.
I know I can do it after the script run with the dos2unix command but I'd rather strip it in the program.
I imagine its another chop statement. I can't begin to figure out what it should be.
Bunny for tested code or an explanation as to why I can't do it.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2004 04:20 PM
тАО05-20-2004 04:20 PM
Re: A little improvement to my webinput perl scripts
This is not recently tested but I remember running into a situtaion like this in a 7 line perl code (this is the extent of my perl capacity goes to tell you the truth) but instead of chop, I remember using chomp to eliminate the trailing carriage return character.
Hope it helps.
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2004 04:45 PM
тАО05-20-2004 04:45 PM
Re: A little improvement to my webinput perl scripts
you can use chomp to remove a substring at the end of a line. $\ specifies the substring. or $INPUT_RECORD_SEPARATOR if you use English module.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2004 11:50 PM
тАО05-20-2004 11:50 PM
Re: A little improvement to my webinput perl scripts
A bunny for a working chomp command.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-20-2004 11:51 PM
тАО05-20-2004 11:51 PM
Re: A little improvement to my webinput perl scripts
A bunny for a working chomp command.
attaching a sample
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 12:02 AM
тАО05-21-2004 12:02 AM
Re: A little improvement to my webinput perl scripts
$filedata =~ s/\s+$//;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 01:03 AM
тАО05-21-2004 01:03 AM
Re: A little improvement to my webinput perl scripts
open(INF,"../links.txt");
@data =
close(INF);
foreach $i (@data) {
chomp($i);
($name,$heading,$text) = split(/\|/,$i);
print "$heading\n";
}
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 01:16 AM
тАО05-21-2004 01:16 AM
Re: A little improvement to my webinput perl scripts
How about (as suggested by curt)
open FILE, "filename" or die "oh no, not again\n";
$/="^M";
while(
chomp;
print;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 01:22 AM
тАО05-21-2004 01:22 AM
Re: A little improvement to my webinput perl scripts
I will be trying them late this afternoon.
I'm concerned that Ken's code will remove all whitespaces including the spaces between words.
Since the program is already runnning, my perference if possible is to add a chomp command to the existing statement so I don't have to execute a secondd program.
Perhaps change:
chop ($filedata) if ($filedata =~/\n$/);
to
chop ($filedata) if ($filedata =~/^M\n$/);
except I know its not carat M, its a single character taht I don't know the escape code for.
Thanks. If there are other ideas, I'll be happy to try them.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-21-2004 01:28 AM
тАО05-21-2004 01:28 AM
Re: A little improvement to my webinput perl scripts
$\="\r\n";
chomp(filedata);
do for you