Hi there,
say the package is in the ~/ and it's ~/packageFoo.pm
I can use usePackage.pl in ~/ (~/usePackage.pl).
Now, if I move it to ~/subDIR/usePackage.pl, the script won't work because it's not in the same DIR with packageFoo.pm
How can i fix it?
Thanks
Gusla (1 Reply)
i am new to perl. i am writing a perl script. i want to know how to change the working directories? for ex. i have a perl script in c:\proj\ . i want to run this script in this directory but i need my script to change its working directory to D:\xyz\ dynamically in the script.
your help is... (1 Reply)
Hi Experts!!
I have written a very simple script in perl.The script is :
$ cat 1.pl
#!/usr/bin/perl
print "Hi there!\n";
When i ran the above perl script it is showing the following error:
$ perl 1.pl
-ksh: cd: bad substitution
Can anybody,help on this ....as why this script is... (1 Reply)
Trying to figure out why this works:
printpwd.pl
#!/usr/bin/perl
use CGI::Carp qw( fatalsToBrowser );
print "Content-type: text/html\n\n";
$A = system("pwd");
$A = `pwd`;
print "$A\n";
^^actually that works/breaks if that makes any sense.. i get the working directory twice but when... (5 Replies)
Hi,
I want to run a Perl script on multiple files, with same name ("Data.txt") but in different directories (eg : 2010_06_09_A/Data.txt, 2010_06_09_B/Data.txt).
I know how to run this perl script on files in the same directory like:
for $i in *.txt
do
perl myscript.pl $i > $i.new... (8 Replies)
Hi Folks,
I have 2 perl scripts and I need to execute 2nd perl script from the 1st perl script in WINDOWS.
In the 1st perl script that I had, I am calling the 2nd script
main.pl
===========
print "This is my main script\n";
`perl C:\\Users\\sripathg\\Desktop\\scripts\\hi.pl`;
... (3 Replies)
Need assistance in the perl script . Below script gives me the results of all the files and directories with mtime with no issues . But i wanted to have a file and specify all the directory locations and use that file as reference and get results . Any ideas are highly Appreciated .
... (6 Replies)
Hi
I have 100 files under file A labled 1.txt 2.txt.....100.txt(made up name)
I have 1 files under file B labled name.txt
How can i run the same perl script on 100 files and file name.txt
I want to run
perl script.pl A/1.txt B/name.txt
perl script.pl A/2.txt B/name.txt
.......
perl... (3 Replies)
Hi All,
I would like to use a Perl (not Bash) script to work with multiple files of the same name in different directories (all in the same parent directory). I tried to create a loop to do so, but it isn't working.
My code so far:
while (defined(my $file = glob("./*/filename.txt")) or... (1 Reply)
Hi,
I have the following segment of a script which is supposed to prompt a user for password and then capture the password entered by the user.
The function is called in by another script and used to work without issue, the problem is that recently the script is not waiting for the user to... (3 Replies)
Discussion started by: belalr
3 Replies
LEARN ABOUT DEBIAN
mojo::command
Mojo::Command(3pm) User Contributed Perl Documentation Mojo::Command(3pm)NAME
Mojo::Command - Command base class
SYNOPSIS
# Lower case command name
package Mojolicious::Command::mycommand;
# Subclass
use Mojo::Base 'Mojo::Command';
# Take care of command line options
use Getopt::Long 'GetOptions';
# Short description
has description => "My first Mojo command.
";
# Short usage message
has usage => <<"EOF";
usage: $0 mycommand [OPTIONS]
These options are available:
-s, --something Does something.
EOF
# <suitable Futurama quote here>
sub run {
my $self = shift;
# Handle options
local @ARGV = @_;
GetOptions('s|something' => sub { $something = 1 });
# Magic here! :)
}
DESCRIPTION
Mojo::Command is an abstract base class for Mojo commands.
See Mojolicious::Commands for a list of commands that are available by default.
ATTRIBUTES
Mojo::Command implements the following attributes.
"description"
my $description = $command->description;
$command = $command->description('Foo!');
Short description of command, used for the command list.
"quiet"
my $quiet = $command->quiet;
$command = $command->quiet(1);
Limited command output.
"usage"
my $usage = $command->usage;
$command = $command->usage('Foo!');
Usage information for command, used for the help screen.
METHODS
Mojo::Command inherits all methods from Mojo::Base and implements the following new ones.
"app"
my $app = $command->app;
Currently active application.
# Introspect
say "Template path: $_" for @{$command->app->renderer->paths};
"chmod_file"
$command = $command->chmod_file('/home/sri/foo.txt', 0644);
Portably change mode of a file.
"chmod_rel_file"
$command = $command->chmod_rel_file('foo/foo.txt', 0644);
Portably change mode of a file relative to the current working directory.
"class_to_file"
my $file = $command->class_to_file('Foo::Bar');
Convert a class name to a file.
Foo::Bar -> foo_bar
FOO::Bar -> foobar
FooBar -> foo_bar
FOOBar -> foobar
"class_to_path"
my $path = $command->class_to_path('Foo::Bar');
Convert class name to path.
Foo::Bar -> Foo/Bar.pm
"create_dir"
$command = $command->create_dir('/home/sri/foo/bar');
Portably create a directory.
"create_rel_dir"
$command = $command->create_rel_dir('foo/bar/baz');
Portably create a directory relative to the current working directory.
"get_all_data"
my $all = $command->get_all_data;
my $all = $command->get_all_data('Some::Class');
Extract all embedded files from the "DATA" section of a class.
"get_data"
my $data = $command->get_data('foo_bar');
my $data = $command->get_data('foo_bar', 'Some::Class');
Extract embedded file from the "DATA" section of a class.
"help"
$command->help;
Print usage information for command.
"rel_dir"
my $path = $command->rel_dir('foo/bar');
Portably generate an absolute path for a directory relative to the current working directory.
"rel_file"
my $path = $command->rel_file('foo/bar.txt');
Portably generate an absolute path for a file relative to the current working directory.
"render_data"
my $data = $command->render_data('foo_bar', @args);
Render a template from the "DATA" section of the command class.
"render_to_file"
$command = $command->render_to_file('foo_bar', '/home/sri/foo.txt');
Render a template from the "DATA" section of the command class to a file.
"render_to_rel_file"
$command = $command->render_to_rel_file('foo_bar', 'foo/bar.txt');
Portably render a template from the "DATA" section of the command class to a file relative to the current working directory.
"run"
$command->run;
$command->run(@ARGV);
Run command. Meant to be overloaded in a subclass.
"write_file"
$command = $command->write_file('/home/sri/foo.txt', 'Hello World!');
Portably write text to a file.
"write_rel_file"
$command = $command->write_rel_file('foo/bar.txt', 'Hello World!');
Portably write text to a file relative to the current working directory.
SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>.
perl v5.14.2 2012-09-05 Mojo::Command(3pm)