Re: Upgrade from Debian 11 to Debian 12 Broke Perl.

2024-03-11 Thread John SJ Anderson
> Can't locate warnings/unused.pm in @INC (you may need to install the 
> warnings::unused module) (@INC contains: /etc/perl 
> /usr/local/lib/x86_64-linux-gnu/perl/5.36.0 /usr/local/share/perl/5.36.0 
> /usr/lib/x86_64-linux-gnu/perl5/5.36 /usr/share/perl5 
> /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.36 
> /usr/share/perl/5.36 /usr/local/lib/site_perl) at /home/martin/etc/p2 line 3.
> BEGIN failed--compilation aborted at /home/martin/etc/p2 line 3.
> 
> So, if I try to use cpanp and re-add that module, I get:
> 
> 1wb5agz martin tmp $ cpanp -i Warnings::Unused
> ERROR] 'Warnings::Unused' does not contain an author part
> 
> [ERROR] Cannot find 'Warnings::Unused' in the module tree

“Warnings::Unused” != “warnings::unused”

Try `cpanp warnings::unused`.

j.


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




Re: Knowledge for a basic programmer and advanced programmer

2024-01-05 Thread John SJ Anderson
> If you are coding you should be backing up every
> 10 minutes or more often.  And you should store 
> a "historical" full copy of the code every 30 minutes
> or more often and save them for days.

No, you shouldn’t, because it is no longer 1985. 

You should learn how to use version control; the de facto standard at this 
point is Git. 

j.



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




Re: Modules

2023-10-24 Thread John Harris Gmail
What modules and/or libraries are you using? Before you code do you block
diagram and flowchart your programs?

On Tue, Oct 24, 2023, 12:06 PM Levi Elias Nystad-Johansen via beginners <
beginners@perl.org> wrote:

> I use modules for complex things that I might get wrong. To re-use other
> people's code is often better than to re-invent their solutions.
>
> https://metacpan.org/pod/WWW::Mechanize::Examples has some good examples
> of useful scripts that are short and simple.
> Imagine how hard it would be to write the same scripts without the module.
>
> When I have an issue that I think others must also have faced, I look for
> a module to solve the issue.
>
> But I am critical to modules that are outdated/abandoned, heavy with many
> dependencies, or unproven with few downloads etc.
>
> I also remove modules when I no longer need them. I find this easier with
> App::cpanminus
>
> - L
>
>
>
>
>
>
>  Original Message 
> On 24. okt. 2023, 17:31, William Torrez Corea < willitc9...@gmail.com>
> wrote:
>
>
> When I must use modules and when I don't must use?
>
> I am working without modules, only i use:
>
>1. Subroutines
>2. Control flow
>
> My programs are short and simple, they do not exceed 15 lines. I think
> that I need more practice and learn more about Perl. I have limited
> knowledge in Perl.
>
> --
>
> With kindest regards, William.
>
> ⢀⣴⠾⠻⢶⣦⠀
> ⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
> ⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
> ⠈⠳⣄
>
>
>


Re: Tool for develop in Perl

2023-10-23 Thread John Tebbe

I use this, it an old one but it meets my needs:

https://sourceforge.net/projects/open-perl-ide/

On 10/23/2023 6:55 AM, Ruprecht Helms wrote:


An Alternative for VIM or Emacs is the Nano-Editor.


Maybe the IDE Eclipse is able to assist you in developing perl-code. 
But like to use Eclipse for PHP-Developing, Handling SQL, ... you have 
to install a plugin to add this oppertunity. By default Eclipse is a 
IDE for Java-Developing.


Regards,
Ruprecht

On 22.10.23 21:46, Francisco Valladolid H. wrote:
The only thing that you need for develop  in perl is vi/vim and Unix 
like terminal.


Regards

On Sun 22 Oct 2023 at 1:38 p.m. Vlado Keselj  wrote:


I use Emacs.

On Fri, 20 Oct 2023, William Torrez Corea wrote:

> What tool can I use for development in Perl?
>
> I use VIM for coding and executing programs with the Perl
Command Line from GNU/Linux. In addition I have installed Eclipse
> but the IDE is abandoned.
>
> My theory: I can make full development from VIM but few
developers use VIM for development. They use Eclipse, Netbeans,
> Visual Studio or some other code editor like Visual Studio
Code, Sublime Text, Atom and Notepad++.
>
> The IDE is complete but large files while the code editor is light.
> --
>
> With kindest regards, William.
>
> ⢀⣴⠾⠻⢶⣦⠀
> ⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
> ⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
> ⠈⠳⣄
>
>
>
>
-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org

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


Re: escape character in regex

2022-10-10 Thread John W. Krahn

On 2022-10-10 18:12, Henrik Park wrote:


I know "/" is a special character for regex, which should be escaped.

But if I put "/" in a variable and use the variable in regex, then it 
doesn't need the explicit escape. Like this one:


$ perl -le '$delimiter="/"; $str="hello/world/buddy"; 
@list=split/$delimiter/,$str;print "@list"'

hello world buddy


Am I right? thank you.




