[25935] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8155 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 8 06:05:36 2005

Date: Wed, 8 Jun 2005 03:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 8 Jun 2005     Volume: 10 Number: 8155

Today's topics:
    Re: ActivePerl and -P option <vcotirlea@hotmail.com>
        Emacs modules for Perl programming (Jari Aalto+mail.perl)
        Exce and Perl <Mark.Seger@hp.com>
    Re: Link List matching <ebohlman@omsdev.com>
    Re: Link List matching <matteod@intelcocomm.com>
    Re: Link List matching (Anno Siegel)
        Net::FTP: cwd(' ') <josef.moellers@fujitsu-siemens.com>
    Re: Net::FTP: cwd(' ') <djames@thehub.com.au>
        Photo does not recognize format of Archive::Zip content <rtrahan@optonline.net>
    Re: summarize bytes <joe@inwap.com>
    Re: summarize bytes <bastardx@S-P-A-Mop.pl>
    Re: summarize bytes <bastardx@S-P-A-Mop.pl>
    Re: symbol table question <rtrahan@optonline.net>
    Re: Tk::FileSelect hangs on W98 root directory <wcitoan@NOSPAM-yahoo.com>
    Re: Tk::FileSelect hangs on W98 root directory <rtrahan@optonline.net>
    Re: Tk::FileSelect hangs on W98 root directory <rtrahan@optonline.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 08 Jun 2005 10:06:11 +0200
From: Viviana Vc <vcotirlea@hotmail.com>
Subject: Re: ActivePerl and -P option
Message-Id: <3gnn45Fd448eU1@individual.net>

Thanks for your answers.

In the end I chose to do as a prerun-step:
cl /EP a.pl > b.pl
where cl is the compiler of VC 7.1 that I have installed on my system,
and then run the b.pl.

Seems everything works as expected like this, so for now I'll stay with
this solution.

Thanks,
Viv

On Fri, 03 Jun 2005 12:04:40 +0200, Viviana Vc <vcotirlea@hotmail.com>
wrote :

>Hi all,
>
>I am new to perl, so I am new to these lists, but I hope I am posting in
>the right groups.
>
>I have installed on my Win 2k system the latest version of ActivePerl
>5.8.6 (http://www.activestate.com/)
>
>I have to write a perl script that uses some defines from an .h file. So
>I decided to include in the perl script that .h file (i.e. #include
>"a.h"), but in order to use those defines (i.e. #define ALFA "alfa") I
>have to run the script through the preprocessor first, and the help says
>this is supported: "-P   run program through C preprocessor before
>compilation".
>
>I tried this in 2 ways, and failed both ways:
>
>1) I tried at the beginning of the perl script to put:
>#!/usr/bin/perl -P
>but by running the script I get:
>"Can't emulate -P on #! line at a.pl line 1."
>
>2) By running the perl with -P option I always get "The system cannot
>find the path specified.". Any clue why do I get this error? Any clue
>how could I fix this?
>
>Any help would be most appreciated,
>Viv



------------------------------

Date: 08 Jun 2005 04:28:36 GMT
From: <jari.aalto <AT> poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1118204896@rtfm.mit.edu>

Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto A T poboxes com

Announcement: "What Emacs lisp modules can help with programming Perl"

    Preface

        Emacs is your friend if you have to do anything comcerning software
        development: It offers plug-in modules, written in Emacs lisp
        (elisp) language, that makes all your programmings wishes come
        true. Please introduce yourself to Emacs and your programming era
        will get a new light.

    Where to find Emacs/XEmacs

        o   Unix:
            http://www.gnu.org/software/emacs/emacs.html
            http://www.xemacs.org/

        o   Unix Windows port (for Unix die-hards):
            install http://www.cygwin.com/  which includes native Emacs 21.x.
            and XEmacs port

        o   Pure Native Windows port
            http://www.gnu.org/software/emacs/windows/ntemacs.html
            ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe

        o   More Emacs resources at
            http://tiny-tools.sourceforge.net/  => Emacs resource page

