I am new to any scripting language. But, still I worked on scripting a bit like tailoring other scripts to work for my purpose. For me, what is the best online resource to learn Perl?
How do I do the following in Perl in order:
a) curl a page and save it to a variable
b) parse the value of the variable (which is HTML content) for values I want (ex: the info is kept between tags like ... )
What is the best way to achieve sscanf like functionality in perl?
I am looking now looking at the sscanf module,
Which is better,
Option-1: Going sscanf way?
Option-2: Regex way? [I am a beginner when it comes to Regex]
Is it possible to use a Perl hash in a manner that has O(log(n)) lookup and insertion?
By default, I assume the lookup is O(n) since it's represented by an unsorted list.
I know I could create a data structure to satisfy this (ie, a tree, etc) however, it would be nicer if it was built in and could be used as a normal hash (ie, with %)
So I am trying to read an XML file into a string in Perl and send it as part of a SOAP message. I know this is not ideal as there are methods for SOAP sending files, however, I am limited to having to use the SOAP that is set up, and it is not set up for sending with file support.
Therefore I need to parse out the markup tags < and replace them with []. What is the best way to do this?
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
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
I'm looking for a way of mapping a uid (unique number representing a system user) to a user name using Perl.
Please don't suggest greping /etc/passwd :)
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
In ksh, I'd use
cd /usr/src/sys
How should I write it in Perl? A conversion such as
cd /usr/src/sys ---> chdir '/usr/src/sys'
Maybe the following would be better:
execute "chdir '/usr/src/sys' "
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.
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
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 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!!!
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 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.
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.
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
??
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?
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