Re: avoid errors when printing to socket

2021-10-02 Thread hw
defined\n"; } Unfortunately, that doesn't receive anything. I have verified with netcat that the connection between the two hosts is possible. The listener doesn't receive anything from netcat, either. How can that be? My program for the relais works the same, and it does re

Re: avoid errors when printing to socket

2021-10-01 Thread Andy Bach
ear printing to a closed file handle *doesn't* (doesn't always?) throw a SIGPIPE. I set the signal handler $ perl -wE 'use strict; $SIG{"PIPE"} = sub { die "pipe\n" }; open(OUT, ">", "/tmp/out"); close OUT ;my $res = print OUT "hi mom\n

Re: avoid errors when printing to socket

2021-09-30 Thread hw
On Thursday, September 30, 2021 9:30:01 PM CEST Andy Bach wrote: > > https://perldoc.perl.org/functions/print says that 'print' would return > > true > > > if successful and doesn't say what it returns otherwise. It also says > > that > > > &

Re: avoid errors when printing to socket

2021-09-30 Thread Andy Bach
> https://perldoc.perl.org/functions/print says that 'print' would return true > if successful and doesn't say what it returns otherwise. It also says that > "Printing to a closed pipe or socket will generate a SIGPIPE signal." Looks like print returns 1 if it

avoid errors when printing to socket

2021-09-30 Thread hw
uccessful or not? It's like I'm seeing the error message and there isn't anything I could do about it. https://perldoc.perl.org/functions/print says that 'print' would return true if successful and doesn't say what it returns otherwise. It also says that "Printi

Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-17 Thread Tetsuo Handa
Hello. I want to represent up to a few hundreds gigabytes for file size. On 32bits platform, I noticed that my $value = ...; printf("%u\n", $value); prints 4294967295 if $value >= 4294967295 whereas my $value = ...; printf("%s\n", $value); and use Math::BigInt; my $value = ...;

Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-17 Thread Tetsuo Handa
Hello. I want to represent up to a few hundreds gigabytes for file size. On 32bits platform, I noticed that my $value = ...; printf("%u\n", $value); prints 4294967295 if $value >= 4294967295 whereas my $value = ...; printf("%s\n", $value); and use Math::BigInt; my $value = ...;

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-15 Thread Tetsuo Handa
On 2018/11/15 9:27, sisyphus wrote: > Are you actually encountering files larger than 1e15 bytes ? On 32bit kernels, filesystems would not allow such large files. For example, max size for xfs filesystem is 16TB. Even on 64bit userspace, nobody will want to upload such large file via network. >

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-15 Thread Tetsuo Handa
I received a comment from Peter John Acklam (current bigint maintainer). Forwarded Message Date: Wed, 14 Nov 2018 20:08:27 +0100 Hello This has actually nothing to do with Math::BigInt. The issue here is that the conversion "u", converts a number to an unsigned integer before t

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-14 Thread sisyphus
On Thu, Nov 15, 2018 at 1:49 AM Tetsuo Handa < penguin-ker...@i-love.sakura.ne.jp> wrote: > 32bits userspace on 64bits kernel: > # truncate -s 9223372036854775807 test > # perl -e 'use File::stat; my $sb = lstat("test"); printf("%s\n", $sb->size);' > 9.22337203685478e+18 > # perl -e 'use File::sta

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-14 Thread Tetsuo Handa
On 2018/11/14 21:46, sisyphus wrote: > On Wed, Nov 14, 2018 at 10:20 PM Tetsuo Handa > wrote: > >> Even on 32bit environments (at least for Linux), lstat() calls 64bit version > Here is some test results on Linux. 32bits userspace on 32bits kernel: # truncate -s 17592186044415 test # perl -e

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-14 Thread sisyphus
On Wed, Nov 14, 2018 at 10:20 PM Tetsuo Handa < penguin-ker...@i-love.sakura.ne.jp> wrote: > Even on 32bit environments (at least for Linux), lstat() calls 64bit version When I check on Windows, I find that the value is actually an NV (not an IV as I had expected). I expect it's the same for you,

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-14 Thread Tetsuo Handa
On 2018/11/14 19:59, sisyphus wrote: > On Wed, Nov 14, 2018 at 9:08 PM Tetsuo Handa > wrote > >> how can I pass $sb->size to Math::BigInt->new() as a string (assuming that >> $sb->size is an integer) ? > > To answer the question, you can do: > > my $x = $sb->size; > $value = Math::BigInt->ne

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-14 Thread sisyphus
On Wed, Nov 14, 2018 at 9:08 PM Tetsuo Handa < penguin-ker...@i-love.sakura.ne.jp> wrote > how can I pass $sb->size to Math::BigInt->new() as a string (assuming that $sb->size is an integer) ? To answer the question, you can do: my $x = $sb->size; $value = Math::BigInt->new("$x"); But doing so

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-14 Thread Tetsuo Handa
Hello, sisyphus. Thank you for your answer. > That can fail if $value is so big that it requires more than 15 decimal > digits to express it accurately. I want to use like (...snipped...) my $sb = lstat($file) || next; next unless (S_ISREG($sb->mode) && $sb->size); (...snipped...) $cu

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-13 Thread sisyphus
e >= 4294967295 whereas > >my $value = ...; >printf("%s\n", $value); > That can fail if $value is so big that it requires more than 15 decimal digits to express it accurately. For example: C:\_32>perl -le "printf '%s', 901234567890123456789;" 9.0123

Re: Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-13 Thread Mike Flannigan
I don't have an answer for you, but I find this interesting.  I note the same issue in 64bit up near 18446744073709551615 I'm guessing the guy who wrote Math::BigInt may have the answer. Mike On 11/13/2018 8:07 AM, Tetsuo Handa wrote: Hello. I want to represent up to a few hundreds gigaby

Strange behavior when printing a 4G+ integer on 32bits platform.

2018-11-13 Thread Tetsuo Handa
Hello. I want to represent up to a few hundreds gigabytes for file size. On 32bits platform, I noticed that my $value = ...; printf("%u\n", $value); prints 4294967295 if $value >= 4294967295 whereas my $value = ...; printf("%s\n", $value); and use Math::BigInt; my $value = ...;

Re: Printing dir into XML

2015-07-09 Thread Ken Slater
On Thu, Jul 9, 2015 at 6:01 AM, Nagy Tamas (TVI-GmbH) < tamas.n...@tvi-gmbh.de> wrote: > Hi, > > > > The following code doesn’t recognize dirs. As I list the dir into the XML, > it shows dirs as ordinary files. > > > > Like the –d would not work. If I add an extra branch to recognize files > with

Printing dir into XML

2015-07-09 Thread Nagy Tamas (TVI-GmbH)
Hi, The following code doesn't recognize dirs. As I list the dir into the XML, it shows dirs as ordinary files. Like the -d would not work. If I add an extra branch to recognize files with -f, it doesn't print either files at all nor dirs. sub Traverse { opendir(DIR, $dir) or d

Suggestions - printing to ZEBRA credit card printer attached to Win7 PC

2014-09-16 Thread Gary Stainburn
mber across the botom of it. The data is being generated by my LAPP based system. I'm looking at options as to how I can implement a system for printing the cards. As I see it, I have a number of options. 1) mail-merge using Word. Generate a CSV file via PHP for download. Manual inte

Re: printing hash having undefined key

2014-06-23 Thread Shaji Kalidasan
t } [/code] [output] key [] value [xsd] key [ ] value [xyz] key [ ] value [ajk] key [456] value [dfg] key [123] value [abc] [/output] Example 2: [code] #Printing the hash in a single line print "key $_ value $hash{$_}\n" foreach (keys %hash); [/code] [output] key value xyz

printing hash having undefined key

2014-06-23 Thread Sunita Pradhan
array; foreach $k (keys %hash){ print "key $k value $hash{$k}\n" if(exists $hash{$k}); } And another issue is , I want to write one line code for printing hash like below: print "key $k value $hash{$k}\n" foreach $k (keys %hash); But it fails with error : syntax err

Re: uninitialized error for hash printing

2014-06-22 Thread Shaji Kalidasan
}\n"; } [/code] [output] key abc:: value 123 key dfg:: value 456 key xsd:: value 34 [/output] Hope it helps. On Mon, Jun 23, 2014 at 1:31 AM, Sunita Pradhan < sunita.pradhan.2...@hotmail.com> wrote: > I have following code for printing a simple hash. > > #!/usr/bin/perl -w >

Re: uninitialized error for hash printing

2014-06-22 Thread Uri Guttman
On 06/22/2014 04:01 PM, Sunita Pradhan wrote: I have following code for printing a simple hash. #!/usr/bin/perl -w %hash = ("abc" => 123, "dfg" => 456, "xsd" => 34); foreach $k (keys %hash){ print "key $k:: value $hash{$k}\n";

Re: uninitialized error for hash printing

2014-06-22 Thread John Delacour
On 22 Jun 2014, at 21:01, Sunita Pradhan wrote: > I have following code for printing a simple hash. > > #!/usr/bin/perl -w > %hash = ("abc" => 123, "dfg" => 456, "xsd" => 34); > foreach $k (keys %hash){ > print &qu

uninitialized error for hash printing

2014-06-22 Thread Sunita Pradhan
I have following code for printing a simple hash. #!/usr/bin/perl -w %hash = ("abc" => 123, "dfg" => 456, "xsd" => 34); foreach $k (keys %hash){ print "key $k:: value $hash{$k}\n"; } It does not print keys and displays following war

Re: Problem printing double quotes in XML using XML::DOM

2013-11-30 Thread Brian Fraser
On Sun, Dec 1, 2013 at 7:28 AM, Shaji Kalidasan wrote: > Dear Shlomi, > > I tried to install https://metacpan.org/release/XML-LibXML in my windows > setup (using Strawberry Perl 5.18.1 on Windows 7) but it failed. Please > suggest where am I going wrong? > > Here is the output from console (comman

Re: Problem printing double quotes in XML using XML::DOM

2013-11-30 Thread Shaji Kalidasan
k to God. --- On Friday, 29 November 2013 1:53 PM, Shlomi Fish wrote: Hello Shaji, On Fri, 29 Nov 2013 13:32:49 +0800 (SGT) Shaji Kalidasan wrote: > Dear Perlers, > > I am trying to print double quotes in the o

Re: Problem printing double quotes in XML using XML::DOM

