![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to get the string stored in a variable in a line??? | jisha | Shell Programming and Scripting | 4 | 04-05-2008 01:50 PM |
| function call | kamel.seg | Shell Programming and Scripting | 2 | 12-28-2007 02:58 PM |
| call function | Jamil Qadir | Shell Programming and Scripting | 4 | 03-20-2007 05:07 AM |
| Help with a function call | Stevhp | High Level Programming | 6 | 03-05-2007 02:44 AM |
| function call | forever_49ers | Shell Programming and Scripting | 3 | 09-13-2006 07:26 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi All
I have written code for storing data in a string based on pattern. whenever i tried to use in a function call its not getting there. Actually the same logic was applied for another string..then i can use the string at any function. the code goes like this /mp metadata/{ start=index($0,"metadata"); if ($2=="metadata") flow_string=substr($0,start); print(flow_string); } I can print the data in this search block If i tried to use in any function the data in the flow_string is not retrieving like function retrieve_data(){ print(flow_string); } It is not working.. but the same thing is working for some other pattern. Please can anyone have an idea whats may be the reason that iam not able to use that string..any globally declaration is need to be done.. for one string the logic is working and why its not working for other string? while parsing data any problem? please help me out... |
|
||||
|
Whatever the reason, an improvement (not merely a workaround!) would be to make sure you always use local variables in functions. This is a basic principle of modular coding; it helps keep code complexity down and reduces the risk that you end up with spaghetti code.
So, in other words, refactor retrieve_data() so that it receives the flow_string as an argument. (We infer from the syntax that this is awk you are talking about.) |
![]() |
| Bookmarks |
| Tags |
| awk, awk function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|