Solved

Perl pos and Solaris cut.

Posted on 2003-10-24
2
954 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now