Sponsored Content
Top Forums Shell Programming and Scripting perl: storing regex in array variables trouble Post 302230350 by xist on Friday 29th of August 2008 06:13:41 AM
Old 08-29-2008
perl: storing regex in array variables trouble

hi
this is an example of code:
Code:
use strict;
use warnings;
open FILE, "/tmp/result_2";
my $regex="\\[INFO\\] Starting program ver. (.*)";
my $res="Program started, version <$1> - OK.\n";
while (<FILE>) {
if ($_ =~ /($regex)/) {
   print "$res";
    }
}
close FILE;

This finds $regex and print out the $res, but "$1" doesn't work. I've tried <\$1> as well and other variations. How to make it work? Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

storing variables in array.Please help

Hi All, I need some help with arrays. I need to take input from the user for hostname, username and password until he enters .(dot) or any other character and store the values in the variable array. I would further connect to the hostname using username and passwd and copy files from server to... (7 Replies)
Discussion started by: nua7
7 Replies

2. Shell Programming and Scripting

Perl Array Variables to be returned to main

Hi All, I can;t seem to print out the array in sequence using the below subroutine. My first element in the array @lotsuffix is suppose to be $lotsuffix as defined in the subroutine, but when the array variable is being pass on the main program, my first element actually becomes $lotsuffix ! ... (4 Replies)
Discussion started by: Raynon
4 Replies

3. Shell Programming and Scripting

date capturing regex and storing

Hi all I need help on how to store two or more date formates captured using regex from an input sentence in PERL ? For example, I have an input sentence consisting of two dates such as : The departure date is August 12, 2009 and arrival date is 20.08.2009. Now, I want to capture the two... (4 Replies)
Discussion started by: my_Perl
4 Replies

4. UNIX for Dummies Questions & Answers

Trouble with grouping regex

Hi Forum im trying to use grouping in a regex statement in a function in a script this is the criteria im trying to match :It MUST have 3 character at the beginning. After that it can have a mix of spaces,alpha-numeric and dashes in any order eg HUG this-stuff, FGU taylor-8-shoes, ZDFnintendo... (2 Replies)
Discussion started by: ShinTec
2 Replies

5. Shell Programming and Scripting

Perl regex and sort trouble

Hi so I have these files where the first thing in them says something along the lines of "This document was accessed 'date' blah blah", I was thinking of a way to extract that date and then sort the files based on that date. My question is how do I get rid of the words in that statement so that... (6 Replies)
Discussion started by: vas28r13
6 Replies

6. Shell Programming and Scripting

Storing data in perl 2D array

Respected All, Kindly help me out. I have got file listings in a directory like this: -rw-r--r-- 1 root root 115149 2011-11-17 07:15 file1.stat.log -rw-r--r-- 1 root root 115149 2011-11-18 08:15 file2.stat.log -rw-r--r-- 1 root root 115149 2011-11-19 09:15 file3.stat.log -rw-r--r-- 1... (2 Replies)
Discussion started by: teknokid1
2 Replies

7. Shell Programming and Scripting

perl : searching for month and storing the date and time in an array

I am writing the code in perl. I have an array in perl and each variable in the array contains the data in the below format Now I need to check the below variable w.r.t system month I need to store the date and time(Tue Aug 7 03:54:12 2012) from the below data into file if contains only 'Aug'... (5 Replies)
Discussion started by: giridhar276
5 Replies

8. Shell Programming and Scripting

Storing the SQL results in array variables

Requirement 1) I need to execute 15 SQL queries in oracle through linux script. All these query results needs to be stored in array variables. Requirement 2) And these 15 queries needs to be executed in parallel. Requirement 3) Once all the queries executed then the shell script should... (3 Replies)
Discussion started by: Niranjancse
3 Replies

9. Shell Programming and Scripting

Bash 3.2 - Array / Regex - IF 3rd member in array ends in 5 digits then do somthing...

Trying to do some control flow parsing based on the index postion of an array member. Here is the pseudo code I am trying to write in (preferably in pure bash) where possible. I am thinking regex with do the trick, but need a little help. pesudo code if == ENDSINFIVEINTS ]]; then do... (4 Replies)
Discussion started by: briandanielz
4 Replies

10. Shell Programming and Scripting

Storing the Linux command output to an array in perl script

Hi I am trying to store the output of a command into an array in perl script. I am able to store but the problem is i am unable to print the array line with one line space. i mean i inserted the \n in loop ...but not getting the result. I have written like this #!/usr/bin/perl @a =... (2 Replies)
Discussion started by: kumar85shiv
2 Replies
Data::FormValidator::ConstraintsFactory(3pm)		User Contributed Perl Documentation	      Data::FormValidator::ConstraintsFactory(3pm)

NAME
Data::FormValidator::ConstraintsFactory - Module to create constraints for HTML::FormValidator. DESCRIPTION
This module contains functions to help generate complex constraints. If you are writing new code, take a look at Data::FormValidator::Constraints::MethodsFactory instead. It's a modern alternative to what's here, offering improved names and syntax. SYNOPSIS
use Data::FormValidator::ConstraintsFactory qw( :set :bool ); constraints => { param1 => make_or_constraint( make_num_set_constraint( -1, ( 1 .. 10 ) ), make_set_constraint( 1, ( 20 .. 30 ) ), ), province => make_word_set_constraint( 1, "AB QC ON TN NU" ), bid => make_range_constraint( 1, 1, 10 ), } BOOLEAN CONSTRAINTS
Those constraints are available by using the ":bool" tag. make_not_constraint( $c1 ) This will create a constraint that will return the negation of the result of constraint $c1. make_or_constraint( @constraints ) This will create a constraint that will return the result of the first constraint that return an non false result. make_and_constraint( @constraints ) This will create a constraint that will return the result of the first constraint that return an non false result only if all constraints returns a non-false results. SET CONSTRAINTS
Those constraints are available by using the ":set" tag. make_set_constraint( $res, @elements ) This will create a constraint that will return $res if the value is one of the @elements set, or the negation of $res otherwise. The "eq" operator is used for comparison. make_num_set_constraint( $res, @elements ) This will create a constraint that will return $res if the value is one of the @elements set, or the negation of $res otherwise. The "==" operator is used for comparison. make_word_set_constraint( $res, $set ) This will create a constraint that will return $res if the value is a word in $set, or the negation of $res otherwise. make_cmp_set_constraint( $res, $cmp, @elements ) This will create a constraint that will return $res if the value is one of the @elements set, or the negation of $res otherwise. $cmp is a function which takes two argument and should return true or false depending if the two elements are equal. NUMERICAL LOGICAL CONSTRAINTS
Those constraints are available by using the ":num" tag. make_clamp_constraint( $res, $low, $high ) This will create a constraint that will return $res if the value is between $low and $high bounds included or its negation otherwise. make_lt_constraint( $res, $bound ) This will create a constraint that will return $res if the value is lower than $bound, or the negation of $res otherwise. make_le_constraint( $res, $bound ) This will create a constraint that will return $res if the value is lower or equal than $bound, or the negation of $res otherwise. make_gt_constraint( $res, $bound ) This will create a constraint that will return $res if the value is greater than $bound, or the negation of $res otherwise. make_ge_constraint( $res, $bound ) This will create a constraint that will return $res if the value is greater or equal than $bound, or the negation of $res otherwise. OTHER CONSTRAINTS
make_length_constraint($max_length) This will create a constraint that will return true if the value has a length of less than or equal to $max_length SEE ALSO
Data::FormValidator(3) AUTHOR
Author: Francis J. Lacoste <francis.lacoste@iNsu.COM> Maintainer: Mark Stosberg <mark@summersault.com> COPYRIGHT
Copyright (c) 2000 iNsu Innovations Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms as perl itself. perl v5.14.2 2011-11-25 Data::FormValidator::ConstraintsFactory(3pm)
All times are GMT -4. The time now is 11:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy