- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- How to split in Perl??
Operating System - Linux
1755839
Members
4756
Online
108838
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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-25-2008 09:52 PM
тАО03-25-2008 09:52 PM
How to split in Perl??
Hi,
I want convert below shell script statement into perl using split// or tr//.
echo "$i"| cut -d ">" -f2 | tr -d "',"
Thanks & Regards,
Rajesh
I want convert below shell script statement into perl using split// or tr//.
echo "$i"| cut -d ">" -f2 | tr -d "',"
Thanks & Regards,
Rajesh
- Tags:
- Perl
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2008 10:41 PM
тАО03-25-2008 10:41 PM
Re: How to split in Perl??
Hello,
Your $i obvious has the following
characteristics:
a) The delimiter is character (>)
b) You want the second field
c) And finally, from the second field
remove all instances of characters
comma (,) and single-quote (').
Here is a little Perl script to
demonstrate what you want:
#!/usr/bin/perl
my $LINE = "baba > second row contains comma (,) and quote (') >third something >fourth and so on>fifth";
my @ARR = split(/>/, $LINE);
print "BEFORE @ARR[1]\n";
@ARR[1] =~ s/'//g;
@ARR[1] =~ s/,//g;
print "AFTER @ARR[1]\n";
exit;
When you run it:
BEFORE second row contains comma (,) and quote (')
AFTER second row contains comma () and quote ()
Perl is very powerful and I am sure there
will be other elegant solutions in this
Forum.
Cheers,
VK2COT
Your $i obvious has the following
characteristics:
a) The delimiter is character (>)
b) You want the second field
c) And finally, from the second field
remove all instances of characters
comma (,) and single-quote (').
Here is a little Perl script to
demonstrate what you want:
#!/usr/bin/perl
my $LINE = "baba > second row contains comma (,) and quote (') >third something >fourth and so on>fifth";
my @ARR = split(/>/, $LINE);
print "BEFORE @ARR[1]\n";
@ARR[1] =~ s/'//g;
@ARR[1] =~ s/,//g;
print "AFTER @ARR[1]\n";
exit;
When you run it:
BEFORE second row contains comma (,) and quote (')
AFTER second row contains comma () and quote ()
Perl is very powerful and I am sure there
will be other elegant solutions in this
Forum.
Cheers,
VK2COT
VK2COT - Dusan Baljevic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2008 11:21 PM
тАО03-25-2008 11:21 PM
Re: How to split in Perl??
Note that perl is not allways the best tool for simple things like this
$ echo "a>b>c>3" | perl -aF\> -ple'($_=$F[1])=~y/\47"//'
b
or in a script
(my $f2 = split m/>/, $i, -1) =~ tr/'"//d;
Enjoy, Have FUN! H.Merijn
$ echo "a>b>c>3" | perl -aF\> -ple'($_=$F[1])=~y/\47"//'
b
or in a script
(my $f2 = split m/>/, $i, -1) =~ tr/'"//d;
Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-13-2008 06:28 PM
тАО04-13-2008 06:28 PM
Re: How to split in Perl??
Hello Guys,
I used following commands to extract the interested values, instead of using array.
for($i=0;$i<=$#fstab_array;$i++)
{
($fstype0, $fstype) = split(/>/, "$fstab_array[$i]");
$fstype =~ tr/',//d;
$i += 1;
}
Thanks & Regards,
Rajesh
I used following commands to extract the interested values, instead of using array.
for($i=0;$i<=$#fstab_array;$i++)
{
($fstype0, $fstype) = split(/>/, "$fstab_array[$i]");
$fstype =~ tr/',//d;
$i += 1;
}
Thanks & Regards,
Rajesh
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP