perl.beginners
  Home FAQ Contact Sign in
perl.beginners only
 
Advanced search
January 2008
motuwethfrsasuw
 123456 1
78910111213 2
14151617181920 3
21222324252627 4
28293031    5
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
perl.beginners Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Re: undefined format error         


Author: Oryann9
Date: Jan 31, 2008 18:34

Please ignore the message below b/c I worked through this.

Basically my format code is not printing in a sorted order based off of 'sz' yet it is correctly sorted in @sorted_large_files as you can see below SORTED.

How can I tell format to print it sorted based off of 'sz'?

Here is how I am sorting

@sorted_large_files =
sort { $meta{$b}->{'sz'} <=> $meta{$a}->{'sz'} } keys %%meta ;

REPORT OF LARGE FILES on:
"hostname xxxxx"

Page 1

FileName Owner GroupOwner Gecos LastModifiedDate Size Mb
========= ...
Show full article (5.78Kb)
no comments
  undefined format error         


Author: Oryann9
Date: Jan 31, 2008 13:57

Hello List,

I am hoping for some help with this. I did post this same question to PerlMonks.

Undefined format "STDOUT" called at find_hog.tdy line 173.
Line 173 is the 1st write statement, but since there are snips in there 173 is not the actual line in this email.
Just look for 1st write statement.

thank you. :)

#!/usr/bin/perl

use strict ;
use warnings ;
use File::Find ;
use File::Find::Closures qw(find_by_min_size) ;
$ENV{"PATH"} = qq(/usr/bin:/bin) ;
delete @ENV{qw (IFS CDPATH KSH_ENV)} ;

my ( $key, $keys, $user, $grp, $gcos, $mod, $mod2, $sz, ) ;
my ( @sorted_large_files, @sorted_root_files, );



sub dateme {
Show full article (5.04Kb)
1 Comment
  Command line installing perl modules         


Author: Bobby
Date: Jan 31, 2008 12:01

Hi,

I'm trying to figure out how to install perl modules from command line (to
automate the install process). CPAN allowed me to d/l direct which results in
tarballs. Are there any caveats to watch out for when installing them this
way?

This will be done only on brand new Slackware 12 installs which does not have
CPAN.

I was thinking of copying .cpan but it's probably not even needed, and might
introduce incompatibility issues. The important part is to get a cookie
cutter system that can be done over and over.

--

Bobby
5 Comments
  IO::Compress::Gzip creates empty file         


Author: Richard Fernandez
Date: Jan 31, 2008 10:06

Hi Folks,

I have the following code:


use IO::Compress::Gzip qw(gzip $GzipError);

...then...

gzip "$company.$ext.$date" => "$company.$ext.$date.gz",
BinModeIn => 1 or do {
warn "Failed to gzip file: $company.$ext.$date:
$GzipError\n";
next DOTDONE;
};


The file "$company.$ext.$date" is created in the immediately preceding
step and definitely contains data, but the resulting compressed file is
empty, and the warn statement is not executed.

I've extracted and wrapped this code to create a little test program
which works fine, that is, the resulting compressed file contains the
data I expect.
Show full article (0.89Kb)
9 Comments
  How can I open a file with "/"?         


Author: Rc
Date: Jan 31, 2008 09:35

I have to create a file with / in the name. I have tried different
techniques but keep getting errors.

My file name also has & in it.

open(MYFILE, ">>", "confused&lost/.com")
or die "2. Can't open MYFILE for writing: $!.
Stopped";

Thank you for the help.
3 Comments
  Newbie: Has anyone used Tie::Hash::TwoWay         


Author: Axtens
Date: Jan 31, 2008 09:13

G'day everyone

I'm confused. I'm trying to make use of Tie::Hash::TwoWay to give me
access to a dictionary of word <=> misspelling. Has anyone got any
idea how I would use TwoWay for this? Nothing I do seems to work.

my $secondary = $dict->{0};
while ( ($k, $v) = ( each %%$secondary ) ) {
print $k . "\t" . $v . "\n";
}

my $primary = $dict->{1};
while ( ($k, $v) = ( each %%$primary ) ) {
print $k . "\t" . $v . "\n";
}

Kind regards,
Bruce.
7 Comments
  Re: JVM thread monitoring         


Author: Jerald Sheets
Date: Jan 31, 2008 06:20

> Is it possible to check the %%CPU,%%MEM usage of each thread produced
> by a
> JVM by using a perl script??? If yes then is there any particular
> module

I'd probably use some of the more esoteric of the $JAVA_OPTS availalbe
at Sun's site to get more detailed logging, and then parse the logfile
for the info you need.

For instance:

you can use the jmap feature and get a heap histogram:

jmap -histo

or you can get heap metrics:

jmap -heap

Also check out the fields you can get from the Heap Profiler:

java -agentlib:hprof

Most of that output can be regexed out.

Any of that can be run via system() and then just parse through for
what you're looking for. There are other utilities out there, I'm
sure, but this is how I would do it.

(I do Apache+Tomcat+Java for The Weather Channel)
Show full article (0.85Kb)
no comments
  Re: About File::Monitor         


Author: Jay Savage
Date: Jan 29, 2008 10:03

On Jan 25, 2008 12:20 PM, newsguy.com> wrote:
> "Jay Savage" gmail.com> writes:
>
>> Finally, Tom's points are important. How do you *know* that the files
>> (in this case a single directory) changed *during the sleep*? Do you
>> know that the output wasn't buffered? That the system didn't delay the
>> writes for some reason? That you were even watching the files you
>> thought you were?
>
>
>> Your best bet to make sure the module is working would, instead of
>> sleeping between scans and trying to modify the watched files from an
>> external process during a narrow window, would probably be to perform
>> your initial scan; open one of the watched files for writing; write to
>> it; flush the buffer; close it; and then rescan.
>
> Sounds like a plan for testing but the end result sought in this case
> is a monitor that *will* see changes done by external processes in some
> reasonable time frame.
> ...
Show full article (4.54Kb)
no comments
  Reference and assignment question         


Author: Roman Daszczyszak
Date: Jan 29, 2008 08:20

I was exploring why something didn't work the way I expected using
DBM::Deep (0.983 from ActiveState) and came upon some behavior I don't
understand. I think it has something to do with using bless or tie,
but I have not used either yet.

Here is my code. My questions are in the comments for the last 4 lines:
---------------------------------------
#!/perl/bin/perl
use strict;
use warnings;

use DBM::Deep;
use Data::Dumper;

unlink("test.db");
my $database = DBM::Deep->new(
file => "test.db",
locking => 1,
autoflush => 1 );
Show full article (2.06Kb)
no comments
  groups of values from an array         


Author: Peter Horvath
Date: Jan 29, 2008 06:25

Hello Perl guru's,
I need to pull multiple values form an array. There are
separator array entries. I need to be able to get all the values between
the separator values, process them, and then move onto the next group
till the end. Here is an example of the array.

========================================================================
========
media ID: 001070
media type: 1/2" cartridge tape (6)
barcode: 001070
media description...
Show full article (3.02Kb)
5 Comments
1 2 3 4 5 6 7 8 9