I don't really understand how scoping works in Perl modules. This doesn't print anything. I would like it if running a.pl printed 1
b.pm
$f=1;
a.pl
use b;
print $f
How to enable user account in Active Directory from PERL if that account is disabled
I am using NET::LDAP . How its not working UserAccountControl Attribute
I have a map in perl which has been dumped into from some legacy code the name of the key has now changed from simply reqHdrs to reqHdrs.bla
$rec->{reqHdrs.bla}
My problem is now I cant seem to access this field from the map any ideas ?
The following is my error
Download Script Output: Bareword "reqHdrs" not allowed while "strict subs" in use
I'm looking for good timer implementation in perl. The situation I met is like: I need to keep track of I/O activities of many files and for thoes files keep untouched for enough time a remove action will be taken upon them, so an efficient timer implementation is really vital for
the app I'm involved right now. To avoid recreate the wheel, ask you guys for help first.
All,
I have a hosts file that looks like this:
10.10.10.1 myserver1 myserver1alias
10.10.10.2 myserver2 myserver2alias
I'm looking for a way using perl to pass in an argument of myserver1 and have it return myserver1alias, likewise if I pass in myserver2 it should return myserver2alias. Any suggestions?
I have Perl code:
my $s = "The+quick+brown+fox+jumps+over+the+lazy+dog+that+is+my+dog";
I want to replace every + with space and dog with cat.
I have this regular expression:
$s =~ s/\+(.*)dog/ ${1}cat/g;
But, it only matches the first occurrence of + and last dog.
How do I write Perl objects with extensible code? Im thinking drivers, or some configuation, where the user can pass in a string "Classname::Class" or something. Thanks.
I need perl script to compare line from file1 with file2 and copy to final file, something like this:
File1.txt:
ASPO01
ASPO02
ASPO03
File2.txt:
ASPO01 2013-11-10 19hrs
ASPO10 2013-11-09 24hrs
ASPO02 2013-11-08 10hrs
ASPO16 2013-11-05 9hrs
ASPO17 2013-11-06 6hrs
ASPO03 2013-11-07 15hrs
ASPO18 2013-11-02 25hrs
...
Search into File2 and copy to final file called final.log, like this:
final.txt:
ASPO01 2013-11-10 19hrs
ASPO02 2013-11-08 10hrs
ASPO03 2013-11-07 15hrs
Thanks for all good friends can help me!!!
Does Perl's foreach loop operator require that the list items be presented in order?
For example
my @a=(1,2,3);
foreach my $item (@a) {
print $item;
}
will always print 1 2 3?
I suspect so, but I can't find it documented.
I have a file containing the following content 1000 line in the following format:
abc def ghi gkl
how to write perl script to convert it into :
abc ghi
??
Say I have an environment variable myvar
myvar=\tapple\n
when the following command will print out this variable
perl -e 'print "$ENV{myvar}"'
I will literally have \tapple\n, however, I want those control chars to be evaluated and not escaped. How would I achieve it?
In the real world $ENV residing in substitution, but I hope the answer will cover that.
Let's say I have a list of elements
@list=(1,2,3);
#desired output
1,2,3
And I want to print them as comma seperated values. And most importantly, I do not want the last element to have a comma after it.
What is the cleanest way to do this in Perl?
What is the smartest way of searching through an array of strings for a matching string in Perl?
One caveat, I would like the search to be case-insensitive
so "aAa" would be in ("aaa","bbb")
hi,
I have a variable which stores the path on Windows. I want to replace all the \ with / in the path.
for eg. $path = C:\Users\scripts.ps1
Am new to Perl and tried something like
$path = s/\////
But it didnt work. can you please help me out....
Is it possible to pass two lists to a sub in Perl , ex
sub Foo {
my(@list1,@list2) = @_;
}
I know I could make @_ two lists, with each sublist being the desired argument, I'm just wondering if there is a cleaner way
Hi guys,
I am parsing command line options in Perl using Getopt::Long. I am forced to use prefix - (one dash) for short commands (-s) and -- (double dash) for long commands (ex. --input=file), but problem is, that there is one special option (-r=) so it is long option for its requirement for argument, but it has to have one dash (-) prefix not double dash (--) like other long options. Is possible to setup Getopt::Long to accept these?
I'm sort of new to Perl and I'm wondering if there a prefered unit testing framework?
Google is showing me some nice results, but since I'm new to this, I don't know if there is a clear preference within the community.
I'm looking for an example of redirecting stdout to a file using Perl. I'm doing a fairly straightforward fork/exec tool, and I want to redirect the child's output to a file instead of the parents stdout.
Is there an equivilant of dup2() I should use? I can't seem to find it
could someone provide a good /nice solution in perl for comparing 2 arrays (a and b ) which check if every element on array a is founded on array b (and founded only once on array b) ?
I need to know if there is some way to replace any string as @ or * or ? or & without to put the "\" before it
Example
perl -pe 'next if /^#/; s/\@d\&/new_value/ if /param5/' test
in this example need to replace the @d& with new_value
but I need to put the "\" before @ or &
can be other way without to put the "\" because I have random char that can be in the old value.