A buddy of mine wants to learn Perl. He asked me how to go about it. I told him:
To learn Perl, you must first write Perl code.
This was seconded by another buddy of mine who writes a lot of good Perl code. It's very zen, but not helpful. The problem is that this is exactly how I learnt to write Perl. At my very first job I had to imp...
Hi. I am trying to accomplish a work in Bash scripting. I have a string which i want to XOR with my key.
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH
teststring="abcdefghijklmnopqr"
Now how do i XOR the value of teststring and store it in a variable using bash?
Any help will be appreciated.
Basically i am trying to dup...
I think I need some sort of Schwartzian Transform to get this working, but I'm having trouble figuring it out, as perl isn't my strongest language.
I have a directory with contents as such:
album1.htm
album2.htm
album3.htm
....
album99.htm
album100.htm
I'm trying to get the album with the highest number from this directory (in this c...
I know that FTP does not support transferring and retaining file date/time stamps
Wondering if anyone has any ideas/scripts (Shell/perl) that would retain a transfered file's timestamp after a put operation?
...
I am writing a perl routine that mounts specific drives at startup. However, when the drives are mounted, they appear in "My Computer" with odd names like "dir$ at 'machinename' (H:)".
Is there a way in perl or C to specify this string (or just the 'dir$' part?) at mount-time?
...
I want to post russian text on a CP1251 site using LWP::UserAgent and get following results:
# $text="Русский текст"; obtained from command line
FIELD_NAME => $text # result: Г?в г'В?г'В?г'В?г?вєг?вёг?в? Г'В'Г?вчг?вєг'В?г'В'
$text=Encode::decode_utf8($text);
FIELD_NAME => $text ...
Hello.
I plan to skip the block content which include the start line of "MaterializeU4()" with the subroutin() read_block below. But failed.
# Read a constant definition block from a file handle.
# void return when there is no data left in the file.
# Otherwise return an array ref containing lines to in the block.
sub read_block {...
I have a HTML string in ISO-8859-1 encoding. I need to pass this string to HTML:Entities::decode_entities() for converting some of the HTML ASCII codes to respective chars. To so i am using a module HTML::Parser::Entities 3.65 but after decode_entities() operation my whole string changes to utf-8 string. This behavior seems fine as the d...
How do perl strings represented internally? What encoding is used? How do I handle different encodings properly?
I've been using perl for quite a long time, but it didn't include a lot of string handling in different encodings, and when I encountered a minor problem that had something to do with encodings I usually resorted to some sham...
How to match strings in shell-style in Perl? For instance:
foo*
{bar,baz}.smth
joe?
foobar[0-9]
...
Hi,i am not able to write a script to print all the latin -1 characters one by one.Can anybody help me in solving the problem?
I am using the below code but it is not giving me expected result.
foreach $char(0..255) {
$hexval = sprintf("%x",$char);
$charval = sprintf("%c",%hexval);
print "$charval";
}
output sho...
Hi Everyone,
i'm just a begginer in perl, and very urgently need to prepare a small script that takes top 3 things from an xml file and puts them in a new one.
Here's an example of an xml file:
<article>
{lot of other stuff here}
</article>
<article>
{lot of other stuff here}
</article>
<article>
{lot of other stuff here}
</ar...
I am trying to parse a date from a GPX (XML track format) that looks like 2009-08-02T12:11:06Z
My initial approach was to use DateTime::Format::RFC3339
But DateTime:Format::XSD seems to do a similar job.
Is there a difference between the applicability of these modules.
...
I created a script in perl to run programs with a timeout. If the program being executed takes longer then the timeout than the script kills this program and returns the message "TIMEOUT".
The script worked quite well until I decided to redirect the output of the executed program.
When the stdout and stderr are being redirected, the p...
The "On the state of i18n in Perl" blog post from 26 April 2009 recommends using Locale::TextDomain module from libintl-perl distribution for l10n / i18n in Perl. Besides I have to use gettext anyway, and gettext support in Locale::Messages / Locale::TextDomain is more natural than in gettext emulation in Locale::Maketext.
The subsecti...
I want to handle a feature which seems to me almost natural with programs, and I don't know how to handle it with Getopt perl package (no matter Std ot Long).
I would like something like:
./perlscript <main option> [some options like -h or --output-file some_name]
Options will be handled with - or --, but I want to be able to let the...
After moving my mod_perl site from Linux hosting to FreeBSD, I have this error in the logfile:
Your vendor has not defined POSIX macro SIGRTMIN, used at ../../lib/POSIX.pm (autosplit into ../../lib/auto/POSIX/SigRt/_init.al) line 993\n
The script just imports POSIX and utilizes some functions (ceil, etc)
How can I solve th...
Hi,
I'am trying to convert the variable $num into its reverse byte order and print it out. This is what I have done so far:
my $num=0x5514ddb7;
my $s=pack('I!',$num);
print "$s\n";
He prints it out as some non-printable characters and in a hex editor it looks right, but how can I get it readable on the console?
Already tried
print ...
Hi,
This code works:
my $href = shift @_; # get reference to hash
my %h = %{$href}; # dereference hash
This one does not:
my %h = %{shift @_};
As well as this one:
my %h = ${$_[0]}
Why?
=============================
One more time to be precisly:
1 #!/usr/bin/perl -w
2 use strict;
3 use warnings;
4
...
I have a shell script, with a list of shell variables, which is executed before entering a programming environment.
I want to use a perl script to enter the programming environment:
system("environment_defaults.sh");
system("obe");
but I when I enter the environment the variables are not set.
...