in reply to Passing file location in a subroutine

welcome Rapazzini.. but ???

First have a look at Markup in the Monastery to put code tags around your code.
After this, your code does not make much sense to me. what org::item::essential is? a subroutine of the org::item class? what that (unknown to me) sub does? Normally a file path form depend on the underlaying operating system:
my $linux_path = '/usr/bin/perl'; my $win_path = 'c:\scripts\my.log'; my $old_macos = 'Hard Drive:My Folder:My Document'; #dunno
You have to pay attention when you pass file names to subs to the current directory where the program works. if you run your program in the /some/path and you do not change current directory while running, then a bare_filename.ext will be relative to /some/path ending to be /some/path/bare_filename.ext

To deal with file path in a OS portable manner you can use the core module File::Spec as simply as:
$path = File::Spec->catfile( @directories, $filename );

HtH
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Passing file location in a subroutine
by Rapazzini (Initiate) on Oct 09, 2015 at 08:42 UTC
    Thank you for the support. Let me clear the thing I have placed the .pm file code here.I now will try to explain it what I understood. I want to call it by using .pl where I will use the pic.pm file
    package alter; sub onPerform { my $nec = shift; my $ipic1 = org::item::essential($nec, "Input Picture"); my $(ipic) = $nec->locateAbsolutepath($ipic1);
    "org::item::essential" is a module of to get some parameters and the "input picture" have to get the parameters that will be assigned to $ipic1. The $(ipic) will take the $ipic1. I want to call the subroutine "onPerform" to input the "Input Picture"
    #!/usr/bin/perl -w use pic;#.pm file my $rapaz1 = 'C:/Users/RAPAZ/Desktop/try/train19_01.chm'; my $rapaz = alter->onPerform(); $rapaz-> {"Input Picture"} = ($rapaz1);
    Please help me how to call the subroutine and pass the file location "input picture" so that it gets the parameter and get prepared for $(ipic)

      First have a look at Markup in the Monastery to put code tags around your code.
      ...
      If you not help my old eyes there is no chance my old brain can produce something useful...

      L*
      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
        Thank you for the support. Let me clear the thing I have placed the .pm file code here.I now will try to explain it what I understood. I want to call it by using .pl where I will use the pic.pm file
        package alter; sub onPerform { my $nec = shift; my $ipic1 = org::item::essential($nec, "Input Picture"); my $(ipic) = $nec->locateAbsolutepath($ipic1); };
        "org::item::essential" is a module of to get some parameters and the "input picture" have to get the parameters that will be assigned to $ipic1. The $(ipic) will take the $ipic1. I want to call the subroutine "onPerform" to input the "Input Picture"
        #!/usr/bin/perl -w use pic;#.pm file my $rapaz1 = 'C:/Users/RAPAZ/Desktop/try/pic12.jpeg'; my $rapaz = alter->onPerform(); $rapaz-> {"Input Picture"} = ($rapaz1);
        The main problem is passing the file by calling the subroutine.Please help me how to call the subroutine and passthe file location "input picture" so that it gets the parameter and get prepared for $(ipic)