10-13-2011
Perl program
Hi
I am new to perl, i need to write a program to convert horizontal words to vertical
eg: cat, dog, cow,.....(text file)
this should be written as
1.cat
2.dog
like this. can u pls help me to work out..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hey all,
I've been trying to learn Perl on my BSD box. When it came to printing the files out, it bothered me that the lines weren't numbered. So here's my little *crap* claim to some-form-of-fame Perl script which numbers files:
... (9 Replies)
Discussion started by: WIntellect
9 Replies
2. Linux
Hi
I am having a file with 243 lines..
The file format s given below
eg
P25787 hsa03050 1 P20618 hsa03050 1
P25786 hsa03050 1 P49721 hsa03050 1
P54132 hsa03440 1 Q13472 hsa03470 1
Q05513 hsa04530 hsa04910 hsa04930 3 Q04759 ... (0 Replies)
Discussion started by: binnybio
0 Replies
3. Shell Programming and Scripting
I wish to write a Perl program that will provide a listing of files in a directory. The files must be listed in sorted order by the file name.
• By default, the program displays only file names.
• By default, the program lists the files in the current directory.
• The program must provide the... (2 Replies)
Discussion started by: livewire06
2 Replies
4. Shell Programming and Scripting
could i get any help with how to link this program together. i dont know what to put where the X's are
print `flush`;
thank(); #print thank header
use Getopt::Std; # use declaration with the options function
getopts("ld:") or usage() and exit; ... (3 Replies)
Discussion started by: livewire06
3 Replies
5. Homework & Coursework Questions
Long story short: I'm working inside of a Unix SSH under a bash shell. I have to code a C program that generates a random number. Then I have to call the compiled C program with a Perl program to run the C program 20 times and put all the generated random #s into a text file, then print that text... (1 Reply)
Discussion started by: jdkirby
1 Replies
6. Shell Programming and Scripting
how would you exit out of a programm correctly, without having for the program to crash?
for example
print "Enter quit";
$input = <STDIN>;
if ($input eq "quit")
{
{QUIT THE PROGRAM}
}
else
{
print "invalid input";
}
one more thing, how do u exit a program "correctly", if... (3 Replies)
Discussion started by: bshell_1214
3 Replies
7. Shell Programming and Scripting
I want to traverse a durectory for a particular file. Situataion is like this. Path is ABC/a/c/g. it has around 100 folders in it.
Search a directory which has word "*latest*" in its path.
and then from the latest go through z/x/c to file final.html.
In total, i want it to go through... (4 Replies)
Discussion started by: hemasid
4 Replies
8. Shell Programming and Scripting
hi,
i have posted the same kind of the question in some other forum of the same site. but realized that it is supposed to be here so i am reposting it .this is the perl script written to check for particular pattern.
my file 1 would look like this
hwk:678:9878:asd:09: abc cfgb 12 nmjk ......... (3 Replies)
Discussion started by: anurupa777
3 Replies
9. Shell Programming and Scripting
can anyone help me out to write a code by connecting to the sql database and I need to print the list of tables present in the databse.
any ideas please. (1 Reply)
Discussion started by: ramkumar15
1 Replies
10. Shell Programming and Scripting
I created a program, so a kid can practice there math on it. It dispenses varies math problems and the kid must input an answer. I also want it to grade the work they have done, but I can't find the best place for it to print out the grade.
I have:
if ( $response =~ m/^/ ) {
$user_wants_to_quit... (1 Reply)
Discussion started by: germany1517
1 Replies
LEARN ABOUT SUSE
perlrequick
PERLREQUICK(1) Perl Programmers Reference Guide PERLREQUICK(1)
NAME
perlrequick - Perl regular expressions quick start
DESCRIPTION
This page covers the very basics of understanding, creating and using regular expressions ('regexes') in Perl.
The Guide
Simple word matching
The simplest regex is simply a word, or more generally, a string of characters. A regex consisting of a word matches any string that
contains that word:
"Hello World" =~ /World/; # matches
In this statement, "World" is a regex and the "//" enclosing "/World/" tells perl to search a string for a match. The operator "=~"
associates the string with the regex match and produces a true value if the regex matched, or false if the regex did not match. In our
case, "World" matches the second word in "Hello World", so the expression is true. This idea has several variations.
Expressions like this are useful in conditionals:
print "It matches
" if "Hello World" =~ /World/;
The sense of the match can be reversed by using "!~" operator:
print "It doesn't match
" if "Hello World" !~ /World/;
The literal string in the regex can be replaced by a variable:
$greeting = "World";
print "It matches
" if "Hello World" =~ /$greeting/;
If you're matching against $_, the "$_ =~" part can be omitted:
$_ = "Hello World";
print "It matches
" if /World/;
Finally, the "//" default delimiters for a match can be changed to arbitrary delimiters by putting an 'm' out front:
"Hello World" =~ m!World!; # matches, delimited by '!'
"Hello World" =~ m{World}; # matches, note the matching '{}'
"/usr/bin/perl" =~ m"/perl"; # matches after '/usr/bin',
# '/' becomes an ordinary char
Regexes must match a part of the string exactly in order for the statement to be true:
"Hello World" =~ /world/; # doesn't match, case sensitive
"Hello World" =~ /o W/; # matches, ' ' is an ordinary char
"Hello World" =~ /World /; # doesn't match, no ' ' at end
perl will always match at the earliest possible point in the string:
"Hello World" =~ /o/; # matches 'o' in 'Hello'
"That hat is red" =~ /hat/; # matches 'hat' in 'That'
Not all characters can be used 'as is' in a match. Some characters, called metacharacters, are reserved for use in regex notation. The
metacharacters are
{}[]()^$.|*+?
A metacharacter can be matched by putting a backslash before it:
"2+2=4" =~ /2+2/; # doesn't match, + is a metacharacter
"2+2=4" =~ /2+2/; # matches, + is treated like an ordinary +
'C:WIN32' =~ /C:\WIN/; # matches
"/usr/bin/perl" =~ //usr/bin/perl/; # matches
In the last regex, the forward slash '/' is also backslashed, because it is used to delimit the regex.
Non-printable ASCII characters are represented by escape sequences. Common examples are " " for a tab, "
" for a newline, and "
" for a
carriage return. Arbitrary bytes are represented by octal escape sequences, e.g., "