Sponsored Content
Top Forums Shell Programming and Scripting Add double quotes to the words after given pattern Post 303027501 by mac-arrow on Monday 17th of December 2018 10:49:40 AM
Old 12-17-2018
Add double quotes to the words after given pattern

Hi,

I have a text file with different results and I would like to add single quotes to the value after the given pattern '='

This would be the original text file:
Code:
user_id=7492 and key=clickid;
user_id=7867 and key=clickid;
user_id=8649 and key=clickid;

And I would like the output to be like that:
Code:
user_id='7492' and key='clickid';
user_id='7867' and key='clickid';
user_id='8649' and key='clickid';

I will appreciate any help Smilie

Regards

Last edited by mac-arrow; 12-17-2018 at 12:03 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Double quotes or single quotes when using ssh?

I'm not very familiar with the ssh command. When I tried to set a variable and then echo its value on a remote machine via ssh, I found a problem. For example, $ ITSME=itsme $ ssh xxx.xxxx.xxx.xxx "ITSME=itsyou; echo $ITSME" itsme $ ssh xxx.xxxx.xxx.xxx 'ITSME=itsyou; echo $ITSME' itsyou $... (3 Replies)
Discussion started by: password636
3 Replies

2. Shell Programming and Scripting

Add double quotes around the string

I have a line in multiple scripts:select into table /dir1/dir2/file.dat dir1 and dir2 are the same but file.dat is different from script to script. I need to include /dir1/dir2/file.dat into double quotes in each file of my directory:select into table "/dir1/dir2/file.dat" (13 Replies)
Discussion started by: surfer515
13 Replies

3. Shell Programming and Scripting

print pattern within double quotes

Hi All, I have multiple lines in a file like:- "abc" def "ghi" jkl "mno" 1 I want to print in output:- abc/ghi/mno 1 How can I do this in perl? Regrds, Nilabh -----Post Update----- Additional info:- The last field of the file should be output as it is.In the above example 1 is... (6 Replies)
Discussion started by: nilabh_s
6 Replies

4. Shell Programming and Scripting

Single quotes and double quotes

Hi guys, I have a sed line in double quotes which works fine, but I want it to be in single quotes here is the sed line sed "/abc_def/s/\'.*\'/\'\${abc_def}\'/" can some one give the equivalent to the above script in single quotes Thanks a ton (5 Replies)
Discussion started by: sol_nov
5 Replies

5. UNIX for Dummies Questions & Answers

grep single quotes or double quotes

Unix superusers, I am new to unix but would like to learn more about grep. I am very familiar with regular expressions as i have used them for searching text files in windows based text editors. Since I am not very familiar with Unix, I dont understand when one should use GREP with the... (2 Replies)
Discussion started by: george_vandelet
2 Replies

6. Shell Programming and Scripting

Enclose words between double quotes

My input is like this: this is a test line. I want my output to be like this: "this", "is", "a", "test", "line" Any idea how this can be done in Linux? (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

7. Shell Programming and Scripting

Issue with Single Quotes and Double Quotes for prompt PS1

Hi, Trying to change the prompt. I have the following code. export PS1=' <${USER}@`hostname -s`>$ ' The hostname is not displayed <abc@`hostname -s`>$ uname -a AIX xyz 1 6 00F736154C00 <adcwl4h@`hostname -s`>$ If I use double quotes, then the hostname is printed properly but... (3 Replies)
Discussion started by: bobbygsk
3 Replies

8. Shell Programming and Scripting

How to pass two words within double quotes as variable?

Hi All, OS - Suse 10 ksh --version version sh (AT&T Research) 93s+ 2008-01-31 I am passing two words within double quotes ("Application Developer") to script as variable, but script is adding two single quotes between two words like ("Application' 'Developer"). below is simple test... (4 Replies)
Discussion started by: srimitta
4 Replies

9. Shell Programming and Scripting

Replace Double quotes within double quotes in a column with space while loading a CSV file

Hi All, I'm unable to load the data using sql loader where there are double quotes within the double quotes As these are optionally enclosed by double quotes. Sample Data : "221100",138.00,"D","0019/1477","44012075","49938","49938/15043000","Television - 22" Refurbished - Airwave","Supply... (6 Replies)
Discussion started by: mlavanya
6 Replies

10. Shell Programming and Scripting

sed add double quotes and comma

Hi, 00000119EEEC3F25 feedoor 20171103 0000011A4F152077 feedard 20171024 00000191FA295F61 feedzipperhola 20171023 00000213C57BB856 feedriodapple 20171005 0000025F778EF9D5 joobakoolrk 20171004 I needed the result as: "00000119EEEC3F25", "feedoor", ... (9 Replies)
Discussion started by: ashokvpp
9 Replies
HTML::FormHandler::Manual::Catalyst(3pm)		User Contributed Perl Documentation		  HTML::FormHandler::Manual::Catalyst(3pm)

NAME
HTML::FormHandler::Manual::Catalyst - using HFH forms in Catalyst VERSION
version 0.40013 SYNOPSIS
Manual Index This part of the FormHandler Manual describes the use of the HTML::FormHandler package in Catalyst controllers. See the other FormHandler documentation at HTML::FormHandler::Manual, or the base class at HTML::FormHandler. DESCRIPTION
Although HTML::FormHandler can be used in any Perl web application, module, or script, one of its most common uses is in Catalyst applications. Using a form takes only a few lines of code, so it's not necessary to have a Catalyst base controller, although you could make a base controller for FormHandler if you're doing more than the basics. A Controller Example The following example uses chained dispatching. The 'form' method is called by both the create and edit actions. package BookDB::Controller::Borrower; use Moose; BEGIN { extends 'Catalyst::Controller' } sub borrower_base : Chained PathPart('borrower') CaptureArgs(0) { } sub list : Chained('borrower_base') PathPart('list') Args(0) { my ( $self, $c ) = @_; my $borrowers = [ $c->model('DB::Borrower')->all ]; my @columns = ( 'name', 'email' ); $c->stash( borrowers => $borrowers, columns => @columns, template => 'borrower/list.tt' ); } sub add : Chained('borrower_base') PathPart('add') Args(0) { my ( $self, $c ) = @_; # Create the empty borrower row for the form $c->stash( borrower => $c->model('DB::Borrower')->new_result({}) ); return $self->form($c); } sub item : Chained('borrower_base') PathPart('') CaptureArgs(1) { my ( $self, $c, $borrower_id ) = @_; $c->stash( borrower => $c->model('DB::Borrower')->find($borrower_id) ); } sub edit : Chained('item') PathPart('edit') Args(0) { my ( $self, $c ) = @_; return $self->form($c); } sub form { my ( $self, $c ) = @_; my $form = BookDB::Form::Borrower->new; $c->stash( form => $form, template => 'borrower/form.tt' ); return unless $form->process( item => $c->stash->{borrower}, params => $c->req->parameters ); $c->res->redirect( $c->uri_for($self->action_for('list')) ); } sub delete : Chained('item') PathPart('delete') Args(0) { my ( $self, $c ) = @_; $c->stash->{borrower}->delete; $c->res->redirect( $c->uri_for($c->action_for('list')) ); } 1; Another way to set up your form If you are setting the schema or other form attributes (such as the user_id, or other attributes) on your form you could create a base controller that would set these in the form on each call using Catalyst::Component::InstancePerContext, or set them in a base Chained method. sub book_base : Chained PathPart('book') CaptureArgs(0) { my ( $self, $c ) = @_; my $form = MyApp::Form->new; $form->schema( $c->model('DB')->schema ); $form->params( $c->req->parameters ); $form->user_id( $c->user->id ); $c->stash( form => $form ); } Then you could just pass in the item_id when the form is processed. return unless $c->stash->{form}->process( item_id => $id ); Putting a form in a Moose attribute You can also put your form in a Moose attribute in the controller. package MyApp::Controller::Book; use Moose; BEGIN { extends 'Catalyst::Controller'; } use MyApp::Form::Book; has 'edit_form' => ( isa => 'MyApp::Form::Book', is => 'rw', lazy => 1, default => sub { MyApp::Form::Book->new } ); Then you can process the form in your actions with "$self->edit_form->process( params => $c->req->body_parameters );" or "my $result = $self->edit_form->run( params => $c->req->body_parameters );". Using HTML::FillInForm If you want to use HTML::FillInForm to fill in values instead of doing it in directly in a template using either the field or the form 'fif' methods, you can use Catalyst::View::FillInForm on your view class: package MyApp::View::TT; use Moose; with 'Catalyst::View::FillInForm'; .... 1; and set the 'fif' hash in the 'fillinform' stash variable: $self->form->process( ... ); $c->stash( fillinform => $self->form->fif ); return unless $form->validated; When the 'fillinform' stash variable is set, HTML::FillInForm will automatically be used by your view to fill in the form values. This can be very helpful when you want to build your forms by hand, or when you have legacy forms that you're just trying to hook up to FormHandler. The Catalyst context FormHandler has a 'ctx' attribute that can be used to set the Catalyst context (or anything you want, really). But if you can avoid passing in the context, you should do so, because you're mixing up your MVC and it makes it much more difficult to test your forms. But if you need to do it, you can: my $form = MyApp::Form->new( ctx => $c ); Usually you should prefer to add new attributes to your form: package MyApp::Form; use HTML::FormHandler::Moose; extends 'HTML::FormHandler'; has 'user_id' => ( is => 'rw' ); has 'hostname' => ( is => 'rw' ); has 'captcha_store' => ( is => 'rw' ); .... 1; Then just pass the attributes in on new: my $form => MyApp::Form->new( user_id => $c->user->id, hostname => $c->req->host, captcha_store => $c->{session}->{captcha} ); Or set them using accessors: $form->user_id( $c->user->id ); $form->hostname( $c->req->host ); $form->captcha_store( $c->{session}->{captcha} ); Then you can access these attributes in your form validation methods: sub validate_selection { my ( $self, $field ) = @_; if( $field->value eq 'something' && $self->hostname eq 'something_else' ) { $field->add_error("some error message" ); } } AUTHOR
FormHandler Contributors - see HTML::FormHandler COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Gerda Shank. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-25 HTML::FormHandler::Manual::Catalyst(3pm)
All times are GMT -4. The time now is 11:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy