Sponsored Content
Top Forums Shell Programming and Scripting Take each number in table row and find the difference from the corresponding line Post 302385862 by kristinu on Sunday 10th of January 2010 11:01:36 AM
Old 01-10-2010
It works ok, but there is a feature I never encountered before. What's the purpose of the 1 at the end. Without it does not work when I redirect the output to a file. So it must be quite important!!!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

To find the Row number

Hi Can any one tell me what is the command to find out the row id or row number for a particular record Thanks sri (6 Replies)
Discussion started by: laxmi131
6 Replies

2. Shell Programming and Scripting

search for difference and find the above line

hello All, i have to two files package.today and package.yesterday , the extension of the files says what day the file belongs to . contents of the file change little bit everyday . i am taking only the package and sub package from the files awk '/^/{print $0}' Packages.today 82 ... (0 Replies)
Discussion started by: posner
0 Replies

3. UNIX for Dummies Questions & Answers

Shell Script: Traverse Database Table Row by Row

Hello Everyone, My issue is that I want to traverse a database table row by row and do some action on the value retrieved in each row. I have gone through a lot of shell script questions/posts. I could find row by row traversal of a file but not a database table. Please help. Thanks &... (5 Replies)
Discussion started by: ahsan.asghar
5 Replies

4. Shell Programming and Scripting

The difference between end number in the early row and the start number in the next

Hi Power User, I'm trying to compute this kind of text file format: file1: jakarta 100 150 jakarta 170 210 beijing 220 250 beijing 260 280 beijing 290 320 new_york 330 350 new_york 370 420 tokyo 430 470 tokyo 480 ... (2 Replies)
Discussion started by: anjas
2 Replies

5. Shell Programming and Scripting

Moving new row and deleting old row to another table

Hi, I want to move a new row to another table if the field from new row doesn't have the first word that I categorized (like: IRC blablabla, PTM blablabla, ADM blablabla, BS blablabla). I already use this script but doesn't work as I expected. CHECK_KEYWORD="$( mysql -uroot -p123456 smsd -N... (7 Replies)
Discussion started by: jazzyzha
7 Replies

6. Shell Programming and Scripting

In php, Moving a new row to another table and deleting old row

Hi, I already succeed moving a new row to another table if the field from new row doesn't have the first word that I categorized (like: IRC blablabla, PTM blablabla, ADM blablabla, BS blablabla). But it can't delete the old row. Please help me with the script. my php script: INSERT INTO... (2 Replies)
Discussion started by: jazzyzha
2 Replies

7. Shell Programming and Scripting

awk to convert table-by-row to matrix table

Hello, I need some help to reformat this table-by-row to matrix? infile: site1 A:o,p,q,r,s,t site1 C:y,u site1 T:v,w site1 -:x,z site2 A:p,r,t,v,w,z site2 C:u,y site2 G:q,s site2 -:o,x site3 A:o,q,s,t,u,z site3 C:y site3 T:v,w,x site3 -:p,routfile: SITE o p q r s t v u w x y... (7 Replies)
Discussion started by: yifangt
7 Replies

8. Shell Programming and Scripting

Get row number from file1 and print that row of file2

Hi. How can we print those rows of file2 which are mentioned in file1. first character of file1 is a row number.. for eg file1 1:abc 3:ghi 6:pqr file2 a abc b def c ghi d jkl e mno f pqr ... (6 Replies)
Discussion started by: Abhiraj Singh
6 Replies

9. Shell Programming and Scripting

awk to find number in a field then print the line and the number

Hi I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field. The source file is pipe delimited and looks something like 1|net|ABC Letr1|1530||| 1|net|EXP_1040 ABC|1121||| 1|net|EXP_TG1224|1122||| 1|net|R_North|1123|||... (5 Replies)
Discussion started by: Mudshark
5 Replies

10. Shell Programming and Scripting

How do we display specific row of an output from bottom given line number?

I pass a number to my script. Passing "1" below. ./getfile.sh 1 echo "User entered: $1" ls -ltr *.conf | sed -n '$p' I wish to use ls -ltr i.e list files in ascending order of time the latest showing at the bottom of the output. Number 1 should get me the last row of ls -ltr output i.e... (9 Replies)
Discussion started by: mohtashims
9 Replies
CGI::Application::Plugin::Forward(3pm)			User Contributed Perl Documentation		    CGI::Application::Plugin::Forward(3pm)

