Sponsored Content
Top Forums Shell Programming and Scripting Perl script to search and extract using wildcards. Post 302308454 by Mumford on Saturday 18th of April 2009 11:32:23 AM
Old 04-18-2009
Drop boundaries on the regex and replace the .* with a less greedy \S*:
Code:
#!/usr/bin/perl -w

$test = "xx1.p  xx2.r \n (xx3.p) ( xx4.p ) \n xx5.r xx.p.pxx \n asdfxx.p \n xxix
iadsf.xx.p  \n xx4.p {xx5.p}   (  xx6.p)";

while ($test =~ /\b(xx\S*\.p)\b/g) {
       print "$1\n";
}

Output:
xx1.p
xx3.p
xx4.p
xxixiadsf.xx.p
xx4.p
xx5.p
xx6.p

I'm with KevinADC... I'm a bit confused how asdfxx.p is expected to be part of the output when you say "of a files beginning with xx".
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using wildcards in this perl command

Hi there, is it possible to use wild cards in this statement ssh $remote_server 'perl -pi -e "s,EXP_SERIAL_19b8be67=\"\",EXP_SERIAL_`hostid`=\"UNKNOWN\"," /var/myfile' This command works fine but the bit in bold (the 8 character hostid) will not always be 19b8be67 so I was hoping I could... (2 Replies)
Discussion started by: hcclnoodles
2 Replies

2. Shell Programming and Scripting

Perl Script Syntax to Extract Everything After Special Character

Hi, I am writing a Perl script that reads in many lines, if a line meets the criteria I want to edit, it. For example, the script will return the following example line... test=abc123 All I want to do is strip off the "test=" and just be left with the abc123. In my script I can easily... (3 Replies)
Discussion started by: edrichard
3 Replies

3. Shell Programming and Scripting

Perl script to extract 'ID' From XML File

File1.xml <?xml version.........> - <abcd:abcd_list version="1" www.john_uncle's_server.com" xmlns: - <device id="100"> <firmware>12.4(3d)</firmware> <location id="500">Sitting Room</location> </device> - <device id="101"> <firmware>12.4(3d)</firmware> <location id="501">Class... (1 Reply)
Discussion started by: sureshcisco
1 Replies

4. Shell Programming and Scripting

Perl, open multiple files with wildcards

I have a question regarding Perl scripting. If I want to say open files that all look like this and assign them to a filehandle and then assign the filehandle to a variable, how do I do this? The file names are strand1.fa.gz.tmp strand2.fa.gz.tmp strand3.fa.gz.tmp strand4.fa.gz.tmp ...... (6 Replies)
Discussion started by: japaneseguitars
6 Replies

5. Shell Programming and Scripting

Perl script to extract second column from a xls

Can Anyone tell me how to extract the second column of a xls sheet And compare the content of each row of the column with a .h file. xls sheet is having only one spreadsheet. (2 Replies)
Discussion started by: suvenduperl
2 Replies

6. Shell Programming and Scripting

Perl - grep issue in filenames with wildcards

Hi I have 2 directories t1 and t2 with some files in it. I have to see whether the files present in t1 is also there in t2 or not. Currently, both the directories contain the same files as shown below: $ABC.TXT def.txt Now, when I run the below script, it tells def.txt is found,... (5 Replies)
Discussion started by: guruprasadpr
5 Replies

7. Shell Programming and Scripting

Script to search and extract the gene sub-location from gff file.

Hi, my problem is that I have two files. File no. 1 is a gff text file (say gi1) that has gene information like : ******************** gene 39389788..39395643 /gene="RPSA" /note="Derived by automated computational analysis using ... (2 Replies)
Discussion started by: reena2305
2 Replies

8. Shell Programming and Scripting

Search for a pattern,extract value(s) from next line, extract lines having those extracted value(s)

I have hundreds of files to process. In each file I need to look for a pattern then extract value(s) from next line and then search for value(s) selected from point (2) in the same file at a specific position. HEADER ELECTRON TRANSPORT 18-MAR-98 1A7V TITLE CYTOCHROME... (7 Replies)
Discussion started by: AshwaniSharma09
7 Replies

9. Shell Programming and Scripting

Perl script to extract a word from the file

Hi everyone, I'm a perl newbie and need your help to extract a word inside the list of files with same pattern. <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ns2:mycode xmlns:ns2="http://www.abcd.com/pqrs/acfSchema-2007a.xsd"> <id>10</id> <name>PaymentServices</name> ... (7 Replies)
Discussion started by: jhamaks
7 Replies

10. Shell Programming and Scripting

Need to extract characters between two search words in a script!!

Hi, I have a log file which is the output from a xml script : <?xml version="1.0" ?> <!DOCTYPE svc_result SYSTEM "MLP_SVC_RESULT_320.DTD"> <svc_result ver="3.2.0"> <slia ver="3.0.0"> <pos> <msid type="MSISDN" enc="ASC">8093078040</msid> <poserr> ... (4 Replies)
Discussion started by: arjunstarz
4 Replies
PERLIVP(1)						 Perl Programmers Reference Guide						PERLIVP(1)

NAME
perlivp - Perl Installation Verification Procedure SYNOPSIS
perlivp [-p] [-v] [-h] DESCRIPTION
The perlivp program is set up at Perl source code build time to test the Perl version it was built under. It can be used after running: make install (or your platform's equivalent procedure) to verify that perl and its libraries have been installed correctly. A correct installation is verified by output that looks like: ok 1 ok 2 etc. OPTIONS
-h help Prints out a brief help message. -p print preface Gives a description of each test prior to performing it. -v verbose Gives more detailed information about each test, after it has been performed. Note that any failed tests ought to print out some extra information whether or not -v is thrown. DIAGNOSTICS
o print "# Perl binary '$perlpath' does not appear executable. "; Likely to occur for a perl binary that was not properly installed. Correct by conducting a proper installation. o print "# Perl version '$]' installed, expected $ivp_VERSION. "; Likely to occur for a perl that was not properly installed. Correct by conducting a proper installation. o print "# Perl @INC directory '$_' does not appear to exist. "; Likely to occur for a perl library tree that was not properly installed. Correct by conducting a proper installation. o print "# Needed module '$_' does not appear to be properly installed. "; One of the two modules that is used by perlivp was not present in the installation. This is a serious error since it adversely affects perlivp's ability to function. You may be able to correct this by performing a proper perl installation. o print "# Required module '$_' does not appear to be properly installed. "; An attempt to "eval "require $module"" failed, even though the list of extensions indicated that it should succeed. Correct by conducting a proper installation. o print "# Unnecessary module 'bLuRfle' appears to be installed. "; This test not coming out ok could indicate that you have in fact installed a bLuRfle.pm module or that the "eval " require "$module_name.pm"; "" test may give misleading results with your installation of perl. If yours is the latter case then please let the author know. o print "# file",+($#missing == 0) ? '' : 's'," missing from installation: "; One or more files turned up missing according to a run of "ExtUtils::Installed -> validate()" over your installation. Correct by conducting a proper installation. For further information on how to conduct a proper installation consult the INSTALL file that comes with the perl source and the README file for your platform. AUTHOR
Peter Prymmer perl v5.18.2 2018-08-17 PERLIVP(1)
All times are GMT -4. The time now is 05:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy