Sponsored Content
Top Forums Shell Programming and Scripting Perl Script Issue - Please Help * Thanks!!! Post 302253585 by BubbaJoe on Saturday 1st of November 2008 03:35:19 AM
Old 11-01-2008
The problem is you are using to many "my" variable. Declare the variable once with my. Then when accessing just use the variable name.

For instance

my $File = "/etc/passwd"
open (FILE, $File) or die "Can't open file"

That should correct most of you issues.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl issue ..

hi one perl issue i have xml file with 2 values and one condition b.w them <rule> <val1>12</val1> <cond>and</cond> <val2>13</val2> </rule> i read these values in hash in perl code $one{val1} = 12 $one{cond} = and $one{val2} = 13 now i want to form... (3 Replies)
Discussion started by: zedex
3 Replies

2. Shell Programming and Scripting

Perl Issue

Hi, I got this script from the web, this generates an LDAP report in CSV format. #!/usr/bin/perl # # Copyright (c) 2004 # Ali Onur Cinar &060;cinar&064;zdo.com&062; # # License: # # Permission to use, copy, modify, and distribute this software and its # documentation for... (23 Replies)
Discussion started by: raj001
23 Replies

3. Shell Programming and Scripting

Perl Script issue. What am I doing wrong?

#!/usr/local/bin/perl open (MYFILE, 'logs_report'); while (<MYFILE>) { $rec=$_; chomp ($rec); @arr=split(/ /,$rec); print $rec,"\n" if ($arr!~/OK/); open (MYF, '>data.txt'); print $rec,"\n" if ($arr!~/OK/); close (MYF); (14 Replies)
Discussion started by: SkySmart
14 Replies

4. Shell Programming and Scripting

Perl issue - please help!

Hello. I've been writing some code in Perl to read in strings from html files and have been having issues. In the html file, each "paragraph" is a certain file on the website. I need to find every one of the files that is a certain type, in this case, having green color....therefore... (7 Replies)
Discussion started by: akreibich07
7 Replies

5. Shell Programming and Scripting

Perl script issue: print

Can someone tell me what I'm doing wrong with my perl script? I am new to Perl. This isn't even the final script, I'm just testing to see if it will print the directories with the files in it. For some reason my output is only printing the 1st, 6th, and last entries of the @sub_dir array. Each... (3 Replies)
Discussion started by: man
3 Replies

6. Web Development

Accessing a Perl CGI script, security issue

Hi Everybody, I was wondering if it was possible for someone to gain access to my Perl CGI scripts before they are interpreted by Perl (mod_perl on apache2) i.e. getting a hold of my raw scripts and not the html output? Let's say I use the DBI module where I have the hostname, user and... (2 Replies)
Discussion started by: z1dane
2 Replies

7. Shell Programming and Scripting

Perl script issue

Hi All, I have a perl script which I am using in Windows environment. There is one more file called "functions.txt" which is having all the functions defined to used in my perl script. And the path for this function file is defined in my perl script. Howeever sometimes I am getting below error... (4 Replies)
Discussion started by: gr8_usk
4 Replies

8. Shell Programming and Scripting

Issue regarding dos2unix perl script

Hi All, I have pearl script which will check and convert the file: INFO("dos2unix_cmds".$#{$dos2unix_cmds}); if ( $#{$dos2unix_cmds} == 0 ) { my $convert_cmd = $$dos2unix_cmds; my $rename_cmd = $$dos2unix_cmds; --conversion going here else INFO ("No need to... (8 Replies)
Discussion started by: saps19
8 Replies

9. Shell Programming and Scripting

Perl : embedding java script with cgi perl script

Hi All, I am aware that html tags can be embedded in cgi script as below.. In the same way is it possible to embed the below javascript in perl cgi script ?? print("<form action="action.htm" method="post" onSubmit="return submitForm(this.Submitbutton)">"); print("<input type = "text"... (1 Reply)
Discussion started by: scriptscript
1 Replies

10. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies
NetSDS::Util::File(3pm) 				User Contributed Perl Documentation				   NetSDS::Util::File(3pm)

NAME
NetSDS::Util::File - file related utilities SYNOPSIS
use NetSDS::Util::File qw(file_read); my $passwd = file_read('/etc/passwd'); file_move('/etc/passwd', '/tmp/find_this'); DESCRIPTION
"NetSDS::Util::File" module contains some routines for files and directories processing tasks like creating, reading, writing, copying and moving files and catalogs. This module of cource uses such well known things like File::Spec, File::Path, File::Copy and others. EXPORTED FUNCTIONS
is_handle($var) - check if argument is a file handle Paramters: some variable Returns: 1 if it's file handle or undef otherwise if (is_handle($var)) { reset_handle($fh); } reset_handle($fh) - reset file handle Paramters: file handle Returns: nothing This function tries to set filehandle to begin of file and set binmode on it. my $fh = file_open('/etc/passwd'); ... do something with file ... reset_handle($fh); # We can read it from the beginning file_open($file) - open file Paramters: file name or file handle Returns: file handle This function provides unified API for opening files. my $f = file_open('/etc/passwd'); file_read($file) - read file to scalar Paramters: file name or file handle Returns: scalar content of file This function provides ability to read file content to scalar variable. my $data = file_read('/etc/passwd'); print "Passwords file: $data "; file_write($file, $data) - write scalar data to file Paramters: file name or open file handle Returns: length of written data or undef in case of error my $data = 'This should be file'; file_write('/tmp/file.dat', $data); file_copy($in_file, $out_file) - copy file Paramters: input file name, output file name Returns: This function copy file to new location. file_move($in_file, $out_file) - move file Paramters: input file name, output file name Returns: 1 or undef This function moves old file to new location. file_temp($dir) - create temporary file Creates new temp file and return its handle dir_create($dir) - create directory with parents Paramters: directory name Returns: directory name or undef # Will create all parent catalogs if necessary dir_create('/var/log/NetSDS/xxx'); dir_delete($dir) - remove directory recursive Paramters: directory name Returns: dir name or undef if error print "We need no libs!"; dir_delete('/usr/lib'); dir_read($dir, $ext) - read files list from catalog Paramters: directory name, extension of files to read Returns: list of files in catalog my @logs = @{ dir_read('/var/log/httpd', 'log') }; print "Logs are: " . join (', ', @logs); dir_read_recursive($dir, $ext, [$res]) - read all files list recursive Paramters: $start catalog, $extension Returns: list of files with extension from parameters my $tpls = dir_read_recursive('/etc/NetSDS', 'tmpl'); foreach my $tpl (@$tpls) { pritn "Template: $tpl "; } exec_external($prog, [$param1, ... $paramN]) - execute external program Paramters: pragram name, arguments list (see perldoc -f system) Returns: 1 if ok, undef otherwise This function calls system() with given parameters and returns 1 if everything happened correctly (program executed and returned correct result). if (exec_external('/bin/rm', '-rf', '/')) { print "Hey! We removed the world!"; } EXAMPLES
None yet BUGS
Unknown yet SEE ALSO
IO::Handle, IO::Scalar, IO::File, File::Spec, File::Copy, File::Path, system() TODO
1. Implement more detailed error handling AUTHOR
Valentyn Solomko <pere@pere.org.ua> Michael Bochkaryov <misha@rattler.kiev.ua> perl v5.12.4 2011-08-27 NetSDS::Util::File(3pm)
All times are GMT -4. The time now is 08:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy