Solved

Perl pos and Solaris cut.

Posted on 2003-10-24
2
968 Views
Last Modified: 2013-12-05
I'm having trouble finding the equivilant of solaris cut in perl

I need to cut a string such as HSTNTXTXCA and grab the state character possition 5 and 6..

solaris equiv:

TID='HSTNTXBGFOMA'
STATE=`echo $TID|cut -c5-6`
0
Comment
Question by:Satalink
2 Comments
 
LVL 2

Accepted Solution

by:
ultimatemike earned 100 total points
ID: 9614444

Use substr.  it will return the specifified string that you're looking for.


use strict;

my $TID='HSTNTXBGFOMA';
my $state= substr($TID,  4, 2 );
0
 
LVL 12

Expert Comment

by:geotiger
ID: 9616824
Or use pattern match as this:

my $tt = "ddff33yy";
my ($s) = ($tt =~ /^\w\w\w\w(\w\w)/);
print "S=$s\n";


GT
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question