- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Backspace characters in perl input
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
тАО03-26-2004 05:32 AM
тАО03-26-2004 05:32 AM
from the user in the form of:
chomp($indata =
which works just fine, except that it the user
types a backspace because he misspelled a word,
the backspace characters show up in the complete text! If what is being entered is a file name, the file can not be found! How can I get perl to read the data already collapsed?
Or, how can I collapse it before saving it?
Thanks for your assistance,
jls
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2004 05:57 AM
тАО03-26-2004 05:57 AM
Re: Backspace characters in perl input
$indata =~ s/^\b+//;
# Step 2. remove all backspace
1 while $indata =~ s/.\b//;
FWIW $indata =~ s/.\b//g; would not work, because that would fail to remove
"abcd\b\b\bxx"
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2004 06:18 AM
тАО03-26-2004 06:18 AM
Re: Backspace characters in perl input
When I enter: myfle
I get nothing (null?) after those commands.
What I want to get is: myfile
How can I get that? Even as I read your code, I am not sure I would have got what I wanted anyway. It looks like I'd get: myfleile, which isn't what I need.
jls
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2004 06:48 AM
тАО03-26-2004 06:48 AM
Solutionlt09:/tmp 107 > perl -de 1
Loading DB routines from perl5db.pl version 1.23
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(-e:1): 1
DB<1> $indata = "myfle^H^Hile"
DB<2> x $indata
0 "myfle\cH\cHile"
DB<3> $indata =~ s/^\b+//
DB<4> x $indata
0 "myfle\cH\cHile"
DB<5> 1 while $indata =~ s/.\b//
DB<6> x $indata
0 ''
DB<7>
Now I see that I erroneously misused \b as backspace, which it is not in a regex.
chomp ($indata = "myfle\b\bile"); # Here it *is* a backspace
$indata =~ s/^\cH+//; # Ctrl-H is backspace
1 while $indata =~ s/.[\b]//; # \b also is backspace inside character class
DB<7> chomp ($indata = "myfle\b\bile"); # Here it *is* a backspace
DB<8> x $indata
0 "myfle\cH\cHile"
DB<9> $indata =~ s/^\cH+//; # Ctrl-H is backspace
DB<10> x $indata
0 "myfle\cH\cHile"
DB<11> 1 while $indata =~ s/.[\b]//; # \b also is backspace inside character class
DB<12> x $indata
0 'myfile'
DB<13>
Enjoy, Have FUN! H.Merijn [ 0 points for the first answer. I feel ashamed! ]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2004 06:59 AM
тАО03-26-2004 06:59 AM
Re: Backspace characters in perl input
You get 2 points for the first try. I don't anyone should get 0 points if they respond to a help request :-)
Thanks much
jls
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-15-2005 02:43 AM
тАО07-15-2005 02:43 AM