HTTP Tiny Range Header

2012-05-28 Thread raphael()
Hello,

I am trying to use HTTP::Tiny module to download file with RANGE attribute.
However I cannot accomplish it.

In WWW::Mechanize the code I use is simple
my $file_obj = $ua-get( $url, 'Range' = sprintf(bytes=%s-%s,
$file_size, $content_length - 1), ) or die;

But I want to use the Tiny Module. How do I do this in HTTP::Tiny?

In the doc it says I have to give it a \%options hash-ref.
my %options= { default_headers = Range = bytes=0-999, };
my $file_obj = $ua-get( $url, \%options ) or die;

something like above or am I sorely mistaken?
The above code doesn't work. Even if half file exists the whole file is
re-downloaded so range attribute doesn't work.
I checked the length of downloaded content in debugger.  May be the hash
ref thing I am doing is wrong!

A sample code will be most helpful.

Thanks in advance.

HTTP::Tiny Documentation
http://search.cpan.org/~dagolden/HTTP-Tiny-0.021/lib/HTTP/Tiny.pm


Re: HTTP Tiny Range Header

2012-05-28 Thread raphael()
On Mon, May 28, 2012 at 8:37 PM, Rob Dixon rob.di...@gmx.com wrote:

 On 28/05/2012 15:15, raphael() wrote:
 
  I am trying to use HTTP::Tiny module to download file with RANGE
 attribute.
  However I cannot accomplish it.
 
  In WWW::Mechanize the code I use is simple
  my $file_obj = $ua-get( $url, 'Range' =  sprintf(bytes=%s-%s,
  $file_size, $content_length - 1), ) or die;
 
  But I want to use the Tiny Module. How do I do this in HTTP::Tiny?
 
  In the doc it says I have to give it a \%options hash-ref.
  my %options= { default_headers =  Range =  bytes=0-999, };
  my $file_obj = $ua-get( $url, \%options ) or die;
 
  something like above or am I sorely mistaken?
 
  The above code doesn't work. Even if half file exists the whole file is
  re-downloaded so range attribute doesn't work.
 
  I checked the length of downloaded content in debugger.  May be the hash
  ref thing I am doing is wrong!
 
  A sample code will be most helpful.

 Hi Raphael

 HTTP::Tiny is very similar to WWW::Mechanize in this regard. The only
 difference is that the request headers should be passed as a hash
 reference instead of a plain hash, so you basically need a pair of
 containing braces around what you have already written.

 You shouldn't play with the default headers unless you want to limit the
 download to the same range of bytes every time. Instead you should pass
 specific values in the calls to the get method.

 Also you cannot initialise a hash using

  my %options= { default_headers =  Range =  bytes=0-999, };

 as you are trying to assign an anonymous hash - a single scalar value -
 to a hash that requires data in key/value pairs.

 You can write

  my $response = $http-get($url, { headers = { Range = 'bytes=1-99' } }
 );

 or you can set up the headers in a separate hash, like this

  my %headers = ( Range = 'bytes=1-99' );
  my $resp = $http-get('http://www.bbc.co.uk/', { headers = \%headers }
 );

 Below is a complete working program for you to experiment with.

 HTH,

 Rob



  use strict;
  use warnings;

  use HTTP::Tiny;

  my $http = HTTP::Tiny-new;

  my %headers = ( Range = 'bytes=1-99' );
  my $resp = $http-get('http://www.bbc.co.uk/', { headers = \%headers }
 );

  print @{$resp}{qw/ status reason /}\n\n;

  print $resp-{content}, \n;


Wow! That was quick and perfect. Also thanks for explaining how to use the
headers hash separately . It was such a simple thing now that I see a
sample code. Shame on me :(


qmv (renameutils) for cygwin using perl

2011-01-22 Thread raphael()
Hello,

qmv.exe (from renameutils) lets you edit multiple filenames in a text
editor.
I cannot get it to work in cygwin 1.7x (gives fork + jump error ??). So I
tried to write it in Perl.

qmv's  format is simple

filename-1empty spacefilename_1_to_be_edited
filename 2empty spacefilename_2_to_be_edited
filename_3empty spacefilename_3_to_be_edited

You edit the names and then it renames the files you have changed. Problem I
am having is how can I split the two file names by space
since file name itself might also have spaces in them.

I tried something like this

( $OldFileName, $NewFileName ) = split /\s{5,}/;

It works but not always.
I also thought to use and alternate anchor like pipe or comma but it looks
ugly.
Beside qmv.exe uses space to separate file names Any help would be
appreciated. Thanks.


Re: qmv (renameutils) for cygwin using perl

2011-01-22 Thread raphael()
On Sat, Jan 22, 2011 at 2:56 PM, Shlomi Fish shlo...@iglu.org.il wrote:

 Hi Raphael,

 On Saturday 22 Jan 2011 11:03:28 raphael() wrote:
  Hello,
 
  qmv.exe (from renameutils) lets you edit multiple filenames in a text
  editor.
  I cannot get it to work in cygwin 1.7x (gives fork + jump error ??). So I
  tried to write it in Perl.
 
  qmv's  format is simple
 
  filename-1empty spacefilename_1_to_be_edited
  filename 2empty spacefilename_2_to_be_edited
  filename_3empty spacefilename_3_to_be_edited
 
  You edit the names and then it renames the files you have changed.
 Problem
  I am having is how can I split the two file names by space
  since file name itself might also have spaces in them.
 
  I tried something like this
 
  ( $OldFileName, $NewFileName ) = split /\s{5,}/;
 

 1. You should use my here so the variables will be declared the closest to
 their usage.

 2. You shouldn't use $_.

 3. Please avoid CamelCase names.

  It works but not always.

 When doesn't it work? Can you give a test case?

 Regards,

Shlomi Fish

  I also thought to use and alternate anchor like pipe or comma but it
 looks
  ugly.
  Beside qmv.exe uses space to separate file names Any help would be
  appreciated. Thanks.

 --
 -
 Shlomi Fish   http://www.shlomifish.org/
 The Human Hacking Field Guide - http://shlom.in/hhfg

 Chuck Norris can make the statement This statement is false a true one.

 Please reply to list if it's a mailing list post - http://shlom.in/reply .



Thanks for the reply.  CamelCase Names ~ my first time as I saw few people
using it and thought what was the attraction! I am usually _underscore_ guy.

-- CODE --

use strict;
use warnings;
use File::Temp;
use Sort::Naturally;
use Getopt::Std 'getopts';

my ( %opts );
getopts('vfephc:', \%opts);
usage if $opts{h};

my ( %hash, %files );
my $tmp = File::Temp-new();
my $filename = $tmp-filename();
my @selected_files = $opts{c} ? glob $opts{c} : glob *;
if ( $opts{f} ) { @selected_files = grep { -f $_ } @selected_files }
%files = map { $_ = $_ } @selected_files ;

for my $file ( nsort keys %files ) {
printf { $tmp } %s %65s\n, $file, $files{$file}; # THIS CAUSES
UNINITIALIZED ERROR IF FILE NAME IS VERY LONG . THE REASON FOR PREVIOUS
QUESTION
} # HOW DO I SEPARATE TWO FILE NAMES?

my $editor =  $opts{e} // 'C:\cygwin\bin\vim-nox.exe';
system( $editor, $filename );
open my $FH, '', $filename or exit $!;
my @names = $FH;
close( $FH );

for ( @names ) {
chomp; # GIVES WARNINGS IF I RUN THE COMMAND UT DONT EDIT ANYTHING
my ( $OldFileName, $NewFileName ) = split /\s{5,}/; # WAS DECLARED
DIDN'T COPY IT IN MAIL
$hash{$OldFileName} = $NewFileName; # DON'T USE CAMEL CASE
}

for my $key ( keys %files ) {
next if ( $files{$key} eq $hash{$key} );
#skip rename if file with edited name exists
unless ( -e $hash{$key} ) {
if ( $opts{p} or $opts{v} ) {
print [$key] = [$hash{$key}]\n;
next if $opts{p} ;
}
   rename( $key, $hash{$key} );
}
}

sub usage
{
print STDERR  EOF;
usage: perl qmv.pl -e -p -v -c'*.extension'

-c selection custom files like -c'*.rar'
-e editor
-f files only (default is files and folders)
-h help (this message!)
-p print-only do not rename
-u undo all changes (not implemented yet)
-v verbose similar to -p but renames files

EOF
exit 0;
}

-- CODE END --

See comments for question. Its a mess of code. I know.


Re: fork, parallel and global values

2010-05-15 Thread raphael()
On Fri, May 14, 2010 at 3:07 PM, Dr.Ruud
rvtol+use...@isolution.nlrvtol%2buse...@isolution.nl
 wrote:

 raphael() wrote:

  I want to do work on all elements of an array simultaneously.


 What kind of data/reality does your array represent?



  I tried Parallel::ForkManager. It works well when you don't need to update
 global value like downloading
 multiple files at the same time. I want something like above that forks
 while updating global values.
 Are threads/fork what I am looking for?


 If you have a list of file names that need to be processed, and that can be
 handled independently, then always go for fork-join, don't even consider
 threading.

 The parent will detect when the child is finished, and can look in a
 predefined location (I normally use a database) for the result.

 If your audience is not a bunch of twitchers, then stay away from
 threading.

 --
 Ruud

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/


Hi,  thanks for replying. No twitching audience :)
This is just a rough project of mine trying to get a feel of parallelism.

Your advice on using a database as a place to use shared info is more useful

after I read http://www.perlmonks.org/index.pl?node_id=288022

*thanks* let see what I can gain from this.


Re: fork, parallel and global values

2010-05-13 Thread raphael()
On Tue, May 11, 2010 at 1:23 AM, C.DeRykus dery...@gmail.com wrote:

 On May 10, 7:07 am, raphael.j...@gmail.com (raphael()) wrote:
  Hello,
 
  -- CODE --
 
  #!/usr/bin/env perl
 
  use strict;
  use warnings;
  use Parallel::ForkManager;
 
  # Parallel::ForkManager
  my $pfm = Parallel::ForkManager-new(5);
 
  my %hash;
  for my $num ( qw/ 1 2 3 4 5 1 / ) {
  $pfm-start and next;
  $hash{$num}++;
  $pfm-finish;}
 
  $pfm-wait_all_children;
 
  # doesn't print because %hash is undef
  print $_ = $hash{$_}\n for sort keys %hash;
 
  print hash is undef\n unless %hash;
 
  --- END ---
 
  I want to do work on all elements of an array simultaneously.
  I tried Parallel::ForkManager. It works well when you don't need to
 update
  global value like downloading
  multiple files at the same time. I want something like above that forks
  while updating global values.
  Are threads/fork what I am looking for?
 
  Any help would be *appreciated.*

 If your host supports Sys V IPC, one possible solution:
 IPC::Shareable

 --
 Charles DeRykus


 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/



No  IPC::Shareable. But I can go in for Win32::MMF::Shareable.
However I went in for threads::shared which is working great so far.

You know this threads `thing` is great. So much work can be done within
short time.

--- CODE --
use strict;
use warnings;
use threads;
use threads::shared;
use File::Basename;
use WWW::Mechanize;
use Parallel::ForkManager;

my ( %hash, @missing ) :shared;

#  ---BLAH BLAH ~ CODE HERE

if ( $response-is_success ) {
my $ref = []; share( $ref );# THIS IS SO COOL! LOL
push @{$ref}, ( $INFO, $url );
$hash{$base} = $ref; # $hash{$base} = [] ~ ERROR.
Only scalar references?
 } else {

--- END ---

That it. No questions for now.


Re: fork, parallel and global values

2010-05-11 Thread raphael()
On Tue, May 11, 2010 at 1:59 AM, Eric Veith1 eric.ve...@de.ibm.com wrote:

 raphael() raphael.j...@gmail.com wrote on 05/10/2010 04:07:58 PM:
  I want to do work on all elements of an array simultaneously.

 To clarify: You want to access an hash defined in the parent process from
 all N child processes?

 I'm sorry to tell you, but this won't work so easily. When forking, data is
 *copied*. Which means that every child process gets a copy of all the
 parent's variables, but whenever you modify them, the modification has only
 an effect within the child process, because it's just a copy.

 There's a whole bag full of inter process communication (IPC) algorithms,
 ranging from files over sockets to posix message queues. You might to have
 a look at perldoc perlipc and the whole lot of IPC modules on cpan.

 HTH.

  Eric

 --
 Eric MSP Veith eric.ve...@de.ibm.com
 Hechtsheimer Str. 2
 DE-55131 Mainz
 Germany

 IBM Deutschland GmbH
 Vorsitzender des Aufsichtsrats: Erich Clementi
 Geschäftsführung: Martin Jetter (Vorsitzender), Reinhard Reschke, Christoph
 Grandpierre, Matthias Hartmann, Michael Diemer, Martina Koederitz
 Sitz der Gesellschaft: Stuttgart
 Registergericht: Amtsgericht Stuttgart, HRB 14562
 WEEE-Reg.-Nr. DE 99369940


Hi Eric. I knew I wouldn't get to eat the cake so easily.
Let see what other have to say  on this. *Thanks* for your reply.

PS - perldoc perlipc seems complicated :(


fork, parallel and global values

2010-05-10 Thread raphael()
Hello,

-- CODE --

#!/usr/bin/env perl

use strict;
use warnings;
use Parallel::ForkManager;

# Parallel::ForkManager
my $pfm = Parallel::ForkManager-new(5);

my %hash;
for my $num ( qw/ 1 2 3 4 5 1 / ) {
$pfm-start and next;
$hash{$num}++;
$pfm-finish;
}
$pfm-wait_all_children;

# doesn't print because %hash is undef
print $_ = $hash{$_}\n for sort keys %hash;

print hash is undef\n unless %hash;

--- END ---

I want to do work on all elements of an array simultaneously.
I tried Parallel::ForkManager. It works well when you don't need to update
global value like downloading
multiple files at the same time. I want something like above that forks
while updating global values.
Are threads/fork what I am looking for?

Any help would be *appreciated.*


Re: how to create a hash on the fly

2010-04-15 Thread raphael()
On Thu, Apr 15, 2010 at 10:55 AM, Uri Guttman u...@stemsystems.com wrote:

  r == raphael()  raphael.j...@gmail.com writes:

  r # abc  -- this_should_be_hash_name

  r {space} random_name_or_number  date  other_things_1
 other_things_2
  r {space} random_name_or_number  date  other_things_1
 other_things_2

  r How can I create a hash by the name that matches

  r m/^#(?:\s+)?(\S+)$/

  r The hash should be created by the name of $1 i.e (\S+)$
  r like if $1 is 'abc' the hash should be %abc which will later be
 filled by
  r keys  values
  r that are matched in the next line. Thus hash should be created
 beforehand.

 this is called symbolic references and it is a very bad
 idea. effectively you would be using perl's symbol table as a data
 structure which gains nothing, can cause major problems (everything is
 global), and can also slow you down.

 the proper solution is to use a hash to hold these hashes. this is
 cleaner, safer, allows you to isolate this data, pass it around easily,
 reclaim its memory when it is not being used anymore, etc.

 notice how many bad things there are about symbolic references and how
 many good things about multilevel hashes? also note that symrefs are not
 allowed under strict (which you should be using all the time).

 so just declare a top level hash like this:

 my %top_data ;  # pick a better name

 and then just assign into it the data you want with an anonymous hash:

$top_data{ $1 } = { $2 = $3 } ;

 or use whatever regex grabs you want.

 read these docs for more on this:

perlreftut
perldsc
perllol

 uri

 --
 Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com--
 -  Perl Code Review , Architecture, Development, Training, Support
 --
 -  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com-



You are right!

But as a beginning Perl programmer I find references extremely complicated.
Although I have to learn them sometime.

Going to code now. Will be back if I get stuck  *thanks* all.


Re: how to create a hash on the fly

2010-04-15 Thread raphael()
On Fri, Apr 16, 2010 at 7:47 AM, Steve Bertrand st...@ibctech.ca wrote:

 On 2010.04.15 03:37, raphael() wrote:
  On Thu, Apr 15, 2010 at 10:55 AM, Uri Guttman u...@stemsystems.com
 wrote:
 
  r == raphael()  raphael.j...@gmail.com writes:
 
   r # abc  -- this_should_be_hash_name

  the proper solution is to use a hash to hold these hashes. this is
  cleaner, safer, allows you to isolate this data, pass it around easily,
  reclaim its memory when it is not being used anymore, etc.

  so just declare a top level hash like this:
 
  my %top_data ;  # pick a better name
 
  and then just assign into it the data you want with an anonymous hash:
 
 $top_data{ $1 } = { $2 = $3 } ;

 
  read these docs for more on this:
 
 perlreftut
 perldsc
 perllol
 

  But as a beginning Perl programmer I find references extremely
 complicated.
  Although I have to learn them sometime.

 Although I Am Not A Programmer, if you do actually desire spending time
 on writing Perl code, my strong advice would be to ingrain references
 into your head as soon and as fast as possible.

 Once you have a clear understanding of how $, @ and % work, spend as
 much time as it takes to learn about references.

 I can personally assure you that if you put references off because they
 seem intimidating, you will waste years of writing one-off scripts, that
 when you look back on them, you will condemn yourself.

 Perhaps that is easy to say when I have an 'ok' understanding of Perl
 references, but nonetheless, I'd hate to see anyone else make the same
 mistake of forgoing them like I did.

 My excuse was that I had been exposed to so many different usage idioms
 by so many different people by reading many different books and online
 information (especially the {} enclosure stuff), that it isn't worth
 learning.

 Don't fret. The learning curve isn't really that insurmountable. Read
 lots, and practice. If you are determined, then in a very short time,
 the light will go on, and all of a sudden, you'll have your own style of
 populating and extracting multi-level structures, and you'll even be
 able to understand them in other people's style (or at least know what
 to Google for).

 fwiw, a dispatch table (as discussed in another thread) is created
 entirely with references. Many people use dispatch tables to automate
 processes that follow the rabbit no matter how deep the hole, or how
 many branches the hole has ;)

  Going to code now. Will be back if I get stuck  *thanks* all.

 Good luck, there's always been someone here to provide feedback.

 Steve


