Please use complete English words, not "chat" abbreviations. Typing "why" instead of "y" only takes 2 keystrokes more, and makes the text much more readable.
It's pretty simple actually:
split will separate the input line (saved in this case in $_(see perlvar for more information)), returning an array, which then is concatenated by join, using a newline (\n) between elements, to a string.
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)
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)
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)
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)
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)
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)
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)
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)
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)
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 LINUX
pcresample
PCRESAMPLE(3) Library Functions Manual PCRESAMPLE(3)NAME
PCRE - Perl-compatible regular expressions
PCRE SAMPLE PROGRAM
A simple, complete demonstration program, to get you started with using PCRE, is supplied in the file pcredemo.c in the PCRE distribution.
A listing of this program is given in the pcredemo documentation. If you do not have a copy of the PCRE distribution, you can save this
listing to re-create pcredemo.c.
The program compiles the regular expression that is its first argument, and matches it against the subject string in its second argument.
No PCRE options are set, and default character tables are used. If matching succeeds, the program outputs the portion of the subject that
matched, together with the contents of any captured substrings.
If the -g option is given on the command line, the program then goes on to check for further matches of the same regular expression in the
same subject string. The logic is a little bit tricky because of the possibility of matching an empty string. Comments in the code explain
what is going on.
If PCRE is installed in the standard include and library directories for your operating system, you should be able to compile the demon-
stration program using this command:
gcc -o pcredemo pcredemo.c -lpcre
If PCRE is installed elsewhere, you may need to add additional options to the command line. For example, on a Unix-like system that has
PCRE installed in /usr/local, you can compile the demonstration program using a command like this:
gcc -o pcredemo -I/usr/local/include pcredemo.c
-L/usr/local/lib -lpcre
In a Windows environment, if you want to statically link the program against a non-dll pcre.a file, you must uncomment the line that
defines PCRE_STATIC before including pcre.h, because otherwise the pcre_malloc() and pcre_free() exported functions will be declared
__declspec(dllimport), with unwanted results.
Once you have compiled and linked the demonstration program, you can run simple tests like this:
./pcredemo 'cat|dog' 'the cat sat on the mat'
./pcredemo -g 'cat|dog' 'the dog sat on the cat'
Note that there is a much more comprehensive test program, called pcretest, which supports many more facilities for testing regular expres-
sions and the PCRE library. The pcredemo program is provided as a simple coding example.
If you try to run pcredemo when PCRE is not installed in the standard library directory, you may get an error like this on some operating
systems (e.g. Solaris):
ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
This is caused by the way shared library support works on those systems. You need to add
-R/usr/local/lib
(for example) to the compile command to get round this problem.
AUTHOR
Philip Hazel
University Computing Service
Cambridge CB2 3QH, England.
REVISION
Last updated: 17 November 2010
Copyright (c) 1997-2010 University of Cambridge.
PCRESAMPLE(3)