Sponsored Content
Full Discussion: PERL function problem
Top Forums Shell Programming and Scripting PERL function problem Post 75034 by avadhani on Wednesday 15th of June 2005 02:00:01 AM
Old 06-15-2005
PERL function problem

I have perl script as follow.
------------------------------------------------------------------------
#! /usr/bin/env perl

use strict;

sub printLines
{
print "Inside the function.............\n";
my (@file , $count , $key ) = $_;
print $count , $ key ; # It does not print this. ?

}
open(READ_FILE ,"simple.txt");
my @fa = <READ_FILE>;
my $symbolkey = "MY_SYMBOL";
my $line;
foreach $line (@fa){
if ($line =~ /$symbolkey/) {
print $line ,"Match found .............\n";
&printLines(@fa,3,$symbolkey);
}
}
close(READ_FILE);

-------------------------------------------------------------------

Function gets called. But inside function , it does not print values of arguments. What is problem with it.

Thank you,
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with timegm function in perl

Hello.. In my code i use the following function: $epochTime = timegm($sec, $min, $hour, $day, $month, $year) The problem is that when $day==31, i get the following error: Day '31' out of range 1..30 at unrated_namp_program line 113 Any idea how to overcome this??? Thank you very... (5 Replies)
Discussion started by: chriss_58
5 Replies

2. UNIX for Dummies Questions & Answers

perl bless function

hi i am not getting what exactly bless function do in perl explanation in perldoc is not very clear i tried to search on google but i am getting confused or rather not getting at all. can anybody explain in short what it does in following example as well as in general ? sub new { my... (1 Reply)
Discussion started by: zedex
1 Replies

3. Homework & Coursework Questions

PERL split function

Hi... I have a question regarding the split function in PERL. I have a very huge csv file (more than 80 million records). I need to extract a particular position(eg : 50th position) of each line from the csv file. I tried using split function. But I realized split takes a very long time. Also... (0 Replies)
Discussion started by: castle
0 Replies

4. Shell Programming and Scripting

PERL split function

Hi... I have a question regarding the split function in PERL. I have a very huge csv file (more than 80 million records). I need to extract a particular position(eg : 50th position) of each line from the csv file. I tried using split function. But I realized split takes a very long time. Also... (1 Reply)
Discussion started by: castle
1 Replies

5. Shell Programming and Scripting

Join Function in PERL

Hi, Can any one please let me know, how to join the lines in a file, but based one a condition. There is a file, where few lines start with a date stamp. and few do not. I wanted to join the lines till I find a date stamp. If found date its should in a newline. Please help me. ... (5 Replies)
Discussion started by: thankful123
5 Replies

6. Shell Programming and Scripting

Identify function image magick problem - perl

Hi, I got some error when I try to write content from file store into array then for each word that separate by space use identify function to display image information.here is my code #!/usr/bin/perl -w open(FILE,'transfer_file_perl.txt') or die "$!"; my $line = <FILE>;#because it is one... (2 Replies)
Discussion started by: guidely
2 Replies

7. Shell Programming and Scripting

perl function enquery

Dear all, I find a perl script that contains the following codes. Does anybody know the meaning of codes highlight. ..... @field = parse_csv($file); chomp(@field); ........ ........ sub parse_csv { my $text = shift; my @new = (); push( @new, $+ ) while $text =~ m{... (9 Replies)
Discussion started by: eldonlck
9 Replies

8. Shell Programming and Scripting

Problem in passing date to external function from perl script.

my $sysdate = strftime('%Y-%m-%d', localtime ); biDeriveByDate('Table_Str',$sysdate,\@lIndx,\@lResVals) In a perl script, when I'm trying to pass $sysdate to some external function it's not working since $sysdate is passed as a string mentioned above but my function is expecting a date value... (1 Reply)
Discussion started by: Devesh5683
1 Replies

9. Shell Programming and Scripting

Problem of Perl's "join" function

$ perl -e '@f=("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","1","911"); print join("\t",@f)."\n";' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ... (5 Replies)
Discussion started by: carloszhang
5 Replies

10. Shell Programming and Scripting

Converting shell to Perl I run into shell built in function trap and need alternative in Perl

I am working on converting shell to Perl script. In shell we have built in function trap Do you know alternative in Perl or actually we don't need it? Thanks for contribution (3 Replies)
Discussion started by: digioleg54
3 Replies
PRINTENV(1)						    BSD General Commands Manual 					       PRINTENV(1)

NAME
printenv, env -- print out the environment, set and print environment SYNOPSIS
printenv [name] env [-i] [name=value ...] [utility [argument ...]] DESCRIPTION
The printenv utility prints out the names and values of the variables in the environment, with one name/value pair per line. If name is specified, only its value is printed. Some shells may provide a builtin printenv command which is similar or identical to this utility. Consult the builtin(1) manual page. The env utility executes utility after modifying the environment as specified on the command line. The option name=value specifies an envi- ronment variable, name, with a value of value. The options are as follows: -i Execute the utility with only those environment values specified. The environment inherited by env is ignored completely. If no utility is specified, env prints out the names and values of the variables in the environment, with one name/value pair per line. The env utility is sometimes useful with the ``#!'' construct (see execve(2)). The only difference between ``#!/usr/local/bin/foo'' and ``#!/usr/bin/env /usr/local/bin/foo'' is that the latter works even if /usr/local/bin/foo is itself interpreted. Using env this way also allows one to reference foo without the path, as well as set up the environment as desired. ENVIRONMENT
The env utility uses the PATH environment variable is used to locate the requested utility if the name contains no '/' characters. DIAGNOSTICS
The printenv utility exits 0 on success, and >0 if an error occurs. The env utility exits 0 on success, and >0 if an error occurs. An exit status of 126 indicates utility was found, but could not be executed. An exit status of 127 indicates utility could not be found. COMPATIBILITY
The env utility accepts the - option as a synonym for -i. SEE ALSO
csh(1), sh(1), execvp(3), environ(7) STANDARDS
The env utility conforms to IEEE Std 1003.1-2001 (``POSIX.1''). HISTORY
The printenv command appeared in 3.0BSD. BUGS
The env utility doesn't handle utility arguments with equal (``='') signs in their names, for obvious reasons. BSD
June 6, 1993 BSD
All times are GMT -4. The time now is 04:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy