encoding script
HI all, i want to write a perl script in linux that would get the file names in the directory i am running it in and then execute a system command for each file.(the encoding line). how should i go about it?? thnx in adv Saurabh PS:- i think i would be using syscall but i am confused about the file name changing thing -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Write stdout to a file as well as stdout
Larry Guest [LG], on Tuesday, January 11, 2005 at 15:40 (-0800) contributed this to our collective wisdom: LG I have a script that does all kinds stuff. LG When its running it outputs all kinds of useful information to the LG screen and exits. LG What I want to do is have this also sent to a file. LG Any thoughts? We have module for that, and here is also small example: use IO::Tee; my $tee = new IO::Tee(\*STDOUT, log.txt); print join(' ', $tee-handles), \n; #could go away for (1..10) { print $tee $_, \n }#print to $tee handles $tee-flush; __END__ helps ? -- ...m8s, cu l8r, Brano. [Anybody can win, unless there is a second entry.] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Execute a perl array
On Wed, 12 Jan 2005 08:55:14 +0200, Groleo Marius [EMAIL PROTECTED] wrote: Hi list! ( as usual ) i have a simple question : how can i execute an array, knowing that it contains perl code? eval for @array; Example: tor% perl -e '@array = (print \hi!\n\, print \hello\n\); eval for @array' hi! hello -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Memory full
Hi, Here is an example of a program and a perl module that parses a .xls file and eats the whole memory. I have tried it under Linux and Windows and it has the same problem under both OSs, so it has big bugs. I have tried using that destructor class in the perl module but I think what I have done is not correct. Thank you for telling me how to solve this issue. The program executes a method from the module but it doesn't need any result of that method, because it just parse a .xls file, get some results and inserts them into MySQL, then the program does the same with the next file, and so on. The program: use lib .; use strict; use Parse; my $f = Parse-new; opendir(DIR, .); my @files = readdir DIR; closedir DIR; foreach my $file(@files) { next unless $file =~ /\.xls$/i; $f-parse($file); } The module: package Parse; use strict; use Spreadsheet::ParseExcel; use DBI; my $dbh = DBI-connect(DBI:mysql:database=bvb;host=127.0.0.1, root, undef, {RaiseError=1, PrintError=0}); sub new { my $init = shift; my $class = ref($init) || $init; my $self = { @_ }; return bless($self, $class); } sub parse { my $self = shift; my $file = shift; my $book = Spreadsheet::ParseExcel::Workbook-Parse($file); my $sheet = ${$book-{Worksheet}}[0]; my %f; for(my $i = 0; $i = 1000; $i++) { my ($cod, $name); my $market = $sheet-{Cells}[$i][3]-{Val}; if ($market =~ /total|regular|deal|odd lot/i and $sheet-{Cells}[$i][6]-{Val} =~ /^[\d,.]+$/) { if ($sheet-{Cells}[$i][1]-{Val} =~ /^\w{3,4}[\*\+]?$/) { $cod = $sheet-{Cells}[$i][1]-{Val}; $cod =~ s/[\*\+]$//; $name = $sheet-{Cells}[$i][2]-{Val}; } elsif ($sheet-{Cells}[$i-1][1]-{Val} =~ /^\w{3,4}[\*\+]?$/) { $cod = $sheet-{Cells}[$i-1][1]-{Val}; $cod =~ s/[\*\+]$//; $name = $sheet-{Cells}[$i-1][2]-{Val}; } elsif ($sheet-{Cells}[$i-2][1]-{Val} =~ /^\w{3,4}[\*\+]?$/) { $cod = $sheet-{Cells}[$i-2][1]-{Val}; $cod =~ s/[\*\+]$//; $name = $sheet-{Cells}[$i-2][2]-{Val}; } elsif ($sheet-{Cells}[$i-3][1]-{Val} =~ /^\w{3,4}[\*\+]?$/) { $cod = $sheet-{Cells}[$i-3][1]-{Val}; $cod =~ s/[\*\+]$//; $name = $sheet-{Cells}[$i-3][2]-{Val}; } $f{$cod}{$market}{name} = $name; $f{$cod}{$market}{vn} = $sheet-{Cells}[$i][4]-{Val}; $f{$cod}{$market}{per} = $sheet-{Cells}[$i][5]-{Val}; $f{$cod}{$market}{close} = $sheet-{Cells}[$i][6]-{Val}; $f{$cod}{$market}{change} = $sheet-{Cells}[$i][7]-{Val}; $f{$cod}{$market}{open} = $sheet-{Cells}[$i][8]-{Val}; $f{$cod}{$market}{max} = $sheet-{Cells}[$i][9]-{Val}; $f{$cod}{$market}{min} = $sheet-{Cells}[$i][10]-{Val}; $f{$cod}{$market}{average} = $sheet-{Cells}[$i][11]-{Val}; $f{$cod}{$market}{volume} = $sheet-{Cells}[$i][12]-{Val}; $f{$cod}{$market}{value} = $sheet-{Cells}[$i][13]-{Val}; $f{$cod}{$market}{trades} = $sheet-{Cells}[$i][14]-{Val}; $f{$cod}{$market}{max52} = $sheet-{Cells}[$i][15]-{Val}; $f{$cod}{$market}{min52} = $sheet-{Cells}[$i][16]-{Val}; $f{$cod}{$market}{van} = $sheet-{Cells}[$i][17]-{Val}; } } my ($year, $mon, $mday) = $file =~ /trades(\d\d\d\d)(\d\d)(\d\d)\.xls$/gi; my $date = $mon/$mday/$year; #Create the table if it is not there my $rapoarte_t = $dbh-do(create table if not exists temp_rapoarte( symbol varchar(10) not null, name varchar(255) not null, market varchar(10) not null, date date not null, open varchar(20) not null, high varchar(20), low varchar(20), close varchar(20) not null, volume varchar(20) not null, vn varchar(20), per varchar(20), change_ varchar(20), average_ varchar(20), value_ varchar(30) not null, trades varchar(5), min52 varchar(20), max52 varchar(20), van varchar(20), primary key(symbol, date, market) )); #Insert into database my $rapoarte_i = $dbh-prepare(insert ignore into temp_rapoarte values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)); foreach my $cod(sort keys %f) { foreach my $market(keys %{$f{$cod}}) { $rapoarte_i-execute($cod, $f{$cod}{$market}{name}, $market, $year-$mon-$mday, $f{$cod}{$market}{open}, $f{$cod}{$market}{max}, $f{$cod}{$market}{min}, $f{$cod}{$market}{close}, $f{$cod}{$market}{volume}, $f{$cod}{$market}{vn}, $f{$cod}{$market}{per}, $f{$cod}{$market}{change}, $f{$cod}{$market}{average}, $f{$cod}{$market}{value}, $f{$cod}{$market}{trades}, $f{$cod}{$market}{min52}, $f{$cod}{$market}{max52}, $f{$cod}{$market}{van}); } } } sub DESTROY { my $self = shift; undef $self; #I don't know if this sub helps, or if it is correctly written } 1; I can send you a .xls file if you think it will help, but I guess the errors of my program or module are obvious. Thank you. Teddy - Original Message - From: Jay [EMAIL PROTECTED] To: Perl Beginners List beginners@perl.org Sent: Wednesday, January 12, 2005 12:22 AM Subject: Re: Memory full On Mon, 10 Jan 2005 12:53:50 +0200, Octavian Rasnita [EMAIL PROTECTED] wrote: Hi, I have made a perl module object oriented which is something like this: Then I access the parse() method in another program that feeds the module with more Excel files (around 500 files). After more files parsed (around 300), the memory is
RE: Execute a perl array
Groleo Marius [EMAIL PROTECTED] asked: i have a simple question : how can i execute an array, knowing that it contains perl code? Assuming you meant a Perl script, not bytecode: eval join(\n,@code); Read all about it with perldoc -f eval. HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Break a loop in Netware's PERL
Hello all I'm absolutely new to PERL -- actually, I'm using it for exactly 1 project I'm mostly through. On Netware's v5.8 of PERL, I have basically a loop, a while 1==1 { stuff }. On Netware, I can't break out of this with CTRL-C. CTRL-D, etc. I'd like to put a check inside the loop to see if 'break' key was pressed. Can someone please tell me how to do this? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: encoding script
Saurabh Singhvi wrote: HI all, Hello, i want to write a perl script in linux that would get the file names in the directory i am running it in and then execute a system command for each file.(the encoding line). how should i go about it?? perl -mstrict -we 'for(`ls`) { chomp;print `grep foo $_`; }' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: encoding script
Saurabh Singhvi wrote: HI all, Hello, i want to write a perl script in linux that would get the file names in the directory i am running it in and then execute a system command for each file.(the encoding line). how should i go about it?? perl -mstrict -we 'for(`ls`) { chomp;print `grep foo $_`; }' Yikes, please don't shell out for this, and please don't suggest newbies should shell out for these calls. If you are going to write shell, why not just write shell. Your script is completely insufficient in terms of error handling, security, speed, etc. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: encoding script
I found this snippet of code in the PERL for system administration book last week while I was reading it. opendir(DIR,.) or die Can't open the current directory: $!\n; @names = readdir(DIR) or die Unable to read current dir:$!\n; closedir(DIR); foreach $name (@names) { # do stuff here } I hope this helps -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of zentara Sent: Wednesday, January 12, 2005 6:58 AM To: beginners@perl.org Subject: Re: encoding script On Wed, 12 Jan 2005 08:03:19 +, [EMAIL PROTECTED] (Saurabh Singhvi) wrote: HI all, i want to write a perl script in linux that would get the file names in the directory i am running it in and then execute a system command for each file.(the encoding line). how should i go about it?? thnx in adv Saurabh PS:- i think i would be using syscall but i am confused about the file name changing thing Here is one way: #!/usr/bin/perl use File::Find; my $path = '.'; finddepth (\wanted,$path); sub wanted { my $old = $_; return unless -f; #-d for dir ops or comment out for both system(d2u -U -b -v $_) or warn $!\n; } __END__ -- 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
Re: Memory full
Here is an example of a program and a perl module that parses a .xls file and eats the whole memory. I have tried it under Linux and Windows and it has the same problem under both OSs, so it has big bugs. [snip] #Insert into database my $rapoarte_i = $dbh-prepare(insert ignore into temp_rapoarte values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)); foreach my $cod(sort keys %f) { foreach my $market(keys %{$f{$cod}}) { $rapoarte_i-execute(...); } } You should call $rapoarte_i-finish() here. I know if you're using Oracle, not finishing will keep cursors open and that could potentially be hogging memory like you're experiencing. Not sure about other databases. What database are you using? Let us know if this solves your problem. sub DESTROY { my $self = shift; undef $self; #I don't know if this sub helps, or if it is correctly written } This is correctly written, but it's kind of redundant... because if something is getting garbage collected, it's going to get undef'd anyway. Unless you have circular references or some other oddity (see Programming Perl v3, chapter 12). Which it doesn't look like is the case, at first glance. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Execute a perl array
- Original Message - From: Groleo Marius [EMAIL PROTECTED] Date: Wednesday, January 12, 2005 1:55 am Subject: Execute a perl array Hi list! ( as usual ) Hello i have a simple question : how can i execute an array, knowing that it contains perl code? Just thought of a beter question, how can you check if perl code is valid with out executing it [ I guess the question may be, can you interpelate with out executing ] ?? -- 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
Re: encoding script
perl -mstrict -we 'for(`ls`) { chomp;print `grep foo $_`; }' Yikes, please don't shell out for this, and please don't suggest newbies should shell out for these calls. If you are going to write shell, why not just write shell. Your script is completely insufficient in terms of error handling, security, speed, etc. You're absolutely right :) How about this instead: perl -mstrict -MFile::Slurp -we 'for(read_dir(.)) { print Process $_ here\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: Memory full
On Wed, 12 Jan 2005 12:24:00 +0200, Octavian Rasnita [EMAIL PROTECTED] wrote: The program: use lib .; use strict; use Parse; my $f = Parse-new; opendir(DIR, .); my @files = readdir DIR; closedir DIR; foreach my $file(@files) { next unless $file =~ /\.xls$/i; $f-parse($file); } sub DESTROY { my $self = shift; undef $self; #I don't know if this sub helps, or if it is correctly written } Teddy, There are a couple of things going on here. The last one is the destructor. Perl should Garbage collect automatically. The only time you need to give it a push, is if you end up creating references to references. the Garabge collector does actually get trid of things, it just lowers their refcount by one. Now that youwe've seen you code, this probably isn't your problem, and messing with $self is dangerous if you don't need to do it. You're real issue here is scoping. Once you call new, that object stays in scope until it passes out of scope. You call new at the beginning of the program, and then go into a forecah loop, and keep adding refferences to Workbook-Parse() objects, and then garbage collection isn't done until the end. This is what allows you to only open the database connection once, but it causes things to pile up in memory. If you don't mind incurring the extra overhead on the database server, move $f = Parse-new ; Inside the foreach loop. This will ensure that that the Parse object is destroyed at the end of each iteration: foreach my $file(@files) { next unless $file =~ /\.xls$/i; $f = Parse-new ; $f-parse($file); } If you want to keep the database connection open, you need to make sure that the reference counts of $f and $book fall to zero each time sub Parse exits. Because they're references, they don't go out of scope when the subroutine exits, so they and the Workbook-Parse objects keep piling up. when you're debugging, you can use Devel::Peek to keep track of the references and make sure the counts go down. Also take a look at Chapter 11 and particularly recipe 11.5 in the _Perl Cookbook_. HTH, --jay -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Getting the prefered language of the browser
Hi all, Does anyone know if there is a perl module that gets the prefered languages of the browser in their preference order? I know to get them from $ENV{HTTP_ACCEPT_LANGUAGE} environment variable, but I don't know how to parse correctly that string. I have tried reading the RFC which talks about this, but I don't understand it very well. It *IS* confusing, isn't it? Reading through http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 Give me the following code snippet my $language_accept = 'da,en-gb;q=0.8,en;q=0.7'; my @range = split(',', $language_accept); @range now has the values ( 'da', 'en-gb;q=0.8', 'en;q=0.7' ); So, a language and an optional preference value. Now, we can use a couple of regexps (smarter people can do this in one regexp ) to extricate the salient data for my $range (@range) { my ($language, $preference); unless (($language, $preference) = $range =~ /(.*);q=([\d\.]*)/) { $language = $range; $preference = 1.0; } Now, we have a loop iterating across all of the possible language-preference pairs and normalizing Let's build an array of hashrefs to hold the language-prerence pairs: push @preference, { language = $language, preference = $preference } ; While *MY* web browser appears to sort language preference automatically in descending order of preference, the specification is silent about the issue -- just for safety's sake, let's explicitly sort: @preference = sort { $b-{preference} = $a-{preference} } @preference; All together, that looks like: -- begin perl code -- #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $language_accept = 'da,en-gb;q=0.8,en;q=0.7,x-pig-latin;q=0.001,es-mx;q=0.3'; my @range = split(',', $language_accept); my @preference; for my $range (@range) { my ($language, $preference); unless (($language, $preference) = $range =~ /(.*);q=([\d.]*)/) { $language = $range; $preference = 1.0; } push @preference, { language = $language, preference = $preference } ; } @preference = sort { $b-{preference} = $a-{preference} } @preference; foreach my $preference (@preference) { print $preference-{language},\n; } --- end perl code --- Plugging this into a CGI and doing something useful with it is, as they say, left as an exercise to the reader. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g Computer software consists of only two components: ones and zeros, in roughly equal proportions. All that is required is to sort them into the correct order. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Using LWP to Browse a Perl Page
I've been reading this list every day for a week or so, and it's a great resource. I'm trying to use a GET or POST command to click on a link at this address: http://ibihost1.com/nycdoh/web/html/rii.pl As you can see, the address points to a Perl script. When you click on a button on this page, you're taken to another page, but the address - rii.pl - stays the same. View source provides no help. I'm wondering how I can use a Perl script to get past this page and subsequent ones. Thanks in advance for pointing me to any relevant resources. Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Crypt SSLeay
I did a build on the latest version of perl. However the library Crypt::SSLeay is not present. Any idea how do I build this library? It is required for https requests. Philip -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Break a loop in Netware's PERL
GMane Python wrote: Hello all Hello, I'm absolutely new to PERL -- actually, I'm using it for exactly 1 project I'm mostly through. On Netware's v5.8 of PERL, I have basically a loop, a while 1==1 { stuff }. On Netware, I can't break out of this with CTRL-C. CTRL-D, etc. I'd like to put a check inside the loop to see if 'break' key was pressed. Can someone please tell me how to do this? Novell has a news group at: news://developer-forums.novell.com/novell.devsup.perl that may be able to answer your question. (I haven't used Netware in a looong time.) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Crypt SSLeay
Tham, Philip wrote: I did a build on the latest version of perl. However the library Crypt::SSLeay is not present. Any idea how do I build this library? It its not a library its a module :) perl -MCPAN -e 'install Crypt::SSLeay;' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: encoding script
Saurabh Singhvi wrote: HI all, Hello, i want to write a perl script in linux that would get the file names in the directory i am running it in and then execute a system command for each file.(the encoding line). how should i go about it?? Something like this should work: #!/usr/bin/perl use warnings; use strict; my $command = 'file'; opendir my $D, '.' or die Cannot open the current directory: $!; while ( my $file = readdir $D ) { next if $file =~ /^\.\.?$/; # skip entries '.' and '..' system( $command, $file ) == 0 or die system $command $file failed: $?; } closedir $D; __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Using LWP to Browse a Perl Page
- Original Message - From: Dan Armstrong [EMAIL PROTECTED] Date: Wednesday, January 12, 2005 1:20 pm Subject: Using LWP to Browse a Perl Page I've been reading this list every day for a week or so, and it's a great resource. I'm trying to use a GET or POST command to click on a link at this address: http://ibihost1.com/nycdoh/web/html/rii.pl This page automaticly redirects me to http://www.nyc.gov/html/doh/html/rii/index.html As you can see, the address points to a Perl script. When you click on a button on this page, you're taken to another page, but the address - rii.pl - stays the same. Seem's like it changes to me ?? Please explain more View source provides no help. I'm wondering how I can use a Perl script to get past this page and subsequent ones. Thanks in advance for pointing me to any relevant resources. Dan -- 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
Re: Crypt SSLeay
I did a build on the latest version of perl. However the library Crypt::SSLeay is not present. Any idea how do I build this library? It is required for https requests. Philip The documentation for the module includes installation tips, http://search.cpan.org/~chamas/Crypt-SSLeay-0.51/SSLeay.pm Easiest way would be to use CPAN for me. perl -MCPAN -e shell cpan install Crypt::SSLeay http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Using LWP to Browse a Perl Page
Dan Armstrong [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I've been reading this list every day for a week or so, and it's a great resource. I'm trying to use a GET or POST command to click on a link at this address: http://ibihost1.com/nycdoh/web/html/rii.pl As you can see, the address points to a Perl script. When you click on a button on this page, you're taken to another page, but the address - rii.pl - stays the same. View source provides no help. I'm wondering how I can use a Perl script to get past this page and subsequent ones. When I click on that page I get redirected to http://www.nyc.gov/html/doh/html/rii/index.html [EMAIL PROTECTED] trwww]$ perl -MWWW::Mechanize::Shell -e 'shell' get http://ibihost1.com/nycdoh/web/html/rii.pl Retrieving http://ibihost1.com/nycdoh/web/html/rii.pl(200) http://www.nyc.gov/html/doh/html/rii/index.htmlforms No forms on current page. http://www.nyc.gov/html/doh/html/rii/index.html But you will probably have better luck using WWW::Mechanize. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Using LWP to Browse a Perl Page
I've been reading this list every day for a week or so, and it's a great resource. I'm trying to use a GET or POST command to click on a link at this address: http://ibihost1.com/nycdoh/web/html/rii.pl As you can see, the address points to a Perl script. When you click on a button on this page, you're taken to another page, but the address - rii.pl - stays the same. View source provides no help. I'm wondering how I can use a Perl script to get past this page and subsequent ones. Thanks in advance for pointing me to any relevant resources. Dan Did you view source for the frame or the original page? The address not changing is an indication that frames is at work. When you click on the button it is loading two different pages in two different frames. The map page is static, the other frame uses a bunch of client side script to generate a URL to make the request. Check the source of the right frame and see if that helps. Alternatively if you use a real browser like Firefox there are extensions you can use to see all of the header information sent in the HTTP request which would show you exactly how to emulate your transaction. HTH, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Using LWP to Browse a Perl Page
On running the command install Crypt::SSLeay I found that the scripts require a c compiler to be installed. gcc is currently installed so I created a symbolic called cc which points to /usr/local/bin/gcc. However on going a build I am still getting the following error: cc -c -I/usr/local/ssl/include -xO3 -xdepend -DVERSION=\0.51\ -DXS_VERSION=\0.51\ -KPIC -I/usr/perl5/5.00503/sun4-solaris/CORE SSLeay.c cc: unrecognized option `-KPIC' cc: language depend not recognized cc: SSLeay.c: linker input file unused because linking not done Running Mkbootstrap for Crypt::SSLeay () chmod 644 SSLeay.bs LD_RUN_PATH=/usr/local/ssl/lib cc -o blib/arch/auto/Crypt/SSLeay/SSLeay.so -R/usr/local/ssl/lib -G SSLeay.o -L/usr/local/ssl/lib -lssl -lcrypto cc: SSLeay.o: No such file or directory *** Error code 1 make: Fatal error: Command failed for target `blib/arch/auto/Crypt/SSLeay/SSLeay.so' /usr/ccs/bin/make -- NOT OK Running make test Oops, make had returned bad status Running make install Oops, make had returned bad status -Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 12, 2005 1:26 PM To: Dan Armstrong; beginners@perl.org Subject: Re: Using LWP to Browse a Perl Page I've been reading this list every day for a week or so, and it's a great resource. I'm trying to use a GET or POST command to click on a link at this address: http://ibihost1.com/nycdoh/web/html/rii.pl As you can see, the address points to a Perl script. When you click on a button on this page, you're taken to another page, but the address - rii.pl - stays the same. View source provides no help. I'm wondering how I can use a Perl script to get past this page and subsequent ones. Thanks in advance for pointing me to any relevant resources. Dan Did you view source for the frame or the original page? The address not changing is an indication that frames is at work. When you click on the button it is loading two different pages in two different frames. The map page is static, the other frame uses a bunch of client side script to generate a URL to make the request. Check the source of the right frame and see if that helps. Alternatively if you use a real browser like Firefox there are extensions you can use to see all of the header information sent in the HTTP request which would show you exactly how to emulate your transaction. HTH, http://danconia.org -- 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
Re: Execute a perl array
On Wed, 12 Jan 2005 [EMAIL PROTECTED] wrote: Just thought of a better question, how can you check if perl code is valid with out executing it [ I guess the question may be, can you interpelate with out executing ] ?? The tools for answering this yourself are in your hands: Try: $ perl --help Or to spell it out for you: $ perl --help | grep -i syntax -c check syntax only (runs BEGIN and CHECK blocks) $ -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: encoding script
On Wed, 12 Jan 2005, JupiterHost.Net wrote: Saurabh Singhvi wrote: HI all, Hello, i want to write a perl script in linux that would get the file names in the directory i am running it in and then execute a system command for each file.(the encoding line). how should i go about it?? perl -mstrict -we 'for(`ls`) { chomp;print `grep foo $_`; }' By which you're basically saying the following non-Perl statement:: $ for file in *; do command $file; done Or, as a full shell script: #/bin/sh command=/whatever/you/want for file in * do $command $file done But I'm still confused -- why not just forget all this and do a $ command * ? I see no need for Perl *or* shell to solve this, unless the system command in question doesn't know how to take multiple files as input. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Break a loop in Netware's PERL
On Wed, 12 Jan 2005, John W. Krahn wrote: GMane Python wrote: I'm absolutely new to PERL -- actually, I'm using it for exactly 1 project I'm mostly through. On Netware's v5.8 of PERL, I have basically a loop, a while 1==1 { stuff }. On Netware, I can't break out of this with CTRL-C. CTRL-D, etc. I'd like to put a check inside the loop to see if 'break' key was pressed. Can someone please tell me how to do this? Novell has a news group at: news://developer-forums.novell.com/novell.devsup.perl that may be able to answer your question. (I haven't used Netware in a looong time.) Maybe it's looping too fast for the ctrl+C to get through. Does it work better if you change it to something like this? while (1 == 1) { stuff(); sleep 1 } That should at least give you a window of opportunity... -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Crypt SSLeay
I faced two problems: 1. The build assumes that cc is the default compiler in the system. I have gcc 2. I created a link from gcc to cc to fixed the above. This time it is rejecting some of the compile options like -KPIC and -x03 and -xdepend. It seems these options are supported by gcc. How can I get a makefile which is gcc compatible. Philip -Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 12, 2005 1:00 PM To: Tham, Philip; beginners@perl.org Subject: Re: Crypt SSLeay I did a build on the latest version of perl. However the library Crypt::SSLeay is not present. Any idea how do I build this library? It is required for https requests. Philip The documentation for the module includes installation tips, http://search.cpan.org/~chamas/Crypt-SSLeay-0.51/SSLeay.pm Easiest way would be to use CPAN for me. perl -MCPAN -e shell cpan install Crypt::SSLeay http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Image Creation: labels
Hi all. I'm hunting for a method of creating labels under Linux. I've already looked at everything on freshmeat.net that came up when I searched for 'labels'. None of them cut it. Requirements: - Coloured, rotated ( 90 degrees ) text rendering - Coloured rectangle rendering That's it. You'd think one of the existing labelling packages would accomodate me so far, right? Nope. Background: We have a filing system where each file has a label, which is made up of ( mainly ) coloured numbers ( ie each number gets a different colour *background* ). This last bit ... the coloured background ... is what's stopping me from using any of the existing labelling packages. So now that I've decided that there isn't anything out there that does what I want, I'm going to have to write something. What should I use? I've had a brief look at PDF::API2, but I can't even figure out if it does what I want - the documentation is a little nonexistant. So should I use GD? -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: [EMAIL PROTECTED] website: http://www.nusconsulting.com.au -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Image Creation: labels
Daniel Kasak wrote: Hi all. I'm hunting for a method of creating labels under Linux. I've already looked at everything on freshmeat.net that came up when I searched for 'labels'. None of them cut it. Requirements: - Coloured, rotated ( 90 degrees ) text rendering - Coloured rectangle rendering That's it. You'd think one of the existing labelling packages would accomodate me so far, right? Nope. Background: We have a filing system where each file has a label, which is made up of ( mainly ) coloured numbers ( ie each number gets a different colour *background* ). This last bit ... the coloured background ... is what's stopping me from using any of the existing labelling packages. So now that I've decided that there isn't anything out there that does what I want, I'm going to have to write something. What should I use? I've had a brief look at PDF::API2, but I can't even figure out if it does what I want - the documentation is a little nonexistant. So should I use GD? http://search.cpan.org/dist/PostScript-MailLabels/ or use some of the PostScript::* modules to roll your own. Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Execute a perl array
- Original Message - From: Chris Devers [EMAIL PROTECTED] Date: Wednesday, January 12, 2005 7:54 pm Subject: Re: Execute a perl array On Wed, 12 Jan 2005 [EMAIL PROTECTED] wrote: Just thought of a better question, how can you check if perl code is valid with out executing it [ I guess the question may be, can you interpelate with out executing ] ?? The tools for answering this yourself are in your hands: Try: $ perl --help Or to spell it out for you: $ perl --help | grep -i syntax -c check syntax only (runs BEGIN and CHECK blocks) $ Nice one !!! Durf on me :-0) -- Chris Devers -- 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
Transforming a space-separated string to an array for words.
Good day, This would be quick and simple. I need to write a script that will prompt the user(using STDIN) to enter a series of numbers separated by white space and then push each of those numbers into an array and then do anything such as sorting it from highest to lowest. I've tried doing it as: print Enter your numbers separated by space: ; my @array = STDIN; print sort @array; ..nothing happened after pressing return. Then I've tried putting the STDIN to a scalar first before assigning it to an array. my $numbers = STDIN; my @array = $numbers; print $array[-1]; #(print the last element) Then it only printed exactly what I've entered as if it has treated the numbers as a single string. I'm thinking perhaps if only I could place the contents of STDIN inside a qw() and assign it to an array like this; @array = qw(23 43 2 5 1); then I would have no problem with spaces between them(and eventually I can do anything with each of its elements). Only that I don't know how to get it in place starting from user input STDIN. Any idea? Thanks. __ Do you Yahoo!? Yahoo! Mail - now with 250MB free storage. Learn more. http://info.mail.yahoo.com/mail_250 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Transforming a space-separated string to an array for words.
Good day, This would be quick and simple. I need to write a script that will prompt the user(using STDIN) to enter a series of numbers separated by white space and then push each of those numbers into an array and then do anything such as sorting it from highest to lowest. I've tried doing it as: print Enter your numbers separated by space: ; my @array = STDIN; print sort @array; ..nothing happened after pressing return. Then I've tried putting the STDIN to a scalar first before assigning it to an array. my $numbers = STDIN; my @array = $numbers; print $array[-1]; #(print the last element) Then it only printed exactly what I've entered as if it has treated the numbers as a single string. I'm thinking perhaps if only I could place the contents of STDIN inside a qw() and assign it to an array like this; @array = qw(23 43 2 5 1); then I would have no problem with spaces between them(and eventually I can do anything with each of its elements). Only that I don't know how to get it in place starting from user input STDIN. Any idea? Thanks. __ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Transforming a space-separated string to an array for words.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Thu, 13 Jan 2005 20:02, Harold Castro wrote: my $numbers = STDIN; my @array = $numbers; Amend to: my @array = split(/ /,$numbers); This will split up the string based on the pattern (in this case, a single space. You may want to change that to gain robustness, e.g. /[ \t]+/ will split on any number of spaces and tabs) - -- Robin [EMAIL PROTECTED] JabberID: [EMAIL PROTECTED] Hostes alienigeni me abduxerunt. Qui annus est? PGP Key 0x776DB663 = DD10 5C62 1E29 A385 9866 0853 CD38 E07A 776D B663 -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQFB5iFgFNNkhamc620RArBuAKCF/Y10NwVcibuOFZ3kDprIfDJuSgCfY8Wk UGWTr/2MXAdOyz7iZFRQxPw= =Hnqz -END PGP SIGNATURE- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
problem with extracting line
Hi I have text file in which I have the below mentioned lines This is a test start-first First Line testing end-first How are you Finally start-second Tested end-second I have a perl file which reads the above file and stores in the variable say $message #!/usr/bin/perl use strict; open INPUT,fp.txt || die File does not exist; my $message=; while(INPUT) { $message=$message.$_; } if ($message =~ (/start_first/../end_first/)) { print The line is $1; } What I expect is that from the variable, $message I wanted to print out this First Line testing as in the text file i have specified the pointers.. In Short I wanted to print the lines in between two words in a file/variable. Is my method correct? Thanks Anish