[26107] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8304 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 4 14:05:29 2005

Date: Thu, 4 Aug 2005 11: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           Thu, 4 Aug 2005     Volume: 10 Number: 8304

Today's topics:
    Re: "anonymous" variable in Perl? <vtatila@mail.student.oulu.fi>
        Download Files With a perl script <heli0s@localhost.localdomain>
    Re: Download Files With a perl script <sisyphus1@nomail.afraid.org>
    Re: Download Files With a perl script axel@white-eagle.invalid.uk
        File::Slurp and using it with chomp <x@rebelhomicide.demon.nl>
    Re: Graphical User Interface for perl <jgibson@mail.arc.nasa.gov>
    Re: writing binary files <john@castleamber.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 4 Aug 2005 19:27:16 +0300
From: "Veli-Pekka Tätilä" <vtatila@mail.student.oulu.fi>
Subject: Re: "anonymous" variable in Perl?
Message-Id: <dctflh$u0d$1@news.oulu.fi>

Anno Siegel wrote:
<localtime>
>> One quick question, though. Is there an elegant way of getting the time
>> components in a hash? It would be easier to memorize <snip>
> You can do it manually, <<snip>
> but that's probably not what you mean by elegant.
Well, no. Having to memorize the ordre at the point of using the function 
sort of negates my point. Because if you memorize the order, it is just 
easier to deal with a list and comment appropriately.

> module Time::Piece (available from CPAN) does it for you.  It overrides
> localtime() and gmtime() so that they return objects
Ah, that's the ticket. I'm not sure if I'll change to this interface 
full-time but nice to know someone has already done the hard work, as usual 
in Perl.

> Note that Time::Piece returns the month (and year) in conventional 
> counting (from 1)
Actually, I find this more intuitive.

-- 
With kind regards Veli-Pekka Tätilä (vtatila@mail.student.oulu.fi)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila/ 




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

Date: Thu, 04 Aug 2005 14:54:26 +0200
From: heli0s <heli0s@localhost.localdomain>
Subject: Download Files With a perl script
Message-Id: <pan.2005.08.04.12.54.25.699110@localhost.localdomain>

Hi,

I'm having a bit of a problem with a script I'm writing. I want the script
to read in a txt file with a list of files to download and then go through
the list of files to get them from the net. 

it should be something like this:

use LWP::Simple;

open (FILE,"all.m3u");
@file = <FILE>;
close FILE;

foreach $line (@file){
	get ( $line );
}

As seen in the above code, i've been looking at LWP::Simple, but what i
have here is no good. Maybe i'm doing something wrong but i havent figured
it out yet.

Greets Christiaan


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

Date: Thu, 4 Aug 2005 23:12:21 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Download Files With a perl script
Message-Id: <42f2146b$0$1909$afc38c87@news.optusnet.com.au>


"heli0s" <heli0s@localhost.localdomain> wrote in message

>
> use LWP::Simple;

use warnings;

>
> open (FILE,"all.m3u");
> @file = <FILE>;
> close FILE;
>
> foreach $line (@file){

chomp($line);

> get ( $line );
> }
>

Hth.

Cheers,
Rob




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

Date: Thu, 04 Aug 2005 17:23:45 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Download Files With a perl script
Message-Id: <BasIe.117$FG3.103@fe3.news.blueyonder.co.uk>

heli0s <heli0s@localhost.localdomain> wrote:
> I'm having a bit of a problem with a script I'm writing. I want the script
> to read in a txt file with a list of files to download and then go through
> the list of files to get them from the net. 
> 
> it should be something like this:
> 
> use LWP::Simple;
> 
> open (FILE,"all.m3u");
> @file = <FILE>;
> close FILE;
> 
> foreach $line (@file){
>        get ( $line );
> }
 
> As seen in the above code, i've been looking at LWP::Simple, but what i
> have here is no good. Maybe i'm doing something wrong but i havent figured
> it out yet.

Do you have a sample of a couple of lines from all.m3u?

Axel
 


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

Date: Thu, 04 Aug 2005 15:30:37 +0200
From: loccy <x@rebelhomicide.demon.nl>
Subject: File::Slurp and using it with chomp
Message-Id: <pan.2005.08.04.13.30.36.990131@rebelhomicide.demon.nl>


Hi all. 

I've been using File::Slurp to avoid using open, mostly because I
will be using it in the future in scripts where many files get read, that
often consist of only one line. It would be a bit tedious to do it without
File::Slurp, and so I'm learning to use it to practice a bit.
qw( slurp ) makes sure slurp() is an alias for read_file() to shorten it
even further. The problem with the script below is, that often these
single line files contain a newline at the end. I have been unable to use
chomp() in an efficient way to counter this (here's an example): 

perl -e 'use File::Slurp ; print chomp(read_file("/proc/uptime")) . "\n";'
Can't modify non-lvalue subroutine call in chomp at -e line 1, near ")) "
Execution of -e aborted due to compilation errors.

It strikes me as inefficient to store everything in a scalar first and
then remove the newlines with a regex. Trying to use map() only got me in
trouble further. Any suggestions?

regards, loccy

(the code below prints newlines, I'd like to have them removed from the
output efficiently)

#!/usr/bin/perl
use File::Slurp qw( slurp );

for 
(glob "/sys/bus/usb/devices/*/*/*/block /sys/bus/usb/devices/*/*/*/*/block" ) {
    $_ = readlink $_;
    s|.*/||g;
    $dev{$_}++;
}

for ( keys %dev ) {
    print(  "$_ "
          . slurp("/sys/block/$_/device/vendor")
          . slurp("/sys/block/$_/device/model")
          . "\n" );
}

# output should be something like "sda Generic USB Flash Disk"



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

Date: Thu, 04 Aug 2005 09:20:54 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Graphical User Interface for perl
Message-Id: <040820050920540742%jgibson@mail.arc.nasa.gov>

In article <pan.2005.08.04.05.13.00.916247@newlogic.com>, Guenther
Sohler <guenther.sohler@newlogic.com> wrote:

> Hallo,
> 
> I'd like to do a perl script which is more user interactive - having
> a graphical frontend. I have found perltk,
> 
> but its not installed in our company and i dont like the concept of tk.
> I more like something like gtk.
> Is there an alternative to perl-tk ?
> Does any similar language to perl support a graphical interface like gtk ?
> 
> rds
> 

See the discussion of Perl-Tk vs. other GUI systems at 

<http://tinyurl.com/btzdr>


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


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

Date: 4 Aug 2005 16:28:57 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: writing binary files
Message-Id: <Xns96A874AFE1F04castleamber@130.133.1.4>

"mermadak" <mermadak@yahoo.com> wrote:

> 
> "John Bokma" <john@castleamber.com> wrote in message 
> news:Xns96A8BA198CF8castleamber@130.133.1.4...
>>> Also, the parts of this that really make it an issue is that the
>>> data is coming off of a DOS machine (so endian is a concern here
>>> right?) and is a rather large text file with a ton of scientific
>>> data points (from 500k to 5MB files).
>>
>> So basically you want to convert numbers in a text file to some short
>> binary notation?
> 
> Exactly... any ideas?

Python or Perl, since your post referred to Python :-D

>> 5MB... you are aware that the current year is 2005? :-)
> 
> Does that mean 5MB shouldn't be a problem???

Yup, your computer probably has 100 times as much memory.

> I originally tried writing a program to simply maniplute these files
> in my native programming languages of VB and C++ which would hang due
> to the size of these files.

If a C++ program would hang on 5MB files, how can programs handle 10M 
MP3 files, or 700 MB movies?

> I finally found a PERL script that would

PERL is not an acronym :-)

> handle parsing this much data.

Again: 5MB is not much. My best guess is that you should rethink your 
algoritm(s).

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

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 8304
***************************************


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