It always comes down to desire and will to do something.
I agree that had I mastered references most of the things I have created in
Perl would have
been really easy to create instead I always looked for ways to bypass my
need to use references!

You were right I was actually putting references off (was going to learn
them *later*).
Your post actually gave me the motivation required to solely dedicate time
to *references* alone.
Lets see why I cannot ingrain them in my head. Reading your post Steve
actually felt good :)
You know when someone speaks from experience. *thanks again*


how to create a hash on the fly

2010-04-14 Thread raphael()
Hello People,
I am stuck on a minor problem. How can I create a hash?

Data is as follow

-- DATA --

# abc  -- this_should_be_hash_name

{space} random_name_or_number  date  other_things_1 other_things_2
{space} random_name_or_number  date  other_things_1 other_things_2

# xyz  -- this_should_be_a_new_hash_name (second_hash)

{space} random_name_or_number  date  other_things_1 other_things_2

-- END --

How can I create a hash by the name that matches

m/^#(?:\s+)?(\S+)$/

The hash should be created by the name of $1 i.e (\S+)$
like if $1 is 'abc' the hash should be %abc which will later be filled by
keys  values
that are matched in the next line. Thus hash should be created beforehand.

Am I making this clear?


Re: Save to memory temporarily

2010-03-23 Thread raphael()
any one here?


Re: Save to memory temporarily

2010-03-22 Thread raphael()
On Thu, Mar 18, 2010 at 7:30 PM, Peter Scott pe...@psdt.com wrote:

 On Wed, 17 Mar 2010 20:19:01 +0530, raphael() wrote:

  Hello,
 
  Is there a way to save/store downloaded data (using WWW::Mechanize) in
  memory (temporarily)
  rather than writing it to disk. Like store 10MB in memory and then flush
  it to the hard disk when data reaches 10MB.

 Not easily.  WWW::Mechanize is a LWP::UserAgent; look at the
 documentation for that module and see the :content_cb hook.  Write a
 handler to concatenate data in memory until you reach 10MB and then flush
 to disk, writing the remainder there.  Set read_size_hint to below 10MB.

 --
 Peter Scott
 http://www.perlmedic.com/ http://www.perldebugged.com/
 http://www.informit.com/store/product.aspx?isbn=0137001274
 http://www.oreillyschool.com/courses/perl1/

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/



*update*
I just can't get it :(

-- CODE --

use strict;
use warnings;
use WWW::Mechanize;
use File::Basename;

--BLAH BLAH--

open(INFILE, '', $file)
or die ! INFILE\n;

my @urls = INFILE;
close( INFILE );

my $wmc = WWW::Mechanize-new
(
agent = 'Mozilla/5.0',
timeout = '20',
max_redirect = '2',
autocheck = '0',
);

for my $url ( @urls ) {
last if ( $url =~ m/__END__/ );
next unless ( $url =~ m/^(?:\s+)?http/ );
my $base = basename( $url );

$wmc-max_size( '512' );
$wmc-get( $url );
my ( $url, $extension ) = $wmc-content =~ m!(REGEX)-IS-(HERE)!;
$wmc-max_size( undef );

--SOME CODE HERE--

open( my $file2write, '', $base.$extension );
binmode $file2write;

my $data_in_memory;
my $bytes_received = 0;
$wmc-get(
$url,
   ':content_cb' = sub {
   my ($data, $response) = @_;
   $bytes_received += length($data);
   $data_in_memory .= $data;

   if ( $bytes_received = 1048576 ) {
   $bytes_received = 0;
   print {$file2write} $data_in_memory;
   $data_in_memory = undef;
   }
});

print \n;
close $file2write;
}

-- END --

Now the above code I wrote using your advice works :)

The only problem is that when the download is ending if the last data
received
is less than one MB (which it naturally is) the end part is not written to
the file on HDD
since the sub doesn't enter if{} block.

So the whole file is now written to HDD in intervals which amount to the
time required to fetch 1MB of data (will increase to 10 MB).

Is there something like another loop or counter that can be added to this
so that it flushes out the last data received even if it is less thank 1MB?

Any help would be appreciated!


Re: Save to memory temporarily

2010-03-20 Thread raphael()
On Thu, Mar 18, 2010 at 11:17 PM, Linux Expert linuxexper...@gmail.comwrote:

 
 
  Not easily.  WWW::Mechanize is a LWP::UserAgent; look at the
  documentation for that module and see the :content_cb hook.  Write a
  handler to concatenate data in memory until you reach 10MB and then flush
  to disk, writing the remainder there.  Set read_size_hint to below 10MB.
 
 
 This is explained in the LWP book, available online at
 http://lwp.interglacial.com/ch03_04.htm
 *See sections 3.4.7.1 and 3.4.7.2


Thanks to all. I was stuck on this after Shlomi left this thread.

I had known about ':content_cb' Peter but couldn't get it to work. Going
to read the link Linux Expert suggested.
Will get to you all after I try to get it to work some more. Let see how it
goes. Thanks again all. Love this place!


Re: New on http://perl-begin.org/ - more topical pages and pages for Perl uses

2010-03-17 Thread raphael()
On Tue, Mar 16, 2010 at 6:49 PM, Shlomi Fish shlo...@iglu.org.il wrote:

 Hi all!

 There are new additions to http://perl-begin.org/ , the site for Perl
 Beginners. Here is a summary of them:

 

 ==16-March-2010: Topical and Uses Pages==

 We added a [http://perl-begin.org/uses/email/ a page about using Perl for
 E-
 mail processing], [http://perl-begin.org/uses/multitasking/ a page about
 Perl
 for multitasking and networking], a some topical pages:

 * [http://perl-begin.org/topics/date-and-time/ Date and Time].
 * [http://perl-begin.org/topics/references/ References in Perl].
 * [http://perl-begin.org/topics/regular-expressions/ Regular Expressions].
 * [http://perl-begin.org/topics/hashes/ Hashes].

 [http://perl-begin.org/IDEs-and-tools/ The IDEs and Tools page] now
 contains
 screenshots.

 Many new links have been added and many typos have been corrected. Enjoy!

 

 We hope to continue improving Perl-Begin into the future and to make it an
 even more useful resource for Perl beginners.

 Regards,

Shlomi Fish

 --
 -
 Shlomi Fish   http://www.shlomifish.org/
 Rethinking CPAN - http://shlom.in/rethinking-cpan

 Deletionists delete Wikipedia articles that they consider lame.
 Chuck Norris deletes deletionists whom he considers lame.

 Please reply to list if it's a mailing list post - http://shlom.in/reply .

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/


 Great effort! Many new Perl programmers will be grateful. I am just going
through the site.


Save to memory temporarily

2010-03-17 Thread raphael()
Hello,

Is there a way to save/store downloaded data (using WWW::Mechanize) in
memory (temporarily)
rather than writing it to disk. Like store 10MB in memory and then flush it
to the hard disk when data reaches 10MB.

Its just a curiosity since utorrent and jdownloader (Java) do this
(though I cannot verify if they actually store data in memory. There are
options for it in its settings).


Re: Save to memory temporarily

2010-03-17 Thread raphael()
On Wed, Mar 17, 2010 at 9:05 PM, Shlomi Fish shlo...@iglu.org.il wrote:

 On Wednesday 17 Mar 2010 16:49:01 raphael() wrote:
  Hello,
 
  Is there a way to save/store downloaded data (using WWW::Mechanize) in
  memory (temporarily)
  rather than writing it to disk. Like store 10MB in memory and then flush
 it
  to the hard disk when data reaches 10MB.

 Yes, standard Perl strings are stored inside the computer's memory. You can
 use a buffer and append to it using .= to put stuff there.

 Note that this memory will be lost when the process exits.

 Regards,

Shlomi Fish

 
  Its just a curiosity since utorrent and jdownloader (Java) do this
  (though I cannot verify if they actually store data in memory. There are
  options for it in its settings).

 --
 -
 Shlomi Fish   http://www.shlomifish.org/
 The Case for File Swapping - http://shlom.in/file-swap

 Deletionists delete Wikipedia articles that they consider lame.
 Chuck Norris deletes deletionists whom he considers lame.

 Please reply to list if it's a mailing list post - http://shlom.in/reply .


Thanks! However just a little coded example would have been extremely
helpful.
Here what a coded (amateurish)!

-- CODE ---
#!/usr/bin/env perl
# 17.03.2010

use strict;
use warnings;
use WWW::Mechanize;
use File::Basename;

# example link
#
http://interfacelift.com/wallpaper_beta/load/02188_theothersideofmanhattan_1680x1050.jpg

my $file = shift;
die No InFile\n unless ( $file );

open( FH, '', $file ) or die;
my @array = FH; close( FH );

my $wmc = WWW::Mechanize-new
(
agent = 'Mozilla/5.0',
timeout = '15',
requests_redirectable = ['GET', 'HEAD'],
max_redirect = '9',
autocheck = '0',
);

my %hash;
for my $url ( @array ) {
last if ( $url =~ m/__END__/ );
next unless ( $url =~ m/^(?:\s+)?http/ );
my $base = basename( $url );

$wmc-get( $url );
$hash{$base} = $wmc-content;
}

for my $img ( keys %hash ) {
open( my $FH, '', $img ) or die;
binmode( $FH );
print {$FH} $hash{$img};
close( $FH );
}
 END 

Got it a little. However I didn't use a concatenation() but a hash. But this
is *memory intensive*.
So the question now becomes is there a way to count how much memory a
scalar/hash/array is using?


Re: Save to memory temporarily

2010-03-17 Thread raphael()
On Wed, Mar 17, 2010 at 10:09 PM, Shlomi Fish shlo...@iglu.org.il wrote:

 Hi raphael()!

 I'll comment on your code below.

 On Wednesday 17 Mar 2010 18:23:29 raphael() wrote:
  On Wed, Mar 17, 2010 at 9:05 PM, Shlomi Fish shlo...@iglu.org.il
 wrote:
   On Wednesday 17 Mar 2010 16:49:01 raphael() wrote:
Hello,
   
Is there a way to save/store downloaded data (using WWW::Mechanize)
 in
memory (temporarily)
rather than writing it to disk. Like store 10MB in memory and then
flush
  
   it
  
to the hard disk when data reaches 10MB.
  
   Yes, standard Perl strings are stored inside the computer's memory. You
   can use a buffer and append to it using .= to put stuff there.
  
   Note that this memory will be lost when the process exits.
  
   Regards,
  
  Shlomi Fish
   
Its just a curiosity since utorrent and jdownloader (Java) do this
(though I cannot verify if they actually store data in memory. There
are options for it in its settings).
  
   --
   -
   Shlomi Fish   http://www.shlomifish.org/
   The Case for File Swapping - http://shlom.in/file-swap
  
   Deletionists delete Wikipedia articles that they consider lame.
   Chuck Norris deletes deletionists whom he considers lame.
  
   Please reply to list if it's a mailing list post -
 http://shlom.in/reply
   .
 
  Thanks! However just a little coded example would have been extremely
  helpful.
  Here what a coded (amateurish)!
 
  -- CODE ---
  #!/usr/bin/env perl
  # 17.03.2010
 
  use strict;
  use warnings;
  use WWW::Mechanize;
  use File::Basename;
 
  # example link
  #
 
 http://interfacelift.com/wallpaper_beta/load/02188_theothersideofmanhattan_
  1680x1050.jpg
 
  my $file = shift;
  die No InFile\n unless ( $file );

 Please call it $filename instead of $file. $file can be ambiguous.

 
  open( FH, '', $file ) or die;
  my @array = FH; close( FH );

 Use lexical file-handles here. And die with $!;

 
  my $wmc = WWW::Mechanize-new
  (
  agent = 'Mozilla/5.0',
  timeout = '15',
  requests_redirectable = ['GET', 'HEAD'],
  max_redirect = '9',
  autocheck = '0',
  );
 
  my %hash;
  for my $url ( @array ) {
  last if ( $url =~ m/__END__/ );
  next unless ( $url =~ m/^(?:\s+)?http/ );
  my $base = basename( $url );

 Use http://search.cpan.org/dist/URI/ to parse URLs. I believe it's a pre-
 requisite of WWW-Mechanize.

 
  $wmc-get( $url );
  $hash{$base} = $wmc-content;

 So you are populating a hash with everything in memory and then writing it
 key-value-by-key-value to disk? That's not very smart. It gives you
 absolutely
 no advantage over writing each of the $base to disk as it is encountered.

  }
 
  for my $img ( keys %hash ) {
  open( my $FH, '', $img ) or die;
  binmode( $FH );
  print {$FH} $hash{$img};
  close( $FH );
  }
   END 
 
  Got it a little. However I didn't use a concatenation() but a hash. But
  this is *memory intensive*.
  So the question now becomes is there a way to count how much memory a
  scalar/hash/array is using?

 There are Devel::Size and stuff.

 Regards,

Shlomi Fish

 --
 -
 Shlomi Fish   http://www.shlomifish.org/
 The Case for File Swapping - http://shlom.in/file-swap

 Deletionists delete Wikipedia articles that they consider lame.
 Chuck Norris deletes deletionists whom he considers lame.

 Please reply to list if it's a mailing list post - http://shlom.in/reply .


Thanks for telling me about URI.

 So you are populating a hash with everything in memory and then writing it
 key-value-by-key-value to disk? That's not very smart. It gives you
absolutely
 no advantage over writing each of the $base to disk as it is encountered.

Right there. I thought the exact same thing after posting the above code
{*frowning*}
How should I go about this? The best way to reduce disk writes when
downloading large amount of data.
[ large amount of files which themselves are large ].


Re: ':content_cb' give what to subroutine?

2010-03-13 Thread raphael()
On Sat, Mar 13, 2010 at 12:31 AM, Uri Guttman u...@stemsystems.com wrote:

  r == raphael()  raphael.j...@gmail.com writes:

  r Hi,
  r -- CODE --

  r use strict;
  r use warnings;
  r use WWW::Mechanize;
  r use File::Basename;
  r use Number::Bytes::Human qw(format_bytes);

  r # CODE GOES ON HERE TILL

  r open( my $file2write, '', $base );
  r binmode $file2write;

  r my $b;
  r $wmc-get(
  r $link,
  r ':content_cb' = sub {

  r my ($c, $r) = @_;# what are $c and $r 

 well, what is $wmc? it is some object with a get method but we can't see
 where it gets created. its docs should say what get() does and what args
 it takes. the coder is doing a very bad thing by using single char var
 names which are evil in almost all cases ($i being the exception but i
 never use it either if i can help it). descriptive names would help here
 but i can guess that $r is the result of a mechanize fetch and $c is the
 actual content. i could be wrong. it feels like partial content being
 passed to a callback sub (the 'cb' in content_cb stands for callback as
 it does get a sub ref for an arg).

  r $b += length($c);
  r if ($r-content_length) {
  r printf STDERR ${base}${extension} - %.2f%% : %s of %s
  \r,
   r 100. * $b / $r-content_length,
   r format_bytes($b),
  r format_bytes($r-content_length);
  r }

  r I got this snippet on perlmonks. It's a kind of progress bar. I
  r want to know what is being passed to @_ by ':content_cb' ??

  r my ($c, $r) = @_;

  r what are $c and $r?

 as i said, you need to backtrace the code to see what $wmc is, then
 search its docs for what get does and the content_cb code ref arg looks
 like and what args it takes. several levels back but all very
 doable. this is a good skill to learn, how to trace back what code is
 doing when the code isn't well written or documented.

 and this is why writing code that can be easily read by others is
 important. the coder wrote for himself but you always should write code
 for others!

 uri

 --
 Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com--
 -  Perl Code Review , Architecture, Development, Training, Support
 --
 -  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com-


Hello Uri,

Sorry for the late reply!
$wmc is just a WWW::Mechanize useragent.

my $wmc = WWW::Mechanize-new
(
agent = 'Mozilla/5.0',
timeout = '15',
requests_redirectable = ['GET', 'HEAD'],
max_redirect = '9',
autocheck = '0',
);

I am still not getting it as to how this code works. I will read the LWP
*docs* tonight.

PS - I always comment my code though I am the only one reading it weeks
later (duh)!
Comments and good variable name are *damn important*.
Reading another guy's commented code makes my blood pressure rise, talk
about single char variable code!

Also thanks Peter LWP::UserAgent manual it is tonight.
Though to tell the truth reading all these docs make my head hazy!


':content_cb' give what to subroutine?

2010-03-12 Thread raphael()
Hi,

-- CODE --

use strict;
use warnings;
use WWW::Mechanize;
use File::Basename;
use Number::Bytes::Human qw(format_bytes);

# CODE GOES ON HERE TILL

open( my $file2write, '', $base );
binmode $file2write;

my $b;
$wmc-get(
$link,
':content_cb' = sub {

my ($c, $r) = @_;# what are $c and $r 

$b += length($c);
if ($r-content_length) {
printf STDERR ${base}${extension} - %.2f%% : %s of %s  \r,
100. * $b / $r-content_length,
format_bytes($b),
format_bytes($r-content_length);
}
print $file2write $c;
});

$b = 0;
print \n;
close $file2write;

-- END --

I got this snippet on perlmonks. It's a kind of progress bar. I want to know
what is being passed to @_ by ':content_cb' ??

my ($c, $r) = @_;

what are $c and $r?


assign s/// value to a scalar

2010-03-11 Thread raphael()
#!/usr/bin/env perl

use strict;
use warnings;

my @array = qw (
http://abc.com/files/randomthings/A/1.html
http://abc.com/files/randomthings/A/2.html
);

for ( @array ) {

#   This works
#   s!/A/\d+.html$!!; $url = $_;

#   Doesn't work ~ gives 1
( my $url ) = ( $_ ) =~ s!/A/\d+.html$!!;
print $url . \n;

}

__END__

I want to remove the '/A/1.html' and assign the remaining value i.e. link to
$url
But all I get is 1 as value of $url which I think is return value that
substitution worked.

How can I remove '/A/1.html' and assign remaining $_ to $url?


Re: mech-content match regex howto

2010-03-03 Thread raphael()
On Wed, Mar 3, 2010 at 4:17 AM, Dr.Ruud
rvtol+use...@isolution.nlrvtol%2buse...@isolution.nl
 wrote:

 raphael() wrote:

  ( my $ip ) = $last_page =~ m/[\d.]+/g


 The \d matches 200+ codepoints, so if you want to match only 0-9, then use
 [0-9.].

 --
 Ruud


 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/


 Thanks for the advice. [0-9.] it is.


Re: regular expression - ?(foo.*)?

2010-03-02 Thread raphael()
On Tue, Mar 2, 2010 at 5:45 PM, Durairaj Muthusamy tech.du...@gmail.comwrote:

 Hi,

  I am a newbie and need your help. The following script doesn't
 display the first print statement like the second one.
  Why?

 @str = qw(NEW food foosball newstr foobasefoot);

 $\ = \n;

 foreach(@str)
 {
print First: $ if ?(foo.*)?;
print Second: $ if /(foo.*)/;
 }

 Output:

 First: food
 Second: food
 Second: foosball
 Second: foobasefoot


 Regards,
 Durai

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/


 Hi,

I didn't understand your question! Are you asking that why first print only
shows one match food unlike second one which shows all matches
matched byfoo.*

If that is the question then the m?? unlike m// only matches once.
Those ?? are special delimiters specially created for this purpose i.e
single match only.


mech-content match regex howto

2010-03-01 Thread raphael()
Hi,

I am trying to understand WWW::Mechanize

I understand that the downloaded content is stored in content().
Why am I not able to use a regex on it in scalar form?

--code--

use strict;
use warnings;
use WWW::Mechanize;

my $mech = WWW::Mechanize-new();
$mech-get(http://checkip.dyndns.org;);
my $last_page = $mech-content(); # last page fetched

# this works if I store content in an array @last_page
# for ( @last_page ) {
#if ( m/([\d+.]+)/ ) {
#print $1\n;
#}
# }

# ( my $ip ) = grep/(\d+\.)/, $last_page;

( my $ip = $last_page ) =~ m/([\d+\.]+)/;
print $ip\n;

--end--

my $ip gets the whole source page as its value.

--
Got it while writing out this post :)
--

Now the question becomes what is the difference between these two?

( my $ip = $last_page ) =~ m/([\d+\.]+)/;

( my $ip ) = ( $last_page ) =~ m/([\d+\.]+)/;

I think the above one is wrong syntax for using list context?

Also  how can I make grep work?

( my $ip ) = grep/(\d+\.)/, $last_page;


File::Find NO RECURSION Howto

2010-03-01 Thread raphael()
Hi,

How can I stop File::Find to go below current dir? i.e. no recursion.

Although I can use glob or * to get file names in current dir.
But I wanted to know if File::Find has a maxdepth limit like linux find.

The script I created uses a switch which decides if recursion is allowed or
not.
It uses the system find like this..

open(FIND, find -maxdepth $recursive | );

I wanted to remove this dependency on system find. Is it possible with
File::Find?

I tried this after googling

http://www.perlmonks.org/?node_id=676958

sub wanted
{
if ( -d ) { # should I write this as -d $File::Find::name
  $File::Find::prune = 1;
  return;
}
print $File::Find::name . \n;
}


Re: File::Find NO RECURSION Howto

2010-03-01 Thread raphael()
On Mon, Mar 1, 2010 at 6:18 PM, Shawn H Corey shawnhco...@gmail.com wrote:

 raphael() wrote:
  Hi,
 
  How can I stop File::Find to go below current dir? i.e. no recursion.
 
  Although I can use glob or * to get file names in current dir.
  But I wanted to know if File::Find has a maxdepth limit like linux
 find.
 
  The script I created uses a switch which decides if recursion is allowed
 or
  not.
  It uses the system find like this..
 
  open(FIND, find -maxdepth $recursive | );
 
  I wanted to remove this dependency on system find. Is it possible with
  File::Find?
 
  I tried this after googling
 
  http://www.perlmonks.org/?node_id=676958
 
  sub wanted
  {
  if ( -d ) { # should I write this as -d $File::Find::name

 # No, this is shorthand for:
if( -d $_ ){

$File::Find::prune = 1;
return;
  }
  print $File::Find::name . \n;
  }
 

 And didn't it work?  The if statement works on all directories.  This
 means that all directories except the top-level one will not be searched.


 --
 Just my 0.0002 million dollars worth,
  Shawn

 Programming is as much about organization and communication
 as it is about coding.

 I like Perl; it's the only language where you can bless your
 thingy.

 Eliminate software piracy:  use only FLOSS.


Nope. It ddn't work. Any ideas?
I am thinking to use File::Find::Rule. But I didn't want any module
dependency for this script.

And Shlomi your message came in while I was typing this. Going to check the
modules you mentioned.
But it would have been great if I didn't has to use a module :( The people
around me no sh*t about installing perl
modules from CPAN.

Thanks all.

PS - Shlomi, your website is GOOD!


Re: mech-content match regex howto

2010-03-01 Thread raphael()
On Mon, Mar 1, 2010 at 6:06 PM, Shawn H Corey shawnhco...@gmail.com wrote:

 raphael() wrote:
  Hi,
 
  I am trying to understand WWW::Mechanize
 
  I understand that the downloaded content is stored in content().
  Why am I not able to use a regex on it in scalar form?
 
  --code--
 
  use strict;
  use warnings;
  use WWW::Mechanize;
 
  my $mech = WWW::Mechanize-new();
  $mech-get(http://checkip.dyndns.org;);
  my $last_page = $mech-content(); # last page fetched
 
  # this works if I store content in an array @last_page
  # for ( @last_page ) {
  #if ( m/([\d+.]+)/ ) {
  #print $1\n;
  #}
  # }
 
  # ( my $ip ) = grep/(\d+\.)/, $last_page;
 
  ( my $ip = $last_page ) =~ m/([\d+\.]+)/;
  print $ip\n;
 
  --end--
 
  my $ip gets the whole source page as its value.
 
  --
  Got it while writing out this post :)
  --
 
  Now the question becomes what is the difference between these two?
 
  ( my $ip = $last_page ) =~ m/([\d+\.]+)/;
 
  ( my $ip ) = ( $last_page ) =~ m/([\d+\.]+)/;
 
  I think the above one is wrong syntax for using list context?
 
  Also  how can I make grep work?
 
  ( my $ip ) = grep/(\d+\.)/, $last_page;
 

 Try:

  my ( $ip ) = $last_page =~ m/([\d\.]+)/;

 This will capture the first one.  To get more than one:

  my @ips = $last_page =~ m/([\d\.]+)/g;


 grep() works on lists.  See `perldoc -f grep` for details.


 --
 Just my 0.0002 million dollars worth,
  Shawn

 Programming is as much about organization and communication
 as it is about coding.

 I like Perl; it's the only language where you can bless your
 thingy.

 Eliminate software piracy:  use only FLOSS.


Thanks!

grep() works on lists. -- How foolish of me, I knew that but didn't recall
it.
That I think are the perils of being new to programming.

I like Perl too; it's the only language where you can bless your
thingy. It is the first programming language that I am learning.

I picked it up because it looked like shell scripting which I daily used.
But Perl is so much better even if you just know the basics. It leaves shell
scripting way behind.


Re: mech-content match regex howto

2010-03-01 Thread raphael()
On Mon, Mar 1, 2010 at 11:27 PM, John W. Krahn jwkr...@shaw.ca wrote:

 raphael() wrote:

 Hi,


 Hello,


  I am trying to understand WWW::Mechanize


 Did you also look at these pages:


 http://search.cpan.org/~petdance/WWW-Mechanize-1.60/lib/WWW/Mechanize/Examples.podhttp://search.cpan.org/%7Epetdance/WWW-Mechanize-1.60/lib/WWW/Mechanize/Examples.pod

 http://search.cpan.org/~petdance/WWW-Mechanize-1.60/lib/WWW/Mechanize/FAQ.podhttp://search.cpan.org/%7Epetdance/WWW-Mechanize-1.60/lib/WWW/Mechanize/FAQ.pod

 http://search.cpan.org/~petdance/WWW-Mechanize-1.60/lib/WWW/Mechanize/Cookbook.podhttp://search.cpan.org/%7Epetdance/WWW-Mechanize-1.60/lib/WWW/Mechanize/Cookbook.pod



  I understand that the downloaded content is stored in content().
 Why am I not able to use a regex on it in scalar form?

 --code--

 use strict;
 use warnings;
 use WWW::Mechanize;

 my $mech = WWW::Mechanize-new();
 $mech-get(http://checkip.dyndns.org;);
 my $last_page = $mech-content(); # last page fetched

 # this works if I store content in an array @last_page
 # for ( @last_page ) {
 #if ( m/([\d+.]+)/ ) {
 #print $1\n;
 #}
 # }


 $mech-content() returns a scalar value so that is the same as saying:

 if ( $last_page[ 0 ] =~ m/([\d+.]+)/ ) {

   print $1\n;
 }


  # ( my $ip ) = grep/(\d+\.)/, $last_page;


 grep() returns the list items that match the expression /(\d+\.)/.  The
 regular expression is only used to determine which items to return, it has
 no effect on the content of those items.  If you want to effect the contents
 of the list then you have to use map() instead.



  ( my $ip = $last_page ) =~ m/([\d+\.]+)/;
 print $ip\n;

 --end--

 my $ip gets the whole source page as its value.

 --
 Got it while writing out this post :)
 --

 Now the question becomes what is the difference between these two?

 ( my $ip = $last_page ) =~ m/([\d+\.]+)/;


 That is the same as:

 my $ip = $last_page;
 $ip =~ m/([\d+\.]+)/;

 You are not doing anything with the string stored in $1.

 And BTW, '+' is not a valid IP address character.



  ( my $ip ) = ( $last_page ) =~ m/([\d+\.]+)/;


 That is equivalent to:

 my $ip;
 if ( $last_page =~ m/([\d+\.]+)/ ) {
$ip = $1;

}


  I think the above one is wrong syntax for using list context?


 No, you *have* to use list context or $ip will be assigned the result of
 the match operator (true or false) and not the contents of the capturing
 parentheses.



  Also  how can I make grep work?

 ( my $ip ) = grep/(\d+\.)/, $last_page;


 You can't, grep() doesn't work that way.  What you are looking for is
 map():

 ( my $ip ) = map /([\d.]+)/, $last_page;

 Or, since you are not actually using a list, use the /g global option to
 the match operator:

 ( my $ip ) = $last_page =~ /[\d.]+/g;

 Note that this will return a list of [\d.]+ strings but only the first one
 will be stored in $ip and the rest will be discarded.




 John
 --
 The programmer is fighting against the two most
 destructive forces in the universe: entropy and
 human stupidity.   -- Damian Conway

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/



Cool! I have to admit that is a detailed answer.
Also thanks for clearing out the differences between these two..

( my $ip = $last_page ) =~ m/([\d+\.]+)/;
( my $ip ) = ( $last_page ) =~ m/([\d+\.]+)/;

Just to clear out any misunderstanding by above one
I meant ( my $ip = $last_page ) =~ m/([\d+\.]+)/;
Now am I getting this right that this is the *wrong syntax* to get list
context.

Your post was very helpful since I didn't know about parenthesis (or lack of
it)
to capture values.

I always did use parenthesis to capture values like
( my $ip ) = $last_page =~ m/*(*[\d+\.]+*)*/g;

Now I *know* this works
( my $ip ) = $last_page =~ m/[\d+\.]+/g;

Thanks again John.


array of anonymous hash?

2010-02-25 Thread raphael()
use strict;
use warnings;
use Data::Dumper;

my @links =
({
name1 = 'http://www.abc.com/data/a/000/name1.txt',
name2 = 'http://www.abc.com/data/a/000/name2.txt',
});

for my $element ( @links ) {
for my $name ( sort keys %$element ) {
print $name -- ${$element}{name1}\n;
}
}
# print Dumper( \...@links );

__END__

what I have is an array of anonymous hash.
How do I access name2 (second hash key) independently? Without using a loop?

Ex. I have to mkdir using name2 then how can I pass it directly to a scalar?

my $scalar = $links ...

$scalar should be 'name2'

I am extremely new to references :|

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




array of anonymous hash?

2010-02-25 Thread raphael()
My BAD :(

THERE IS NO FIRST ELEMENT IN A HASH!!

PLEASE FORGIVE ME.  I AM IN A THICK OF EVERYTHING TODAY.

LET ME REPHRASE --
HOW DO I LOOP OVER THE ANONYMOUS HASH WHICH IS INSIDE AN ARRAY?

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




die unless match is successful

2009-11-29 Thread raphael()
Hi,

I want the below if loop to end if it cannot find any match  print the die
message.
However it just exit without hitting my die

As you can see in the code below I have tried many foolish ways to make the
script say
that it cannot find the number searched in while loop.

while ( my $line = $FH-readline ) {
chomp;
next if ( $line =~ m/return/i );
if ( $line =~ m/^$number\s+(\S+)\s+(.*)$/ ) {

 get_info($number, $1, $2); # if ( $1, $2 ); # -- don't
execute sub get_info unless a match

 die \nNo Entries Found By Number: [$number]\n unless ($1);
  # print $1; exit;

 last;
}
}
$FH-close();

Any Ideas?


PRINT LAST ENTRY IN A FILE

2009-11-28 Thread raphael()
Hi,

I want to print the last entry by record  in this file records.txt
The file is read in a subroutine and prints last line by the number in this
example.


# records.txt
 25.11.2009 NAME_0
 15.12.2006 NAME_3
 20.10.2007 NAME_1
 01.01.2008 NAME_3-- This whole line should be printed.
 10.10.2008 NAME_4

Using while in a while loop matching ( m// ) I get all the entries
having .


sub who_is_who($) {

open( FILE_DB, '', INFODB.TXT) || die Cannot open INFODB.TXT\n;
my $number = $_[0]; # print \$number is $_[0]\n;

while ( FILE_DB ) {
while ( m/^$number\s+(\S+)\s+(.*)$/mgs ) {   # -- tried while as
well as if
get_info($match, $1, $2);
# if (! $1) { die \nNo Entries Found for $match\n\n };
}
}
close(FILE_DB);
}

How can I do this?


Query Online File Size

2009-11-26 Thread raphael()
Hi,

I am writing a small script to download files of the web.
How can I get the file size without downloading the file?

use LWP::Simple;
my $file = http://www.abc.com/file.mp3;
my @array = head($file);
print $array[1]\n;

head() doesn't always returns all values?  why??
Sometime there are all values some time @array is empty!
Should I try LWP::UserAgent or is there any other way?


calc time elapsed in days

2009-11-26 Thread raphael()
Hi,

I have to code a script to calc time elapsed in days as to calc the rent to
be charged.
The person would write an object number and date in a text file like

db.txt
OBJECT_NUM, DATE_GIVEN

2525,25.11.2008
2526,01.01.2009
2527,26.11.2009

Now when he enter OBJECT_NUM I have to tell him the numbers of days
elapsed since DATE_GIVEN
and the rent he should charge which increases every 15 days like

first 15 days = 2
next 15 days = 3
next 15 days = 5
next 15 days = 8
next 15 days = 10
now its always 10

So if the OBJECT is returned in say 40 days the rent charged is 10 (2 + 3 +
5)

Being a beginner, I thought of hard coding the values in the code.

if ( $days_elapsed = 15 ) {
$total_cost = 2;
} elsif ( $days_elapsed = 30 ) {
$total_cost = 5;
} elsif ( $days_elapsed = 45 ) {
$total_cost = 10;
} elsif ( $days_elapsed = 60 ) {
$total_cost = 18;
} elsif ( $days_elapsed = 75 ) {
$total_cost = 28;
} elsif ( $days_elapsed = 90 ) {
$total_cost = 38;
} else {
print More than 90 days! SPECIAL RATE\n;
exit;
}


HOW CAN I COUNT ELAPSED DAYS ?

I tried in localtime() days value like

my @array_date = localtime();
my $current_dayofyear = @array_date[7];


But this would break on New year as $current_dayofyear would be reset.


SO HOW CAN I COUNT ELAPSED DAYS IF THE DATE FORMAT IS  01.01.2009?


Learning Perl Student Workbook

2009-10-31 Thread raphael()
Hi,

I just finished reading 'Learning Perl'  I was wondering if someone
could point me to the book Perl Study Guide,
also called Learning Perl Student Workbook. It's a companion book to
Learning Perl but is not available in my country.

I was hoping if someone could give me a link to a soft copy (an ebook).


match pattern

2009-09-18 Thread raphael()
Hi

How do I pick out matching words if there are more than one on the same
line?


Example

INFILE.TXT

www.site01.com www.site02.com www.site03.com
www.site04.com

--

while () {
if ( m!(www.\S+.com)!s ) {
#   print $1\n;
#   print $\n;
print;
};
}
--

I want to get all the 'match' in the INFILE.TXT on separate lines to
OUTFILE.TXT

www.site01.com
www.site02.com
www.site03.com
www.site04.com

But all I get is

www.site01.com
www.site04.com

If I try $1 or $ I only get two instances of 'match'  from the first in the
line.
Any help is appreciated


better way to write this

2009-06-10 Thread raphael()
Hi,

It is actually very enlightening to read all the post
on this list. Most of the stuff actually goes over my head as
I have no need/knowledge of CGI or dbase. Just some text processing.

I am new to Programming/Perl (chapter 5 Learning Perl).
I also read a little about 'system()  exec().

This is my first actual 'useful' Perl script!!
I had written this as a Bash script then converted it to Perl.

--code--

#!/usr/bin/perl

use 5.010;
use strict;
use warnings;

my ($A, @B, @C, $D);

$A = 'http://abc.com/texts/files/getthisfile_';

# For files that are numbered by 01.txt
# Also can append a '0' to $A   still use @C
@B = qw { 01 02 03 04 05 06 07 08 09 10 };

# For files that are numbered by 1.txt
@C = (1..10);

$D = '.txt';

foreach my $i (@C) {
system 'wget', ${A}${i}${D}; # I know wget can read from a file.
#   say ${A}${i}${D};# say $A$i$D; # Which is correct? both work!
}

--code--

Is there a better way to write this without modules?
OR is it just too simple  just fine written this way?


imlib2: draw special-chars

2007-05-02 Thread Raphael
Hi Users...

I want to write a text into a picture with Image::Imlib2
with this line:

$image-draw_text($x, $y, $text);

before this I define also the font-path, the font-color and load after
the font...

If the text is this:

10/17

all went fine and the text is on the picture...

but if the text is

10°/17° (10 degree / 17 degree)

then the text is only 10 and after it's finish...

what can I do to draw the degree-sign... I don't like to draw a circle
the graphic way... 

Google don't show me a solution...
Thanks a lot for any help.

have nice evening...
Raphael

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




How to source another perl-file into one

2007-04-08 Thread Raphael
Hi Users,

I want to source another file (also a perl-script) into my one at the
beginning. There are definitions which are to be loaded before executing
the rest of the other script. In a shell-script, I can do it with .
filename, and in perl?

Thanks for any ideas and help.

Greetings Raphael

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Problems with installing WWW::Mechanize::Shell

2006-12-24 Thread Raphael Brunner
Dear Users...

I want to install WWW::Mechanize::Shell on a actual debian-testing linux-box.
Perl seems to normaly installed.

But, I have errors during the install-process and don't know how to solve it
btw. what the problem is... (please see at the end of this messages).

Thanks for any help and ideas...
Greetings Raphael


what I input:
# perl -MCPAN -e 'install WWW::Mechanize::Shell'

the output:

CPAN: File::HomeDir loaded ok
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
  Database was generated on Mon, 04 Dec 2006 01:25:25 GMT
Running install for module WWW::Mechanize::Shell
Running make for C/CO/CORION/WWW-Mechanize-Shell-0.36.tar.gz
CPAN: Digest::SHA loaded ok
CPAN: Compress::Zlib loaded ok
Checksum for 
/root/.cpan/sources/authors/id/C/CO/CORION/WWW-Mechanize-Shell-0.36.tar.gz ok
Scanning cache /root/.cpan/build for sizes
WWW-Mechanize-Shell-0.36/
WWW-Mechanize-Shell-0.36/t/
WWW-Mechanize-Shell-0.36/t/05-options.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Mozilla.t
WWW-Mechanize-Shell-0.36/t/15-history-save.t
WWW-Mechanize-Shell-0.36/t/27-index.html
WWW-Mechanize-Shell-0.36/t/14-command-identity.t
WWW-Mechanize-Shell-0.36/t/99-unix-text.t
WWW-Mechanize-Shell-0.36/t/22-complete-command.t
WWW-Mechanize-Shell-0.36/t/03-documentation.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Common.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display.t
WWW-Mechanize-Shell-0.36/t/02-fallback-Pod-Constant.t
WWW-Mechanize-Shell-0.36/t/99-pod.t
WWW-Mechanize-Shell-0.36/t/99-manifest.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-TempFile.t
WWW-Mechanize-Shell-0.36/t/13-command-au.t
WWW-Mechanize-Shell-0.36/t/27-form_number.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Win32-IE.t
WWW-Mechanize-Shell-0.36/t/401-server
WWW-Mechanize-Shell-0.36/t/99-todo.t
WWW-Mechanize-Shell-0.36/t/20-restart-without-script.t
WWW-Mechanize-Shell-0.36/t/16-form-fillout.t
WWW-Mechanize-Shell-0.36/t/07-history-items.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-OSX.t
WWW-Mechanize-Shell-0.36/t/25-save-file-nolink.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-OSX-Safari.t
WWW-Mechanize-Shell-0.36/t/26-form-no-form.t
WWW-Mechanize-Shell-0.36/t/23-check-dumpresponses.t
WWW-Mechanize-Shell-0.36/t/18-browser-autosync.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Win32-OLE.t
WWW-Mechanize-Shell-0.36/t/00-use.t
WWW-Mechanize-Shell-0.36/t/08-unknown-command.t
WWW-Mechanize-Shell-0.36/t/19-value-multi.t
WWW-Mechanize-Shell-0.36/t/04-history-invariant.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Phoenix.t
WWW-Mechanize-Shell-0.36/t/17-eval-multiline.t
WWW-Mechanize-Shell-0.36/t/02-fallback-HTML-TableExtract.t
WWW-Mechanize-Shell-0.36/t/11-browse-without-request.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Win32.t
WWW-Mechanize-Shell-0.36/t/06-valid-output.t
WWW-Mechanize-Shell-0.36/t/10-nonexistent-host.t
WWW-Mechanize-Shell-0.36/t/24-source-file.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Debian.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Opera.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-OSX-Camino.t
WWW-Mechanize-Shell-0.36/t/01-HTML-Display-TempFile-share.t
WWW-Mechanize-Shell-0.36/t/09-invalid-filename.t
WWW-Mechanize-Shell-0.36/t/21-autofill-re.t
WWW-Mechanize-Shell-0.36/t/00-HTML-Display-use.t
WWW-Mechanize-Shell-0.36/t/98-bin.t
WWW-Mechanize-Shell-0.36/t/12-comments.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Dump.t
WWW-Mechanize-Shell-0.36/t/01-fallback-Win32-OLE.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Galeon.t
WWW-Mechanize-Shell-0.36/t/00a-Term-Shell-catch-smry.t
WWW-Mechanize-Shell-0.36/lib/
WWW-Mechanize-Shell-0.36/lib/HTML/
WWW-Mechanize-Shell-0.36/lib/HTML/Display/
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Opera.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Dump.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/OSX/
WWW-Mechanize-Shell-0.36/lib/HTML/Display/OSX/Safari.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/OSX/Camino.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Debian.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Phoenix.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/OSX.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Mozilla.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Galeon.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Win32.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Win32/
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Win32/OLE.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Win32/IE.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/TempFile.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Common.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display.pm
WWW-Mechanize-Shell-0.36/lib/WWW/
WWW-Mechanize-Shell-0.36/lib/WWW/Mechanize/
WWW-Mechanize-Shell-0.36/lib/WWW/Mechanize/Shell.pm
WWW-Mechanize-Shell-0.36/inc/
WWW-Mechanize-Shell-0.36/inc/Test/
WWW-Mechanize-Shell-0.36/inc/Test/HTTP/
WWW-Mechanize-Shell-0.36/inc/Test/HTTP/log-server
WWW-Mechanize-Shell-0.36/inc/Test/HTTP/LocalServer.pm
WWW-Mechanize-Shell-0.36/inc/IO/
WWW-Mechanize-Shell-0.36/inc/IO/Catch.pm
WWW

Problems with installing WWW::Mechanize::Shell

2006-12-05 Thread Raphael Brunner
Dear Users...

I want to install WWW::Mechanize::Shell on a debian-testing linux-box.

But, I have errors during the process and don't know how to solve it
btw. what the problem is...

Thanks for any help and ideas...
Greetings Raphael

# perl -MCPAN -e 'install WWW::Mechanize::Shell'


CPAN: File::HomeDir loaded ok
CPAN: Storable loaded ok
Going to read /root/.cpan/Metadata
  Database was generated on Mon, 04 Dec 2006 01:25:25 GMT
Running install for module WWW::Mechanize::Shell
Running make for C/CO/CORION/WWW-Mechanize-Shell-0.36.tar.gz
CPAN: Digest::SHA loaded ok
CPAN: Compress::Zlib loaded ok
Checksum for 
/root/.cpan/sources/authors/id/C/CO/CORION/WWW-Mechanize-Shell-0.36.tar.gz ok
Scanning cache /root/.cpan/build for sizes
WWW-Mechanize-Shell-0.36/
WWW-Mechanize-Shell-0.36/t/
WWW-Mechanize-Shell-0.36/t/05-options.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Mozilla.t
WWW-Mechanize-Shell-0.36/t/15-history-save.t
WWW-Mechanize-Shell-0.36/t/27-index.html
WWW-Mechanize-Shell-0.36/t/14-command-identity.t
WWW-Mechanize-Shell-0.36/t/99-unix-text.t
WWW-Mechanize-Shell-0.36/t/22-complete-command.t
WWW-Mechanize-Shell-0.36/t/03-documentation.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Common.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display.t
WWW-Mechanize-Shell-0.36/t/02-fallback-Pod-Constant.t
WWW-Mechanize-Shell-0.36/t/99-pod.t
WWW-Mechanize-Shell-0.36/t/99-manifest.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-TempFile.t
WWW-Mechanize-Shell-0.36/t/13-command-au.t
WWW-Mechanize-Shell-0.36/t/27-form_number.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Win32-IE.t
WWW-Mechanize-Shell-0.36/t/401-server
WWW-Mechanize-Shell-0.36/t/99-todo.t
WWW-Mechanize-Shell-0.36/t/20-restart-without-script.t
WWW-Mechanize-Shell-0.36/t/16-form-fillout.t
WWW-Mechanize-Shell-0.36/t/07-history-items.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-OSX.t
WWW-Mechanize-Shell-0.36/t/25-save-file-nolink.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-OSX-Safari.t
WWW-Mechanize-Shell-0.36/t/26-form-no-form.t
WWW-Mechanize-Shell-0.36/t/23-check-dumpresponses.t
WWW-Mechanize-Shell-0.36/t/18-browser-autosync.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Win32-OLE.t
WWW-Mechanize-Shell-0.36/t/00-use.t
WWW-Mechanize-Shell-0.36/t/08-unknown-command.t
WWW-Mechanize-Shell-0.36/t/19-value-multi.t
WWW-Mechanize-Shell-0.36/t/04-history-invariant.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Phoenix.t
WWW-Mechanize-Shell-0.36/t/17-eval-multiline.t
WWW-Mechanize-Shell-0.36/t/02-fallback-HTML-TableExtract.t
WWW-Mechanize-Shell-0.36/t/11-browse-without-request.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Win32.t
WWW-Mechanize-Shell-0.36/t/06-valid-output.t
WWW-Mechanize-Shell-0.36/t/10-nonexistent-host.t
WWW-Mechanize-Shell-0.36/t/24-source-file.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Debian.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Opera.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-OSX-Camino.t
WWW-Mechanize-Shell-0.36/t/01-HTML-Display-TempFile-share.t
WWW-Mechanize-Shell-0.36/t/09-invalid-filename.t
WWW-Mechanize-Shell-0.36/t/21-autofill-re.t
WWW-Mechanize-Shell-0.36/t/00-HTML-Display-use.t
WWW-Mechanize-Shell-0.36/t/98-bin.t
WWW-Mechanize-Shell-0.36/t/12-comments.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Dump.t
WWW-Mechanize-Shell-0.36/t/01-fallback-Win32-OLE.t
WWW-Mechanize-Shell-0.36/t/embedded-HTML-Display-Galeon.t
WWW-Mechanize-Shell-0.36/t/00a-Term-Shell-catch-smry.t
WWW-Mechanize-Shell-0.36/lib/
WWW-Mechanize-Shell-0.36/lib/HTML/
WWW-Mechanize-Shell-0.36/lib/HTML/Display/
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Opera.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Dump.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/OSX/
WWW-Mechanize-Shell-0.36/lib/HTML/Display/OSX/Safari.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/OSX/Camino.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Debian.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Phoenix.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/OSX.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Mozilla.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Galeon.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Win32.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Win32/
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Win32/OLE.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Win32/IE.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/TempFile.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display/Common.pm
WWW-Mechanize-Shell-0.36/lib/HTML/Display.pm
WWW-Mechanize-Shell-0.36/lib/WWW/
WWW-Mechanize-Shell-0.36/lib/WWW/Mechanize/
WWW-Mechanize-Shell-0.36/lib/WWW/Mechanize/Shell.pm
WWW-Mechanize-Shell-0.36/inc/
WWW-Mechanize-Shell-0.36/inc/Test/
WWW-Mechanize-Shell-0.36/inc/Test/HTTP/
WWW-Mechanize-Shell-0.36/inc/Test/HTTP/log-server
WWW-Mechanize-Shell-0.36/inc/Test/HTTP/LocalServer.pm
WWW-Mechanize-Shell-0.36/inc/IO/
WWW-Mechanize-Shell-0.36/inc/IO/Catch.pm
WWW-Mechanize-Shell-0.36/MANIFEST.skip
WWW-Mechanize-Shell-0.36/Makefile.PL
WWW-Mechanize-Shell-0.36/MANIFEST
WWW-Mechanize

use strict and local variables

2006-10-16 Thread Raphael Brunner
Dear Users

is there a possibility to use use strict and to define variables in
the programm, which are also seen in the subroutines called from this
block? I want the same value in the var in the subroutine like before,
but without it to define as global. What could I do?

Thanks for all ideas and help.
Greetings Raphael

eg:

use strict;
my $var = 20;

print $var\n;
routine;
exit;


sub routine {
print $var\n;
}



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: use strict and local variables

2006-10-16 Thread Raphael Brunner
Thanks for your answer!

But, my problem is, i must see this variable after the call of the sub.
I'm sorry for the first example, it was inaccurate. But this is ok (I
think) :) (because I have a lot of variables, which I must change in the
sub, I want to define they as global inside my parent-routine (in the
example: the programm, but by me: the parent-sub)).

Thanks for all, Raphael

eg:

use strict;
my $var = 20;

print before: $var\n;
routine;
print after: $var\n;
exit;


sub routine {
$var += 1;
 }


On Mon, Oct 16, 2006 at 07:36:13PM +0800, Jeff Pang wrote:
 
 
 eg:
 
 use strict;
 my $var = 20;
 
 print $var\n;
 routine;
 exit;
 
 
 sub routine {
  print $var\n;
 }
 
 
 Hi,you can do it by passing the vars to the subroutine like:
 
 my $var = 20;
 routine($var);
 
 sub routine {
 my $var = shift;
 print $var;
 }
 
 --
 Books below translated by me to Chinese.
 Practical mod_perl: http://home.earthlink.net/~pangj/mod_perl/
 Squid the Definitive Guide: http://home.earthlink.net/~pangj/squid/
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




HTML to Image Module?

2006-10-06 Thread Raphael Brunner
Dear Users

does anyone know a perl-Module which can make a image (png/jpg/...) from
a website?

Thanks a lot for all ideas...

Greetings, Raphael

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Imlib2 Module install failure problem

2006-10-05 Thread Raphael Brunner
Thanks for your tip, but how can i reinstall this module? in the
perl-shell show the command help only install etc, but nothing to
reinstall. And if I choose install, then it says: it is always on the
newest version...

Sorry this question. :-(

Thanks a lot!
Raphael


On Wed, Oct 04, 2006 at 07:43:39AM -0400, zentara wrote:
 On Tue, 3 Oct 2006 16:10:13 +0200, [EMAIL PROTECTED] (Raphael Brunner) wrote:
 
 Dear Users
 
 I work on debian testing with perl 5.8.8. If I try to install the module
 Image::Imlib2 to install (perl -MCPAN -e shell / install Image::Imlib2)
 then after a few downloads, I see this error-message:
 
 -- snip --
 
 Warning: this distribution contains XS files, but Module::Build is not
 configured with C_support at
 /usr/local/share/perl/5.8.8/Module/Build/Base.pm line 1128.
 Checking prerequisites...
 Looks good
 
 I hit this before. You need to reinstall Module::Build and build
 it with C_support, so it can build xs files. IIRC it will prompt you
 for a y/n as you build it.
 
 
 make: *** [all] Fehler 2
   /usr/bin/make  -- NOT OK
   Running make test
 Can't test without successful make
 Running make install
   make had returned bad status, install seems impossible
   Failed during this command:
 LBROCARD/Image-Imlib2-1.12.tar.gz: make NO
 
 
 -- 
 I'm not really a human, but I play one on earth.
 http://zentara.net/japh.html
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Imlib2 Module install failure problem

2006-10-03 Thread Raphael Brunner
Dear Users

I work on debian testing with perl 5.8.8. If I try to install the module
Image::Imlib2 to install (perl -MCPAN -e shell / install Image::Imlib2)
then after a few downloads, I see this error-message:

-- snip --

Warning: this distribution contains XS files, but Module::Build is not
configured with C_support at
/usr/local/share/perl/5.8.8/Module/Build/Base.pm line 1128.
Checking prerequisites...
Looks good

Creating new 'Build' script for 'Image-Imlib2' version '1.12'
CPAN: YAML loaded ok
/usr/bin/perl Build --makefile_env_macros 1
lib/Image/Imlib2.pm - blib/lib/Image/Imlib2.pm
lib/Image/Imlib2.xs - lib/Image/Imlib2.c
/usr/bin/perl -I/usr/lib/perl/5.8 -I/usr/share/perl/5.8
/usr/share/perl/5.8/ExtUtils/xsubpp -noprototypes -typemap
/usr/share/perl/5.8/ExtUtils/typemap lib/Image/Imlib2.xs
Module::Build is not configured with C_support at
/usr/local/share/perl/5.8.8/Module/Build/Base.pm line 3734.
make: *** [all] Fehler 2
  /usr/bin/make  -- NOT OK
  Running make test
Can't test without successful make
Running make install
  make had returned bad status, install seems impossible
  Failed during this command:
LBROCARD/Image-Imlib2-1.12.tar.gz: make NO

-

Does anyone have any idea, what the problem could be? And how to solve
this? Thanks a lot for all help and ideas...

Greetings Raphael


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response