08-14-2008
At least the mawk manual page says that if the separator is the empty string, no splitting will take place (this is quite unlike Perl). But anyway, what's wrong with simply looping over each character with substr?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have a string like 'xyz' and i want to to split the above string into letters for comparision purpose.
any idea pls.
cheers
RRK. (3 Replies)
Discussion started by: ravi raj kumar
3 Replies
2. Shell Programming and Scripting
Hi,
I am new to shell scripting, Can any body suggest me how I can split a string with a delimiter as whitespace into words and store into a array.
I have read a line from file, now I want to split the line into words and store in a array for further use.
eg : the sky is blue
want... (3 Replies)
Discussion started by: smk
3 Replies
3. Programming
Hello,
I am recently working on an application that sends large strings accross a network very often. These then need to be broken up first with '!' and then with ','. My current function (below) works fine for this when not too much data is being sent across the network but segfaults when a... (4 Replies)
Discussion started by: kpedersen
4 Replies
4. Shell Programming and Scripting
Let's say I have a very long string with no spaces but just words stored in $very_long_string.
$very_long_string = "aaaaaaaaaaabbbbbbbbbbbccccccccccccdddddddddddd";
I can do this to split the string into 1 character each and store them in an array:
@myArray = split(//, $very_long_string); ... (3 Replies)
Discussion started by: teiji
3 Replies
5. UNIX for Dummies Questions & Answers
Hello all!
I'm trying to put together a small script that will take in a file name and attach a datestamp to the end of it (but before the file type extension).
To illustrate...
Before:
filename.txt
anotherfilename.txt
After:
filename_20090724.txt
anotherfilename_20090724.txt
... (7 Replies)
Discussion started by: jisoo411
7 Replies
6. Shell Programming and Scripting
Hi,
I have a string like this in a file,
I want to retrive the words separated by comma's in 3 variables. like
How do i get that.plz advice (2 Replies)
Discussion started by: suresh_kb211
2 Replies
7. UNIX for Dummies Questions & Answers
Hello I need help with the following. I have strings like
#if defined(__def1__)
#if defined(__def1__) || defined(__def2__)
#if defined(__def1__) && defined(__def2__) && defined(__def3__).
#if defined(__def1__) || defined(__def2__) || defined(__def3__).
I need to print what is there in... (4 Replies)
Discussion started by: srk
4 Replies
8. Shell Programming and Scripting
Input:
Debris Linux is a minimalist, desktop-oriented distribution and live CD based on Ubuntu.
It includes the GNOME desktop and a small set of popular desktop applications, such
as GNOME Office, Firefox web browser, Pidgin instant messenger, and ufw firewall manager.
Debris Linux ships... (5 Replies)
Discussion started by: cola
5 Replies
9. Shell Programming and Scripting
Hi ,
can someone help me how to make an AWK code for splitting a string of equal parts of 500 chars in while loop?
Thank you! (4 Replies)
Discussion started by: sanantonio7777
4 Replies
10. Shell Programming and Scripting
Hi Experts.
I'm stuck with the below AWK code where i'm trying to move the records containing any special characters in the last field to a bad file.
awk -F, '{if ($NF ~ /^|^/) print >"goodfile";else print >"badfile"}' filename
sample data
1,abc,def,1234,A *
2,bed,dec,342,* A ... (6 Replies)
Discussion started by: shell_boy23
6 Replies
LEARN ABOUT DEBIAN
perl::critic::policy::subroutines::requirefinalreturn
Perl::Critic::Policy::Subroutines::RequireFinalReturn(3pUser Contributed Perl DocumentatPerl::Critic::Policy::Subroutines::RequireFinalReturn(3pm)
NAME
Perl::Critic::Policy::Subroutines::RequireFinalReturn - End every path through a subroutine with an explicit "return" statement.
AFFILIATION
This Policy is part of the core Perl::Critic distribution.
DESCRIPTION
Require all subroutines to terminate explicitly with one of the following: "return", "carp", "croak", "die", "exec", "exit", "goto", or
"throw".
Subroutines without explicit return statements at their ends can be confusing. It can be challenging to deduce what the return value will
be.
Furthermore, if the programmer did not mean for there to be a significant return value, and omits a return statement, some of the
subroutine's inner data can leak to the outside. Consider this case:
package Password;
# every time the user guesses the password wrong, its value
# is rotated by one character
my $password;
sub set_password {
$password = shift;
}
sub check_password {
my $guess = shift;
if ($guess eq $password) {
unlock_secrets();
} else {
$password = (substr $password, 1).(substr $password, 0, 1);
}
}
1;
In this case, the last statement in check_password() is the assignment. The result of that assignment is the implicit return value, so a
wrong guess returns the right password! Adding a "return;" at the end of that subroutine solves the problem.
The only exception allowed is an empty subroutine.
Be careful when fixing problems identified by this Policy; don't blindly put a "return;" statement at the end of every subroutine.
CONFIGURATION
If you've created your own terminal functions that behave like "die" or "exit", then you can configure Perl::Critic to recognize those
functions as well. Just put something like this in your .perlcriticrc:
[Subroutines::RequireFinalReturn]
terminal_funcs = quit abort bailout
BUGS
We do not look for returns inside ternary operators. That construction is too complicated to analyze right now. Besides, a better form is
the return outside of the ternary like this: "return foo ? 1 : bar ? 2 : 3"
AUTHOR
Chris Dolan <cdolan@cpan.org>
COPYRIGHT
Copyright (c) 2005-2011 Chris Dolan.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license
can be found in the LICENSE file included with this module.
perl v5.14.2 2012-06-07 Perl::Critic::Policy::Subroutines::RequireFinalReturn(3pm)