NAME
CGI::Application::Plugin::Forward - Pass control from one run mode to another VERSION
Version 1.06 SYNOPSIS
use base 'CGI::Application'; use CGI::Application::Plugin::Forward; sub setup { my $self = shift; $self->run_modes([qw( start second_runmode )]); } sub start { my $self = shift; return $self->forward('second_runmode'); } sub second_runmode { my $self = shift; my $rm = $self->get_current_runmode; # 'second_runmode' } DESCRIPTION
The forward method passes control to another run mode and returns its output. This is equivalent to calling "$self->$other_runmode", except that CGI::Application's internal value of the current run mode is updated. This means that calling "$self->get_current_runmode" after calling "forward" will return the name of the new run mode. This is useful for modules that depend on the name of the current run mode such as CGI::Application::Plugin::AnyTemplate. For example, here's how to pass control to a run mode named "other_action" from "start" while updating the value of "current_run_mode": sub setup { my $self = shift; $self->run_modes({ start => 'start', other_action => 'other_method', }); } sub start { my $self = shift; return $self->forward('other_action'); } sub other_method { my $self = shift; my $rm = $self->get_current_runmode; # 'other_action' } Note that forward accepts the name of the run mode (in this case 'other_action'), which might not be the same as the name of the method that handles the run mode (in this case 'other_method') You can still call "$self->other_method" directly, but "current_run_mode" will not be updated: sub setup { my $self = shift; $self->run_modes({ start => 'start', other_action => 'other_method', }); } sub start { my $self = shift; return $self->other_method; } sub other_method { my $self = shift; my $rm = $self->get_current_runmode; # 'start' } Forward will work with coderef-based runmodes as well: sub setup { my $self = shift; $self->run_modes({ start => 'start', anon_action => sub { my $self = shift; my $rm = $self->get_current_runmode; # 'anon_action' }, }); } sub start { my $self = shift; return $self->forward('anon_action'); } FORWARD vs. REDIRECT Calling "forward" changes the run mode of your application, but it stays within the same HTTP request. To redirect to a new runmode using a completely new web request, you might consider using the "redirect" method provided by CGI::Application::Plugin::Redirect. The advantage of using an external redirect as opposed to an internal forward is that it provides a 'clean break' between pages. For instance, in a typical BREAD application (Browse, Read, Edit, Add, Delete), after the user completes an action, you usually return the user to the Browse list. For instance, when the user adds a new record via a POST form, and your app returns them to the list of records. If you use "forward", then you are still in the same request as the original add record. The user might hit reload, expecting to refresh the list of records. But in fact, reload will attempt to repost the add record form. The user's browser might present a warning about reposting the same data. The browser may refuse to redisplay the page, due for caching reasons. So in this case, it may make more sense to do a fresh HTTP redirect back to the Browse list. METHODS
forward Runs another run mode passing any parameters you supply. Returns the output of the new run mode. return $self->forward('run_mode_name', @run_mode_params); HOOKS
Before the forwarded run mode is called, the "forward_prerun" hook is called. You can use this hook to do any prep work that you want to do before any new run mode gains control. This is similar to CGI::Application's built in "cgiapp_prerun" method, but it is called each time you call forward; not just the when your application starts. sub setup { my $self = shift; $self->add_callback('forward_prerun' => &prepare_rm_stuff); } sub prepare_rm_stuff { my $self = shift; # do any necessary prep work here.... } Note that your hooked method will only be called when you call forward. If you never call "forward", the hook will not be called. In particuar, the hook will not be called for your application's "start_mode". For that, you still use "cgiapp_prerun". If you want to have a method run for every run mode including the "start_mode", then you can call the hook directly from "cgiapp_prerun". sub setup { my $self = shift; $self->add_callback('forward_prerun' => &prepare_rm_stuff); } sub cgiapp_prerun { my $self = shift; $self->prepare_rm_stuff; } sub prepare_rm_stuff { my $self = shift; # do any necessary prep work here.... } Alternately, you can hook "cgiapp_prerun" to the "forward_prerun" hook: sub setup { my $self = shift; $self->add_callback('forward_prerun' => &cgiapp_prerun); } sub cgiapp_prerun { my $self = shift; # do any necessary prep work here.... } This is a less flexible solution, since certain things that can be done in "cgiapp_prerun" (like setting "prerun_mode") won't work when the method is called from the "forward_prerun" hook. AUTHOR
Michael Graham, "<mag-perl@occamstoothbrush.com>" BUGS
Please report any bugs or feature requests to "bug-cgi-application-plugin-forward@rt.cpan.org", or through the web interface at <http://rt.cpan.org>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. ACKNOWLEDGEMENTS
Thanks to Mark Stosberg for the idea and...well...the implementation as well. COPYRIGHT &; LICENSE Copyright 2005 Michael Graham, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2011-06-28 CGI::Application::Plugin::Forward(3pm)
All times are GMT -4. The time now is 11:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy