Sponsored Content
Full Discussion: Perl function extraction
Top Forums Shell Programming and Scripting Perl function extraction Post 302377375 by summer_cherry on Friday 4th of December 2009 12:34:38 AM
Old 12-04-2009
Code:
while(<DATA>){
	if(/.*?() (\S*)\s*input/){
		print "OPCODE is $1\n";
		print "Input function\n";
	}
	elsif(/output/){
		print "Output function\n";
	}
	else{
		print;
	}
}
__DATA__
D function_add() ADD input data 1021214
0 VAR1 STR 10
0 VAR2 STR 20
0 VAR3 STR
1 SUM=VAR1+VAR2
D function_add() ADD output data 1021267
0 DISPLAY SUM

D function_sub() SUB input data 1021214
0 VAR1 STR 10
0 VAR2 STR 20
0 VAR3 STR
1 sub=VAR1-VAR2
D function_sub() SUB output data 1021267
0 DISPLAY sub

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Optimize/speed-up perl extraction

Hi, Is there a way I can extract my data faster. You know my data is 1.2 GB text file with 8Million rows with 38 columns/fields. Imagine how huge this is. How I can optimized the data extraction using perl. That is why I'm creating a script to filter only those informations that I need. Is... (3 Replies)
Discussion started by: pinpe
3 Replies

2. Shell Programming and Scripting

metapattern extraction in PERL

Hi, I want to extract some part of a pattern that matches my requirement in a string with PERL. A case in point is a string like: $eqtst="abh nmae res = 10 s abh nmae req = 10 s"; from which I want the words preceding the "=" symbol. Previously I was assured that there would be only 2 such... (4 Replies)
Discussion started by: Abhishek Ghose
4 Replies

3. Shell Programming and Scripting

String Extraction in Perl

I have a string stored in a variable. For instance, $str = " Opcode called is : CM_OP_xxx " where xxx changes dynamically and can be either LOGIN or SEARCH..... depends on runtime. For example : $str = " Opcode called is : CM_OP_SEARCH " $str = " Opcode called is : CM_OP_LOGIN " I... (3 Replies)
Discussion started by: vkca
3 Replies

4. Shell Programming and Scripting

Function extraction in PERL

the log contains mathematical operation as follows fm_void_mathematics : PCM_OP_MATHS input function PIN_FLD_NUM1 INT 1 PIN_FLD_NUM2 INT 2 PIN_FLD_RESULTS int PIN_FLD_OUT INT * D Wed Sep 16 05:40:22 2009 solaris_testing fm_void_add : PIN_FLD_SUM int 3 D Wed Sep 16 05:40:22 2009... (1 Reply)
Discussion started by: vkca
1 Replies

5. Shell Programming and Scripting

Data extraction in perl variable

HI, i have variable in perl like below $tmp="/home/sai/automation/work/TFP_GN.txt" it can conatain any path its filled from config file. now i want extarct the path upto this /home/sai/automation/work/ and put it in another variable say... (4 Replies)
Discussion started by: raghavendra.nsn
4 Replies

6. Shell Programming and Scripting

Data Extraction problem in perl

Hello, I want to extract the words from a file which starts with SRD-R or SRD-DR. I have written a script which is able to trace the word but it is printing the whole line. sub extract_SRD_tag{ my ($tag, $app, $path, @data, $word ); $path = shift; $app = shift; open (FILE, $path) or... (2 Replies)
Discussion started by: suvendu4urs
2 Replies

7. Shell Programming and Scripting

perl extraction of code between comments /* .. */

Hi, I am using the following code to retrieve the contents between C-style comments "/* .. */". perl -lne 'while(/(\/\*.*?\*\/)/g) {print "$1";}' This works fine when the commented section of code is present in a single line. But I also need to extract the data which is present inside... (3 Replies)
Discussion started by: royalibrahim
3 Replies

8. Shell Programming and Scripting

perl function enquery

Dear all, I find a perl script that contains the following codes. Does anybody know the meaning of codes highlight. ..... @field = parse_csv($file); chomp(@field); ........ ........ sub parse_csv { my $text = shift; my @new = (); push( @new, $+ ) while $text =~ m{... (9 Replies)
Discussion started by: eldonlck
9 Replies

9. Shell Programming and Scripting

Perl-extraction using windows cmd

Hi, I need to extract Password expires from the output of windows command print `net user %USERNAME% /domain`; in perl. So i want to redirect the output of this win-cmd to a file and try extracting Password expires along with its value. i'm trying with this code but getting errors. #!usr/bin/perl... (1 Reply)
Discussion started by: sam_bd
1 Replies

10. Shell Programming and Scripting

Converting shell to Perl I run into shell built in function trap and need alternative in Perl

I am working on converting shell to Perl script. In shell we have built in function trap Do you know alternative in Perl or actually we don't need it? Thanks for contribution (3 Replies)
Discussion started by: digioleg54
3 Replies
ISELECT(1)							Ralf S. Engelschall							ISELECT(1)

NAME
iSelect -- Interactive Selection Tool SYNOPSIS
iselect [-d STR,STR] [-c] [-f] [-a] [-e] [-p NUM] [-k KEY[:OKEY]] [-m] [-n STR] [-t STR] [-S] [-K] [-P] [-Q STR] [line1 line2 ...] iselect [-V] VERSION
1.4.0 (08-Jul-2007) DESCRIPTION
Intend iSelect is an interactive line selection tool for ASCII files, operating via a full-screen Curses-based terminal session. It can be used either as an user interface frontend controlled by a Bourne-Shell, Perl or other type of script backend as its wrapper or in batch as a pipe filter (usually between grep and the final executing command). In other words: iSelect was designed to be used for any types of interactice line-based selections. Input Data Input is read either from the command line (line1 line2 ...) where each argument corresponds to one buffer line or from stdin (when no arguments are given) where the buffer lines are determined according to the newline characters. You can additionally let substrings displayed in Bold mode for non-selectable lines (because the selectable lines are always displayed bold) by using the construct ``"<b>"..."</b>"'' as in HTML. Selections The selection is either just a single line (default) or multiple lines (option -m). Per default no lines are selectable. If a line contains the string ``"<s>"'' (or a string with different delimiters configured via option -d) at any position this string is stripped and the line is selectable. Its result (printed to stdout) is the line contents itself (but without the ``"<s>"'' string of course). If option -a is used all lines are selectable and their result is again the line itself, i.e. using option -a is the same as adding ``"<s>"'' to every line of the input data. When you want a specific result (i.e. not just the line contents itself), you have to use the special variant ``"<s:result text>"'' which results in the output ``"result text"'' when the corresponding line is selected. When you use a specific result via ``"<s:result text>"'' the result text can contain ``"%[query text]s"'' and ``"%[query text]S"'' constructs. For every such construct an interactive query is done and the result replaces the construct. The ``"%[query text]S"'' construct is like ``"%[query text]s"'' except that the empty string as the query result is not accepted on input. The Curses-based full-screen selection is always done via /dev/tty, because the stdin and stdout filehandles are usually tied to the input and output data streams. Output Data The output is the line itself or the string given with ``"<s:result text>"''. When multiple line selection mode (option -m) is used the output is all selected lines theirself or their configured result strings. Output always is written to stdout. OPTIONS
Input Options These options control how iSelect parses its input. -d STR, --delimiter=STR Sets the delimiters for the selection tags. The default is `"<,>"', i.e. the selection tags have to read ``"<s>"'' and ``"<s:result text>"'' -c, --strip-comments Strips all sharp comment lines from the input buffer before parsing. -f, --force-browse Browse always, i.e. even when the input buffer contains no or only one line. -a, --all-select Force all lines to be selectable. -e, --exit-no-select Exit immediately if no lines are selectable. In this case not even the Curses screen is initialized. Display Options -p NUM, --position=NUM Sets the cursor position to line NUM. -k KEY[:OKEY], --key=KEY[:OKEY] Defines an additional input key. Per default OKEY is "RETURN", i.e. for instance -kf defines another selection key `"f"'. -m, --multi-line Enable multi-line selection where you can select more then one line via SPACE key. -n STR, --name=STR Sets the name string, displayed flush left at the bottom of the browser window. -t STR, --title=STR Sets the title bar string, displayed centered at the bottom of the browser window. Output Options -S, --strip-result Strip all leading and trailing whitespaces from the result string. -K, --key-result Prefix the result string (given on stdout) with the corresponding selection key which was used. This usually is "RETURN" or "KEY_RIGHT" but can be any of the additional keys defined by option -k. When you use -kf and select a line "Foo Bar" with key `"f"' the result string is ``"f:Foo Bar"''. -P, --position-result Prefix the result string (given on stdout) with the corresponding cursor position followed by a colon. When you selected line N and this line has the result "Foo Bar" configured the result string is ``"N:Foo Bar"''. -Q STR, --quit-result=STR Sets the result string on quit. Default is the empty string. Giving Feedback -V, --version Displays version identification string. KEYSTROKES
Cursor Movement Use these to browse through the selection list. CURSOR-UP ..... Move cursor one line up CURSOR-DOWN ... Move cursor one line down PAGE-UP ....... Move cursor one page up PAGE-DOWN ..... Move cursor one page down g ............. Goto first line G ............. Goto last line Line Selection Use these to select one line and exit in standard mode or one or more lines in multi-line mode. RETURN ........ Select line and exit CURSOR-RIGHT .. Select line and exit SPACE ......... Select line and stay (multi-line mode only) Others Use these to quit iSelect or to show its help and version page. q ............. Quit (exit without selection) CURSOR-LEFT ... Quit (exit without selection) h ............. Help Page v ............. Version Page EXAMPLE
As an example we present a real-life situation where iSelect can enhance an existing functionality. We define two Bash functions (for your $HOME/.bashrc file) which enhance the built-in `cd' command of the shell. # database scan for enhanced cd command cds () { (cd $HOME; find . -type d -print | sed -e "s;^.;$HOME;" | sort -u >$HOME/.cdpaths ) & } # definition of the enhanced cd command cd () { if [ -d $1 ]; then builtin cd $1 else builtin cd `egrep "/$1[^/]*$" $HOME/.cdpaths | iselect -a -Q $1 -n "chdir" -t "Change Directory to..."` fi PS1="u@h:$PWD :> " } This new `cd' command is compatible with Bashs built-in variant for the case where the specified directory actually exists. When it doesn't, the original `cd' would immediately give an error (assuming we have no CDPATH variable defined). Here this enhanced version tries harder. First it searches for such a directory in a previously built (via cds) $HOME/.cdpaths files. When no line was found, iSelect just returns the given directory as the default result and `cd' then fails as usual with an error message. When only one directory was found, iSelect directly results this particular line to `cd'. And only when more then one directory was found, iSelect opens its Curses-based selection screen and lets the user choose interactively between those directories. The chosen directory is then finally given to `cd'. For more useful examples on how to use iSelect, see the contrib/ directory of the iSelect distribution tarball. AUTHOR
Ralf S. Engelschall rse@engelschall.com www.engelschall.com SEE ALSO
iSelect Home: http://www.ossp.org/pkg/tool/iselect/ EN
2011-09-04 ISELECT(1)
All times are GMT -4. The time now is 02:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy