For those unaware of Perl's autobox, it is a module that gives you methods on built in primitives, and lets you even override them.
# primitives
'a string'->toupper();
10->to(1); # returns [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
# Arrays, array refs
[qw(A B C D E)]->for_each( sub { ... } );
@array->length()
# Hashes, hash refs
{ key => 'value...
Hello to All MSSSQL/Perl guru's,
I want to emulate MSSQL/TDS-Server ,
so my 'Microsoft SQL Server Management Studio' (windows client) could SQL-SELECT(only READ)
some distributed data that sits on Linux machines using regular-SQL query or linked-server
( and that's why i cannot use OLE DB Providers and their friends , i also cann...
I wanted to know if we could find out what type of switch our machine is directly connected to ..
For instance if I am connected to a Cisco,Brocade,foundry and Force10 switch .
Is it possible to write a perl script to find out the management address of the switch [without logging in]
Is it possible to write a perl script to find out t...
This answer indicates that glob can sometimes return 'filenames' that don't exist.
@deck = glob "{A,K,Q,J,10,9,8,7,6,5,4,3,2}{\x{2660},\x{2665},\x{2666},\x{2663}}";
However, that code returns an empty list when I run it.
What am I missing?
This run was from the command prompt using -e, on Windows XP, with ActiveState Perl version ...
I have an array of HTML::Elements obtained from HTML::TreeBuilder and HTML::Element->find and I need to assign their as_text value to some other variables. I know I can really easily do
my ($var1, $var2) = ($arr[0]->as_text, $arr[1]->as_text);
but I was hoping I could use map instead just to make the code a bit more readable as there ...
I have an xml like this
<address>
<street>abc</street>
<number>123</number>
</address>
<address>
<street>abc1</street>
<number>345</number>
</address>
...
...
<address>
<street>xyz</street>
<number>999</number>
</address>
I want to be able to convert this to
<address><street>abc</street><number>123</number></addr...
From a related question asked by Bi, I've learnt how to print a matching line together with the line immediately below it. The code looks really simple:
#!perl
open(FH,'FILE');
while ($line = <FH>) {
if ($line =~ /Pattern/) {
print "$line";
print scalar <FH>;
}
}
I then searched Google for a different code that...
I want to get a specific string, for example 123 in <received>123</received> from
some XML that will be retrieved from a URL.
I have write a code but stuck with an error message:
Attempt to bless into a reference at /usr/share/perl5/XML/Twig.pm line 392.
How can I solve it?
The code:
use XML::Twig;
use LWP::Simple;
my $url = '...
I am currently developing a piece of monitoring software that takes an input file of server names and ip addresses and creates a rudimentary database of information. I want to default some values as it processes the config file and it works fine for the first time round the loop but any subsequent entries get created with weird (well wei...
In a Perl script I'm writing I'm having a problem where I block the INT and QUIT signals, execute a process within backticks, and then unblock the INT and QUIT signals. I want to prevent an INT or a QUIT from reaching the child process and killing it.
The script successfully blocks and unblocks at the right points in the code, however...
I am considering writing some Perl scripts that interact with Active Directory. Being somewhat new to Perl, I was wondering if there were any specific modules, tools, techniques, etc. that anyone would suggest I use. As of right now, I am only looking to pull user information to process with the script.
...
I currently have this: tr/[.]+(?=<)//d which should remove all characters (represented by [.]+) up to the first "<", because I'm using a positive lookahead. But for some reason, it's removing all "." and "<" from the string.
For the record, I am not processing HTML or XML with regular expressions.
...
I have done some digging through perldoc and the O'Reilly books but haven't found any way to do this. Am I relegated to using something like Readonly?
UPDATE:
I have nothing against Readonly. I just wanted to be able to do something like PHP's constant().
Example if Perl had constant():
use constant {
FIELD_EXAMPLE_O => 345,
...
How I should install 32-bit Perl on 64-bit machine without affecting the existing applications that uses 64-bit Perl? Is it possible to have a single application (Read: Single file) use different version of Perl for different tasks?
...
I'm trying to convert a Perl script to python, and it uses quite a few different packs. I've been able to figure out the lettering differences in the "templates" for each one, but I'm having an issue with understanding how to handle Perl's lack of length declaration.
example:
pack('Nc*',$some_integer,$long_array_of_integers);
I don't...
I can only imagine I'm not searching correctly; this seems like an obvious question to be asked here. My apologies if this is a duplicate.
I'm writing a Perl program that will take a filename as a command-line argument. I need to convert the filename (or the filename with a relative path attached) to an absolute path (specifically to wo...
Hi all,
I m doing a sysread in Perl 5.8.2 on AIX 5.3. As per the documentation, sysread is supposed to give 0 when it has read all read from filehandle.
In my scenario, the filehandle is STDIN and points to a socket. So I m basically doing a sysread from a socket. But I never get 0 from sysread and it just blocks, even after client ha...
I want to execute a C program using Perl script. What ever inputs are given to the C executable manually, those should be given by my program..
Lets take a simple program, which takes input of two nos. and prints the sum of it.
The values should be provided by Perl script.
Kindly guide me through some tutorial where I can achieve the s...
Is it possible to assign an array variable to an array reference instead of to scalar variables?
Instead of this:
($a, $b) = some_sub(\@d, \@e);
I want something like this:
(@x, @y) = some_sub(\@x1, \@y1);
If so, how can I dereference it.where as in case of former, @$xxxx does for us.
Thanks.
...
I'm creating a web page to select some options from a CSV file:
CSV File Sample:
Time,h1,h2,h3,....
00:00:00,n1,n2,n3.....
.....so on
h -> header
n -> numbers
Below is the Perl code subroutine I have written to filter the header and values and return:
sub TimeData
{
use Text::CSV;
my @time;
my @data;
my ($csv_file,...