Greping array values in Bash like Perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Greping array values in Bash like Perl
# 1  
Old 08-10-2010
Greping array values in Bash like Perl

Hi,

Is there an easy way to simulate following Perl code in Bash.

Code:
 if ( grep {$my_value eq $_} @ARGV ){
       print "Do Something\n";
 } else {
            die "Invalid value";
}


Last edited by Franklin52; 08-10-2010 at 03:40 PM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Values rotation in array with bash

Hello :) I created a little script that allow to make a rotation of values in an array. The goal was to shift the values to the right and that the last value of the array became the first value in order to create a rotation. The purpose of the exercice was to do it without using a temporary... (6 Replies)
Discussion started by: Nexy
6 Replies

2. Shell Programming and Scripting

Values rotation in array with bash

Hello :) I created a little script that allow to make a rotation of values in an array. The goal was to shift the values to the right and that the last value of the array became the first value in order to create a rotation. The purpose of the exercice was to do it without using a temporary... (3 Replies)
Discussion started by: Nexy
3 Replies

3. UNIX for Beginners Questions & Answers

Qn on awk greping values

Hello Experts, I was trying to awk out some data out of a text file. Below is a sample file which I have xxx ***Wed Jun 28 18:00:59 CDT 2015 avg-cpu: %user %nice %system %iowait %steal %idle 17.10 0.00 4.56 2.86 0.00 75.48 Device: rrqm/s wrqm/s ... (2 Replies)
Discussion started by: DevAnand
2 Replies

4. Shell Programming and Scripting

Perl next if @array (exclude a list of values)

I'm trying to exlude a list of values with perl to process while reading in a file. Is there a way to use the next if with a list? Example: @array = qw(val1 val2 val3 val6); while (<>) { next if $_ =~ @array; # values I don't want to process here print; # process the rest here }... (8 Replies)
Discussion started by: timj123
8 Replies

5. Shell Programming and Scripting

Perl : Assigning multile hash values to a single array

I know that @food = %fruit; Works. But how do I assign %fruit and %veggies to @food ? (2 Replies)
Discussion started by: popeye
2 Replies

6. UNIX for Advanced & Expert Users

Search and replace a array values in perl

Hi, i want to search and replace array values by using perl perl -pi -e "s/${d$i]}/${b$j]}" *.xml i am using while loop for the same. if i excute this,it shows "Substitution replacement not terminated at -e line 1.". please tell me what's wrong this line (1 Reply)
Discussion started by: arindam guha
1 Replies

7. UNIX for Dummies Questions & Answers

Passing values from file into array in Bash

Hi, I'm trying to write a bash script that takes a file and passes each line from the file into an array with elements separated by column. For example: Sample file "file1.txt": 1 name1 a first 2 name2 b second 3 name3 c third and have arrays such as: line1 = ( "1" "name1" "a"... (3 Replies)
Discussion started by: ShiGua
3 Replies

8. Shell Programming and Scripting

How to map the values of an array in perl?

Hi, I have 2 arrays: @names=qw(amith veena chaitra); @files=qw(file.txt file1.txt file3.txt); There is one to one relationship between names and files. There needs to be mapping created between names and files. The output should be like this: amith --> file.txt veena --->... (3 Replies)
Discussion started by: vanitham
3 Replies

9. Shell Programming and Scripting

perl -write values in a file to @array in perl

Hi can anyone suggest me how to write a file containing values,... say 19 20 21 22 .. 40 to an array @array = (19, 20, ... 40) -- Thanks (27 Replies)
Discussion started by: meghana
27 Replies

10. Shell Programming and Scripting

perl: Assigning array values..

I have to add a variable value to an array, something like this: ...... @my_array_name = $value_of_this_variable; This doesnt seem to work, any ideas why? Thanks! (4 Replies)
Discussion started by: looza
4 Replies
Login or Register to Ask a Question
Imager::QRCode(3pm)					User Contributed Perl Documentation				       Imager::QRCode(3pm)

NAME
Imager::QRCode - Generate QR Code with Imager using libqrencode SYNOPSIS
use Imager::QRCode; my $qrcode = Imager::QRCode->new( size => 2, margin => 2, version => 1, level => 'M', casesensitive => 1, lightcolor => Imager::Color->new(255, 255, 255), darkcolor => Imager::Color->new(0, 0, 0), ); my $img = $qrcode->plot("blah blah"); $img->write(file => "qrcode.gif"); # or instance method use Imager::QRCode qw(plot_qrcode); my $img = plot_qrcode("blah blah", \%params); $img->write(file => "qrcode.gif"); DESCRIPTION
This module allows you to generate QR Code with Imager. This module use libqrencode '2.0.0' and above. METHODS
new $qrcode = Imager::QRCode->new(%params); The "new()" constructor method instantiates a new Imager::QRCode object. "new()" accepts the following parameters. o "size" - Horizontal and vertical size of module(dot). Default is 4. o "margin" - Margin size of QR Code. Default is 3. o "level" - Error collectin level. Valid values are 'M', 'L', 'Q' or 'H'. Default is 'L'. o "version" - Version of the symbol. If specify '0', this module chooses the minimum version for the input data. Default is '0'. o "mode" - Encoding mode. Valid values are 'numerical', 'alpha-numerical', '8-bit' or 'kanji'. Default is '8-bit'. If not give "casesensitive" then should be given "mode". If 'kanji' is given, characters will be encoded as Shift-JIS characters. If '8-bit' is given, all of non-alpha-numerical characters will be encoded as is. If you want to embed UTF-8 string, choose '8-bit'. o "casesensitive" - If your application is case-sensitive using 8-bit characters, set to '1'. Default is '0'. plot($text) $img = $qrcode->plot("blah blah"); Create a new QR Code image. This method returns Imager object ploted QR Code with the given text. INSTANT METHODS
plot_qrcode($text, \%params) Instant method. $text is input text. %params is same parameter as "new()". SEE ALSO
"Imager", "http://www.qrcode.com/", "http://megaui.net/fukuchi/works/qrencode/index.en.html" AUTHOR
Yoshiki KURIHARA "<kurihara __at__ cpan.org>" THANKS
Tokuhiro Matsuno LICENCE AND COPYRIGHT
Copyright (c) 2011, Yoshiki KURIHARA "<kurihara __at__ cpan.org>". This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. perl v5.14.2 2012-12-16 Imager::QRCode(3pm)