Sponsored Content
Top Forums Shell Programming and Scripting Need help figuring out how to create sharable functions in Perl Post 302919761 by gandolf989 on Friday 3rd of October 2014 01:46:10 PM
Old 10-03-2014
Hi Aia. Your explanation helps. So can I use the following syntax to make my code aware of code from another file, "use myfile;" then I can call the subroutines from that file, passing in variables that are needed and getting back data? Do I need to specify the package name where I am calling the code from to call a method in the file being included with the use statement?

Do you have any recommendations on what I should look at online to get a clearer idea on how to structure my packages?

Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Figuring out Crons

Hello, I've built a news site using SimplePie to pull in a set of feeds and display them on a page. The caching is working but the problem is that the first initial load is slow. After that, you can hit refresh and it loads very quickly. I'd like to eliminate that first slow load by creating a... (2 Replies)
Discussion started by: eightgames
2 Replies

2. Shell Programming and Scripting

perl functions and arrays

Hi, First I will tell my objective of this function (function one). I have a table for ex: id passwd name -- ------ ----- 1 fdhgfs werwer 2 fsdfs sdfsdf 3 sdfs sdfsdf 4 fdsfs dssdf . . . . . . The id, passwd and name are the arguments for another function say two. (1 Reply)
Discussion started by: mercuryshipzz
1 Replies

3. UNIX for Advanced & Expert Users

problems figuring out dns

Im on an OS X 10.4 Mac server running bind 9.3, I just replaced the entire network with cisco hardware, all machines including servers now have private ip addresses that t he firewall resolves. I need to have a dns that works for both internal and external connections. any help would be great! (1 Reply)
Discussion started by: nbredthauer
1 Replies

4. Shell Programming and Scripting

perl - passing hash references to functions

hi there I have the following script in which i have created a PrintHash() function. I want to pass to this function the reference to a hash (in the final code i will be passing different hashes to this print function hence the need for a function). I am getting an error Type of arg 1 to... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

5. Shell Programming and Scripting

Perl script to find where functions is called in c

Hello, I need to write a perl script to find where functions is called in c files.. The script should scan the file and find out the function names and then search to see where they are called... Lets for now assume all functions are internal. I don't know where to start :( ... (4 Replies)
Discussion started by: bojomojo
4 Replies

6. Shell Programming and Scripting

figuring out wildcards

I'm trying to delete everything between ( and ) in a line, ie: ( start xxxx, end xxx ). there is uppercase, lowercase and numbers in the parans. and are of varied length. I tried this: sed 's/()//' infile > outfileI'm not understanding the wildcard use in brackets (2 Replies)
Discussion started by: dba_frog
2 Replies

7. Shell Programming and Scripting

figuring out an awk one liner

I have googled around a bit and could not find an answer to how this works: echo $STRING | awk '$0=$NF' FS= I know what each part is doing. The record is being set to equal the last field and the field separator is being set to null so that each character is considered a field. Why can FS= be... (4 Replies)
Discussion started by: benalt
4 Replies

8. Shell Programming and Scripting

How to execute functions or initiate functions as command line parameters for below requirement?

I have 7 functions those need to be executed as command line inputs, I tried with below code it’s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line if then... (8 Replies)
Discussion started by: saku
8 Replies

9. Programming

Perl: How to load some functions automaticaly, starting Perl inteructively (with -d -e 0)?

I would like to use Perl in 'interactive' mode (kind off), starting it by > perl -d -e 0; But I need to have some function be read on loading. Also, it should not be for anyone who starting Perl or use it any how. I did try to search, but not much result. I have try a file '.perldb':... (1 Reply)
Discussion started by: alex_5161
1 Replies

10. Debian

Need help figuring out how to use my Debian Partitions

Greetings, I've installed my Debian Server over 4 months ago, I didn't quite understand what the paritions were for, but the server provider made my partitions. Anyway I was putting most of my files in /gserver and it ran otu of space quickly when in the store page it says 2tb I barely used 18gb... (2 Replies)
Discussion started by: debianguy4
2 Replies
Sub::Install(3) 					User Contributed Perl Documentation					   Sub::Install(3)

NAME
Sub::Install - install subroutines into packages easily VERSION
version 0.926 SYNOPSIS
use Sub::Install; Sub::Install::install_sub({ code => sub { ... }, into => $package, as => $subname }); DESCRIPTION
This module makes it easy to install subroutines into packages without the unslightly mess of "no strict" or typeglobs lying about where just anyone can see them. FUNCTIONS
install_sub Sub::Install::install_sub({ code => &subroutine, into => "Finance::Shady", as => 'launder', }); This routine installs a given code reference into a package as a normal subroutine. The above is equivalent to: no strict 'refs'; *{"Finance::Shady" . '::' . "launder"} = &subroutine; If "into" is not given, the sub is installed into the calling package. If "code" is not a code reference, it is looked for as an existing sub in the package named in the "from" parameter. If "from" is not given, it will look in the calling package. If "as" is not given, and if "code" is a name, "as" will default to "code". If "as" is not given, but if "code" is a code ref, Sub::Install will try to find the name of the given code ref and use that as "as". That means that this code: Sub::Install::install_sub({ code => 'twitch', from => 'Person::InPain', into => 'Person::Teenager', as => 'dance', }); is the same as: package Person::Teenager; Sub::Install::install_sub({ code => Person::InPain->can('twitch'), as => 'dance', }); reinstall_sub This routine behaves exactly like "install_sub", but does not emit a warning if warnings are on and the destination is already defined. install_installers This routine is provided to allow Sub::Install compatibility with Sub::Installer. It installs "install_sub" and "reinstall_sub" methods into the package named by its argument. Sub::Install::install_installers('Code::Builder'); # just for us, please Code::Builder->install_sub({ name => $code_ref }); Sub::Install::install_installers('UNIVERSAL'); # feeling lucky, punk? Anything::At::All->install_sub({ name => $code_ref }); The installed installers are similar, but not identical, to those provided by Sub::Installer. They accept a single hash as an argument. The key/value pairs are used as the "as" and "code" parameters to the "install_sub" routine detailed above. The package name on which the method is called is used as the "into" parameter. Unlike Sub::Installer's "install_sub" will not eval strings into code, but will look for named code in the calling package. EXPORTS
Sub::Install exports "install_sub" and "reinstall_sub" only if they are requested. exporter Sub::Install has a never-exported subroutine called "exporter", which is used to implement its "import" routine. It takes a hashref of named arguments, only one of which is currently recognize: "exports". This must be an arrayref of subroutines to offer for export. This routine is mainly for Sub::Install's own consumption. Instead, consider Sub::Exporter. SEE ALSO
Sub::Installer This module is (obviously) a reaction to Damian Conway's Sub::Installer, which does the same thing, but does it by getting its greasy fingers all over UNIVERSAL. I was really happy about the idea of making the installation of coderefs less ugly, but I couldn't bring myself to replace the ugliness of typeglobs and loosened strictures with the ugliness of UNIVERSAL methods. Sub::Exporter This is a complete Exporter.pm replacement, built atop Sub::Install. AUTHOR
Ricardo Signes, "<rjbs@cpan.org>" Several of the tests are adapted from tests that shipped with Damian Conway's Sub-Installer distribution. BUGS
Please report any bugs or feature requests 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. COPYRIGHT
Copyright 2005-2006 Ricardo Signes, 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.16.2 2012-02-26 Sub::Install(3)
All times are GMT -4. The time now is 03:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy