Sponsored Content
Top Forums Shell Programming and Scripting how do i strip this line using perl regex. Post 302176489 by ramky79 on Tuesday 18th of March 2008 11:11:17 AM
Old 03-18-2008
how do i strip this line using perl regex.

I have a variable dynamically generated
$batch = /dataload/R3P/interface/Bowne/reports/RDI00244.rpt

Now I'd like to strip '/dataload/R3P/interface/Bowne/reports/RDI' and '.rpt' from this variable

my output should be only 00244
how to do this using perl regex.I'm a newbie to perl and would like to know how to do this.

thanks and regards,
Ram.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

strip first 4 and last 2 lines from a file using perl

Hi I have a file from which i need to remove the first 4 and the last 2 lines.. i know how to do it with sed but i need to do it in a perl script.. can you please help me how to do that. Thanks (10 Replies)
Discussion started by: meghana
10 Replies

2. Shell Programming and Scripting

Strip one line from 2 blank lines in a file

Hi Is there any command to scan thru a file looking for 2 consecutive blank lines and if any remove one of them. Please let me know. Regards, Tipsy (6 Replies)
Discussion started by: tipsy
6 Replies

3. Shell Programming and Scripting

Trying to strip some character in perl

I have some character strings and I would like to know how can I remove them using perl. My file contains the following output shown below. An example of a string in the file: + netmck(uid=500)-root + netmck(uid=500)-root + netmck(uid=500)-root + netmck(uid=0)-root . . . I would... (1 Reply)
Discussion started by: smlushing
1 Replies

4. Shell Programming and Scripting

Perl REGEX - How do extract a string in a line?

Hi Guys, In the following line: cn=portal.090710.191533.428571000,cn=groups,dc=mp,dc=rj,dc=gov,dc=br I need to extract this string: portal.090710.191533.428571000 As you can see this string always will be bettween "cn=" and "," strings. Someone know one regular expression to... (4 Replies)
Discussion started by: maverick-ski
4 Replies

5. Shell Programming and Scripting

perl regex multi line cut

hello mighty all there's a file with lots of comments.. some of them looks like: =comment blabla blablabla bla =cut i'm trying to cut this out completely with this code: $line=~s/^=.+?=cut//sg; but no luck also tryed to change it abit but still I don't understand how the... (9 Replies)
Discussion started by: tip78
9 Replies

6. Shell Programming and Scripting

Converting perl regex to sed regex

I am having trouble parsing rpm filenames in a shell script.. I found a snippet of perl code that will perform the task but I really don't have time to rewrite the entire script in perl. I cannot for the life of me convert this code into something sed-friendly: if ($rpm =~ /(*)-(*)-(*)\.(.*)/)... (1 Reply)
Discussion started by: suntzu
1 Replies

7. Shell Programming and Scripting

How to strip '$' sign on the line

echo "dddd$dddd"|sed 's/$//' will return dddd echo "dddd$ddd"|tr -d '$' will return dddd I need to replace it with any other character or just live a blank space instead Thank you! (8 Replies)
Discussion started by: zam
8 Replies

8. Shell Programming and Scripting

Perl regex to remove a segment in a line

Hello, ksh on Sun5.8 here. I have a pipe-delimited, variable length record file with sub-segments identified with a tilda that we receive from a source outside of our control. The records are huge, and Perl seems to be the only shell that can handle the huge lines. I am new to Perl, and am... (8 Replies)
Discussion started by: gary_w
8 Replies

9. Shell Programming and Scripting

Perl, RegEx - Help me to understand the regex!

I am not a big expert in regex and have just little understanding of that language. Could you help me to understand the regular Perl expression: ^(?!if\b|else\b|while\b|)(?:+?\s+){1,6}(+\s*)\(*\) *?(?:^*;?+){0,10}\{ ------ This is regex to select functions from a C/C++ source and defined in... (2 Replies)
Discussion started by: alex_5161
2 Replies
B::Xref(3pm)						 Perl Programmers Reference Guide					      B::Xref(3pm)

NAME
B::Xref - Generates cross reference reports for Perl programs SYNOPSIS
perl -MO=Xref[,OPTIONS] foo.pl DESCRIPTION
The B::Xref module is used to generate a cross reference listing of all definitions and uses of variables, subroutines and formats in a Perl program. It is implemented as a backend for the Perl compiler. The report generated is in the following format: File filename1 Subroutine subname1 Package package1 object1 line numbers object2 line numbers ... Package package2 ... Each File section reports on a single file. Each Subroutine section reports on a single subroutine apart from the special cases "(definitions)" and "(main)". These report, respectively, on subroutine definitions found by the initial symbol table walk and on the main part of the program or module external to all subroutines. The report is then grouped by the Package of each variable, subroutine or format with the special case "(lexicals)" meaning lexical variables. Each object name (implicitly qualified by its containing Package) includes its type character(s) at the beginning where possible. Lexical variables are easier to track and even included dereferencing information where possible. The "line numbers" are a comma separated list of line numbers (some preceded by code letters) where that object is used in some way. Simple uses aren't preceded by a code letter. Introductions (such as where a lexical is first defined with "my") are indicated with the letter "i". Subroutine and method calls are indicated by the character "&". Subroutine definitions are indicated by "s" and format definitions by "f". For instance, here's part of the report from the pod2man program that comes with Perl: Subroutine clear_noremap Package (lexical) $ready_to_print i1069, 1079 Package main $& 1086 $. 1086 $0 1086 $1 1087 $2 1085, 1085 $3 1085, 1085 $ARGV 1086 %HTML_Escapes 1085, 1085 This shows the variables used in the subroutine "clear_noremap". The variable $ready_to_print is a my() (lexical) variable, introduced (first declared with my()) on line 1069, and used on line 1079. The variable $& from the main package is used on 1086, and so on. A line number may be prefixed by a single letter: i Lexical variable introduced (declared with my()) for the first time. & Subroutine or method call. s Subroutine defined. r Format defined. The most useful option the cross referencer has is to save the report to a separate file. For instance, to save the report on myperlprogram to the file report: $ perl -MO=Xref,-oreport myperlprogram OPTIONS
Option words are separated by commas (not whitespace) and follow the usual conventions of compiler backend options. "-oFILENAME" Directs output to "FILENAME" instead of standard output. "-r" Raw output. Instead of producing a human-readable report, outputs a line in machine-readable form for each definition/use of a variable/sub/format. "-d" Don't output the "(definitions)" sections. "-D[tO]" (Internal) debug options, probably only useful if "-r" included. The "t" option prints the object on the top of the stack as it's being tracked. The "O" option prints each operator as it's being processed in the execution order of the program. BUGS
Non-lexical variables are quite difficult to track through a program. Sometimes the type of a non-lexical variable's use is impossible to determine. Introductions of non-lexical non-scalars don't seem to be reported properly. AUTHOR
Malcolm Beattie, mbeattie@sable.ox.ac.uk. perl v5.18.2 2013-11-04 B::Xref(3pm)
All times are GMT -4. The time now is 11:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy