04-24-2008
Ah, more than one way to do it... I too think that "from" is the key here because the XYZ.TABLENAME always follows the word "FROM".
SQLstr =~ /[FROM | from]\s(\w+)\./;
OK so... find FROM (in upper or lowere case) followed by one or more spaces \s followed by one or more WORD \w+ characters (i.e. letters) followed by a literal dot \.
Now the parentheses around \w+ actually captures that part of the match in $1, so next you can substitute that piece alone....
SQLstr =~ s/$1/OWNER/e
The "e" causes the $1 to be EVALUATED so that the resulting string is expanded before the substitution....
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
HI
In my script, i am reading the input from the user and want to find the length of the string.
The input may contain leading spaces. Right now, when leading spaces are there, they are not counted.
Kindly help me
My script is like below. I am using the ksh.
#!/usr/bin/ksh
echo... (2 Replies)
Discussion started by: dayamatrix
2 Replies
2. Shell Programming and Scripting
Hi,
In principle I am searching for a Perl equivalent for this sed command:
sed "/TIM_AM_ARGS=/ s/60/1440/" $EDIT_FILE > $TEMP_FILE
cp $TEMP_FILE $EDIT_FILE
I was wondering if it needs to be like this, or that there other, shorter, alternatives:
open (TIMENVFILE, "<$timenvfile") or die... (5 Replies)
Discussion started by: ejdv
5 Replies
3. Shell Programming and Scripting
find . -type f -name "*.sql" -print|xargs perl -i -pe 's/pattern/replaced/g'
this is simple logic to find and replace in multiple files & folders
Hope this helps.
Thanks
Zaheer (0 Replies)
Discussion started by: Zaheer.mic
0 Replies
4. Shell Programming and Scripting
Hi
Need a perl script to read lines in a file, scan for a string named "APPLE" and write to different file the only lines containing the matched string. (5 Replies)
Discussion started by: PrasannaKS
5 Replies
5. Shell Programming and Scripting
Hi,
I am taking the current time using localtime function in perl. For example if the time is:
#Using localtime
$time = "12:3:10";
I have to replace the value 3 (03) i.e second position to be 03.
The output should be:
12:03:10
But if the other string for example:
$str:... (1 Reply)
Discussion started by: vanitham
1 Replies
6. Linux
Hi all,
I have a question..
Here is my requirement..I have 500 files in a path say /a/b/c
I have some numbers in a file which are comma seperated...and I wanted to check if the numbers are present in the FileName in the path /a/b/c..if the number is there in the file that is fine..but if... (1 Reply)
Discussion started by: us_pokiri
1 Replies
7. Shell Programming and Scripting
I have two files
1. input.txt
2. keyword.txt
input.txt has contents like
.src_ref 0 "call.s" 24 first
0x000000 0x5a80 0x0060 BRA.l 0x60
.src_ref 0 "call.s" 30 first
0x000002 0x1bc5 RETI
.src_ref 0 "call.s" 31 first
0x000003 0x6840 ... (2 Replies)
Discussion started by: acdc
2 Replies
8. Shell Programming and Scripting
Hello
I would like to get know how to do this:
I got a big file (about 1GB) and I need to find a string (for instance by grep )
and then find all records in this file based on a string.
Thanks for advice.
Martin (12 Replies)
Discussion started by: mape
12 Replies
9. Shell Programming and Scripting
Hello Forum.
I have a file called abc.sed with the following commands;
s/1/one/g
s/2/two/g
...
I also have a second file called abc.dat and would like to substitute all occurrences of "1 with one", "2 with two", etc and create a new file called abc_new.dat
sed -f abc.sed abc.dat >... (10 Replies)
Discussion started by: pchang
10 Replies
10. Shell Programming and Scripting
Trying to find and replace one string with another string in a file
#!/usr/bin/perl
$csd_table_path = "/file.ntab";
$find_str = '--bundle_type=021';
$repl_str = '--bundle_type=021 --target=/dev/disk1s2';
if( system("/usr/bin/perl -p -i -e 's/$find_str/$repl_str/' $csd_table_path")... (2 Replies)
Discussion started by: cillmor
2 Replies
LEARN ABOUT PHP
fbsql_query
FBSQL_QUERY(3) 1 FBSQL_QUERY(3)
fbsql_query - Send a FrontBase query
SYNOPSIS
resource fbsql_query (string $query, [resource $link_identifier], [int $batch_size])
DESCRIPTION
Sends a $query to the currently active database on the server.
If the query succeeds, you can call fbsql_num_rows(3) to find out how many rows were returned for a SELECT statement or
fbsql_affected_rows(3) to find out how many rows were affected by a DELETE, INSERT, REPLACE, or UPDATE statement.
PARAMETERS
o $query
- The SQL query to be executed.
Note
The query string shall always end with a semicolon.
o $
link_identifier -A FrontBase link identifier returned by fbsql_connect(3) or fbsql_pconnect(3).If optional and not specified, the
function will try to find an open link to the FrontBase server and if no such link is found it will try to create one as if
fbsql_connect(3) was called with no arguments.
o $batch_size
-
RETURN VALUES
fbsql_query(3) returns TRUE (non-zero) or FALSE to indicate whether or not the query succeeded. A return value of TRUE means that the query
was legal and could be executed by the server. It does not indicate anything about the number of rows affected or returned. It is perfectly
possible for a query to succeed but affect no rows or return no rows.
For SELECT statements, fbsql_query(3) returns a new result identifier that you can pass to fbsql_result(3).
fbsql_query(3) will also fail and return FALSE if you don't have permission to access the table(s) referenced by the query.
EXAMPLES
The following query is syntactically invalid, so fbsql_query(3) fails and returns FALSE:
Example #1
fbsql_query(3) example
<?php
$result = fbsql_query("SELECT * WHERE 1=1")
or die ("Invalid query");
?>
The following query is semantically invalid if my_col is not a column in the table my_tbl, so fbsql_query(3) fails and returns FALSE:
Example #2
fbsql_query(3) example
<?php
$result = fbsql_query ("SELECT my_col FROM my_tbl;")
or die ("Invalid query");
?>
SEE ALSO
fbsql_affected_rows(3), fbsql_db_query(3), fbsql_free_result(3), fbsql_result(3), fbsql_select_db(3), fbsql_connect(3).
PHP Documentation Group FBSQL_QUERY(3)