2013-11-29 Thread Shaji Kalidasan
i Kalidasan wrote: > Dear Perlers, > > I am trying to print double quotes in the output (output.xml) but it is > printing " instead of "". How can I include double quotes "" in the > output. Please help. > In XML, «"» is an XML entity (see https://en

Re: Problem printing double quotes in XML using XML::DOM

2013-11-29 Thread Shlomi Fish
Hello Shaji, On Fri, 29 Nov 2013 13:32:49 +0800 (SGT) Shaji Kalidasan wrote: > Dear Perlers, > > I am trying to print double quotes in the output (output.xml) but it is > printing " instead of "". How can I include double quotes "" in the > output. Pleas

Problem printing double quotes in XML using XML::DOM

2013-11-28 Thread Shaji Kalidasan
Dear Perlers, I am trying to print double quotes in the output (output.xml) but it is printing " instead of "". How can I include double quotes "" in the output. Please help. Here is the code [code] #!/usr/bin/perl use strict; use warnings; use XML::DOM; my $parse

Re: printing content of a pipe

2013-06-28 Thread Rajeev Prasad
i see, it changes 'destination' for the rest of the perl script, you mean. i have another question which i will submit in new thread. From: Shlomi Fish To: Rajeev Prasad Cc: perl list Sent: Friday, June 28, 2013 11:45 AM Subject: Re: printing

Re: printing content of a pipe

2013-06-28 Thread Shlomi Fish
On Fri, 28 Jun 2013 07:37:57 -0700 (PDT) Rajeev Prasad wrote: > Shlomi/Uri, > what do you mean by 'It's a good idea not to use "select" on filehandles like > that because it willaffect the default filehandle permanently.'? shlomif@lap:~$ cat Test.pl #!/usr/bin/perl use strict; use warnings; us

Re: printing content of a pipe

2013-06-28 Thread Rajeev Prasad
28, 2013 4:48 AM Subject: Re: printing content of a pipe Hi Rajeev, see below for some comments on your code. On Thu, 27 Jun 2013 15:07:50 -0700 (PDT) Rajeev Prasad wrote: > in the below code I am not able to print anything except whatever is in the > $pty.  I want to print LINE_START

Re: printing content of a pipe

2013-06-28 Thread shawn wilson
On Jun 28, 2013 9:24 AM, "Shawn H Corey" wrote: > > On Fri, 28 Jun 2013 11:57:24 +0100 > Rob Dixon wrote: > > > On 28/06/2013 02:32, Uri Guttman wrote: > > > > > > you don't need > > > ever to set $| on stderr as it is not buffered like stdout is. and > > > you rarely need to set it on stdout as

Re: printing content of a pipe

2013-06-28 Thread Shawn H Corey
On Fri, 28 Jun 2013 11:57:24 +0100 Rob Dixon wrote: > On 28/06/2013 02:32, Uri Guttman wrote: > > > > you don't need > > ever to set $| on stderr as it is not buffered like stdout is. and > > you rarely need to set it on stdout as any print with a \n will > > flush stdout. > > That isn't true. >

Re: printing content of a pipe

2013-06-28 Thread Rob Dixon
On 28/06/2013 02:32, Uri Guttman wrote: you don't need ever to set $| on stderr as it is not buffered like stdout is. and you rarely need to set it on stdout as any print with a \n will flush stdout. That isn't true. Perl will buffer STDOUT up to 8KB regardless of whether a newline has been p

Re: printing content of a pipe

2013-06-28 Thread *Shaji Kalidasan*
Shaji --- Your talent is God's gift to you. What you do with it is your gift back to God. --- From: Shlomi Fish To: perl list Sent: Friday, 28 June 2013 3:18 PM Subject: Re: print

Re: printing content of a pipe

2013-06-28 Thread Shlomi Fish
Hi Rajeev, see below for some comments on your code. On Thu, 27 Jun 2013 15:07:50 -0700 (PDT) Rajeev Prasad wrote: > in the below code I am not able to print anything except whatever is in the > $pty.  I want to print LINE_START: in the beginning of each line of the > output, but it does not pr

Re: printing content of a pipe

2013-06-27 Thread Uri Guttman
On 06/27/2013 06:07 PM, Rajeev Prasad wrote: in the below code I am not able to print anything except whatever is in the $pty. I want to print LINE_START: in the beginning of each line of the output, but it does not print that, it only prints what the output of the exceuted command produced.

printing content of a pipe

2013-06-27 Thread Rajeev Prasad
in the below code I am not able to print anything except whatever is in the $pty.  I want to print LINE_START: in the beginning of each line of the output, but it does not print that, it only prints what the output of the exceuted command produced. why is that so?     while(<$pty>) {          

Re: tt hash values not printing....

2012-10-30 Thread Rajeev Prasad
not printing Hello, Since I did not get any reply in last few hours. I am now posting this question to the perl list too. I apologize if you mind. thank you. starting with a hash ref my $my_hash = {}; building the hash in a loop...           push(@tmp_arr,$val1);           push(@tmp_

tt hash values not printing....

2012-10-30 Thread Rajeev Prasad
Hello, Since I did not get any reply in last few hours. I am now posting this question to the perl list too. I apologize if you mind. thank you. starting with a hash ref my $my_hash = {}; building the hash in a loop...           push(@tmp_arr,$val1);           push(@tmp_arr,$val2);  

Re: printing anonymous array

2012-07-08 Thread John W. Krahn
timothy adigun wrote: [snip] my %new_hash = (); foreach my $data1 ( keys %$hash1 ) { while ( my ( $key, $value ) = each %$hash2 ) { my ($new_value) = keys %$value; $new_hash{$key} = $new_value if $data1 == $key; } } No need for the nested llops: my %new_hash; for

Re: printing anonymous array

2012-07-08 Thread Chris Stinemetz
Thank you very much. That was the solution I was looking for. Take care, Chris

Re: printing anonymous array

2012-07-08 Thread timothy adigun
Hi Chris, Please, check comments and codes below. On Sun, Jul 8, 2012 at 6:19 AM, Chris Stinemetz wrote: > Thank you very much for your responses. > > I have another question. > > I would like to replace the second element from hash1 with the second key > from %hash2 > > I believe what you

Re: printing anonymous array

2012-07-07 Thread Chris Stinemetz
Thank you very much for your responses. I have another question. I would like to replace the second element from hash1 with the second key from %hash2 Where both of the firsts keys match in the two hashes. I shortened the sample data below but there will be a match for each instances of the key

Re: printing anonymous array

2012-07-07 Thread Rob Dixon
On 07/07/2012 14:07, Chris Stinemetz wrote: Hello list, I have constructed an anonymous array with all the data I need. I am having some difficulty in accessing and printing out the data the way I want. For the sake of not cluttering this thread too much I have uploaded the anonymous array Data

Re: printing anonymous array

2012-07-07 Thread timothy adigun
gt; >> On Sat, Jul 7, 2012 at 9:07 AM, Chris Stinemetz >> wrote: >> > Hello list, >> > >> > I have constructed an anonymous array with all the data I need. >> > I am having some difficulty in accessing and printing out the data the >> way >&g

Re: printing anonymous array

2012-07-07 Thread timothy adigun
all the data I need. > > I am having some difficulty in accessing and printing out the data the > way > > I want. > > For the sake of not cluttering this thread too much I have uploaded the > > anonymous array Data::Dumper output at github:gist > > > > https://

Re: printing anonymous array

2012-07-07 Thread Ken Slater
On Sat, Jul 7, 2012 at 9:07 AM, Chris Stinemetz wrote: > Hello list, > > I have constructed an anonymous array with all the data I need. > I am having some difficulty in accessing and printing out the data the way > I want. > For the sake of not cluttering this thread too much I

printing anonymous array

2012-07-07 Thread Chris Stinemetz
Hello list, I have constructed an anonymous array with all the data I need. I am having some difficulty in accessing and printing out the data the way I want. For the sake of not cluttering this thread too much I have uploaded the anonymous array Data::Dumper output at github:gist https

Re: printing hashes

2012-03-25 Thread Chris Stinemetz
> If there is anything I didn't explain well, just say so. > > Good job on your attempts. > > Steve > Thank you very much! I am very grateful for your help and explanations. Take care, Chris -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h.

Re: printing hashes

2012-03-25 Thread Steve Bertrand
On 2012-03-25 23:15, Chris Stinemetz wrote: ok. You didn't do anything wrong per-se, all you did was try to go one level too deep into your data structure. $cell (eg 149) was the name of the key for the top-level %hash container. All hash keys can only have one value associated with it. In t

Re: printing hashes

2012-03-25 Thread Chris Stinemetz
> > replace all of this: > > >>   foreach my $hr ( sort keys %{ $href->{$cell}} ) { >>     # print "\t$hr"; >>     foreach my $count ( sort keys %{ $href->{$cell}->{$hr}} ) { #<-- line >> 48 >>     print "\t$count"; >>     } >>   } > > > ...with this: > > >    foreach my $hr ( sort keys %{ $href->{

Re: printing hashes

2012-03-25 Thread Steve Bertrand
On 2012-03-25 22:39, Chris Stinemetz wrote: Use a block sort to sort numerically: perl -E '%h=qw(3 a 2 b 1 c 4 d); say sort { $a<=>$b } keys %h;' Show us what you have so far if you need help with a specific code segment. references are still a bit foreighn to me. Below is the error I am ge

Re: printing hashes

2012-03-25 Thread Chris Stinemetz
> > Use a block sort to sort numerically: > > perl -E '%h=qw(3 a 2 b 1 c 4 d); say sort { $a<=>$b } keys %h;' > > Show us what you have so far if you need help with a specific code segment. > references are still a bit foreighn to me. Below is the error I am getting along with the snippit of code.

Re: printing hashes

2012-03-25 Thread Steve Bertrand
On 2012-03-25 22:13, Chris Stinemetz wrote: Any advice on how to include a numerical sort on the second key? I've been trying to resolve this for a while and have had no luck. Use a block sort to sort numerically: perl -E '%h=qw(3 a 2 b 1 c 4 d); say sort { $a<=>$b } keys %h;' Show us what y

Re: printing hashes

2012-03-25 Thread Chris Stinemetz
On Mar 25, 2012 11:15 AM, "Steve Bertrand" wrote: > > On 2012-03-25 12:02, Chris Stinemetz wrote: >> >> How would I return the values along with the keys that meet the criteria >> from the sub routine? > > >> On Mar 25, 2012 10:04 AM, "Rob Dixon" wrote: > > > Keeping with the use of $_, replace t

Re: printing hashes

2012-03-25 Thread Chris Stinemetz
> code snippet: > my $href = %data; > I changed my $href = %data; to my $href = \%data; and it works now. Thanks all, Chris -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: printing hashes

2012-03-25 Thread Chris Stinemetz
> > Keeping with the use of $_, replace the following 'print map' statement to > the following: > > >>> print map "$_\n", @wanted; > > > foreach ( @wanted ){ >    print "$_:\n"; >    foreach ( values %{ $href->{ $_ } } ){ >       print "\t$_\n"; >    } > } > > ** OUTPUT ** > > 149: >        2 >    

Re: printing hashes

2012-03-25 Thread Steve Bertrand
On 2012-03-25 12:02, Chris Stinemetz wrote: How would I return the values along with the keys that meet the criteria from the sub routine? On Mar 25, 2012 10:04 AM, "Rob Dixon" wrote: Keeping with the use of $_, replace the following 'print map' statement to the following: print map "$_

Re: printing hashes

2012-03-25 Thread Chris Stinemetz
ave. >> >> What is the best approach for only printing the hashes that have the >> value 'ND' or hashes that have different values such as '149' does >> below. >> >> '149' => { >>

Re: printing hashes

2012-03-25 Thread Rob Dixon
On 25/03/2012 14:11, Chris Stinemetz wrote: Below is snippet from Data::Dumper dump from a hash I have. What is the best approach for only printing the hashes that have the value 'ND' or hashes that have different values such as '149' does bel

Re: printing hashes

2012-03-25 Thread Dr.Ruud
On 2012-03-25 15:11, Chris Stinemetz wrote: What is the best approach for only printing the hashes that have the value 'ND' or hashes that have different values such as '149' does below. Code it, in Perl. -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@per

printing hashes

2012-03-25 Thread Chris Stinemetz
Below is snippet from Data::Dumper dump from a hash I have. What is the best approach for only printing the hashes that have the value 'ND' or hashes that have different values such as '149' does below. '149' => { '05&#x

Re: Splitting and printing on a single line

2012-01-05 Thread John W. Krahn
bob wrote: Hello Hello, I am very new to perl and I need some guidance on the following issue My data set is like this --- Record 38 Richard Nixon http://en.wikipedia.org/wiki/Richard_Nixon --- Record 39 Gerald Ford http://en.wikipedia.org/wik

Splitting and printing on a single line

2012-01-05 Thread bob
Hello I am very new to perl and I need some guidance on the following issue My data set is like this --- Record 38 Richard Nixon http://en.wikipedia.org/wiki/Richard_Nixon --- Record 39 Gerald Ford http://en.wikipedia.org/wiki/Gerald_Ford -

Re: printing existing png image to .pl file ?

2011-12-03 Thread Huub van Niekerk
On Sat, 03 Dec 2011 10:02:02 -0500, Zak Zebrowski wrote: > Yes. Also, you may want to look at imager, which doesn't require image > magic (which works better on some environments.). Also, the synopsis of > imager produces thumbnails with perl. > > Best > Zak Ok, thanks. I'll with that.. --

Re: printing existing png image to .pl file ?

2011-12-03 Thread Zak Zebrowski
Yes. Also, you may want to look at imager, which doesn't require image magic (which works better on some environments.). Also, the synopsis of imager produces thumbnails with perl. Best Zak Sent from my iPod On Dec 3, 2011, at 1:55 AM, Huub van Niekerk wrote: > Hi, > > I want to use an ex

printing existing png image to .pl file ?

2011-12-02 Thread Huub van Niekerk
Hi, I want to use an existing png image for changing into a smaller size and write into a .pl file that will be printed. So far I've found several posts talking about using ImageMagick and dealing with raster images, but nothing tells me about writing in combination with .pl. Is this possible

Re: Help- storing and printing array contents

2011-03-17 Thread Uri Guttman
SV> my @sorted_url_array = sort(@unique_url_array); no need for the temp array: my @sorted_url_array = sort keys %hash; SV> print "Printing sorted_url_array:\n"; SV> for ($j=0; $j <= $#sorted_url_array; $j++) no need for even the sorted temp array:

Re: Help- storing and printing array contents

2011-03-17 Thread Uri Guttman
pace in the array no need to preallocate arrays. and no need for $i. see below. just declare that array as my @urls (no need to have 'array' as a suffix for arrays). SV> find (\&wanted, $dir_to_process); SV> print "Printing url_array\n:"; SV> for ($j=0; $j <

Re: Help- storing and printing array contents

2011-03-17 Thread Saral Viral
ed_url_array = sort(@unique_url_array); print "Printing sorted_url_array:\n"; for ($j=0; $j <= $#sorted_url_array; $j++) { print ($sorted_url_array[$j], "\n"); # This PRINTS sorted, non-duplicate array } print "END Printing sorted_url_array\n"; sub wanted

Help- storing and printing array contents

2011-03-17 Thread Saral Viral
r_to_process:$1"; print "Files in $dir_to_process are:\n"; $i = 0; @url_array = (1..2000); # initialized to have enough space in the array find (\&wanted, $dir_to_process); print "Printing url_array\n:"; for ($j=0; $j <= $#url_array; $j++) { print ($url_array[$j

Re: Printing Bash and Kernel Version numbers using Perl

2011-03-12 Thread Alan Haggai Alavi
Hello Parag, Vern Nice. Completely impressed. But I thought Perl might have some internal variable at least for Kernel version. But anyways this work for me too. `Config` module's `config_re` function can be used: =pod code use Config 'config_re'; my ($os_version) = config_re('^osvers'); $o

Re: Printing Bash and Kernel Version numbers using Perl

2011-03-12 Thread Parag Kalra
perl -MConfig -e 'print "$Config{perlpath}:$^V\n$ENV{SHELL}:" . qx{ bash > --version | head -1 } . "/kernel/$^O:" . qx{ uname -r }' > Vern Nice. Completely impressed. But I thought Perl might have some internal variable at least for Kernel version. But anyways this work for me too. ~Parag

Re: Printing Bash and Kernel Version numbers using Perl

2011-03-12 Thread Alan Haggai Alavi
Hello Parag, perl -MConfig -le 'print "$Config{perlpath}:$^V\n$ENV{SHELL}: \n/kernel/$^O:"' =pod code perl -MConfig -e 'print "$Config{perlpath}:$^V\n$ENV{SHELL}:" . qx{ bash --version | head -1 } . "/kernel/$^O:" . qx{ uname -r }' =cut Regards, Alan Haggai Alavi. -- The difference makes th

Printing Bash and Kernel Version numbers using Perl

2011-03-12 Thread Parag Kalra
Hi, Wanted to have suggestions to modify below 1 liner so that it can also print Shell (preferably Bash) version and along with Operating System Kernel version. Currently I am just printing the place holders for Shell and Kernel version numbers. perl -MConfig -le 'print "$Config{perlp

Re: Traversing Hash printing two times

2010-09-02 Thread Uri Guttman
> "JG" == Jim Gibson writes: JG> At 11:29 AM +0530 9/3/10, Jatin Davey wrote: >> Any reason to use named variables than to use the default variable ($_) ? JG> Two reasons that I know: JG> 1. If you use a named variable, you and everybody else reading your JG> code will know what i

Re: Traversing Hash printing two times

2010-09-02 Thread Uri Guttman
> "JWK" == John W Krahn writes: JWK> Uri Guttman wrote: >>> "JD" == Jatin Davey writes: >> >> >> but it isn't as good as my code. don't use $_ unless you have to (as in >> >> map/grep). it is much better to use named variables. JD> Any reason to use named variables than to

Re: Traversing Hash printing two times

2010-09-02 Thread John W. Krahn
Uri Guttman wrote: "JD" == Jatin Davey writes: >> but it isn't as good as my code. don't use $_ unless you have to (as in >> map/grep). it is much better to use named variables. JD> Any reason to use named variables than to use the default variable ($_) ? yes, you can read the co

Re: Traversing Hash printing two times

2010-09-02 Thread Jim Gibson
At 11:29 AM +0530 9/3/10, Jatin Davey wrote: Any reason to use named variables than to use the default variable ($_) ? Two reasons that I know: 1. If you use a named variable, you and everybody else reading your code will know what it is for. While it doesn't matter much for 3-line loops, s

Re: Traversing Hash printing two times

2010-09-02 Thread Jatin Davey
yes, you can read the code and see what the variable is for. $_ is useful in some situations but not for foreach loops and similar things. names are important in code and $_ has no name. you lose the opportunity to tell the reader of the code what the variable contains and what it is used for.

Re: Traversing Hash printing two times

2010-09-02 Thread Uri Guttman
> "JD" == Jatin Davey writes: >> but it isn't as good as my code. don't use $_ unless you have to (as in >> map/grep). it is much better to use named variables. JD> Any reason to use named variables than to use the default variable ($_) ? yes, you can read the code and see what the var

Re: Traversing Hash printing two times

2010-09-02 Thread Jatin Davey
but it isn't as good as my code. don't use $_ unless you have to (as in map/grep). it is much better to use named variables. Any reason to use named variables than to use the default variable ($_) ? and please learn to edit quoted emails and to bottom post. you can google for what that means.

Re: Traversing Hash printing two times

2010-09-02 Thread Uri Guttman
> "JD" == Jatin Davey writes: JD> for (keys %months) { JD> print "Months in $_ : @{$months{$_}} \n"; JD> } JD> and it worked fine. but it isn't as good as my code. don't use $_ unless you have to (as in map/grep). it is much better to use named variables. JD> On 9/3/2010 10:47

Re: Traversing Hash printing two times

2010-09-02 Thread Jatin Davey
Changed it to: #!/usr/bin/perl use warnings; use strict; my @english = qw(january february march april may june july); my @french = qw(janvier fverier mars avril mai juin juily); my %months; $months{english} = \...@english; $months{french} = \...@french; for (keys %months) { print "Months in

Re: Traversing Hash printing two times

2010-09-02 Thread Uri Guttman
> "JD" == Jatin Davey writes: JD> #!/usr/bin/perl JD> use warnings; JD> use strict; very good to see those. JD> my @english = qw(january february march april may june july); JD> my @french = qw(janvier fverier mars avril mai juin juily); JD> my %months; JD> my $eng_ref; JD>

Traversing Hash printing two times

2010-09-02 Thread Jatin Davey
Hi I am a newbie to Perl , I have this piece of code : *CODE:* #!/usr/bin/perl use warnings; use strict; my @english = qw(january february march april may june july); my @french = qw(janvier fverier mars avril mai juin juily); my %months; my $eng_ref; my $fre_ref; $eng_ref = \...@english; $

Re: printing grep results in Perl

2010-08-02 Thread John W. Krahn
Erik Witkop wrote: There is one more task that I am unable to solve. If $_ was something like FYUY or fO76, I would like to remove the first ^[Ff].But keep the last 3 character. Find and Replace does not work obviously as I would lose those last 3 characters that I want. I researched the map f

Re: printing grep results in Perl

2010-08-02 Thread Brian Fraser
If you don't mind a newbie trying to help... Since you want to replace something, using bare //'s won't do, since that's an alias for m//; m, as in match. You want a substitution, s///. The regex you are looking for should look something like this (Untested code): > s/ > \b #Word boundary

Re: printing grep results in Perl

2010-08-02 Thread Erik Witkop
On Jul 27, 11:34 pm, u...@stemsystems.com ("Uri Guttman") wrote: > > "EW" == Erik Witkop writes: > >   EW> I have spent half the day looking at map and I still don't get it. > > it is easier than you think. > >   EW> I don't get the EXPR versus BLOCK and how I can treat them differently. > > t

Re: printing grep results in Perl

2010-07-27 Thread Uri Guttman
> "EW" == Erik Witkop writes: EW> I have spent half the day looking at map and I still don't get it. it is easier than you think. EW> I don't get the EXPR versus BLOCK and how I can treat them differently. that is mostly a syntax difference. you can have a single expression, then a com

Re: printing grep results in Perl

2010-07-27 Thread Erik Witkop
Hi Uri, I have spent half the day looking at map and I still don't get it. I don't get the EXPR versus BLOCK and how I can treat them differently. I think I am close but my regex is not hitting. /@final_results = map { m/^[a-zA-Z0-9]{3,4}?$/$1/ } @just_cust_codes; foreach (@final_results){ pr

Re: printing grep results in Perl

2010-07-27 Thread Erik Witkop
Thanks Uri. It is time that I learned map. I typically lean on grep and =~ for matching patterns. But map sounds like a great solution. Thanks again. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: printing grep results in Perl

2010-07-27 Thread Uri Guttman
> "EW" == Erik Witkop writes: EW> Thanks Uri. EW> It is time that I learned map. I typically lean on grep and =~ for EW> matching patterns. But map sounds like a great solution. grep is NOT a regex function or has anything to do with regexes. get that false association out of your head

Re: printing grep results in Perl

2010-07-27 Thread Uri Guttman
> "EW" == Erik Witkop writes: EW> So I have an array full of elements in the following format: EW> 32F--sometext--x EW> F32-sometext12-xxx EW> I am only interested in the first portion before the first hyphen. EW> I am able to grep to get that portion. grep doesn't give back

Re: printing grep results in Perl

2010-07-27 Thread John W. Krahn
Erik Witkop wrote: So I have an array full of elements in the following format: 32F--sometext--x F32-sometext12-xxx I am only interested in the first portion before the first hyphen. I am able to grep to get that portion. @grep_results1 = grep(/[a-zA-Z0-9]{2,4}-/, @sho_port_small_array);

  1   2   3   4   5   6   7   8   9   >