I ran across a very strange line of code in a legacy Perl application. The code here is part of a homegrown RSS reader that does some caching to prevent being blacklisted.
open(CAT, "/usr/bin/cat -v /tmp/cat-cache 2>&1|");
Does it seem likely that the original author ran the results through cat -v to strip out non-printing characters...
For a Perl porting project I am using ActiveState's Komodo IDE 5.1
For external reasons, the xyz.pm modules reside in a different directory tree.
By adding a PERL5LIB=<> under the "environemt" tab of the debu/run dialog, I can show Komodo/Perl how to run the script.
Unfortunately the syntax checking doesn't seem to evaluate those direc...
Perl is really good for writing the kind of string/file parsing programs that I usually need to do. What I really love is the insignificant amount of time it takes me to write quick scripts and throwaway code, compared to C/C++/JAVA. However, I want to learn how to speed things up.
For example, I would want to learn how to give hints to...
Here is some dprofpp -I output, for almost the same program on different input sizes (program uses File:Tie to read input file and does some filtering of lines.
The question is why is the elapsed time always double for this program?
I am asking this because fixing this would make my program faster by 2x without any more magic - is it,...
This is more a puzzle question for my curiosity than anything else. I'm looking for a single regular expression substitution that will convert entity escaped ampersands to an unescaped ampersands only within href attributes in an html file. For example:
<a href="http://example.com/index.html?foo=bar&amp;baz=qux&amp;frotz=frobnit...
Hi,
How can I convert a binary number into a string character using Perl script?
thanks in advance.
...
Hi all,
How can I check for the next line while running in a current loop?
Also, how can I move C comments to end of the line for a table?
I have a file like this:
array_table=
{
/* comment 1*/ (unsigned int a);
/* comment 2*/ (unsigned int b);
/* comment 3*/ (unsigned int c);
/* comment 4*/ (unsigned int d);
}
My...
I'm maintaining a script that can get its input from various sources, and works on it per line. Depending on the actual source used, linebreaks might be Unix-style, Windows-style or even, for some aggregated input, mixed(!).
When reading from a file it goes something like this:
@lines = <IN>;
process(\@lines);
...
sub process {
@...
How can I find extended ASCII characters in a file using Perl? Can anyone get the script?
.....thanks in advance.....
...
While running a perl program I encountered the following error
*** glibc detected *** perl: double free or corruption (!prev): 0x0c2b7138 ***
/lib/tls/i686/cmov/libc.so.6[0xb7daea85]
/lib/tls/i686/cmov/libc.so.6(cfree+0x90)[0xb7db24f0]
perl(Perl_pregfree+0x3e)[0x80a004e]
perl(perl_destruct+0xcf1)[0x806b711]
/usr/local/lib/perl/5.8.8/au...
For Python, it can create a pre-compiled version file.pyc so that the program can be run without interpreted again. Can Ruby, PHP, and Perl do that same on the command line?
...
I have a Perl script that contains this code snippet, which calls the system shell to get some files by SFTP and unzip them with WinZip:
# Run script to get files from remote server
system "exec_SFTP.vbs";
# Unzip any files that were retrieved
foreach $zipFile (<*.zip>) {
system "wzunzip $zipFile";
}
Even if some files are retr...
Long version...
A co-worker asserted today after seeing my use of while (1) in a Perl script that for (;;) is faster. I argued that they should be the same hoping that the interpreter would optimize out any differences. I set up a script that would run 1,000,000,000 for loop iterations and the same number of while loops and record the ...
I wrote a very simple perl script, and now I want to make it executable from everywhere.
I know I could just drop it into /bin/, rename it from 'mytest.pl' -> 'mytest', and chmod +x, but is this standard practice? I noticed nothing in /bin/ is a perl script.
Also, I want it to be able to log to /var/logs/mytest/*
Are there any securit...
G'day,
I am using the following Perl fragment to extract output from a Solaris cluster command.
open(CL,"$clrg status |");
my @clrg= grep /^[[:lower:][:space:]]+/,<CL>;
close(CL);
I get the following when I print the content of the elements of the array @clrg BTW "=>" and "<=" line delimiters are inserted by my print statement:
=><=...
I'm parsing an file, and parts of it is a records thing, the format is like:
CategoryA--
5: UserA
6: UserB
7: UserC
CategoryB--
4: UserA
5: UserB
I want to move it to a hash that looks like:
{ UserA => { CategoryA => 5, CategoryB => 4, },
UserB => { CategoryA => 6, CategoryB => 5, },
UserC => { CategoryA => 7, },
}
How do I do...
Hi,
I have the following code in my perl script:
my $directory;
my @files;
my $help;
my $man;
my $verbose;
undef $directory;
undef @files;
undef $help;
undef $man;
undef $verbose;
GetOptions(
"dir=s" => \$directory, # optional variable with default value (false)
"files=s" => \@files, # optional variable t...
I'm reading a regular expression from a configuration file, which may or may not have invalid syntax in it. (It's locked down behind a firewall, so let's not get into security.) I've been able to test for a number of errors and give a friendly message.
No such luck on this one:
Unrecognized escape \Q passed through in regex
I k...
Hi all,
My string
(champs1 (champs6 donnee_o donnee_f) [(champs2 [] (champs3 _YOJNJeyyyyyyB (champs4 donnee_x)) (debut 144825 25345) (fin 244102 40647)), (champs2 [] (champs3 _FuGNJeyyyyyyB (champs4 donnee_z)) (debut 796443 190570) (fin 145247 42663))] [] []).
( Annotated For readability ):
(champs1
(champs6 donnee_o donnee_f...
The requirements are :
Fact 1 : We have some data files produced by a legacy system
Fact 2 : We have some data files produced by a new system that should eventually replace the legacy one
Fact 3 :
Both the files are text/ASCII files,
with records being composed of
multiple lines.
Each line, within a record, consists
of a fieldname a...