"/" is NOT a special charater in a regular expression.  It is just that 
in Perl the default delimiter for some operators is "/" (i.e. m//, s///, 
tr///, etc.).


John

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




Re: Benchmark for Scala, Ruby and Perl

2022-01-15 Thread John W. Krahn

On 2022-01-15 00:04, Jon Smart wrote:


Hello Paul

Do you mean by undef $/ and with <$fh> we can read the file into memory 
at one time?


$/ is the input record separator, newline by default.
If undefined that means that the whole file is treated as one single record.


Yes that would be faster b/c we don't need to read file by each line, 
which increases the disk IO.


Another questions:
1. what's the "truss" command?


truss is a "unix" command.  Search for "truss unix".



2. what's the syntax "<:mmap"?


mmap enables a memory mapped file.  I treats the file as if it were a 
chunk of memory instead of a file.


Depending on the size of the file and the amount of memory available it 
may not make a difference.  Benchmark to confirm.




On 15.01.2022 15:45, Paul Procacci wrote:


-
use strict;

$/ = undef;


That is usually written as:

local $/;

because $/ is a global variable and you want to limit the scope of any 
change.




my %stopwords = do {
    open my $fh, '<:mmap', 'stopwords.txt' or die $!;
    map { $_ => 1; } split /\n/, <$fh>;
};

my %count = do {
    my %res;
    open my $fh, '<:mmap', 'words.txt' or die $!;
    map { $res{$_}++ unless $stopwords{$_}; } split /\n/, <$fh>;
    %res;
};

my $i=0;
for (sort {$count{$b} <=> $count{$a}} keys %count) {
    if ($i < 20) {
    print "$_ -> $count{$_}\n"
    } else {
   last;
    }
    $i ++;
}




John

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




Re: A Philosophical Point To Be Made: The Truth

2021-10-26 Thread John SJ Anderson
This is off-topic for this mailing list; please take this discussion elsewhere. 

thanks,
john,
list mom. 


> On Oct 26, 2021, at 03:06, Shlomi Fish  wrote:
> 
> Hi Brandon!
> 
>> On Sun, 17 Oct 2021 01:15:13 -0400
>> Brandon McCaig  wrote:
>> 
>> Hello All,
>> 
>> It has been a while. I haven't been active on the list in years.
>> Something much bigger has been stealing my focus. And now I think
>> I might be ready to share it with the world.
>> 
>> Do be warned, I make best efforts to be inclusive of all, but I
>> only know what I know. But if I'm right I have the answer to all
>> of this for all of us.
>> 
>> https://castopulence.org/
>> 
>> To summarize, I think I know what the "correction" to
>> insensitivity is. A better social network. Based upon the truth.
>> 
>> I wonder too if the Perl developers themselves might be
>> interested in this discussion because of its relationship to
>> linguistics and software. Though I dare not try to send it their
>> way directly without a push (and maybe a direction).
>> 
>> Feedback, constructive or otherwise, is welcomed and encouraged.
>> 
> 
> After reading that page, I still don't understand how the issue manifests
> itself as well as how the proposed solution will be implemented. Perhaps try
> giving concrete examples.
> 
>> Regards,
>> 
>> 
>> 
>> Brandon McCaig   <
>> bamb...@castopulence.org>  
>> Castopulence Software <https://www.castopulence.org/>
>> Blog <https://www.bambams.ca/ <http://www.bambams.ca/>>
>> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
>> q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
>> tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'
> 
> 
> 
> -- 
> 
> Shlomi Fish   https://www.shlomifish.org/
> Beginners Site for the Vim text editor - https://vim.begin-site.org/
> 
> Buddha has the Chuck Norris nature.
>— https://www.shlomifish.org/humour/bits/facts/Chuck-Norris/
> 
> Please reply to list if it's a mailing list post - https://shlom.in/reply .
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 


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




Re: memory mapped file example

2020-10-03 Thread John W. Krahn

On 2020-10-03 5:41 a.m., stefano cerbioni wrote:

hi guys i try to read a memory mapped file created with c++ , this is a c++
code that i have
[code]


[snip code]



[/code]

how can read a  memory mapped created ?
thankz at all



A memory mapped file should be just like any other file.  Just find out 
what the file name is and determine what format the data is stored in 
that file.


John

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




Re: Wide character in print at HTML::TreeBuilder::XPath function

2020-01-26 Thread John SJ Anderson
> That, I am very grateful to report, solved that question.  I guess the
> scope of "use utf8;" is more narrow than I had thought.

When you have a bit of time, sitting down and reading through 
https://github.com/rgs/p5-intelligible-unicode 
<https://github.com/rgs/p5-intelligible-unicode> is a really good investment in 
reducing future frustrations when working with Unicode in Perl.

chrs,
john.





Re: question about perl script

2019-10-30 Thread John W. Krahn

On 2019-10-29 7:48 p.m., 刘东 wrote:

Dear every one:


Hello.


I try to write a perl script to delet the content of file carp01_1_both.txt as 
same as from another file carp-carp01_TKD181002053-1_1_sg.txt, so to get a new 
file from file carp-carp01_TKD181002053-1_1_sg.txt but excluding file 
carp01_1_both.txt. However, when I run this scrip, it does not work, and 
display the information as follows:
...

Semicolon seems to be missing at carp01_1_both.txt line 44993.




syntax error at carp01_1_both.txt line 1, near "979:"


These messages say that perl is trying to interpret your data file as if 
it were a Perl program.




perl script:
#!/usr/bin/perl -w
open(NAME,"<$ARGV[0]")|| die;
open(SECON,"<$ARGV[1]")|| die;
open(SELEC,">$ARGV[2]")|| die;
$name = "";
%pair = ();

while(){
  chomp;
  my @line = split("\t",$_);
 $name = $line[0];
 $pair{$name} = 1;
}

while(my $li = ){
 chomp($li);
 my  @line = split("\t",$li);
 $name = $line[0];
 my  $cont = $li;
if (exists $hash{$name}) { # if current read appeared before
 next;
 } else { # if it haven't been read before
 print SELEC "$cont\n";
  }
}

close NAME;
close SECON;
close SELEC;


#!/usr/bin/perl
use warnings;
use strict;

open my $NAME, '<', $ARGV[ 0 ] or die "Cannot open '$ARGV[0]' because: $!";
open my $SECON, '<', $ARGV[ 1 ] or die "Cannot open '$ARGV[1]' because: $!";
open my $SELEC, '>', $ARGV[ 2 ] or die "Cannot open '$ARGV[2]' because: $!";

my %pair;

while ( <$NAME> ) {
my ( $name ) = split /\t/;
$pair{ $name }++;
}

while ( <$SECON> ) {
my ( $name ) = split /\t/;
print { $SELEC } $_ unless exists $pair{ $name };
}

close $NAME;
close $SECON;
close $SELEC;

__END__


John

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




Re: Help me with a regex problem

2019-10-25 Thread John W. Krahn

On 2019-10-25 3:23 a.m., Maggie Q Roth wrote:

  Hello


Hello.


There are two primary types of lines in the log:


What are those two types?  How do you define them?



60.191.38.xx/
42.120.161.xx   /archives/1005


From my point of view those two lines have two fields, the first looks 
like an IP address and the second looks like a file path.  In other 
words I can't distinguish the difference between these two "types".




I know how to write regex to match each line, but don't get the good result
with one regex to match both lines.

Can you help?


Perhaps if you could describe the problem better?


John

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




Re: perl script question

2019-10-10 Thread John W. Krahn

On 2019-10-09 7:21 p.m., 刘东 wrote:

hellow:
I have written a script, but it does not work, can you tell me what wrong with 
me?


#! /usr/bin/perl

use strict;
use warnings;
use Getopt::Long;

my ($dir, $files, $file_name, $file_format, $file_dir, $file_main);

GetOptions ('dr=s'  =>\$dir);

open INF,"<",'sine.fa' or die "can't read open sine";

foreach $files (glob("$dir/*.fa")) {
open FASEQ, "<", $files or die "can not read open $!";
   ($file_dir, $file_main) = split (/\/\//,$files);
   ($file_name,$file_format) =split(/\./,$file_main);
open OUTFILE, '>', $file_name.".txt";
`./usearch -ublast FASEQ -db INF -evalue 1e-5 -userout OUTFILE -strand both 
-userfields query+qlo+qhi+ql+qs+qstrand+target+tlo+thi+tl`;
}

close FASEQ;
close OUTFILE;
close INF;


(Sorry, correction added.)
Perhaps it may work better like this:

#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long;

GetOptions( 'dr=s' => \my $dir );

opendir my $DH, $dir or die "Cannot open '$dir' because: $!";

while ( my $file = readdir $DH ) {

my $file_name = $file =~ s/\.fa\z/.txt/r or next;

0 == system './usearch',
'-ublast', "$dir/$file",
'-db', 'sine.fa',
'-evalue', '1e-5',
'-userout', $file_name,
'-strand', 'both',
'-userfields', 'query+qlo+qhi+ql+qs+qstrand+target+tlo+thi+tl'
or die "system ./usearch failed: $?";
}


John

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




Re: perl script question

2019-10-10 Thread John W. Krahn

On 2019-10-09 7:21 p.m., 刘东 wrote:

hellow:
I have written a script, but it does not work, can you tell me what wrong with 
me?


#! /usr/bin/perl

use strict;
use warnings;
use Getopt::Long;

my ($dir, $files, $file_name, $file_format, $file_dir, $file_main);

GetOptions ('dr=s'  =>\$dir);

open INF,"<",'sine.fa' or die "can't read open sine";

foreach $files (glob("$dir/*.fa")) {
open FASEQ, "<", $files or die "can not read open $!";
   ($file_dir, $file_main) = split (/\/\//,$files);
   ($file_name,$file_format) =split(/\./,$file_main);
open OUTFILE, '>', $file_name.".txt";
`./usearch -ublast FASEQ -db INF -evalue 1e-5 -userout OUTFILE -strand both 
-userfields query+qlo+qhi+ql+qs+qstrand+target+tlo+thi+tl`;
}

close FASEQ;
close OUTFILE;
close INF;



Perhaps it may work better like this:

#!/usr/bin/perl

use strict;
use warnings;
use Getopt::Long;

GetOptions( 'dr=s' => \my $dir );

opendir my $DH, $dir or "Cannot open '$dir' because: $!";

while ( my $file = readdir $DH ) {

my $file_name = $file =~ s/\.fa\z/.txt/r or next;

0 == system './usearch',
'-ublast', "$dir/$file",
'-db', 'sine.fa',
'-evalue', '1e-5',
'-userout', $file_name,
'-strand', 'both',
'-userfields', 'query+qlo+qhi+ql+qs+qstrand+target+tlo+thi+tl'
or die "system ./usearch failed: $?";
}


John

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




Re: symlink to "pack"

2019-09-09 Thread John W. Krahn

On 2019-09-08 12:20 p.m., Jorge Almeida wrote:

On Sun, Sep 8, 2019 at 8:08 PM John W. Krahn  wrote:


On 2019-09-07 1:25 p.m., Jorge Almeida wrote:

On Unix/Linux a character in a file name can be any character except a
slash '/' character because that is used to separate path elements, or a
null "\0" character because that is what the C language uses to signify
the end of a string.


Yes, but does a symlink target counts as a "file name"? Probably, but
it's not very clear. (I didn't want to dereference the symlink, only
readlink() it...)

Jorge


So your Perl string "\0\f" is read by C as a zero length string.



The operating system is written in C.  The symlink(2) function is part 
of the operating system and is written in C.  Therefore, when perl calls 
symlink(2) it has to send a valid C type string.  Because your string 
starts with a NULL character it is a C string with zero characters.



John

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




Re: symlink to "pack"

2019-09-08 Thread John W. Krahn

On 2019-09-07 1:25 p.m., Jorge Almeida wrote:

Sorry about the title, it's the best I can do...

#!/usr/bin/perl
use strict;
use warnings;
my $num=12;
my $target=pack('n', $num);
symlink($target, "foo") || die $!;

It dies with "No such file or directory"
No symlink is created. What I want is a symlink named "foo" pointing
to a 2-byte string. Yes, it would be a broken symlink. (Yes, this is
how I want it).

Symlink() can create broken links, the problem is the target. What to
do? (And why doesn't it work?)



$ perl -le'
use warnings;
use strict;
use Data::Dumper;
$Data::Dumper::Useqq = 1;

my $num = 12;
my $target = pack "n", $num;
print Dumper $target;
'
$VAR1 = "\0\f";


On Unix/Linux a character in a file name can be any character except a 
slash '/' character because that is used to separate path elements, or a 
null "\0" character because that is what the C language uses to signify 
the end of a string.


So your Perl string "\0\f" is read by C as a zero length string.


John

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




Re: ActiveState unauthorized license claims?

2019-05-31 Thread John SJ Anderson
> probably that's the wrong list for that question but I didn't find a better 
> one - hints are welcome.

Yes, this is very much not the right list for this. 

I would suggest posting this to the Perl 5 Porters list; it’s probably the best 
venue to get an answer to your question. 

https://lists.perl.org/list/perl5-porters.html 
<https://lists.perl.org/list/perl5-porters.html>

chrs,
john.




Re: What are the environmental variables used by Perl?

2019-05-30 Thread John SJ Anderson
> 
> Do you know if there is a list of environmental variables anywhere?

I think maybe this is what you’re looking for?  
https://perldoc.pl/perlrun#ENVIRONMENT 


Re: Syntax "||" before sub

2018-11-22 Thread John W. Krahn

On 2018-11-22 8:08 a.m., David Precious wrote:



You'll often see these operators used to provide default values.

e.g.

   sub hello {
   my $name = shift;
   $name ||= 'Anonymous Person';


Which is usually written as:

   sub hello {
   my $name = shift || 'Anonymous Person';



I do notice that there isn't actually a very useful section on ||=
and //= - I may try to raise a pull requests to add more documentation
on them.


$var ||= 'VALUE';

Is just shorthand for:

$var = $var || 'VALUE';

The syntax is borrowed from the C programming language and it is 
slightly more efficient when compiled to machine code.




John

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




Re: Code Assistance Pls

2018-11-21 Thread John W. Krahn

On 2018-11-21 3:08 a.m., Amanda Paziuk wrote:


I'm hoping someone can assist as I'm having difficulty with parsing a
section of the following configuration:

This is the code I have:

 push @list, $datum; # should only contain '1', and '3'

>
> ...
>

 foreach my $i (@list){ # loops through dynamically-learned file IDs
 open (IN, $file);
 while () {
 chomp;
 if (/^file-id $i/) {


If $i contains 1 then this will match "file-id 10" or "file-id 1234" or 
any number whose first digit is 1.

You need to either use anchors:

 if ( /^file-id \b$i\b/ ) {

Or capture the number and do numerical comparison:

 if ( /^file-id (\d+)/ && $1 == $i ) {




John

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




RE: XML::LibXML and comments

2018-09-11 Thread John Cortland Morgan
Hi Lawrence,

  Works great, thanks! Never thought of appending the comment directly to the 
$doc, just assumed I
Needed to set the root first.

Regards,

John

From: Lawrence Statton 
Sent: Monday, September 10, 2018 9:44 PM
To: beginners@perl.org
Subject: Re: XML::LibXML and comments




On Sep 10, 2018, at 6:33 AM, John Cortland Morgan 
mailto:johncortland.mor...@ericsson.com>> 
wrote:

Hi,

 I'm trying to place a comment directly after the XML declaration using 
XML::LibXML,
But cannot seem to manage, always receiving error:

setDocumentElement: ELEMENT node required at .../LibXML.pm line 1393

What I would like:




 testing


My relevant code thus far:

My $dom = XML::LibXML::Document->new( "1.0", "UTF-8");
My $root =  XML::LibXML::Comment->new( "test comment" );
$dom->setDocumentElement($root);


Any help would be greatly appreciated. I'm kinda stuck with using XML::LibXML 
though.

John

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


The root of a document cannot be a comment, however you can add a comment with

$dom->addChild($dom->createComment(‘test comment’))

#!/usr/bin/perl

use strict;
use warnings;
use XML::LibXML;

my $doc = XML::LibXML::Document->new(qw/1.0 utf-8/);

$doc->appendChild($doc->createComment('test comment'));
$doc->setDocumentElement(my $e_products = $doc->createElement('products'));
$e_products->appendTextChild(field => 'testing');

print $doc->toString(1);




XML::LibXML and comments

2018-09-10 Thread John Cortland Morgan
Hi,

  I'm trying to place a comment directly after the XML declaration using 
XML::LibXML,
But cannot seem to manage, always receiving error: 

setDocumentElement: ELEMENT node required at .../LibXML.pm line 1393

What I would like:




  testing


My relevant code thus far:

My $dom = XML::LibXML::Document->new( "1.0", "UTF-8");
My $root =  XML::LibXML::Comment->new( "test comment" );
$dom->setDocumentElement($root);


Any help would be greatly appreciated. I'm kinda stuck with using XML::LibXML 
though.

John

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




RE: Eclipse/Epic/PadWalker for Perl

2018-07-31 Thread John Cortland Morgan
Padwalker needs to be installed befor EPIC, so EPIC knows that it is there.
Try to remove EPIC and reinstall.

Regards

From: Lauren C. 
Sent: Tuesday, July 31, 2018 3:27 AM
To: James Kerwin ; beginners@perl.org
Subject: Re: Eclipse/Epic/PadWalker for Perl

[OT] maybe you want to change IDE to vi/vim since you are using Perl. :)


发件人: James Kerwin
日期: 2018年7月30日 星期一 下午9:19
至: mailto:beginners@perl.org>>
主题: Eclipse/Epic/PadWalker for Perl

Hi all,

I appreciate this isn't a place for the Eclipse IDE, but maybe some of you may 
have an answer.

I installed Eclipse Photon, EPIC and then PadWalker. Unfortunately I can't seem 
to see variables and their values in eclipse. I can't seem to find a diagnosis 
or solution.

Would anybody be able to shed some light onto this?

I should add that my scripts run in eclipse as expected. The debugging just 
doesn't seem to be behaving itself.

Thanks,
James


Re: help with a stat script

2018-07-12 Thread John W. Krahn
On Thu, 2018-07-12 at 19:35 +0800, Lauren C. wrote:
> 
> My web is powered by Apache and PHP,its access log seems as blow,
> 
> xx.xx.xx.xx - - [12/Jul/2018:19:29:43 +0800] "GET 
> /2018/07/06/antique-internet/ HTTP/1.1" 200 5489 "https://miscnote.ne
> t/" 
> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 
> (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
> 
> A perl script for stat purpose of this log:
> 
> tail -f /var/log/apache2/access.log|perl -nle 'next unless m{^(\S+) -
> - 
> \[(\S+).*\] \"GET (.*?/)\s+}; printf "%-20s%-40s%-40s\n",$1,$3,$2'
> 
> I was totally confused about it.
>   what does m{...} and its content stand for?



m{^

Start with the (^) beginning of line anchor, the following pattern must
match at the beginning of the line.

(\S+)

Match one or more non-whitespace characters and store the match in the
$1 variable.  This matches the "xx.xx.xx.xx" portion of your string.

' - - \['

Match the literal characters SPACE HYPHEN SPACE HYPHEN SPACE LEFT-
BRACKET.

(\S+)

Match one or more non-whitespace characters and store the match in the
$2 variable.  This matches the "12/Jul/2018:19:29:43" portion of your
string.

'.*\] \"GET '

Match zero or more non-newline characters followed by the literal
string '] "GET '.

(.*?/)

Match as few as possible non-newline characters followed by a '/'
character and store the match in the $3 variable.  This matches the
"/2018/07/06/antique-internet/" portion of your string.

\s+}

And finally, match one or more whitespace characters so that the
previous non-greedy pattern will match correctly.  The modifier is
redundant so it could simply be:

\s}



John

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




Re: Removing a Pattern using a Regular Expression

2018-06-14 Thread John W. Krahn
On Wed, 2018-06-13 at 21:21 -0500, Martin McCormick wrote:
> I wrote a small perl program to more quickly read all the
> subjects in an email list.  One of the things the script does is
> to remove the mailing list name which repeats for every message
> and consists of a [, some English text and finally a ].
> 
>   I was able to write a RE that identifies that text and
> cause the script to save that string in a variable called
> $remove.  That part works and looks like:
> 
> foreach my $field (@fields) {#Assemble the new subject.
> if($field =~ m/\[(.*?)\]/) 

if you want to remove this string then why not just remove it here:

if ( $field =~ s/\[(.*?)\]// )


> { #$field is the blocked field.
> $remove = $field;
> } #field is the blocked field.
> else
> { #$field is not the blocked string.
> $newest = $newest . $field;
> } #$field is not the blocked string.
> }#Assemble the new subject.
> 
> if ( $newest eq $previous ) {#Skip this iteration.
> $newest = "";
> next;
> }#Skip this iteration.
> else
> { #they are different.
> 
>   This is where things don't quite work yet.  At this
> point, I have $remove which contains that bracketted list name
> such as
> 
> [BLIND-HAMS] or any number of other names enclosed in brackets.
> So, the next thing I do is to attempt to remove just that part of
> the subject line, keeping everything else that was there.
> 
>    $subject =~ s/'$remove'//;

After string interpolation you have:

$subject =~  s/'[BLIND-HAMS]'//;

Which is a string of three characters consisting of the "'" character
followed by a character class followed by the "'" character.

The character class says to match one character that is either 'A' or
'B' or 'D' or 'E' or 'F' or 'G' or 'H' or 'I' or 'L' or 'M' or 'N' or
'S'.

You probably need to use quotemeta:

$subject =~  s/'\Q$remove\E'//;



John

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




Re: project euler #8

2018-06-07 Thread John SJ Anderson
Hi Shlomi. 

A reminder that sometimes when somebody does something, you can just ignore the 
email and _not_ reply to it. 

Thanks,
John the list mom. 

-- 
John Anderson // j...@genehack.org 

> On Jun 7, 2018, at 08:58, Shlomi Fish  wrote:
> 
> Hi,
> 
> why did you resurrect a one year old's thread for which there were proper
> replies here -
> https://www.nntp.perl.org/group/perl.beginners/2017/05/msg126502.html and here
> - https://github.com/shlomif/project-euler/tree/master/project-euler/8 . just
> let sleeping dogs rest. Some comments on your code:
> 
> On Wed, 06 Jun 2018 19:23:11 -0700
> "John W. Krahn"  wrote:
> 
>> On Tue, 2017-05-16 at 14:01 +0800, derr...@thecopes.me wrote:
>> 
>> 
>> I am working on problem #8 of the euler project. see below.
>>> 
>>> 
>>> 
>>> The four adjacent digits in the 1000-digit number that have the
>>> greatest product are 9 × 9 × 8 × 9 = 5832.
>>> 
>>> 73167176531330624919225119674426574742355349194934
>>> 96983520312774506326239578318016984801869478851843
>>> 85861560789112949495459501737958331952853208805511
>>> 12540698747158523863050715693290963295227443043557
>>> 66896648950445244523161731856403098711121722383113
>>> 6222989342338030813533627661428280686645238749
>>> 30358907296290491560440772390713810515859307960866
>>> 70172427121883998797908792274921901699720888093776
>>> 65727333001053367881220235421809751254540594752243
>>> 52584907711670556013604839586446706324415722155397
>>> 53697817977846174064955149290862569321978468622482
>>> 83972241375657056057490261407972968652414535100474
>>> 82166370484403199890008895243450658541227588666881
>>> 16427171479924442928230863465674813919123162824586
>>> 17866458359124566529476545682848912883142607690042
>>> 2421902267105562632109370544217506941658960408
>>> 07198403850962455444362981230987879927244284909188
>>> 84580156166097919133875499200524063689912560717606
>>> 05886116467109405077541002256983155200055935729725
>>> 71636269561882670428252483600823257530420752963450
>>> 
>>> Find the thirteen adjacent digits in the 1000-digit number that have
>>> the greatest product. What is the value of this product?  
>> 
>> 
>> 
>> #!/usr/bin/perl
>> use warnings;
>> use strict;
>> 
>> ( my $x = < 
> Please use a more meaninful var name.
> 
>> 73167176531330624919225119674426574742355349194934
>> 96983520312774506326239578318016984801869478851843
>> 85861560789112949495459501737958331952853208805511
>> 12540698747158523863050715693290963295227443043557
>> 66896648950445244523161731856403098711121722383113
>> 6222989342338030813533627661428280686645238749
>> 30358907296290491560440772390713810515859307960866
>> 70172427121883998797908792274921901699720888093776
>> 65727333001053367881220235421809751254540594752243
>> 52584907711670556013604839586446706324415722155397
>> 53697817977846174064955149290862569321978468622482
>> 83972241375657056057490261407972968652414535100474
>> 82166370484403199890008895243450658541227588666881
>> 16427171479924442928230863465674813919123162824586
>> 17866458359124566529476545682848912883142607690042
>> 2421902267105562632109370544217506941658960408
>> 07198403850962455444362981230987879927244284909188
>> 84580156166097919133875499200524063689912560717606
>> 05886116467109405077541002256983155200055935729725
>> 71636269561882670428252483600823257530420752963450
>> STUFF
>> 
>> my @z = ( 0 ) x 5;
> 
> why 5?
>> while ( $x =~ / ( . ) (?= ( . ) ( . ) ( . ) ( . ) ( . ) ( . ) ( . ) ( .
>> ) ( . ) ( . ) ( . ) ( . ) ) /xg ) {
>> my $y = $1 * $2 * $3 * $4 * $5 * $6 * $7 * $8 * $9 * $10 * $11 *
>> $12 * $13;
>> @z = ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $y )
>> if $z[ -1 ] < $y;
>> }
>> 
> 
> this code is full of duplicate functionality and you are abusing the capture
> vars as arrays.
> 
> The ?= trick is nice, though.
> 
>> print "@z\n";
>> 
>> 
>> __END__
>> 
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 

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




Re: project euler #8

2018-06-06 Thread John W. Krahn
On Tue, 2017-05-16 at 14:01 +0800, derr...@thecopes.me wrote:


I am working on problem #8 of the euler project. see below.
> 
> 
> 
> The four adjacent digits in the 1000-digit number that have the
> greatest product are 9 × 9 × 8 × 9 = 5832.
> 
> 73167176531330624919225119674426574742355349194934
> 96983520312774506326239578318016984801869478851843
> 85861560789112949495459501737958331952853208805511
> 12540698747158523863050715693290963295227443043557
> 66896648950445244523161731856403098711121722383113
> 6222989342338030813533627661428280686645238749
> 30358907296290491560440772390713810515859307960866
> 70172427121883998797908792274921901699720888093776
> 65727333001053367881220235421809751254540594752243
> 52584907711670556013604839586446706324415722155397
> 53697817977846174064955149290862569321978468622482
> 83972241375657056057490261407972968652414535100474
> 82166370484403199890008895243450658541227588666881
> 16427171479924442928230863465674813919123162824586
> 17866458359124566529476545682848912883142607690042
> 2421902267105562632109370544217506941658960408
> 07198403850962455444362981230987879927244284909188
> 84580156166097919133875499200524063689912560717606
> 05886116467109405077541002256983155200055935729725
> 71636269561882670428252483600823257530420752963450
> 
> Find the thirteen adjacent digits in the 1000-digit number that have
> the greatest product. What is the value of this product?



#!/usr/bin/perl
use warnings;
use strict;

( my $x = 

Re: CPAN will shutdown

2018-05-22 Thread John SJ Anderson

> On 22May2018, at 20:41, Practical Perl <practicalp...@gmail.com> wrote:
> 
> search.cpan.org is shutting down
> For details read Perl NOC. After June 25th this page will redirect to 
> MetaCPAN.org 

1) Please don’t cross-post between this list and other lists. It’s rude. 

2) It’s not “shutting down” so much as it is being replaced by the existing 
MetaCPAN search site. This is positive news about the future of Perl: an older, 
less capable tool has been replaced, and is being shutdown and transitioned to 
its replacement in an orderly fashion. This is what a healthy programming 
language community looks like. 

chrs,
john.

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




Re: regex with HEX ascii chars

2018-04-13 Thread John W. Krahn
On Thu, 2018-04-12 at 17:26 +0100, Gary Stainburn wrote:
> I have a text file (created by  pdftotext) that I've imported into my
> script.
> 
> It contains ASCII characters 251 for crosses and 252 for ticks.

ASCII defines 128 characters so those characters are not ASCII.


John

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




Re: [^/]* Is Not Working

2018-03-17 Thread John SJ Anderson


> But this one in its place does not work:
> if ($link =~ m/\/([^/]*)$/) { # Oddly this does not work

You still need to escape the `/` inside the character class.

This works in my testing: `m/\/([^\/]*)$/`.

IMO this is a case where an alternative delimiter for `m//` — such as the `#` 
in your working example — is a better approach. 



chrs,
john.

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




Re: compute depth of word in line

2018-03-10 Thread John W. Krahn
On Sat, 2018-03-10 at 00:14 +0100, hw wrote:
> 
> Not really, the words I get from the ReadLine functions are not
> organized in an array.
> 
> I´ve come up with this function to compute the "depth" of a word:
> 
> 
> sub get_depth {
>   my $string = shift;
> 
>   $string =~ s/\s/ /g;
>   $string =~ s/\s+/ /g;
>   $string =~ s/^\s*//;
>   $string =~ s/\s*$//;
> 
>   my $depth = 0;
>   my $position = 0;
>   while((my $start = index($string, ' ', $position)) != -1) {
> $position = $start + 1;
> $depth++;
>   }
> 
>   return $depth;
> }

That function could be simplified to:

sub get_depth {
my $string = shift;

$string =~ s/^\s+//;
$string =~ s/\s+$//;
my $depth = $string =~ s/\s+/ /g;

return $depth;
}


John

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




Re: Find::Perl find not returning

2017-12-13 Thread John W. Krahn
On Wed, 2017-12-13 at 11:28 +, Mike Martin wrote:
> Hi
> I have the following code
> 
> use strict;
> use File::Find;
> my @vsbe;
> my $top='P:\PT-6\PT-60\PT-603\Shared\Data Store\Files Dump Folder';
> my $max_depth=9;
> my $cnt1=0;
> 
> find({wanted=>\,preprocess=>\},$top) ;
> 
> sub wanted1 {
> 
> if ($cnt1 <=1000){
> my $file = $File::Find::name;
> if (grep {/vsb$/} $file){

grep works on lists so you don't need grep there:

if ( $file =~ /vsb$/ ) {


> push @vsbe, $file if $cnt1 <=1000 ;
> $cnt1++;
> print $cnt1,"\n" ;
> }
> else {return}
> 
> return if $cnt1 >=1000
> }
> return
> 
> }
> sub preprocess1 {
> my $depth = $File::Find::dir =~ tr[\\][];
> #print 'depth',"\t",$depth,"\t",$File::Find::dir,"\n";
> return  @_ if $depth < $max_depth;
> return grep { not -d } @_ if $depth == $max_depth;
> return;
> }
> 
> Unfortunately the wanted function never returns, it (at best) stays
> stuck
> on print the last value of $cnt1 (1000)
> 
> Any ideas what is happening here

The wanted function does return, but it does not return to your
process.  It is called inside a loop in the File::Find code and when it
returns the loop continues until all the files are found.


John

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




Re: Using Pack and Unpack

2017-12-06 Thread John W. Krahn
On Wed, 2017-12-06 at 21:53 -0600, Martin McCormick wrote:
> A perl program needs to send binary data to an external device
> such that 0xff looks like 


$ perl -le'my $x = sprintf q/%b/, 0xff; print $x'




>   I have a line in the program as follows:
> 
> my $txstart = pack("h*","fefe5a95");
> 
> Are those 4 bytes usable as the binary data 
> 
> fe fe 5a 95?
> 
>   Is there a good way when running perl -d to view the
> contents of the string to make sure it is what it should be?


use Data::Dumper;
$Data::Dumper::Useqq = 1;

my $txstart = pack 'h*', 'fefe5a95';

print Dumper $txstart;



John

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




Re: Use of uninitialized value for perl

2017-11-05 Thread John W. Krahn
On Sun, 2017-11-05 at 00:43 +, Dong Liu wrote:
> I try used perl script to get characters from data:
> 
> #!/usr/bin/perl -w
> use v5.14;
> while (){
> chomp;
> my $line = '';
> $line = (split //,@_)[5];

At no point in your script do you or perl assign a value to the array
@_ so the array will have 0 elements, and an array in scalar context
will return the number of elements in the array, so that statement is
the same as:

$line = ( split //, '0' )[ 5 ];

Which will create the list ( '0' ).  So every element other than zero
(the first element) will be undef.  So that statement is the same as:

$line = undef;


> print "it is $line.\n";
> }
> 
> __DATA__
> Danio rerio strain Tuebingen chromosome 1 GRCz11 Primary Assembly
> Danio rerio strain Tuebingen chromosome 2 GRCz11 Primary Assembly
> 
> the results is :
> Use of uninitialized value $line in concatenation (.) or string at
> foundins.pl line 9,  line 1.
> it is .
> Use of uninitialized value $line in concatenation (.) or string at
> foundins.pl line 9,  line 2.
> it is .
> 
> the aim for the work is to get the number for each line such as:
> 1 for first line and
> 2 for second lin

When using a while ( <> ) loop the current line number can be found in
the $. variable:

$ perldoc -v $.




John

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




Re: Perl invocations

2017-10-29 Thread John W. Krahn
On Sun, 2017-07-02 at 11:16 -0400, Shawn H Corey wrote:
> On Sun, 2 Jul 2017 14:29:25 +0200
> Eric de Hont  wrote:
> 
> > What it boils down to: use warnings as well as -w works, but -w is 
> > considered old fashioned.
> 
> The problem with -w is that it can't be turned off.

$ perl -le'
use warnings;
my $x;
{   no warnings;
print $x;
}
print $x;
'

Use of uninitialized value $x in print at -e line 7.

$ perl -wle'
my $x;
{   local $^W = 0;
print $x;
}
print $x;
'

Use of uninitialized value $x in print at -e line 6.

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




Re: perl -e 'my $i = 0; $i = defined($i) ? (!!$i) : 0; print "i: $i\n";'

2017-07-01 Thread John Harris
What are these emails really about?

On Jul 1, 2017 2:42 PM, "Chas. Owens"  wrote:

>
>
> On Sat, Jul 1, 2017, 12:44 Shlomi Fish  wrote:
>
>> Hi Shawn!
>>
>> On Sat, 1 Jul 2017 11:32:30 -0400
>> Shawn H Corey  wrote:
>>
>> > !!$i which is !(!(0)) which is !(1) which is 0
>> >
>>
>> I suspect !1 returns an empty string in scalar context.
>>
>
> !1 returns PL_sv_no (an internal scalar variable). It is a dualvar that
> contains the empty string, the int 0 and the double 0.0. depending on the
> context the value is used in, it will be one of those values.
>
> Many people think it is an empty string because the print function forces
> string context.
>
>>


Re: dangerous perl (Re: is this reasonably save?)

2017-05-26 Thread John SJ Anderson
Take. It. Off. The. List. 

I've asked nicely. Now I'm telling you. Take it off the list. 

John 
List moderator. 

-- 
John Anderson // j...@genehack.org 

> On May 26, 2017, at 19:09, Kent Fredric <kentfred...@gmail.com> wrote:
> 
>> On 27 May 2017 at 00:01, lee <l...@yagibdah.de> wrote:
>> You have a variable.
> 
> Even in C, you'd have a variable as well.  It would be a variable that
> contains a *pointer* to a data structure.
> 
> The variable may be *typed*, but *types* don't impact anything about
> the data storage in memory.
> 
> *types* in C are mechanisms that direct the compiler how to handle the
> memory the variable deals with.
> 
>> 
>>> Because as far as I'm concerned, I have both data structures and
>>> references in play.
>> 
>> As far as I'm concerned, you seem to have assigned a reference to the
>> variable, and what it might be referring to is difficult to figure out.
>> 
>> Some sort of construction that resembles a hash seems involved.  As far
>> as I'm concerned, hashes are key/value pairs.  I don't consider them as
>> data structures any more than, for example, an integer.  They are a
>> given element of the language which can be useful when you have a bunch
>> of values you want to refer to by names.
>> 
>> So I'm not sure what you have there.
> 
> It is a variable that references a hash, whos values in turn reference hashes.
> 
> Accessing the value "total" is as simple as:
> 
> $var->{memory}->{total}
> 
> This is not entirely unlike C where you look up a struct member of a
> struct which has a nested struct within.
> 
> var.memory.total
> 
> ( I think )
> 
> The real distinctions being that structs are compile-time semantics
> that boil expressions down to memory offsets in the block, whereas the
> Perl equivalent is not quite so bounded, and the memory addresses are
> computed at runtime.
> 
> They're rather different at the machine level in how the actual data
> is laid out, but from a users perspective, multi-level structs and
> multi-level hash references are equally convenient.
> 
> How you define a "Data structure" and how the C version being "a data
> structure" and the Perl version "not a data structure" is a little
> confusing to me, because to me, a data structure is supposed to be an
> abstract idea for laying out your data in a way convenient to coding,
> and the implementation details of how that data structure works under
> the hood are not too important, as long as the user visible promises
> remain the same.
> 
>>> References are not a low level mechanic that only the Perl VM needs to
>>> care about.
>>> 
>>> References are a mechansim to allow data structures to be passed
>>> *without copying*
>> 
>> Yes, that works nicely in C.
>> 
>>> my $x = 5;
>>> my $y = $x;   # x is a copy of y
>>> 
>>> However, if I do:
>>> 
>>> my $x = 5;
>>> $y  = \$x
>>> 
>>> 
>>> Y is now a reference to X
>> 
>> $y = 5;
>> 
>> Now $y is 5.  That is what's evil.
> 
> All you're saying here is there's no strong typing.
> 
> That's pretty much just par for dynamic languages.
> 
> That is, it doens't mean there are no data structures, it means there
> are no compile time constraints that prevent storing bits classes as
> one type of data in a container that previously held another.
> 
>> 
>>> If I now do:
>>> 
>>>  ${$y}  = 10
>>> 
>>> X changes.
>> 
>> Yes, and that's a horrible notation.
> 
> That's a matter of preference really. Pointer notation in C is worse
> because it uses the same syntax for multiple different purposes.
> 
>> 
>>> Its a useful tool, that programmers have uses for.
>>> 
>>> If you think they're evil, then you're probably thinking too much in C.
>> 
>> They are evil in perl because the notation is unwieldy, especially when
>> you need to de-reference a reference.  That they are indistinguishable
>> from non-references doesn't help.
> 
> They're not entirely indistinguishable, the Perl VM can tell, that's
> what the "ref" built-in is for.
> 
> They're not *visually* indistinguishable, but C is no different if the
> scope where the variable was defined is not currently in your screen.
> 
>   fun( foo, bar );
> 
> ^ Tell me what foo and bar are, _and_ tell me what types fun() takes
> in C from that statement alone.
> 
> 
> 
>> 
>> Perhaps I do think too much in C --- at least such

Re: dangerous perl (Re: is this reasonably save?)

2017-05-25 Thread John SJ Anderson
Folks, this has passed the event horizon of what’s appropriate for the 
Beginners list a good while back. If y’all wanna continue this conversation, 
please kindly do so outside the bounds of this mailing list. 

thanks,
john,
the resident list mom. 



> On 25May2017, at 10:52, Uri Guttman <u...@stemsystems.com> wrote:
> 
> On 05/25/2017 01:33 PM, lee wrote:
>> Uri Guttman <u...@stemsystems.com> writes:
>> 
>>> >> this private IMO>
>>> 
>>> 
>>> On 05/24/2017 08:20 PM, lee wrote:
>>>> Uri Guttman <u...@stemsystems.com> writes:
>>>> 
>>>> 
>>>> you can get an array of hashes, where each hash is one row.
>>>> 
>>>> learning dereferencing will do you much more good than using eval
>>>> EXPR. references are key to deeper data structures in perl and are
>>>> used all over the place. it is a core skill you should focus on as it
>>>> will solve your current problem and many to come.
>>>> Since when are there any data structures in perl?  Variables are even
>>>> virtually typeless.
>>> since when is a variable a data structure? :)
>> It is when it has a type.
>> 
>> 
>> typedef struct {
>>   unsigned long MemTotal;
>>   unsigned long MemFree;
>>   unsigned long Buffers;
>> } meminfo;
>> 
>> 
>> meminfo test;
>> meminfo foo[20];
>> 
>> int bar;
>> int baz[20];
>> 
>> 
>> The difference between 'int' and 'meminfo' is that 'int' is pre-defined
>> while 'meminfo' is defined by the programmer.  Both are data types of
>> which you can declare variables.  The variables you declare are
>> instances of the data structures that correspond to the type of the
>> variable.  For practical purposes, the variables 'test', 'foo[]', 'bar',
>> 'baz[]' are all data structures.
> 
> that is c, not perl. why do you keep bringing up c? languages are different 
> for various reasons. perl doesn't do strong typing so if you want to use and 
> learn perl, you can't say it should be like c. that isn't the way to learn 
> anything.
> 
> and those are trivial data structures in c. perl has hashes for simple data 
> structures. and YES, hashes are data structures, no matter what you say in 
> opposition.
>> 
>> Perl doesn't have data structures, so variables in perl are not data
>> structures.  That is unfortunate.
> wrong. i won't argue this again. you haven't the experience in programming to 
> defend that point.
>>> the key is again references which still seems to confuse you. a scalar
>>> can hold only one thing.
>> A scalar can hold many different things, like an integer, a float, a
>> double, a string, and at least three different types of references.  You
>> never really know what it happens to be.
> you code so you know what it can be.
>> Why would I need a reference to put a hash into an array or into a hash? 
>> Perl may need that internally, which isn't relevant to the programmer in the 
>> first place. 
> 
> huh??? that is how you build complex data structures in perl. you haven't 
> learned that yet. please learn references before you rant about them.
>>>>> if you need help with references, this list is the place to ask.
>>>> Why is it so awfully difficult to dereference a reference to an array
>>>> that contains references to arrays, and why does DBI, for example,
>>>> provide a function that returns such a reference?  It involves holding
>>>> the data in memory, so what is the supposed advantage of using cascaded
>>>> references?
>>> how will you organize the data without references?
>> I put it into a database.
> and when you get it out of the database what do you do with it? what about 
> complex cross connected tables? how do you manage that in memory. you haven't 
> dealt with complex data yet if you think that is a solution.
>> 
>>> they are the branches in the tree of data. returning a single
>>> reference is much more efficient than returning the whole array or
>>> hash. that would involve copying the array/hash onto the stack and
>>> then copying it again to a variable in the caller. that is very slow.
>> Programming is even slower when you have to mess around with nested
>> references, trying to figure out how to de-reference them correctly.  I
>> did spent hours with that ...
> hours? i spent years. decades even. experience helps. :)
>>> you say cascaded references. i call that a data tree.
>> Arrays do not look like trees to me, they look like rows.
> arrays of arrays

Re: WWW::Mechanize requires wget

2017-04-04 Thread John SJ Anderson

> On 4Apr2017, at 11:13, SSC_perl <p...@surfshopcart.com> wrote:
> 
>> On Apr 4, 2017, at 10:59 AM, John SJ Anderson <j...@genehack.org> wrote:
>> 
>> I’m not sure what was behind the resolution of your problem, but I can 
>> assure you I’m typing this on a Macintosh without wget installed, and 
>> WWW::Mechanize works just fine.
> 
>   Weird.  Which OS are you running?  I’m on 10.11.6.
> 
>   Perhaps something else got installed along with wget, but whatever it 
> was, that install solved my problem.

It’s whatever is current, but I’ve used WWW::Mechanize on MacOS for the last 
*mumble* versions, never having wget installed, without any problem. 

I also just checked, and the string ‘wget’ does not appear in the 
WWW::Mechanize dist at all. ¯\_(ツ)_/¯ 


j.

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




Re: WWW::Mechanize requires wget

2017-04-04 Thread John SJ Anderson

> On 4Apr2017, at 10:43, SSC_perl <p...@surfshopcart.com> wrote:
> 
>   This is a heads up for anyone wanting to use WWW::Mechanize on OS X.  
[snip]

Apple ships ‘curl’ instead of ‘wget’. Always has; not sure why.

‘wget’ is *NOT* required for WWW::Mechanize on MacOS, however. I’m not sure 
what was behind the resolution of your problem, but I can assure you I’m typing 
this on a Macintosh without wget installed, and WWW::Mechanize works just fine.

chrs,
john.

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




Re: search and replace

2016-06-29 Thread John SJ Anderson

> On Jun 29, 2016, at 09:20, Uri Guttman <u...@stemsystems.com> wrote:
> 
> since you are correct about modules being already there, why do you write 
> your own versions of 
> slurp_file and write_file? the module File::Slurp has those functions which 
> are stable, fast and debugged.

Please don’t use File::Slurp. See 
http://blogs.perl.org/users/leon_timmermans/2015/08/fileslurp-is-broken-and-wrong.html
 for some reasons why. 

File::Slurper or Path::Tiny are both good alternatives; Path::Tiny in 
particular has a very convenient API and makes working with files, directories, 
and paths in a cross-platform way super easy. 

thanks,
john.


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




Re: how to install WWW::Salesforce::Simple on a Mac? cpanm refuses to install Crypt::SSLeay

2016-04-15 Thread John SJ Anderson
>  Apparently the Crypt::SSLeay module won't install for my protection
> (HeartBleed?), but it is still a required prerequisite for
> WWW::Salesforce.

Apple stopped distributing the OpenSSH headers recently. Those are required to 
build Crypt::SSLeay. 

You can get the source for OpenSSH and install it to /usr/local (it’s the 
standard './configure && make && sudo make install' dance, and it will end up 
under /usr/local. Once you’ve done that, Crypt::SSLeay will install without 
issue.

I haven’t looked at all, but I imagine the Crypt::SSLeay dependency is because 
the Salesforce module needs to talk HTTPS, which needs Crypt::SSLeay. 

chrs,
john.


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




Re: Storing Output file.

2016-02-01 Thread John SJ Anderson

> On Feb 1, 2016, at 05:34, Thomas J Hughes <thugh...@gmail.com> wrote:
[ snip ]

This is *completely* inappropriate for the perl-beginners list, or as an 
off-list reply to a message received from the list.

If you don't want to get email related to people trying to learn the Perl 
language, I suggest you make use of this unsubscribe link immediately. 

> To unsubscribe, e-mail: beginners-unsubscr...@perl.org

Failing that, if you intend to remain on this list, you need to moderate both 
your language and your tone. Any further instances of this type of behavior 
will be grounds for your removal from this mailing list. 

john,
perl-beginners list mom. 




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




Re: converting Genbank format in gff format

2015-08-18 Thread John SJ Anderson
On Mon, Aug 17, 2015 at 3:58 PM, Uri Guttman u...@stemsystems.com wrote:

 On 08/17/2015 03:57 AM, atteyet-alla.yas...@ukb.uni-bonn.de wrote:

 hi all,

 is there a possibilty to convert Genbank format in gff format using perl?
 I installed perl5 in my linux.


Atteyet-Alla -- there's a 'genbank2gff' script in the Bioperl dist, perhaps
that at least gives you some hints on where to start? Code is here:

https://metacpan.org/source/CJFIELDS/BioPerl-1.6.924/scripts/Bio-DB-GFF/bp_genbank2gff.pl


You'll need to install the Bioperl module.

 the answer is yes, perl can convert anything into anything. that is true
 for most if not all languages. do you have more questions?


Wow, Uri, do you suppose Perl could convert your smug condescending answer
into something useful? Geez.


john.

-- 
*John Anderson* • j...@genehack.org • *@genehack* • www.genehack.org
Suck it up, buttercup.


Re: reading from socket

2015-08-11 Thread John SJ Anderson
On Tue, Aug 11, 2015 at 6:58 AM, John SJ Anderson j...@genehack.org wrote:

 On Tue, Aug 11, 2015 at 5:24 AM, Chris Knipe sav...@savage.za.org wrote:



 my $numBytesToRead = 512;

 my $buffer;

 while ($bytesRead = read($TCPSocket, $buffer, $numBytesToRead)) {

   if ($buffer =~ m/\r\n\.\r\n$/) {

 print $buffer;

 last;

   }

 }



 I’m obviously doing this wrong :(  Can anyone perhaps show me the light?


 Don't you need to put $bytesRead into $buffer at some point?


Wow, and this is why we don't review the code before the coffee... 8^/

j.


-- 
*John Anderson* • j...@genehack.org • *@genehack* • www.genehack.org
Suck it up, buttercup.


Re: reading from socket

2015-08-11 Thread John SJ Anderson
On Tue, Aug 11, 2015 at 5:24 AM, Chris Knipe sav...@savage.za.org wrote:



 my $numBytesToRead = 512;

 my $buffer;

 while ($bytesRead = read($TCPSocket, $buffer, $numBytesToRead)) {

   if ($buffer =~ m/\r\n\.\r\n$/) {

 print $buffer;

 last;

   }

 }



 I’m obviously doing this wrong :(  Can anyone perhaps show me the light?


Don't you need to put $bytesRead into $buffer at some point?

j.


-- 
*John Anderson* • j...@genehack.org • *@genehack* • www.genehack.org
Suck it up, buttercup.


Re: Compilation fails with Padre (a Perl IDE) on RHEL-based distros (CentOS, etc.)

2015-05-26 Thread John SJ Anderson
On Tue, May 26, 2015 at 8:53 AM, someone called someonecal...@safe-mail.net
 wrote:


 ATTENTION: It apperars 'g++' is not a working compiler, please make
 sure all necessary packages are installed.

  that is your problem. For whatever reason, g++ (the GNU C++ compiler)
is not installed properly, or is not being found in your path, or
_something_.

Try seeing what running 'g++' tells you.

j.


Re: Perlists groupware service

2015-04-15 Thread John SJ Anderson
I don't see any indication that web site is at all affiliated with this
mailing list. What leads you to think we can answer your question?

On Wed, Apr 15, 2015 at 2:59 AM, Masayoshi Fujimoto 
m.fujim...@rocketmail.com wrote:

 Hi.
 How should I delete my email address from the following website?

 https://groups.perlists.pm/sympa/home

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





Re: Doubt

2015-03-29 Thread John SJ Anderson
Please show exactly what commands you ran and what output you got. In what
you're reporting, there's a typo, and it's not clear if that's a copy-paste
error or a problem in the actual command.

chrs,
john.


On Mon, Mar 30, 2015 at 1:16 AM, Frank Vino vinofra...@gmail.com wrote:

 When i try to install Alias.pm file from environment i was getting an
 error message as cannot locate alimas.pm file, then i checked in cpan it
 was showing, In case how to fix this and update the Alias.pm file.

 Frank



Re: Why doesn't this script error?

2015-03-14 Thread John SJ Anderson
Try again with 'use strict' and 'use warnings' turned on.

On Sat, Mar 14, 2015 at 1:40 PM, Sherman Willden sherman.will...@gmail.com
wrote:

 I am new to Eclipse and Epic so I wrote the below script which I thought
 would error but it runs. Why?

 #!/usr/bin/perl

 use 5.18.2;

 print Hello World \n;

 print this

 1

 Thank you;

 Sherman



Re: Re[2]: Need something like macro

2015-03-09 Thread John SJ Anderson
On Mon, Mar 9, 2015 at 12:48 PM, Артём Варнайский varnays...@mail.ru
wrote:

Execution time of inline variant approximately 17.6ms, subroutine solution
 slower about 26%. My script is captcha generator. Random sign used very
 often during execution. I think 26% is a lot enough in this case.


And the average latency of the network connection you're serving this
captcha over is... ?

j.


Re: Looping regexes against a list

2015-01-19 Thread John Mason
On Mon, Jan 19, 2015 at 11:36 AM, Shawn H Corey shawnhco...@gmail.com
wrote:

 On Mon, 19 Jan 2015 11:18:01 -0500
 bill pemberton wape...@gmail.com wrote:

  I fail to see why a regex can only be changed by a programmer.  please
  expand upon this.

 You shouldn't blindly trust input from a user, there should be
checking/limits on what input is allowed .

John


Re: How does opendir/readdir process files

2015-01-14 Thread John SJ Anderson
On Tue, Jan 13, 2015 at 7:40 PM, Brandon McCaig bamcc...@gmail.com wrote:
 Harry:

 (Expect typographical errors in such a long post...)

 tl;dr? RTFM.

Please don't tell people that. It's not helpful, it's not a helpful
attitude, and it's really not welcome here.

The rest of your post may be excellent, but I couldn't say, as I
stopped reading immediately after reading that.

john.

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




Re: How does opendir/readdir process files

2015-01-08 Thread John SJ Anderson
On Thu, Jan 8, 2015 at 5:52 PM, Harry Putnam rea...@newsguy.com wrote:
 Opening a directory and readdir with a grep in there to find specific
 filenames, how does that process collect the files?

See http://www.perlmonks.org/?node_id=533744

tl;dr: it depends on your OS.


 I mean will the generated @ar of files be oldest first or someother
 reliable order?

and tl;dr: no, most likely not.

j.

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




Re: Unable to install Net::IP

2014-12-02 Thread John SJ Anderson
Whenever you have a module installation fail, your first step should
be to ask: is it failing for other people?

Results of CPAN Testers (which is basically a distributed testing
network) are available on the dist's MetaCPAN page. For Net::IP,
that's here: https://metacpan.org/pod/Net::IP

(Spoiler: it has a tiny number of fails but a _huge_ number of passes.
It works for almost everybody.)

Based on those results, the good news is, it seems like the module
itself (probably) isn't broken, but instead, there's something about
your machine that isn't working for it.

Based on the output you have shown, my first question would be: do you
actually have make installed?

If you do have make installed, the next step would be to download the
dist tarball yourself (there's a download link on that MetaCPAN page),
expand it, cd into it, and run 'perl Makefile.PL  make', and see
what the output of that is. I suspect make is giving an error that's
getting eaten by the cpan client, for whatever reason.

(Aside: doing the make as root is not the best idea. (Least privilege)++)

chrs,
john.


On Tue, Dec 2, 2014 at 2:17 PM,  z...@psoftulsa.com wrote:
 Hi,

 I'm unable to find information on this issue.  Whenever I try to install
 Net::IP (to do a simple DHCP configuration file that will make IP address
 reservations DNS files that will do forward and reverse lookups) it gives me
 the following results:

 root@SERVER:~# cpan -i Net::IP
 Reading '/root/.cpan/Metadata'
   Database was generated on Tue, 02 Dec 2014 10:53:28 GMT
 Running install for module 'Net::IP'
 Running make for M/MA/MANU/Net-IP-1.26.tar.gz
 Checksum for /root/.cpan/sources/authors/id/M/MA/MANU/Net-IP-1.26.tar.gz ok

   CPAN.pm: Building M/MA/MANU/Net-IP-1.26.tar.gz

 Checking if your kit is complete...
 Looks good
 Writing Makefile for Net::IP
 Writing MYMETA.yml and MYMETA.json
   MANU/Net-IP-1.26.tar.gz
   make -- NOT OK
 Running make test
   Can't test without successful make
 Running make install
   Make had returned bad status, install seems impossible


 I'm running Ubuntu server:
 root@SERVER:~# cat /etc/os-release
 NAME=Ubuntu
 VERSION=14.04.1 LTS, Trusty Tahr
 ID=ubuntu
 ID_LIKE=debian
 PRETTY_NAME=Ubuntu 14.04.1 LTS
 VERSION_ID=14.04
 HOME_URL=http://www.ubuntu.com/;
 SUPPORT_URL=http://help.ubuntu.com/;
 BUG_REPORT_URL=http://bugs.launchpad.net/ubuntu/;

 Perl 5.18:
 root@SERVER:~# perl -v

 This is perl 5, version 18, subversion 2 (v5.18.2) built for
 x86_64-linux-gnu-thread-multi
 (with 41 registered patches, see perl -V for more detail)

 Copyright 1987-2013, Larry Wall

 Perl may be copied only under the terms of either the Artistic License or
 the
 GNU General Public License, which may be found in the Perl 5 source kit.

 Complete documentation for Perl, including FAQ lists, should be found on
 this system using man perl or perldoc perl.  If you have access to the
 Internet, point your browser at http://www.perl.org/, the Perl Home Page.

 I'm running always as root for everything.  It makes my server management
 much easier by saving me from typing sudo for everything I do.

 Any help would be greatly appreciated!

 Zac
 Power Switch of Tulsa, LLC

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

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




Re: At wits end CG::unescape

2014-11-25 Thread John SJ Anderson
What version of CGI::Application do you have installed?

Assuming the most recent one
(https://metacpan.org/source/MARKSTOS/CGI-Application-4.50/lib/CGI/Application.pm),
line 1951 is:

if ( $p{path_info}  $self-query-path_info() ) {

$self-query calls the 'query' method, defined at line 493. I'm
guessing code flow goes into the 'else' half of the branch there, and
ends up calling $self-cgiapp_get_query() (on line 503).

That method is defined at line 250, and ultimately returns the result
of calling CGI-new().

I would suggest either putting in some debug print() statements into
that cgiapp_get_query() routine, or using the debugger to stop
execution inside there and looking at what that call from CGI-new()
is actually returning.

chrs,
john.








On Tue, Nov 25, 2014 at 7:56 AM, Patton, Billy N billy.pat...@h3net.com wrote:
 OS : mac 10.10.1 Yosemite
 Perl version : 5.16.0 (perlbrew)
 I have file cp.cgi that is the top level
 It uses CP.pm
 which inherits Base.pm
 which inherits CGI::Application
 CGI::Application Requires CGI.pm
 CGI.pm has a use CGI::Util qw(… unescape …);

 When I try and run cp.cgi I get a timeout.
 The erro log only tells me that I get a timeout
 [Tue Nov 25 09:13:53.677383 2014] [cgi:warn] [pid 461] [client ::1:63053] 
 AH01220: Timeout waiting for output from CGI script 
 /Library/WebServer/Documents/cportal/html/cp.cgi, referer: 
 http://localhost/index.html

 when I try and run it from the command line : perl cp.cgi
 I get
 h1Software error:/h1
 preUndefined subroutine CGI::unescape
  at 
 /Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application.pm
  line 1951.
 /pre
 p
 For help, please send mail to this site's webmaster, giving this error message
 and the time and date of the error.

 /p
 [Tue Nov 25 09:34:59 2014] cp.cgi: Undefined subroutine CGI::unescape
 [Tue Nov 25 09:34:59 2014] cp.cgi:  at 
 /Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application.pm
  line 1951.

 unescape exists in CGI::Util.pm and is exported.

 When I put a Dumper \%INC I get: Making sure that I wasn’t mixing too many 
 version

 'CGI/Application.pm'  = 
 '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application.pm’,
 'CGI/Application/Plugin/Redirect.pm'  = 
 '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/Redirect.pm',
 'CGI/Application/Plugin/TT.pm'  = 
 '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/TT.pm’,
 'CGI/Application/Plugin/ValidateRM.pm'  = 
 '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/ValidateRM.pm’,
 'CGI/Application/Plugin/LogDispatch.pm'  = 
 '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/LogDispatch.pm',
 'CGI/Carp.pm'  = 
 '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Carp.pm’,
 'CGI/Application/Plugin/Config/YAML.pm'  = 
 '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/Config/YAML.pm',
 'CGI/Application/Plugin/DBH.pm'  = 
 '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/DBH.pm’,
 'CGI/Util.pm'  = 
 '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Util.pm’,
 'CGI/Application/Plugin/Forward.pm'  = 
 '/Users/bpatto/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/CGI/Application/Plugin/Forward.pm’,

 unescape does not exist in Application, even though it tells me line 1951
 %INC shows me that it is including the right file.
 Util.pm is exporting
 package CGI::Util;
 use base 'Exporter';
 require 5.008001;
 use strict;
 use if $] = 5.019, 'deprecate';
 our @EXPORT_OK = qw(rearrange rearrange_header make_attributes unescape escape
 expires ebcdic2ascii ascii2ebcdic);

 our $VERSION = '4.09’;

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




Re: CGI::Application::Plugin::TT

2014-11-12 Thread John SJ Anderson
On Wed, Nov 12, 2014 at 4:54 AM, Patton, Billy N billy.pat...@h3net.com wrote:
 I’ve , mistakenly, updated to Mac OS 10.10 Yosemite.
 That completely caused my app to fail in Apache 2.4.
 Looks like it might be a version problem for TT.pm

TT.pm is really 'Template.pm'. Are you sure the Perl you're using has
it installed?

What does 'perl -MTemplate -e 1' tell you if you run it in a terminal?

On my Yosemite install, the system perl (at /usr/bin/perl) does not
have Template.pm installed. I'm not sure whether installed modules
were propagated across the update process (because I don't rely on the
system perl for anything), but I would strongly suspect they were
_not_.

You should consider -- *strongly* consider -- using perlbrew or plenv
to set up a Perl installation that is not under the control of your
operating system vendor. That helps reduce the occurrence of these
issues.

 I’ve tried to install a new TT.pm from cpan but it tells me that it is up to 
 date.
 I’ve tried changing the Template-new to HTML::Template- new with bad 
 results.
 I’ve tried changing use Template to use HTML::Template with bad results
 I’ve tried changing the use Template 2.0; to use Template. results are still 
 it fails;

One more note. This ^^ is what thrashing looks like. Don't start
randomly changing around pieces of your code hoping things will
magically work. Look at the actual error message that you're getting,
from the code that used to work. What does that say?

j.

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




Re: WWW::Mechanize question

2014-11-04 Thread John SJ Anderson
well, are you passing the authentication credentials when you create
the LWP useragent?

IIRC, there's a whole section in the LWP documentation on HTTP basic auth...

(also, you might want to consider taking your questions over to
'beginn...@perl.org' -- not sure there are that many people on this
list anymore.)

j.


On Mon, Nov 3, 2014 at 8:41 AM, Patton, Billy N billy.pat...@h3net.com wrote:
 I’ve gotten everything copied and working from the Chrome, but when I execute 
 my test script I get :
 ok 1 - In sub main::login
 ok 2 -: 49   : Credentials passed ok
 Error GETing http://cportal-test.dfw0.hypercube-llc.com/html/cp.cgi: 
 Authorization Required at 
 /System/Library/Perl/Extras/5.18/LWP/Authen/Basic.pm line 56.

 Here is my .htaccess :
 AuthType Basic
 AuthName HyperCube Customer Portal requires a username and password
 AuthUserFile /var/www/passwords/cportal.passwd
 Require valid-user


 login/password is the same for all versions.


 I know it is something just one step away, can’t get what it is?


 On Nov 3, 2014, at 8:50 AM, John SJ Anderson geneh...@genehack.org wrote:

 Hi Billy -

 Are any of the forms in the templates displayed conditionally? (I.e.,
 are there forms inside IF blocks in the templates.)

 If not -- if all the forms are always shown -- then yes, the numbers
 should be stable.

 My suggestion would be to just add unique identifiers to the forms,
 because then you won't have to worry about it.

 chrs,
 john.


 On Mon, Nov 3, 2014 at 6:41 AM, Patton, Billy N billy.pat...@h3net.com 
 wrote:
 I’ve inherited an app that uses templates.
 Most of the template contain multiple forms and tables within and buttons 
 within that.
 The order of the forms I can get from the template, most are not named 
 forms so I have to get them with form_number(#)

 Question:
Can I depend on the form number being the same each time it is 
 loaded?
Or will it change.


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




Re: Testing my CGI

2014-11-04 Thread John SJ Anderson
Look at the source code for the module. The 'tick' method just uses a
bare 'return' on success, which means it's going to fail an ok() test
regardless of whether or not it works.

You may also want to look at Test::WWW::Mechanize.

chrs,
john.


On Tue, Nov 4, 2014 at 7:30 AM, Patton, Billy N billy.pat...@h3net.com wrote:
 I’m using WWW::Mechanize for testing my CGI.
 I’m having trouble with the $mech-tick

 Here’s my code :
   ok($mech-form_name('cdr_format'),getting form cdr_format);
 print pAllFields =  . $mech-value('pAllFields') . \n;
 219-  ok($mech-tick('pAllFields',1), 'Setting checkbox to native CDR 
 format');
 220-  ok($mech-tick('pAllFields’,0), 'Setting checkbox to native CDR 
 format’);



 Here’s a snippet of the html :
 div id='myForm'
 form name='cdr_format' method='POST' action='file_admin.cgi'
 input type='hidden' name='rm' value='process_cdr_format'
 input type='hidden' name='CGISESSID' 
 value='ec4c3463d5a7f9d04d2924968413f240'
 input type='hidden' name='cdr_format' value='1'
 table border='0' cellpadding='3' cellspacing='0' width='100%'
 tr
 td class='fieldLabel' width='60%'
 We would like the files in native CDR format:
 /td
 td class='field'
 input type='checkbox' class='checkbox' name='pAllFields' value='1'

 /td
 /tr


 When I execute I get this :
 ok 40 - getting form cdr_format
 Use of uninitialized value in concatenation (.) or string at 
 ./test_cportal.pl line 218.
 pAllFields =
 not ok 41 - Setting checkbox to native CDR format
 #   Failed test 'Setting checkbox to native CDR format'
 #   at ./test_cportal.pl line 219.
 not ok 42 - Setting checkbox to native CDR format
 #   Failed test 'Setting checkbox to native CDR format'
 #   at ./test_cportal.pl line 220.

 Here’s the documentation from WWW::Mechanize
 $mech-tick( $name, $value [, $set] )

 Ticks the first checkbox that has both the name and value associated with 
 it on the current form. Dies if there is no named check box for that value. 
 Passing in a false value as the third optional argument will cause the 
 checkbox to be unticked.

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




Re: WWW::Mechanize question

2014-11-03 Thread John SJ Anderson
Hi Billy -

Are any of the forms in the templates displayed conditionally? (I.e.,
are there forms inside IF blocks in the templates.)

If not -- if all the forms are always shown -- then yes, the numbers
should be stable.

My suggestion would be to just add unique identifiers to the forms,
because then you won't have to worry about it.

chrs,
john.


On Mon, Nov 3, 2014 at 6:41 AM, Patton, Billy N billy.pat...@h3net.com wrote:
 I’ve inherited an app that uses templates.
 Most of the template contain multiple forms and tables within and buttons 
 within that.
 The order of the forms I can get from the template, most are not named forms 
 so I have to get them with form_number(#)

 Question:
 Can I depend on the form number being the same each time it is loaded?
 Or will it change.

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




Re: (Possibly a terrible lamer) is `open' format wrong

2014-11-03 Thread John SJ Anderson
On Mon, Nov 3, 2014 at 9:57 AM, Harry Putnam rea...@newsguy.com wrote:
 Ken Slater kenslate...@gmail.com writes:

 that attribution is wrong. Ken didn't say this, Shlomi did.

 It is a good idea to avoid using $_ in production code:

This is an opinion. I think it's ... I hesitate to use the word
controversial, but it's not universally shared, let us say.

 But why is this important?

It's not. (Somebody is going to reply to this and talk about
maintainability, and maybe clarity or something like that, and all of
that may be valid, but for something this trivial, if the code works
and you're happy, don't worry about it.)

chrs,
john.

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




Re: Interactive perl based application who works as per schedule

2014-10-09 Thread John SJ Anderson
On Thu, Oct 9, 2014 at 2:19 AM, Benjamin Fernandis benjo11...@gmail.com wrote:
 Hi,

Hi!

[ snip ]

 Please suggest me for this.

I suggest you don't try to re-invent cron. Cron works. Cron is a known
quantity. You don't need to re-invent cron.

What you need is a way to let other people edit crontab files, with a
better UI. So make a Perl web application. Require authentication --
tie it into your AD or LDAP or whatever -- and provide a UI that
writes out a crontab file based on the users input.

Then have a cronjob that runs every minute that looks at those crontab
files, detects when one has been changed, and reloads it.

chrs,
john.

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




Re: cgi and inheritance

2014-10-06 Thread John SJ Anderson
On Mon, Oct 6, 2014 at 6:33 AM, Patton, Billy billy.pat...@h3net.com wrote:
 I’ve recently inherited some code that hasn’t been touched in over 5 years. 
 It’s all cgi and OOPerl.
 I’ve ran across this one statement that I don’t understand.

 $self-log-error(*)

That's calling the 'error()' method, on the result returned by calling
the 'log()' method, on the current object ($self).

You could also write that as:

my $log = $self-log();
$log-error(*)

(I'm assuming '*' is a stand-in for the actual arguments.)

chrs,
john.

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




Re: Problem with regex

2014-10-06 Thread John Delacour

 On 6 Oct 2014, at 18:57, punit jain contactpunitj...@gmail.com wrote:
 
 Thanks Paul. However I think I couldnot explain the problem.
 
 The issue is when I have mailid's as well as a part of input stream.
 
  Input stream --- $str=ldap:///uid=user1,ou=People,o=test.com 
 http://test.com/,a...@test.com mailto:a...@test.com,t...@test.com 
 mailto:t...@test.com,r...@test.com 
 mailto:r...@test.com,ldap:///uid=user2,ou=People,o=test.com 
 http://test.com/,ldap:///uid=user3,ou=People,o=test.com http://test.com/

Suddenly you've switched to double quotes.  That won't do unless you escape the 
@s.

 expected output
 
 first=uid=user1,ou=People,o=test.com http://test.com/
 first=a...@test.com mailto:a...@test.com
 first=t...@test.com mailto:t...@test.com
 first=r...@test.com mailto:r...@test.com
 first = uid=user2,ou=People,o=test.com http://test.com/
 first = uid=user3,ou=People,o=test.com http://test.com/

Try this.

#!/usr/bin/perl
use strict;
my $str 
='ldap:///uid=user1,ou=People,o=test.com,a...@test.com,t...@test.com,r...@test.com,ldap:///uid=user2,ou=People,o=test.com,ldap:///uid=user3,ou=People,o=test.com';
my @ldap = split 'ldap:///', $str;
my $concat;
for (@ldap){
  for (split /,/) {
if (/\@/) {
  $concat .= \nfirst=$_
} elsif (/uid/) {
  $concat .= \nfirst=$_,
} else {
  $concat .= $_,
}
  }
}
my @printlist = split /\n/, $concat;
for (@printlist) {
  unless (/^$/){ # skip empty lines
s~,$~~g; # remove trailing commas
print $_\n;
  }
}


#JD





Re: [ANN] SurfShop 1.6.1 Shopping Cart Released

2014-09-21 Thread John W. Krahn
;


There is a problem in the following subroutine.  If you know how hashes 
work you should be able to figure it out.


admin.cgi:922:sub new_field {
admin.cgi:923:  my ($names, $cols, $html, $current, $action) = @_;
admin.cgi:924:  my ($cell, $totalcells, $count, $counter, %cell) = ();
admin.cgi:925:  while ($current =~ m|(!--//BEGINCELL 
(.+?)//--.*?!--//ENDCELL .+?//--)|sig) {

admin.cgi:926:  $cell{$2} = $1;
admin.cgi:927:  $totalcells++;
admin.cgi:928:  }
admin.cgi:929:  if ($action eq 'del') {
admin.cgi:930:  foreach my $name (split (/, */ , $names)) {
admin.cgi:931:  delete ($cell{$name});
admin.cgi:932:  $totalcells--;
admin.cgi:933:  }
admin.cgi:934:  }
admin.cgi:935:  else {
admin.cgi:936:  foreach my $name (split (/, */ , $names)) {
admin.cgi:937:  next unless ($name =~ /\w/);
admin.cgi:938:  my $sortstr = substr(00$totalcells, 
-2);  # Pads $totalcells with 2 leading zeroes for non-HTML emails.
admin.cgi:939:  $html =~ s~/tdtd~/td\ntd~g;  # add 
a new line between /tdtd for cleaner HTML
admin.cgi:940:  $cell{$sortstr$name} = 
!--//BEGINCELL $name//--\n$html\n!--//ENDCELL $name//--;
admin.cgi:941:  $cell{$sortstr$name} =~ 
s/\[NAME\]/$name/sig;

admin.cgi:942:  $totalcells++;
admin.cgi:943:  }
admin.cgi:944:  }
admin.cgi:945:  ($counter, $count) = 0;
admin.cgi:946:  $current = \n;  # start off with a new line so HTML 
looks cleaner

admin.cgi:947:  foreach my $cell (sort keys (%cell)) {
admin.cgi:948:  my $cell_name = substr ($cell, 2);  # removes the 2 
digit number from the beginning of $cell and leaves only the calc name

admin.cgi:949: next unless ($cell);
admin.cgi:950: $current .= \n! if:$cell_name:ne:0\n unless 
($count);  # adds an IF statement around custom calcs so they don't show 
if = $0.00

admin.cgi:951: $current .= $cell{$cell}\n;
admin.cgi:952: $count++;
admin.cgi:953: $counter++;
admin.cgi:954: if ($count = $cols || $counter == $totalcells) {
admin.cgi:955: $count = 0;
admin.cgi:956: $current .= ! /if\n;
admin.cgi:957:  }
admin.cgi:958:  }
admin.cgi:959:  $html =~ s|/tdtd|/td\ntd|g;  # add a new line 
between /tdtd for cleaner HTML
admin.cgi:960:  return 
!--NEWFIELDSSTART($cols)--//$html//--$current!--NEWFIELDSEND--;

admin.cgi:961:}





John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

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




Re: Any project like Ipython/Bpython in Perl.

2014-09-15 Thread John SJ Anderson
On Mon, Sep 15, 2014 at 5:19 AM, Sam p...@net153.net wrote:

 If you are just looking for a REPL, look at:
 https://metacpan.org/pod/Devel::REPL

IMO, Reply is a little nicer -
https://metacpan.org/pod/distribution/Reply/bin/reply

j.

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




Re: returning arrays

2014-09-09 Thread John SJ Anderson
On Tue, Sep 9, 2014 at 2:57 PM, Shawn H Corey shawnhco...@gmail.com wrote:

 Lists are sequences used by Perl. They are very short lived, seldom
 longer than one statement.

The way I've always liked to explain this is that arrays are the
containers you use to store a list.

As Shawn says, a list is usually pretty ephemeral -- but if you want
it to stick around, you can put it in an array variable.

chrs,
john.

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




Re: cygwin64 perl blead YAML and JSON backend chicken and egg.

2014-09-07 Thread John SJ Anderson
Hi Dave -

I really don't think Perl beginners is the best place to be asking
this question. Have you considered trying something like
http://code.activestate.com/lists/perl-win32-users/ ? That seems like
a more likely place to connect with somebody who can help you.

chrs,
john.


On Mon, Sep 1, 2014 at 6:46 AM, Dave Horner daveydave1...@gmail.com wrote:
 continuing to play with the cygwin64 perl blead that I built on Aug-12th.  I
 mentioned the strange infinite loop in the questioning of gpg tool; haven't
 had time to research why that happened, yet.  I'm trying to get basic
 reporting facilities up, as I have yet to report a single cygwin report.
 All of my testing is failing within configure so force does not help and of
 course they don't get reported.

 As I mentioned before I have to be cognizant of the environment variables
 shared with my windows strawberry perl.
 This means at first I was tried all these options with PERL_YAML_BACKEND and
 PERL_JSON_BACKEND set...which didn't work.  So I've also tried unsetting
 them, ensuring they were not in env/set output, and trying to install again.

 It appears that PERL_YAML_BACKEND defaults to YAML when no value is set.

 the issue it seems resides within: /usr/local/lib/perl5/5.21.3/CPAN/Meta.pm
 $backend = Parse::CPAN::Meta-yaml_backend();
 $data = eval { no strict 'refs'; {$backend\::Dump}($struct) };
 if ( $@ ) {
   croak $backend-can('errstr') ? $backend-errstr : $@
 }

 # running Build.PL
 Could not load PERL_YAML_BACKEND 'YAML'
  at /usr/local/lib/perl5/5.21.3/CPAN/Meta.pm line 613.

 I've tried forcing installing YAML::XS, YAML, YAML::Tiny, YAML::Old,
 JSON::XS, JSON

 They all give me a similar error about the backend not being there;  what am
 I missing?  Do I need to be bootstrapping these files manually?  Shouldn't a
 basic backend support for YAML/JSON come out of the box with perl blead?

 I appreciate any help/guidance.

 Thanks,
 --dave
 https://questhub.io/realm/perl/quest/53d39f40b587a43011000143
 http://wiki.cpantesters.org/wiki/YACSmokePOE - built perl using instructions
 found here.

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




Re: [ANN] SurfShop 1.6.1 Shopping Cart Released

2014-09-07 Thread John SJ Anderson
Hi -

This is a list for people starting to learn Perl, or with Perl questions.

It's not a list for announcing software written in Perl, so your post
here is off topic.

thanks,
john.


On Sat, Sep 6, 2014 at 5:55 PM, SSC_perl p...@surfshopcart.com wrote:
 Sorry for a repost so soon, but if you downloaded SurfShop 1.6.0, you 
 were greeted with a 500 error upon installation.  Somehow, during the upload, 
 GitHub for Mac corrupted some of the files with extraneous text which 
 rendered SurfShop unusable.  Unfortunately, it wasn't caught for a few days.

 I apologize profusely if you were bitten by this.  I have found and 
 cleaned all the miscreant files, and version 1.6.1 was uploaded to GitHub on 
 Friday.  After that fiasco, I wanted to sit on the fix awhile and run more 
 tests before letting everyone know that it was fixed.  I'm pleased to say 
 that version 1.6.1 fixes those problems.

 So, if you're interested in an open source Perl/MySQL shopping cart, 
 check out our forum for more information:

 http://www.surfshopcart.com/forrumm/viewtopic.php?f=2

 Again, let us know what you think!  Your feedback, as always, is 
 appreciated.

 Regards,
 Frank Jance

 http://www.surfshopcart.com/
 Setting up shop has never been easier!

 Follow us on GitHub!
 https://github.com/surfshopcart/surfshop

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



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




Re: return the list content

2014-08-18 Thread John SJ Anderson
On Mon, Aug 18, 2014 at 1:38 AM, Paul Johnson p...@pjcj.net wrote:
 On Mon, Aug 18, 2014 at 04:17:53PM +0800, Ken Peng wrote:

 which one is the better way to return the list content? And if the
 method is an instance method?

 Functionally, the two are identical.  The first is returning a reference
 to the array you have created.  The second is returning a reference to a
 new array created from a (shallow) copy of the array you have created.

[ snip ]

To expand further (because you asked about list context), note that
both are returning a _scalar_, because references are always scalars.
If you want to return a list, you should just do

return @x;

If you wanted the return value to depend on the calling context, you
could use 'wantarray' like so:

return wantarray ? @x : \@x;

That said, APIs that have contextually dependent return values are
usually fairly confusing to use, so consider not doing this.

chrs,
john.

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




Re: Suddenly.... Part 2

2014-07-31 Thread John W. Krahn

Peter Holsberg wrote:

I think I've isolated the section that is not doing what I want.

open (FHIN, $recapfile) or die $!;


That would be better as:

open my $FHIN, '', $recapfile or die Cannot open '$recapfile' because: 
$!;




my $indexb; ## for the recapfile array
my $ofile;


You never use this variable, it should be:

my @ofile;



# Create new array containing all the lines of recapfile up to
# the string RESULTS OF BOARD 1

XYZZY:
while (FHIN)
{
last XYZZY if  / RESULTS OF BOARD 1/;
chomp;
$ofile[$indexb++] .= $_;


That would be better as:

push @ofile, $_;



 }
close FHIN;

To see what was put into ofile, a line at a time, I used

foreach (@ofile) {
   print $_\n;
}

Is that correct?


That is correct.


John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

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




Re: Why Does the Following Not Work?

2014-07-30 Thread John SJ Anderson
 die(***YOU MUST HAVE A DESTINATION ADDRESS/NETWORK address.\n)
 if (@destinations);

Don't you mean 'if !@destinations' or 'unless @destinations' here?
That test is for whether @destinations has any entries.

% perl -E 'my @x=(); say lives if (@x)'

%  perl -E 'my @x=(1); say dies if (@x)'
dies

j.

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




Re: Apologetic request for simple one-off script

2014-07-14 Thread John Delacour

On 14 Jul 2014, at 05:39, Shlomi Fish shlo...@shlomifish.org wrote:

 don't use two-args open

perldoc -f open

In the one- and two-argument forms of the call, the mode and
filename should be concatenated (in that order), preferably
separated by white space. You can--but shouldn't--omit the mode
in these forms when that mode is . It is always safe to use
the two-argument form of open if the filename argument is a
known literal.

JD

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




Re: Apologetic request for simple one-off script

2014-07-14 Thread John SJ Anderson
Hi. List Mom here.

Please take this off list, it's not on-topic.

John: Thank you for answering the OP's question. However, Shlomi is
right, the two argument form of open() is something that the general
Perl community considers to be a deprecated style that should not be
used with new code. This list is not the place to argue that, that
ship has sailed.

Shlomi: line-by-line teardowns of scripts people post in response to
questions are generally not helpful, particularly when the script
_will_ work as written. It makes people feel attacked and leads to
defensive responses that make the list appear to be an unfriendly
place. If you think you can write a better or more correct script,
just provide it; this type of critique ends up being an overall
negative contribution.


thanks,
john,
perl-beginners list mom

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




Re: Apologetic request for simple one-off script

2014-07-14 Thread John Delacour

On 14 Jul 2014, at 14:11, Shlomi Fish shlo...@shlomifish.org wrote:

 perldoc -f open

 This is irrelevant. Two-args open is dangerous - always use three-args open:
 
 * http://perl-begin.org/tutorials/bad-elements/#open-function-style

Who wrote that?  Ah...a certain Shlomi Fish.

open my $fh,  $path; # with or without the space _does_ contain three 
arguments to all intents and purposes.

Now tell us exactly how this is “dangerous”.  Give examples.

JD


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




Re: Apologetic request for simple one-off script

2014-07-14 Thread John SJ Anderson
You were asked to take this off list once.

I'm now telling you, in my official capacity as list moderator:
further discussion of this is off-topic and does not belong on this
list.

Let it go.

thanks,
john.



On Mon, Jul 14, 2014 at 7:18 AM, John Delacour johndelac...@gmail.com wrote:

 On 14 Jul 2014, at 14:11, Shlomi Fish shlo...@shlomifish.org wrote:

 perldoc -f open

 This is irrelevant. Two-args open is dangerous - always use three-args open:

 * http://perl-begin.org/tutorials/bad-elements/#open-function-style

 Who wrote that?  Ah...a certain Shlomi Fish.

 open my $fh,  $path; # with or without the space _does_ contain three 
 arguments to all intents and purposes.

 Now tell us exactly how this is “dangerous”.  Give examples.

 JD


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



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




Re: Apologetic request for simple one-off script

2014-07-13 Thread John Delacour

On 13 Jul 2014, at 21:43, ESChamp esch...@gmail.com wrote:

 ...lastname firstname other other other ... emailaddress
 
 I wish to write a new file that contains only the emailaddress field
 contents.

Here’s an easily-understood way of doing it:

#!/usr/bin/perl
use strict;
while (DATA){
  chomp;
  @_ = split / /;
  print $_[-1] . $/;
}
__DATA__
x x x a@b
x x x x c@d
x x e@f




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




Re: Apologetic request for simple one-off script

2014-07-13 Thread John Delacour

On 13 Jul 2014, at 23:48, ESChamp esch...@gmail.com wrote:

 John Delacour has written on 7/13/2014 5:31 PM:
 
 On 13 Jul 2014, at 21:43, ESChamp esch...@gmail.com wrote:
 
 ...lastname firstname other other other ... emailaddress
 
 I wish to write a new file that contains only the emailaddress field
 contents.
 
 Here’s an easily-understood way of doing it:
 
 #!/usr/bin/perl
 use strict;
 while (DATA){
  chomp;
  @_ = split / /;
  print $_[-1] . $/;
 }
 __DATA__
 x x x a@b
 x x x x c@d
 x x e@f
 
 That's great! How do I get it to read the data from a file?

Like this:

#!/usr/bin/perl
use strict;
my $filepath = $ENV{HOME}/temp/a.txt;
open my $fh, $filepath or die $!; 
while ($fh) {
 chomp;
 @_ = split / /;
 print $_[-1] . $/;
}


# JD


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




Re: Creating a hash of arrays from DATA

2014-07-09 Thread John SJ Anderson
On Wed, Jul 9, 2014 at 6:59 PM, SSC_perl p...@surfshopcart.com wrote:
 If someone could explain what I'm doing wrong, I'd appreciate it.  I 
 just can't see it.

You're looping over the entries in the array, not the entries in the hash.

 foreach my $state (sort keys %entries) {
 say The Zip Codes of $state are;
 foreach (@{$entries{$state}}) {

This foreach loop is looping over the five zip codes in the array...

 print Dumper (@{$entries{$state}});

And printing out the same array each time.

Try something like

foreach my $state ( sort keys %entries) {
  say The ZIP codes of $state are: ;
  foreach my $zip ( @{ $entries{$state} } ) {
say \t$zip;
  }
}


j.

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




Re: want to write to file in different format

2014-07-07 Thread John Delacour

On 7 Jul 2014, at 09:18, Sunita Pradhan sunita.pradhan.2...@hotmail.com wrote:

 I have a file of contents:
 ---
 1 6
 2 7
 3 8
 4 9
 5 10
 --
 I want a file with content:
 
 1 2 3 4 5
 6 7 8 9 10

Try this:


#!/usr/local/bin/perl
use strict;
my (@col1, @col2);
while (DATA) {
  chomp;
  my @words = split / /;
  push @col1, $words[0];
  push @col2, $words[1];
}
print join  , @col1;
print \n;
print join  , @col2;
__DATA__
1 6
2 7
3 8
4 9
5 10

#JD




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




Re: one line script for word count

2014-06-30 Thread John Delacour

On 30 Jun 2014, at 20:05, Jim Gibson jimsgib...@gmail.com wrote:

 Try this:
 
 $c = () = $line =~ /\b$w\b/g;

Or, slightly less obscure:

#!/usr/bin/perl
use strict;
my $line = one potato two potato three potato four;
my @hits = $line =~ /potato/g;
print scalar @hits; # = 3
 

#JD

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




Re: CGI script produces blank screen

2014-06-27 Thread John SJ Anderson
On Fri, Jun 27, 2014 at 7:34 PM, SSC_perl p...@surfshopcart.com wrote:
 Any input would be greatly appreciated!

Look in the web server error log.

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




Re: uninitialized error for hash printing

2014-06-22 Thread John Delacour

On 22 Jun 2014, at 21:01, Sunita Pradhan sunita.pradhan.2...@hotmail.com 
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;
  }
 --
 Use of uninitialized value $k:: in concatenation (.) or string at 
 hash_test2.pl

Try this:

#!/usr/bin/perl -w
use strict;
my %hash = (
abc = 123,
dfg = 456,
xsd = 34
);
foreach my $k (keys %hash){
print key $k\:: value $hash{$k}\n;
}

#JD



Re: Install Alien SVN::Core

2014-06-15 Thread John SJ Anderson
On Fri, Jun 13, 2014 at 3:45 PM, Tim Dunphy bluethu...@gmail.com wrote:

 How can I specify apr-util to this perl module when apr-util 1.5.1 is
 already installed.

Can you confirm that 'which apr-util' shows that the command is
actually in your $PATH?

j.

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




Re: Install Alien SVN::Core

2014-06-15 Thread John SJ Anderson
On Sun, Jun 15, 2014 at 10:39 AM, Tim Dunphy bluethu...@gmail.com wrote:
 Hi John,

 --
 /usr/bin/install -c -m 644 aprutil.exp /usr/local/apr/lib
 /usr/bin/install -c -m 755 apu-config.out /usr/local/apr/bin/apu-1-config

 However when I do a 'which apr-util' I get nothing back.

Sorry, I forgot apr-utils isn't the name of the command you need.

It's apu-1-config -- see the last 'install' command in the 'make
install' output above.

 [root@host1 apr-util-1.5.3]# which apr-util
 /usr/bin/which: no apr-util in
 (/opt/python27/bin:/opt/php-5.3.28/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/opt/csvquerytool-0.0.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/apache2/bin:/root/bin)

You don't have /usr/local/apr/bin in that PATH. Try adding it.

j.

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




Re: perlbrew error

2014-06-15 Thread John SJ Anderson
On Sun, Jun 15, 2014 at 10:31 AM, Subinoy Biswas suny@gmail.com wrote:
 Hi,
 I am having a trouble installing any module with cpanm in perlbrew
 perl-5.20.0 in an test1 local lib. Below I am pasting the verbose. Please
 help me to solve this issue

So, you need to install Tie::Hash::Indexed:

 Can't locate Tie/Hash/Indexed.pm in @INC (you may need to install the
 Tie::Hash::Indexed module)

Which you tried to do:

 subinoybiswas@sunymacs:~/work_ubc/seq$ cpanm Tie::Hash::Indexed
[ snip ]

Which failed:

 ! Installing Tie::Hash::Indexed failed. See
 /Users/subinoybiswas/.cpanm/build.log for details.

So the contents of that file might be helpful.

Additionally:

 cannot unlink file for
 /Users/subinoybiswas/.cpanm/work/1383165137.7601/build.log: Permission
 denied at /loader/0x7fd8d10320a0/App/cpanminus/script.pm line 1.
 cannot restore permissions to 0100644 for
 /Users/subinoybiswas/.cpanm/work/1383165137.7601/build.log: Permission
 denied at /loader/0x7fd8d10320a0/App/cpanminus/script.pm line 1.
 cannot remove directory for
 /Users/subinoybiswas/.cpanm/work/1383165137.7601: Directory not empty at
 /loader/0x7fd8d10320a0/App/cpanminus/script.pm line 1.

Those errors suggest something is messed up in your ~/.cpanm directory
hierarchy. If I had to bet, I'd bet that you ran something as root,
once upon a time, and the above errors are from root-owned files that
got produced at that point.

You should just be able to 'rm -rfv ~/.cpanm' without issue.


j.

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




Re: Install Alien SVN::Core

2014-06-15 Thread John SJ Anderson
On Sun, Jun 15, 2014 at 11:36 AM, Tim Dunphy bluethu...@gmail.com wrote:
 Ok! Well if I do a which on that program:

 [root@uszmpaplp005lc apr-util-1.5.3]# which apu-1-config
 /usr/bin/apu-1-config

 It's found. Yay!

That's finding the system one, not the one you just installed under
/usr/local/apr/bin.

 But just for good measure I try adding that directory to my PATH.

 [root@host1 apr-util-1.5.3]# echo $PATH
 /opt/python27/bin:/opt/php-5.3.28/bin:/opt/csvquerytool-0.0.3/bin:/opt/python27/bin:/opt/php-5.3.28/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/opt/csvquerytool-0.0.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/apache2/bin:/root/bin:/opt/apache2/bin:/usr/local/apr/bin

Because you added it to the end of the PATH, the system will still
find the one under /usr/bin first.

 So I ran the perl Build.PL process again and got much further along than I
 had before! However no luck as of yet, as it's now giving me this error:

I'm pretty deep into SWAG territory here, but my guess is that the
version installed with the system is not the required 1.5.3 (or
whatever it was), and that explains those C compiler errors you're
getting.

j.

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




Re: how to create a text progress status line that updates on the same line in Perl?

2014-06-10 Thread John SJ Anderson
On Tue, Jun 10, 2014 at 2:59 PM, Kenneth Wolcott
kennethwolc...@gmail.com wrote:
 Hi All;

 how to create a text progress status line that updates on the same line in 
 Perl?

You mean something like https://metacpan.org/pod/Text::ProgressBar::Bar ?

Maybe reading that source code would be informative. 8^)

chrs,
john.

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




Re: Running module using cpan.

2014-06-10 Thread John SJ Anderson
On Tue, Jun 10, 2014 at 9:47 PM, Priyal Jain jpri...@juniper.net wrote:
 Hello,

 I uploaded my module in CPAN on 02June,2014 
 http://search.cpan.org/search?mode=allquery=Net%3A%3ANetconf but while 
 installing my module using cpan i.e. cpan Net::Netconf its giving warning

Have you seen https://rt.cpan.org/Public/Bug/Display.html?id=95038 ?

It looks like the distribution you uploaded is not set up correctly in
at least a few ways. In addition to the missing META.yml file, the POD
markup is rendering wrong on search.cpan.org, and the module doesn't
seem to be indexed at all on MetaCPAN, which is generally indicative
of problems.

My advice would be to contact the person who submitted that ticket,
and take them up on their offer to help you.

chrs,
john.

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




Re: regular expression

2014-05-06 Thread John SJ Anderson
On Tue, May 6, 2014 at 10:19 PM, Danny Wong (dannwong)
dannw...@cisco.com wrote:

 What is a regular expression where I can extract ³danwong² from either
 string (one string have () parentheses and the other doesn¹t have
 parentheses)?

I'm not entirely sure what you're trying to accomplish, but perhaps
something like:

#! /usr/bin/env perl

use strict;
use warnings;
use 5.010;

my @strings = (
  ^Modifications made by Danny Wong (danwong) on 2014/05/06 18:27:48
from database brms ,
  ^Modifications made by danwong on 2014/05/06 18:27:48 from database brms²,
);

foreach my $string ( @strings ) {
  say Matched '$1' in '$string'
if $string =~ /(danwong)/;
}

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




Re: regular expression

2014-05-06 Thread John SJ Anderson
On Tue, May 6, 2014 at 10:30 PM, Danny Wong (dannwong)
dannw...@cisco.com wrote:
 Both string are possible outputs, so I want to be able to grep for the
 username only.

Well, if the username will always be either the only thing between
'by' and 'on', or in parens if it's not...

#! /usr/bin/env perl

use strict;
use warnings;
use 5.010;

my @strings = (
  ^Modifications made by Danny Wong (danwong) on 2014/05/06 18:27:48
from database brms ,
  ^Modifications made by danwong on 2014/05/06 18:27:48 from database brms²,
);

foreach my $string ( @strings ) {
  my( $match ) = $string =~ /by (.*?) on/;
  if ( $match and $match =~ /\(([^)]+)\)/ ) {
$match = $1;
  }
  say Matched '$1' in '$string'
if $match;
}

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




Re: small puzzle

2014-04-25 Thread John SJ Anderson
On Fri, Apr 25, 2014 at 12:18 PM, Harry Putnam rea...@newsguy.com wrote:

 About just using 'shift':  How I happened to be using that weird
 looking notation at all was because I thought it was a way to avoid
 the extra step of compiling the rgx in qr// after shifting.

My advice to you on this point would be that when you're trying to do
two things, it's perfectly okay to use two lines of code to do it.
(It's even okay sometimes when you're only trying to do one thing!)

Perl doesn't charge you by the lines of code you use, so doing this:

   my $re = shift;
   $re = qr/$re/;

is just fine.


chrs,
john.

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




Re: small puzzle

2014-04-25 Thread John SJ Anderson
*puts on List Mom hat*

Okay, we're done here. The original question was asked and answered (a
couple times). Let's move on and get back to dealing with Perl
questions, not personalities.

thanks,
john.

*takes List Mom hat back off*

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




Re: small puzzle

2014-04-24 Thread John SJ Anderson
On Thu, Apr 24, 2014 at 8:40 PM, Harry Putnam rea...@newsguy.com wrote:
 my $dir2sr  = @{[shift]};

This shifts an element off @ARGV, makes an array reference containing
a single element (the value that was just shifted off), then
deferences that arrayref to create an array (which still contains a
single element, the value that was just shifted off), then assigns the
result of evaluating that array in a scalar context (which is the
number of elements in the array, i.e., 1) to $dir2sr.

(The same thing happens earlier, when you're pulling the first value
off @ARGV, but there the evaluation of the array is happening inside
qr//, which I guess imparts a list context so it DWyouM.)

In general, anywhere you're doing '@{[shift]}', unless you REALLY know
what's going on and why you'd want to do that ... instead just do
'shift'.

j.

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




Re: Where's this documented?

2014-03-20 Thread John W. Krahn

shawn wilson wrote:


Oh, I guess I was thinking that using the file name repeats the stat
(which it does). Since I was complaining about the ugliness of '_'.
However, you're right - that works as well as (-f _)-- that doesn't
look weird as shit? I've got issues moving my fingers into typing
that Whatever, y'all answered my question and I learned something
(though damn them for not just making another perlvar or something
else to do this) - I appreciate the help/info.


_ is a perlvar.  It is part of the typeglob that includes $_, @_, %_ and _.

perldoc perldata
perldoc perlmod
perldoc perlref



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

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




Re: Where's this documented?

2014-03-18 Thread John W. Krahn

Shaji Kalidasan wrote:


You can use more than one file test on the same file to create a
complex logical condition.
Suppose you only want to operate on files that are both readable and
writable; you check each attribute and combine them with and:

if (-r $file and -w $file) {
...
}

Each time you perform a file test


or use stat() or lstat()


, Perl asks the filesystem for all of
the information about the file (Perl’s actually doing a stat each time,
which we talk about in the next section). Although you already got that
information when you tested -r, Perl asks for the same information
again so it can test -w. What a waste! This can be a significant
performance problem if you’re testing many attributes on many files.

The virtual filehandle _ (just the underscore) uses the information
from the last file lookup that a file test operator


or stat() or lstat()


performed. Perl
only has to look up the file information once now:




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

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




Re: Turn part of a string into a single newline

2014-02-14 Thread John W. Krahn

Parysatis Sachs wrote:

Hi everyone!


Hello,



I'm new to this mailing list as well as to programming and Perl in general.
So there is a chance I might ask relatively stupid questions with very
obvious answers... Please bear with me!

So, here it goes:

I have a very long string with lots of Ns in it, like this:
agctagccgagctaNNatggctaNNNatgtgaNNatg

So, I want to get rid of the Ns and get ONE SINGLE newline for each group
of Ns

So far I've managed to do this:

if ($joinedDNA =~ s/N+/\n/g) {

$joinedDNA =~ s/\R//g;

}


That should be just:

$joinedDNA =~ s/N+/\n/g;

Or just:

$joinedDNA =~ tr/N/\n/s;


The statement:

$joinedDNA =~ s/\R//g;

removes all newlines.




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

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




Re: Test::More is_deeply failed data

2014-02-11 Thread John SJ Anderson
On Tue, Feb 11, 2014 at 10:17 AM, shawn wilson ag4ve...@gmail.com wrote:
 Is there a way to see the data difference when is_deeply fails?

So, with this code:

#! perl

use Test::More;

my $a = { foo = {bar = { baz = 'bargle' }}};
my $b = { foo = {baz = { bar = 'bargle' }}};

is_deeply( $a , $b );

done_testing;

I get this output:

% prove deeply.t
deeply.t .. 1/?
#   Failed test at deeply.t line 8.
# Structures begin differing at:
#  $got-{foo}{baz} = Does not exist
# $expected-{foo}{baz} = HASH(0x7fdb798283f0)
# Looks like you failed 1 test of 1.
deeply.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests

Test Summary Report
---
deeply.t (Wstat: 256 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
Files=1, Tests=1,  0 wallclock secs ( 0.03 usr  0.01 sys +  0.02 cusr
0.00 csys =  0.06 CPU)
Result: FAIL

What do you get?

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




Re: constant in object

2014-02-10 Thread John SJ Anderson
On Mon, Feb 10, 2014 at 10:07 PM, shawn wilson ag4ve...@gmail.com wrote:

  which I still don't see why this is bad?

In classic object-oriented programming, object constructors -- which
is what new() is in your class -- are always class methods. Calling
'new()' as an object method doesn't make any sense. Further, as Uri
points out, the semantics can get confused when you call a 'new()'
method on an object. Are you asking for a new, fresh instance of an
object of the class that the existing object is a member of, or are
you asking for a a new instance that's a copy of the object you're
calling the method on?

(Aside: that confusion is the reason why Uri is suggesting an object
method called 'clone()'. I can only assume he's intending for it to
return a copy of the object it is called on, not a completely fresh
instance of the object defined by the class of the object that it is
called on.)

TL;DR - if you can't offer a positive reason why you're doing this --
and it doesn't seem to hurt anything is *not* a positive reason --
then you shouldn't do it.

j.

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




Re: Package version numbers

2014-01-14 Thread John SJ Anderson
On Tue, Jan 14, 2014 at 2:50 PM, SSC_perl p...@surfshopcart.com wrote:
 I'm trying to number packages the way it's written about on page 406 
 of Programming Perl, 4th ed., e.g.

 package Emailer 1.01;

 However, when I do that, I get the following error:

 syntax error at ss_files/Emailer.pm line 1, near package Emailer 1.01
 Compilation failed in require at admin.cgi line 38.
 BEGIN failed--compilation aborted at admin.cgi line 38.

 I'm running Perl 5.10.1 on my laptop so that should be new enough to 
 handle this.  What am I doing wrong?

I'm not sure exactly when that syntax was added, but for what it's
worth, it fails with 5.10.1 here too. Perl 5.12.5, on the other hand,
works.

You may just need to upgrade.

chrs,
john.

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




Re: Package version numbers

2014-01-14 Thread John SJ Anderson
 Thanks for the test, John.  In the book's example, they have:

 use v5.10;

 so I thought I was new enough, but maybe not.

http://use.perl.org/use.perl.org/articles/10/04/13/1953252.shtml also
notes it as a new feature in 5.12. I'm sure the authors regret the
typo. ;^)



j.

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




  1   2   3   4   5   6   7   8   9   10   >