NetApp Interview Question for Testing / Quality Assurances






Comment hidden because of low score. Click to expand.
2
of 2 vote

## Given string, needs to squeze
my $string = "squeezing spaces fro m t h e string";
## regex that squeeze the spaces
$string =~ s/\s//g;
print "$string \n";

- Anonymous December 09, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

subroutine in perl to remove space from front and end of the sentence.

sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}

- punch007 August 29, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

what about space in the middle of the string?

- Aditya Kulkarni December 19, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

chomp($string=<STDIN>);

$string =~ s/\s+//g; #g means anywhere = globally

print "\n string is $string \n";

- Gaurav Khurana April 21, 2014 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

#!/usr/bin/perl

# Declare the subroutines
sub trim($);
sub ltrim($);
sub rtrim($);

# Create a test string
my $string = " \t Hello world! ";

# Here is how to output the trimmed text "Hello world!"
print trim($string)."\n";
print ltrim($string)."\n";
print rtrim($string)."\n";

# Perl trim function to remove whitespace from the start and end of the string
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
# Left trim function to remove leading whitespace
sub ltrim($)
{
my $string = shift;
$string =~ s/^\s+//;
return $string;
}
# Right trim function to remove trailing whitespace
sub rtrim($)
{
my $string = shift;
$string =~ s/\s+$//;
return $string;
}

- Anonymous December 09, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

There is no trim function in perl.This can be done using regular expressions.

$string=" remove Space ";
#removes leading white spaces
$string=~ s/^\s+//;
#removes trailing white spaces
$string=~ s/\s+$//;

- Smita August 26, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

char s[]="a b cde f";
int i,j;
for(i=j=0;s[j];j++) {
if(s[j] != ' ') {
s[i]=s[j]; i++;
}
}
s[i]='\0';

- Raja August 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

# include<stdio.h>
# include <conio.h>
void main()
{
int i=0,j=0;
char widspc[80],wospc[80];
printf("\n Enter A string with blank spaces: ");
gets(widspc);
while (widspc[i]!='\0')
{
if (widspc[i] != ' ')
{
wospc[j]=widspc[i];
j=j+1;
}
i=i+1;
}
wospc[j+1]='\0';
printf("\n");
puts(wospc);
}

- navin9876 August 07, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Question is asked in perl ,So try to solved using perl regular exp

- punch007 August 29, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#Here is code in perl

$num=56439823;
@num=split("",$num);
$len=scalar(@num);
$i=$len-1;

while($i>=0){
$j=0;
while($j<=$len-1){
if($num[$i]==$num[$j]){unless ($i==$j){$num[$i]

=undef;}}
$j++;
}
$i--;
}


print reverse(@num);

- Shankar January 19, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#!/usr/bin/perl
#My First Solution
$myString = " I need To Remove  Spaces";
@myArray = split(' ',$myString);
$myString = '';
foreach $a (@myArray){
    $myString = $myString.$a;
    print "$a\n"
}
print "$myString\n";

#solution with regex
$myString =" I need To remove Spaces";
$myString =~ s/\s//g;
print "$myString\n";

- Mafioso January 03, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More