Emacs Perl Modules

    Cperl -- Perl programming mode

        http://www.cpan.org/modules/by-authors/id/ILYAZ/cperl-mode/
        http://math.berkeley.edu/~ilya/software/emacs/
        by Ilya Zakharevich

        CPerl is major mode for editing perl files. Forget the default
        `perl-mode' that comes with Emacs, this is much better. Comes
        standard in newest Emacs.

    TinyPerl -- Perl related utilities

        http://tiny-tools.sourceforge.net/

        If you ever wonder how to deal with Perl POD pages or how to find
        documentation from all perl manpages, this package is for you.
        Couple of keystrokes and all the documentaion is in your hands.

        o   Instant function help: See documentation of `shift', `pop'...
        o   Show Perl manual pages in *pod* buffer
        o   Grep through all Perl manpages (.pod)
        o   Follow POD references e.g. [perlre] to next pod with RETURN
        o   Coloured pod pages with `font-lock'
        o   Separate `tiperl-pod-view-mode' for jumping topics and pages
            forward and backward in *pod* buffer.

        o   Update `$VERSION' variable with YYYY.MMDD on save.
        o   Load source code into Emacs, like Devel::DProf.pm
        o   Prepare script (version numbering) and Upload it to PAUSE
        o   Generate autoload STUBS (Devel::SelfStubber) for you
            Perl Module (.pm)

    TinyIgrep -- Perl Code browsing and easy grepping

        [TinyIgrep is included in Tiny Tools Kit]

        To grep from all installed Perl modules, define database to
        TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
        how to set up dattabases for Perl5, Perl4 whatever you have
        installed

        TinyIgrep calls Igrep.el to to do the search, You can adjust
        recursive grep options, set search case sensitivity, add user grep
        options etc.

        You can find latest `igrep.el' module at
        <http://groups.google.com/groups?group=gnu.emacs.sources> The
        maintainer is Jefin Rodgers <kevinr <AT> ihs.com>.

    TinyCompile -- To Browse grep results in Emacs *compile* buffer

        TinyCompile is a minor mode for *compile* buffer from where
        you can collapse unwanted lines or shorten file URLs:

            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
            /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT

            -->

            cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
            file1:NNN: MATCHED TEXT
            file1:NNN: MATCHED TEXT

End



------------------------------

Date: Wed, 08 Jun 2005 05:37:39 -0400
From: Mark Seger <Mark.Seger@hp.com>
Subject: Exce and Perl
Message-Id: <42a6055a$1@usenet01.boi.hp.com>

I've been playing with the perl ole interface to talk to excel.  Very 
cool.  The problem I'm having is virtually all the documentation on how 
to do it in perl is too simplistic for anything more sophisticated and 
the everything else is in VB - perhaps an opportunity for some 
documentation enhancement?  In any event the good news is I've managed 
to figure out how to map from one syntax to the other except for VB arrays.

Specifically, I want to read in a text file that has space separated 
field and the first one is in date format.  To do everything but specify 
the date one simply does:

$Book = $Excel->Workbooks->OpenText({
   Filename=>$filename, ConsecutiveDelimiter=>1, Space=>1,});

and it works like a champ.  However to tell Excel the format of specific 
  fields, you need to add "FieldInfo" and that is defined as an array of 
2 element arrays.  I've tried a number of things but to no avail. 
Anybody know how?

If anyone is interested, the way this is captured as a macro in Excel 
looks like:

   Workbooks.OpenText Filename:= _
         "C:\mjs\excel-perl\20050601-cx01-slab-s-days1.txt",
         Origin:=437, StartRow:= 1,
         DataType:=xlDelimited, TextQualifier:=xlDoubleQuote,
         ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False,
         Comma:=False, Space:=True, Other:=False,
	FieldInfo:=Array(Array(1, 5), Array(2, 1),
         Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1),
         Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1),
         Array(11, 1)), TrailingMinusNumbers:=True

but I don't need to set all the fields as most of them are already 
defaulted the way I want them.

-mark



------------------------------

Date: 7 Jun 2005 22:12:43 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: Link List matching
Message-Id: <Xns966EB08DF2A02ebohlmanomsdevcom@130.133.1.4>

"Matteo D'Amato" <matteod@intelcocomm.com> wrote in
news:Xns966EB3FD5CE67matteodintelcocommco@216.40.28.72: 

>          I have a pipe delimited text file containing country codes
>          with their 
> country names. i.e.
> 
> 
> 30741|Greece - Corinth
> 30751|Greece - Argos
> 30821|Greece - Crete
> 31|Netherlands
> 316|Netherlands - Mobile
> 319|Netherlands - Mobile
> 3110|Netherlands - Rotterdam
> 3120|Netherlands - Amsterdam
> 3123|Netherlands - Haarlem/Heemstede
> 
> 
> This is just a sample, the actual file contains 19732 lines. Now I
> need to write a program that will take in a full phone number as an
> argument i.e. 
> 
> 308212398721 -> and will return 'Greece - Crete' and matched prefix
> '30821' 
> 
> I tried to used the link list example from the PERL FAQ, but it takes
> 7 minutes just to read the file and build the tree. Can anyone give me
> some guide lines on how to write this in the fastest way using Perl.
> Thanks 

I'd populate a hash (let's call it %codes) with the country codes as keys 
and the locations as values, and while doing that I'd keep track of the 
longest country code seen (in your example, it would be 5 digits); let's 
call that $maxcode.  To match a number, I'd start by taking the first 
$maxcode digits of the number and looking it up in the hash.  If not 
found, I'd repeat using the first $maxcode-1 digits, and so on.

I'm being a little vague here deliberately because your request looks 
slightly like a homework problem so I don't want to fill in *all* the 
details.


------------------------------

Date: 7 Jun 2005 21:27:01 -0500
From: "Matteo D'Amato" <matteod@intelcocomm.com>
Subject: Re: Link List matching
Message-Id: <Xns966EE4B635FC7matteodintelcocommco@216.40.28.72>

Ok, this sounds faster. You gave me an idea, how about grouping them by 
prefix size? i.e

group size 5:
30741|Greece - Corinth
30751|Greece - Argos
 ..

group size 2:
31|Netherlands
 ..

while also keeping track of max size. So start at max size and only look in 
the group matching that size and work my way down. How does this sound? Can 
it be improved?

--Matteo


Eric Bohlman <ebohlman@omsdev.com> wrote in
news:Xns966EB08DF2A02ebohlmanomsdevcom@130.133.1.4: 

> "Matteo D'Amato" <matteod@intelcocomm.com> wrote in
> news:Xns966EB3FD5CE67matteodintelcocommco@216.40.28.72: 
> 
>>          I have a pipe delimited text file containing country codes
>>          with their 
>> country names. i.e.
>> 
>> 
>> 30741|Greece - Corinth
>> 30751|Greece - Argos
>> 30821|Greece - Crete
>> 31|Netherlands
>> 316|Netherlands - Mobile
>> 319|Netherlands - Mobile
>> 3110|Netherlands - Rotterdam
>> 3120|Netherlands - Amsterdam
>> 3123|Netherlands - Haarlem/Heemstede
>> 
>> 
>> This is just a sample, the actual file contains 19732 lines. Now I
>> need to write a program that will take in a full phone number as an
>> argument i.e. 
>> 
>> 308212398721 -> and will return 'Greece - Crete' and matched prefix
>> '30821' 
>> 
>> I tried to used the link list example from the PERL FAQ, but it takes
>> 7 minutes just to read the file and build the tree. Can anyone give
>> me some guide lines on how to write this in the fastest way using
>> Perl. Thanks 
> 
> I'd populate a hash (let's call it %codes) with the country codes as
> keys and the locations as values, and while doing that I'd keep track
> of the longest country code seen (in your example, it would be 5
> digits); let's call that $maxcode.  To match a number, I'd start by
> taking the first $maxcode digits of the number and looking it up in
> the hash.  If not found, I'd repeat using the first $maxcode-1 digits,
> and so on. 
> 
> I'm being a little vague here deliberately because your request looks 
> slightly like a homework problem so I don't want to fill in *all* the 
> details.



------------------------------

Date: 8 Jun 2005 09:52:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Link List matching
Message-Id: <d86f5c$kgm$1@mamenchi.zrz.TU-Berlin.DE>

Matteo D'Amato <matteod@intelcocomm.com> wrote in comp.lang.perl.misc:
> 
> Hi,
>     	I have a pipe delimited text file containing country codes with their 
> country names. i.e.
> 
> 
> 30741|Greece - Corinth
> 30751|Greece - Argos
> 30821|Greece - Crete
> 31|Netherlands
> 316|Netherlands - Mobile
> 319|Netherlands - Mobile
> 3110|Netherlands - Rotterdam
> 3120|Netherlands - Amsterdam
> 3123|Netherlands - Haarlem/Heemstede
> 
> 
> This is just a sample, the actual file contains 19732 lines. Now I need to 
> write a program that will take in a full phone number as an argument i.e.
> 
> 308212398721 -> and will return 'Greece - Crete' and matched prefix '30821'
> 
> I tried to used the link list example from the PERL FAQ, but it takes 7 
> minutes just to read the file and build the tree. Can anyone give me some 
> guide lines on how to write this in the fastest way using Perl. Thanks

The canonical data structure for a prefix-oriented search is the "trie".
A trie (from "retrieval") is a tree-like collection of data organized
so that all codes that begin with the same prefix are stored together.
A classic treatment is in Knuth, _TAoCP_, Sorting and Searching, but
most textbooks with "Data Structures" in the title will deal with tries.

In view of the fact that codes consist of digits only, we can use a
Perl array(ref) as the basic structure, using the individual digits
as indices.  Thus the data above would be represented as an array
with a single entry under index 3 (because all codes begin with 3).
This location holds a sub-trie (an array again) whose two entries
are stored at indices 0 and 1 (the only digits in second position
in the data) with 0 holding the Greek fraction and 1 the Dutch one.
And so on...  Since "31" is a valid entry (for "Netherlands"),
we use an index that can't be a digit (10) to mark the fact.

Retrieval is fast and simple:  At each level, (that is, for each digit
of a code to search) follow the sub-trie indicated by the digit.
If it doesn't exist, the search has failed.  If the last digit of
the search code is reached, look if an entry under index 10 exists in
the corresponding sub-trie.  If it does, we have found the entry.
If it doesn't the search also fails.

This standard trie search finds only exact matches, but a variant
would find the longest possible prefix of a given number.

There are trie modules on CPAN you could use, but below is an ad-hoc
solution.

Anno

    #!/usr/bin/perl
    use strict; use warnings; $| = 1; # @^~`
    use Vi::QuickFix;

    my $trie;
    while ( <DATA> ) {
        print;
        chomp;
        add_to_trie( $trie, split /\|/);
    }
    print "\n";

    for (
        qw( 4 99 30742 30741999), # non-existing
        qw( 30741 30751 30821 31 316 319 3110 3120 3123), # existing
     ) {
        my $res = find_in_trie( $trie, $_) || '-none-';
        print "$_ -> $res\n";
    }

    ########################################################################

    use constant VAL => 10;

    sub add_to_trie {
        $_[ 0] ||= [];
        my ( $trie, $str, $val) = @_;
        if ( my ( $char, $rem) = $str =~ /(.)(.*)/ ) {
            add_to_trie( $trie->[ $char], $rem, $val);
        } else {
            $trie->[ VAL] = $val;
        }
    }

    sub find_in_trie {
        my ( $trie, $str) = @_;
        if ( my ( $char, $rem) = $str =~ /(.)(.*)/ ) {
            return find_in_trie( $trie->[ $char], $rem);
        } else {
            return $trie->[ VAL];
        }
    }

    __DATA__
    30741|Greece - Corinth
    30751|Greece - Argos
    30821|Greece - Crete
    31|Netherlands
    316|Netherlands - Mobile
    319|Netherlands - Mobile
    3110|Netherlands - Rotterdam
    3120|Netherlands - Amsterdam
    3123|Netherlands - Haarlem/Heemstede


------------------------------

Date: Wed, 08 Jun 2005 10:36:23 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Net::FTP: cwd(' ')
Message-Id: <d86agm$7s6$1@nntp.fujitsu-siemens.com>

Hi,

I have this problem:

I'd like to access a directory named ' ' (a single blank) on an ftp serve=
r.
I can connect all right, but the $ftp->cwd(' '), while succeeding, only=20
moves me to /, rather than into the directory.
I've also tried '" "' and '\ ' to no avail.

#!/usr/bin/perl
use Net::FTP;

my $host =3D 'X.Y.Z';
my $username =3D 'anonymous';
my $password =3D 'anonymous';

my $dir =3D ' ';

$ftp=3DNet::FTP->new($host,Timeout=3D>240) or die "Cannot connect";
print "Connected\n";

$ftp->login($username, $password) or die "Cannot login";
print "Logged in\n";

$ftp->cwd($dir) or die "Cannot chdir to blank";
print "Now in ", $ftp->pwd, "\n";

my @files =3D $ftp->ls or die "Cannot get file list";
foreach (@files) {
     print ">$_<\n";
}
$ftp->quit;

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



------------------------------

Date: Wed, 08 Jun 2005 09:33:29 GMT
From: Damian James <djames@thehub.com.au>
Subject: Re: Net::FTP: cwd(' ')
Message-Id: <slrndadefb.ak5.djames@puli.home>

On Wed, 08 Jun 2005 10:36:23 +0200, Josef Moellers said:
> 
> I'd like to access a directory named ' ' (a single blank) on an ftp server.
> I can connect all right, but the $ftp->cwd(' '), while succeeding, only
> moves me to /, rather than into the directory.
> I've also tried '" "' and '\ ' to no avail.
> 

Hmmm

puli% mkdir foo
puli% mkdir foo/\ 
puli% touch foo/\ /bar
puli% perl -le 'system "ls $_" for glob "test/*"'

puli% perl -le 's/[ ]/\\$&/, system "ls $_" for glob "foo/*"'
bar


Remember that to put a literal backslash in a string, even in single
quotes, you need to escape it. So that should be '\\ '.

--damian


------------------------------

Date: Wed, 08 Jun 2005 05:13:30 -0400
From: Richard Trahan <rtrahan@optonline.net>
Subject: Photo does not recognize format of Archive::Zip contents
Message-Id: <cEype.70207$NZ1.53010@fe09.lga>

Consider the following sub. On entry, $tl is a Toplevel, $rmn is an 
index into an array of Archive::Zip object member names; comments 
explain the others.

sub display_image
{
   my ($tl,$rmn) = @_; # Toplevel, requested member number
   my $mnref = $tl->{'member_names'};  # ref to member names array
   my $zip = $tl->{'zip'}; # Archive::Zip object

   my $membername = $mnref->[$rmn];
   my $member = $zip->memberNamed($membername);
   $tl->{'current_member_number'} = $rmn;  # reset current member
   my $fh;
   my $fn = "C:/windows/temp/temp.jpg";
   open $fh,">",$fn;
   $member->extractToFileHandle($fh);  # this works ok
   close $fh;
   # my $contents = $zip->contents($member);  # (binary) jpeg data
   # open $fh,">","C:/temp/temp2.jpg";
   # binmode $fh;
   # print $fh $contents;  # this works ok
   # close $fh;
   my $image = $tl->Photo(
     '-format' => 'jpeg',
     # -data => $contents,  # this doesn't work
     -file => $fn,  # this works ok
     );
   my $button = $tl->{'button'}; # button where image is displayed
   $button->configure(-image => $image); # set image
   $tl->configure(-title => $tl->{'file_name'} .
     ":" . $tl->{'sequence'} . " - $membername");
}

Commented sections show that I can successfully extract the "contents" 
of a Zip::Archive member (all of which are jpeg files), and write it to 
a file (it displays perfectly in a browser, PhotoEditor, etc.). I can 
also "extract" that member to another file and specify that file name to 
the Photo object, whereupon it displays just fine. But when I take the 
"contents", which is supposed to be pure jpeg binary data, and feed it 
to the Photo object, the system complains that it doesn't recognize the 
file format.

Any help, please.


------------------------------

Date: Tue, 07 Jun 2005 15:30:49 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: summarize bytes
Message-Id: <XvCdnUC9s6OsvTvfRVn-uQ@comcast.com>

bastardx wrote in <d84idb$r1u$1@nemesis.news.tpi.pl>:

> I wonder if you can point me to some scripts because I don't know perl.
> I think that perl is best for what I want to do.
> 
> ID    DATE    IN    OUT
> id12    2005-06-07    12    1091
> id16    2005-06-07    893    17881
> id12    2005-06-07    53    9912
> id34    2005-06-07    323    7211
> id34    2005-06-07    15    2381
> id34    2005-06-07    542    9771
> id16    2005-06-07    90    9912
> id16    2005-06-07    409    6712
> id12    2005-06-07    311    3443
> id34    2005-06-07    342    1123
> id12    2005-06-07    90    7455
> id34    2005-06-07    145    512
> id12    2005-06-07    88    1667
> 
> I want to summarize IN and OUT bytes for particular ID per day

Joe Smith wrote:
> That's trivial to do using a hash or two in Perl.

Two hashes:     $in{$_} and $out{$_},
One hash: $data{$_}{IN} and $data{$_}{OUT})

#!/usr/bin/perl
use strict; use warnings;
my %data;
$_ = <DATA>;    # Swallow first line
$_ = "  ID";
$data{$_}{DATE} = 'last DATE';
$data{$_}{IN}   = 'TOTAL_IN';
$data{$_}{OUT}  = 'TOTAL_OUT';
while(<DATA>){
   my($id,$date,$in,$out)=split;
   $data{$id}{DATE} = $date;
   $data{$id}{IN}  += $in;
   $data{$id}{OUT} += $out;
}
printf "%-6s %10s %10s %10s\n",$_,
   $data{$_}{DATE},$data{$_}{IN},$data{$_}{OUT}
     foreach sort keys %data;

__DATA__
ID      DATE           IN    OUT
id12    2005-06-03     12   1091
id16    2005-06-04    893  17881
id12    2005-06-04     53   9912
id34    2005-06-04    323   7211
id34    2005-06-04     15   2381
id34    2005-06-04    542   9771
id16    2005-06-04     90   9912
id16    2005-06-05    409   6712
id12    2005-06-05    311   3443
id34    2005-06-06    342   1123
id12    2005-06-06     90   7455
id34    2005-06-07    145    512
id12    2005-06-07     88   1667


------------------------------

Date: Wed, 8 Jun 2005 10:29:18 +0200
From: "bastardx" <bastardx@S-P-A-Mop.pl>
Subject: Re: summarize bytes
Message-Id: <d86aig$kk3$1@nemesis.news.tpi.pl>


> #!/usr/bin/perl
> use strict; use warnings;
> my %data;
> $_ = <DATA>;    # Swallow first line
> $_ = "  ID";
> $data{$_}{DATE} = 'last DATE';
> $data{$_}{IN}   = 'TOTAL_IN';
> $data{$_}{OUT}  = 'TOTAL_OUT';
> while(<DATA>){
>   my($id,$date,$in,$out)=split;
>   $data{$id}{DATE} = $date;
>   $data{$id}{IN}  += $in;
>   $data{$id}{OUT} += $out;
> }
> printf "%-6s %10s %10s %10s\n",$_,
>   $data{$_}{DATE},$data{$_}{IN},$data{$_}{OUT}
>     foreach sort keys %data;

Thank you very much for that hint
I will try to customize that a litlle bit :) 




------------------------------

Date: Wed, 8 Jun 2005 10:51:49 +0200
From: "bastardx" <bastardx@S-P-A-Mop.pl>
Subject: Re: summarize bytes
Message-Id: <d86bsn$hv$1@nemesis.news.tpi.pl>


> Two hashes:     $in{$_} and $out{$_},
> One hash: $data{$_}{IN} and $data{$_}{OUT})
>
> #!/usr/bin/perl
> use strict; use warnings;
> my %data;
> $_ = <DATA>;    # Swallow first line
> $_ = "  ID";
> $data{$_}{DATE} = 'last DATE';
> $data{$_}{IN}   = 'TOTAL_IN';
> $data{$_}{OUT}  = 'TOTAL_OUT';
> while(<DATA>){
>   my($id,$date,$in,$out)=split;
>   $data{$id}{DATE} = $date;
>   $data{$id}{IN}  += $in;
>   $data{$id}{OUT} += $out;
> }
> printf "%-6s %10s %10s %10s\n",$_,
>   $data{$_}{DATE},$data{$_}{IN},$data{$_}{OUT}
>     foreach sort keys %data;
>
> __DATA__
> ID      DATE           IN    OUT
> id12    2005-06-03     12   1091
> id16    2005-06-04    893  17881
> id12    2005-06-04     53   9912
> id34    2005-06-04    323   7211
> id34    2005-06-04     15   2381
> id34    2005-06-04    542   9771
> id16    2005-06-04     90   9912
> id16    2005-06-05    409   6712
> id12    2005-06-05    311   3443
> id34    2005-06-06    342   1123
> id12    2005-06-06     90   7455
> id34    2005-06-07    145    512
> id12    2005-06-07     88   1667


works great
this exacly  what i want
how to read this data from file? 




------------------------------

Date: Wed, 08 Jun 2005 04:45:22 -0400
From: Richard Trahan <rtrahan@optonline.net>
Subject: Re: symbol table question
Message-Id: <Rdype.70200$NZ1.60217@fe09.lga>

Jim Gibson wrote:

> In article <s3lpe.3083$S62.3007@fe11.lga>, Richard Trahan
> Have you looked at comp.lang.perl.tk ? I think they are hanging out
> there.
> 
> 
Thank you. I would have found this before Google screwed up their Groups
by removing computer/programming/languages; now it doesn't show up 
anywhere, but I found it in my browser subscriptions list.


------------------------------

Date: Wed, 08 Jun 2005 00:12:28 -0000
From: "W. Citoan" <wcitoan@NOSPAM-yahoo.com>
Subject: Re: Tk::FileSelect hangs on W98 root directory
Message-Id: <slrndacdv3.2ks.wcitoan@wcitoan-via.supernews.com>

Richard Trahan wrote:
>  I'm running ActiveState build 811 on W98. When using Tk::FileSelect,
>  attempting to navigate to the root directory of any drive hangs the
>  interpeter. There is no mention of this problem in this ng. Is anyone
>  else experiencing this?

Your example code works fine for me (811 on XP).  A quick Google search
shows that this appears to be a known problem on 98.
http://groups-beta.google.com/groups?q=perl%20windows%2098%20FileSelect
Look at the 1st and 2nd thread.  The first thread suggests using
getOpenFile instead (which uses the standard Windows interface).

- W. Citoan
-- 
If voting changed anything, they'd make it illegal.
-- Graffiti


------------------------------

Date: Wed, 08 Jun 2005 04:35:54 -0400
From: Richard Trahan <rtrahan@optonline.net>
Subject: Re: Tk::FileSelect hangs on W98 root directory
Message-Id: <Z4ype.70199$NZ1.57252@fe09.lga>

W. Citoan wrote:
> Richard Trahan wrote:
> 
>> I'm running ActiveState build 811 on W98. When using Tk::FileSelect,
>> attempting to navigate to the root directory of any drive hangs the
>> interpeter. There is no mention of this problem in this ng. Is anyone
>> else experiencing this?
> 
> 
> Your example code works fine for me (811 on XP).  A quick Google search
> shows that this appears to be a known problem on 98.
> http://groups-beta.google.com/groups?q=perl%20windows%2098%20FileSelect
> Look at the 1st and 2nd thread.  The first thread suggests using
> getOpenFile instead (which uses the standard Windows interface).
> 
> - W. Citoan

Thank you for your response. I will use that method, but there is still
something wrong with it.

The example shown in the Perl html page for getOpenFile shows a 
variable, $types, as a list of lists, and it works ok as shown, but if
you reduce this list to a single line, you get a syntax error. Specifically:
my $types = [
	['Text Files',  ['.txt','.text']],
];
will not work. IMO, this is clearly a bug. Notice also that the syntax 
of $types is inconsistent with the description under the heading 
"Specifying File Patterns"; the $types example shows an extra level of 
list nesting.

It's too bad they didn't fix FileSelect; getOpenFile is not quite the 
same because it isn't a widget and it allows the user to do things I 
don't want him/her to do, like delete files and create directories.

In the context of the birth and death of galaxies, I suppose it's not
that important.


------------------------------

Date: Wed, 08 Jun 2005 04:54:58 -0400
From: Richard Trahan <rtrahan@optonline.net>
Subject: Re: Tk::FileSelect hangs on W98 root directory
Message-Id: <Qmype.70204$NZ1.5493@fe09.lga>

Also, it ignores -initialdir.


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8155
***************************************


home help back first fref pref prev next nref lref last post