Wildcards not working

2002-10-27 Thread mike
I am trying to cd into a directory referenced by a value in a list with
wildcards like shell command
ls test* or cd test*

however nothing seems to work, I have tried amongst others

$dir9= system(ls $dir1.*\$);
opendir(DIRLIST,.);
$dir9=grep$dir1.*\$, readdir DIRLIST
-- 
Linux, Gnome what more do you need
http://www.redtux.demon.co.uk

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




extra characters return plus 0 in script

2002-11-21 Thread mike
I'm getting confused - I have the following script

open(DESK,gtkdoclist) or die cant open;
@desk1=DESK;
foreach $desk1 (@desk1){
chomp $desk1;
print $desk1\n;
$gtkdoc1=system(grep -h gtk_doc_min_version= $desk1);
chomp $desk1;
print $gtkdoc1;

however the output is this
(notice the zeros at the start of line)
atk/configure.in
gtk_doc_min_version=0.6
0atk/configure
gtk_doc_min_version=0.6
0at-spi/configure.in
gtk_doc_min_version=0.6
0at-spi/configure
gtk_doc_min_version=0.6
0bonobo-activation/configure.in
gtk_doc_min_version=0.6

the source file looks like this

atk/configure.in
atk/configure
at-spi/configure.in
at-spi/configure
bonobo-activation/configure.in
bonobo-activation/configure

As you can see there are extraneous returns and zeros - anyone any idea
where they are coming from?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: extra characters return plus 0 in script

2002-11-22 Thread mike
On Fri, 2002-11-22 at 05:44, John W. Krahn wrote:
 Mike wrote:
  
  I'm getting confused - I have the following script
  
  open(DESK,gtkdoclist) or die cant open;
  @desk1=DESK;
  foreach $desk1 (@desk1){
  chomp $desk1;
  print $desk1\n;
  $gtkdoc1=system(grep -h gtk_doc_min_version= $desk1);
  chomp $desk1;
  print $gtkdoc1;
  

Solved the immediate problem but now from this script

#!/usr/bin/perl -w
open(DESK,gtkdoclist) or die cant open;
@desk1=DESK;
foreach $desk1 (@desk1){
print $desk1;
$desk3=$desk1;
$gtkdoc1=`grep gtk_doc_min_version= $desk1`;
chop $gtkdoc1;
chomp $gtkdoc1;
chomp $gtkdoc1;
print $gtkdoc1\n;
@gtkdoc2=split /=/, $gtkdoc1;
print $gtkdoc2[1]\n;
$gtkdoc3=$gtkdoc2[1];
$mult='10';
$gtkdoc4=$gtkdoc3 * $mult;# this is the error
print $gtkdoc3
$gtkdoc5=$gtkdoc1;


gives the following error

atk/configure.in
gtk_doc_min_version=0.6
0.6
Filehandle main::0.6 never opened at ./gtkdocchk line 17, DESK line
41.

as you can see (0.6) my var for calculation seems in scope but
calculation is not taking place
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: extra characters return plus 0 in script

2002-11-22 Thread mike
On Sat, 2002-11-23 at 04:50, John W. Krahn wrote:
 Mike wrote:
  
  On Fri, 2002-11-22 at 05:44, John W. Krahn wrote:
   Mike wrote:
   
I'm getting confused - I have the following script
   
open(DESK,gtkdoclist) or die cant open;
@desk1=DESK;
foreach $desk1 (@desk1){
chomp $desk1;
print $desk1\n;
$gtkdoc1=system(grep -h gtk_doc_min_version= $desk1);
chomp $desk1;
print $gtkdoc1;
 
 Did you try the code that I posted here in my last reply?

I modified my code to use backticks, when the code worked up to that
point - thanks.

 
  Solved the immediate problem but now from this script
  
  #!/usr/bin/perl -w
  open(DESK,gtkdoclist) or die cant open;
  ^^
 You should include the actual file name and the $! variable in the error
 message.
 

I know I should (and would if the file handle was not being opened -
noting after this would work if it wasn't)

  @desk1=DESK;
  foreach $desk1 (@desk1){
  print $desk1;
 ^  ^
 The quotation marks are not required as the print function will convert
 everything it prints to a string.
 
 
  $desk3=$desk1;
  $gtkdoc1=`grep gtk_doc_min_version= $desk1`;
 
 Do you understand what the backticks do in a scalar context?
 

I think so - ie: feeding the result back to perl ($gtkdoc1 above)

  chop $gtkdoc1;
  chomp $gtkdoc1;
  chomp $gtkdoc1;
 
 Do you understand what chop() and chomp() do?
 

yep - just making sure

  print $gtkdoc1\n;
  @gtkdoc2=split /=/, $gtkdoc1;
  print $gtkdoc2[1]\n;
  $gtkdoc3=$gtkdoc2[1];
  $mult='10';
  $gtkdoc4=$gtkdoc3 * $mult;# this is the error
  print $gtkdoc3
 ^
 The actual error is here.  Something is missing.
 
 
  $gtkdoc5=$gtkdoc1;
  
  gives the following error
  
  atk/configure.in
  gtk_doc_min_version=0.6
  0.6
  Filehandle main::0.6 never opened at ./gtkdocchk line 17, DESK line
  41.
  
  as you can see (0.6) my var for calculation seems in scope but
  calculation is not taking place
 
 That is because the result of the multiplication is stored in a
 different variable then the one you are printing.
 

sorry about the typo in the last print. I am still trying to work out
where the error is coming from.

more errors follow to show more of what seems to be happening

glib/configure.in
gtk_doc_min_version=0.6
0.6
Filehandle main::6 never opened at ./gtkdocchk line 17, DESK line 41.
glib/configure
gtk_doc_min_version=0.6
0.6
Filehandle main::6 never opened at ./gtkdocchk line 17, DESK line 41.
gnome-panel/configure.in
gtk_doc_min_version=0.9
0.9
Filehandle main::9 never opened at ./gtkdocchk line 17, DESK line 41

The Filehandle main error seems to be referencing the first digit to the
right of the decimal point

As I understand it up to my problem is

I split $gtkdoc1 - OK
I print $gtkdoc2[1] - OK
I assign this to $gtkdoc3 -Ok
I print this to be sure (0.6 or 0.9 or 0.7 etc) -Ok

then I try to assign to gtkdoc4 a multiplication of $gtkdoc3 * $mult,
which is where it goes toes up

 
 John
 -- 
 use Perl;
 program
 fulfillment
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Problem calling sub

2003-01-04 Thread mike
(@file1){
#$file1=~s/gtk_doc_min_version=0.7/gtk_doc_min_version=0.10/g;
#print GTKDOCERR1 $file1
#};
#close GTKDOCERR;
#close GTKDOCERR1;
#open (GTKDOCERR1,gstdoc.m4) or die no such file1;
#open (GTKDOCERR,common//m4//gst-doc.m4) or die no such file3 $@;
#@file3=GTKDOCERR1;
#print GTKDOCERR @file3;
system (CPPFLAGS=$cflags ./configure --prefix=$prefix --sysconfdir=$sys --localstatedir=$local $debug --disable-gtk-doc --disable-more-warnings --disable-plugin-builddir);
system './autogen.sh'; 
system (CPPFLAGS=$cflags ./configure --prefix=$prefix --sysconfdir=$sys --localstatedir=$local $debug --disable-gtk-doc --disable-more-warnings --disable-plugin-builddir);
system 'make';
system (checkinstall -R -y --pkgname=$dir1 --pkgversion=$ARGV[0] --pkgrelease=$ARGV[1] --strip=$strip --stripso=$stripso);
}
elsif ( $dir1 eq 'mb_client' ) {
system './autogen.sh'; 
system (CPPFLAGS=$cflags ./configure --prefix=$prefix --sysconfdir=$sys --localstatedir=$local $debug --enable-gtk-doc=no --disable-more-warnings );
system 'make';
system (checkinstall -R -y --pkgname=$dir1 --pkgversion=$ARGV[0] --pkgrelease=$ARGV[1] --strip=$strip --stripso=$stripso);
}
elsif ( $dir1 eq 'mad-0.14.2b' or $dir1 eq 'cog-0.5.1' or $dir1 eq 'startup-notification-0.4' ) {
system (./configure --prefix=$prefix --sysconfdir=$sys --localstatedir=$local $debug --enable-gtk-doc=no --disable-more-warnings );
system 'make';
system (checkinstall -R -y --pkgname=$dir1 --pkgversion=$ARGV[0] --pkgrelease=$ARGV[1] --strip=$strip --stripso=$stripso);
}
elsif ( $dir1 eq 'Hermes-1.3.2' ) {
system(rm -rf libtool lt*);
system(libtoolize --force);
system './autogen.sh'; 
system (./configure --prefix=$prefix --sysconfdir=$sys --localstatedir=$local $debug --enable-gtk-doc=no --disable-more-warnings );
system 'make';
system (checkinstall -R -y --pkgname=$dir1 --pkgversion=$ARGV[0] --pkgrelease=$ARGV[1] --strip=$strip --stripso=$stripso);
}
elsif ( $dir1 eq 'nautilus' ) {
system (./autogen.sh --prefix=$prefix --sysconfdir=$sys --localstatedir=$local $debug --enable-gtk-doc=no --disable-more-warnings );
system 'make';
system (checkinstall -R -y --pkgname=$dir1 --pkgversion=$ARGV[0] --pkgrelease=$ARGV[1] --strip=$strip --stripso=$stripso);
}
elsif ( $dir1 eq 'gtkhtml2' ) {
system (CPPFLAGS=$cflags ./autogen.sh --prefix=$prefix --sysconfdir=$sys --localstatedir=$local $debug --enable-gtk-doc=no --disable-more-warnings );
system 'make';
system (checkinstall -R -y --pkgname='libgtkhtml2' --pkgversion=$ARGV[0] --pkgrelease=$ARGV[1] --strip=$strip --stripso=$stripso);
}
elsif ( $dir1 eq 'libxslt' ) {
system (CPPFLAGS=$cflags ./autogen.sh --prefix=$prefix --sysconfdir=$sys --localstatedir=$local $debug --enable-gtk-doc=no --disable-more-warnings );
system 'make';
system(make install);
}
else
{
system (CPPFLAGS=$cflags ./autogen.sh --prefix=$prefix --sysconfdir=$sys --localstatedir=$local $debug --enable-gtk-doc=no --disable-more-warnings);
system 'make';
system (checkinstall -R -y --pkgname=$dir1 --pkgversion=$ARGV[0] --pkgrelease=$ARGV[1] --strip=$strip --stripso=$stripso);
}
system(make distclean);
chdir $dir0;
$dir3=getcwd();
print $dir3\n;

system(/home/mike/rmla);
};





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Question about permissions

2004-04-09 Thread mike
I have developed an intranet perl/postgesql app which works fine except
for one bizarre problem

I have all the appropriate scripts with the following permissions
-rw-r-xr--  1 mike apache 

However periodically the permissions change with the group ownership
changing.

This is on Fedora with perl-5.8.1, apache-2.0.47,postgresql-7.4.2

Anyone any clues why this is happening?

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




OT - problem with script running on a refresh

2004-06-08 Thread mike
Hi I have a CGI/dbi script which whenever the page is reloaded the
following executes

print start_multipart_form (POST);

print Subject, popup_menu(-name='Subject1',-values=[EMAIL PROTECTED]);

print Area, popup_menu(-name='area1',-values=[EMAIL PROTECTED]),p;
print Description,textfield(-name='file_desc',-size='50');
$subj1=param('Subject1');
$area1=param('area1');
$desc=param('file_desc');
#print $subj1;
#$subj2=param('Subject1');
#$area2=param('area1');
$row3=$dbh-prepare(SELECT subj_id FROM tb_file_subj WHERE subj_desc
= ?);
$row4=$dbh-prepare(SELECT area_id FROM tb_file_area WHERE area_desc
= ?);
$row3-bind_param(1,$subj1);
$row4-bind_param(1,$area1);
$row3-execute();
$row4-execute();
while (($subj2) = $row3-fetchrow_array()){

$subj3=$subj2;
}
print $subj3;
while (($area2) = $row4-fetchrow_array()){
$area3=$area2;

}
print $area3;
$sth=$dbh-prepare(q{INSERT INTO tb_files (subj, area, file_no,
file_desc) select ?, ?,(SELECT coalesce(max(file_no),0)+1 FROM tb_files
WHERE subj = ? AND  area = ?),?}) ;

$sth-bind_param(1,$subj3);
$sth-bind_param(2,$area3);

$sth-bind_param(3,$subj3);
$sth-bind_param(4,$area3);
$sth-bind_param(5,$desc);
$sth-execute ;
print p;

if($DBI::errstr ne ''){
print $DBI::errstr\n;
}
print p;
print submit;
print end_form;

This is not I want - I only want it to execute when I click submit - is
this possible?

Curioisly, when I click refresh, the values dont reset

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




OT - problem with script running on a refresh

2004-06-08 Thread mike
Hi I have a CGI/dbi script which whenever the page is reloaded the
following executes

print start_multipart_form (POST);

print Subject, popup_menu(-name='Subject1',-values=[EMAIL PROTECTED]);

print Area, popup_menu(-name='area1',-values=[EMAIL PROTECTED]),p;
print Description,textfield(-name='file_desc',-size='50');
$subj1=param('Subject1');
$area1=param('area1');
$desc=param('file_desc');
#print $subj1;
#$subj2=param('Subject1');
#$area2=param('area1');
$row3=$dbh-prepare(SELECT subj_id FROM tb_file_subj WHERE subj_desc
= ?);
$row4=$dbh-prepare(SELECT area_id FROM tb_file_area WHERE area_desc
= ?);
$row3-bind_param(1,$subj1);
$row4-bind_param(1,$area1);
$row3-execute();
$row4-execute();
while (($subj2) = $row3-fetchrow_array()){

$subj3=$subj2;
}
print $subj3;
while (($area2) = $row4-fetchrow_array()){
$area3=$area2;

}
print $area3;
$sth=$dbh-prepare(q{INSERT INTO tb_files (subj, area, file_no,
file_desc) select ?, ?,(SELECT coalesce(max(file_no),0)+1 FROM tb_files
WHERE subj = ? AND  area = ?),?}) ;

$sth-bind_param(1,$subj3);
$sth-bind_param(2,$area3);

$sth-bind_param(3,$subj3);
$sth-bind_param(4,$area3);
$sth-bind_param(5,$desc);
$sth-execute ;
print p;

if($DBI::errstr ne ''){
print $DBI::errstr\n;
}
print p;
print submit;
print end_form;

This is not I want - I only want it to execute when I click submit - is
this possible?

Curioisly, when I click refresh, the values dont reset

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




Re: Mail::Sendmail

2004-06-09 Thread mike
On Wed, 2004-06-09 at 10:59 +0200, Miguel ngel Morales wrote:
 Hi all!
 
 I am using Mail::Sendmail module to send e-mails from my perl application but the 
 text of these messages seems to be too much long and when receiving the e-mail the 
 text of the message is not complete.
 Do yo know if there are any message size limitation?  It this limitation exists, 
 what module, without limitation, can I use?
 
 Thanks in advance,
 
 Miguel ngel
 

Have you tried MIMEtools/mailtools (they let you send attachments as
well)


 
 **
 Madrid 2003 Global IPv6 Summit
 Presentations and videos on line at:
 http://www.ipv6-es.com
 
 This electronic message contains information which may be privileged or 
 confidential. The information is intended to be for the use of the individual(s) 
 named above. If you are not the intended recipient be aware that any disclosure, 
 copying, distribution or use of the contents of this information, including attached 
 files, is prohibited.
 

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




Very wierd problem with CGI.pm

2004-06-11 Thread mike
Has anyone ever come accross this wied problem before

I have a script which pulls records from a DB then loops into a form and
shows each record, with the id no being concatenated to the field name
to give a unique record id.

However if I have this
Banked,textfield(-name='bk_amt'.$bank_inv,-value=$bk_amt1);

the params are zeroed

but if I have this

Banked,textfield(-name=' bk_amt'.$bank_inv,-value=$bk_amt1);
 
(ie; a space)
everything is fine

Anyone have any idea what is going on here?

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




Re: Very wierd problem with CGI.pm

2004-06-14 Thread mike
On Sat, 2004-06-12 at 08:30 -0700, David Storrs wrote:
 On Fri, Jun 11, 2004 at 01:07:54PM +0100, mike wrote:
  Has anyone ever come accross this wied problem before
  
  I have a script which pulls records from a DB then loops into a form and
  shows each record, with the id no being concatenated to the field name
  to give a unique record id.
  
  However if I have this
  Banked,textfield(-name='bk_amt'.$bank_inv,-value=$bk_amt1);
  
  the params are zeroed
  
  but if I have this
  
  Banked,textfield(-name=' bk_amt'.$bank_inv,-value=$bk_amt1);
   
  (ie; a space)
  everything is fine
  
  Anyone have any idea what is going on here?
 
 
 Can't really tell without seeing your form but my first guess would be
 that the HTML for the textfield looks something like this:
 
 input type=text name= bk_amt ...
 
 Meaning that its name actually IS ' bk_amt' and not 'bk_amt'.
 Therefore, when you try to access the field name without a space,
 there is no such field, so you get nothing.
 

No, wrong way round, if I name the test field WITHOUT a space then I
have a problem, if there is a space it works sort of (it re-orders the
params)

this is the script in full (except user/pass info)
#!/usr/bin/perl -w
use warnings;
use CGI::Carp;
use CGI qw/:standard/;
print header;
print start_html(-title=Banking Input,-BGCOLOR='#FCD08C',);
use DBI;
;use DBD::Pg;
$dbh=DBI-connect(dbi:Pg:dbname=data_cc,$user,$pw);
$row1=$dbh-prepare(SELECT  date_paid,bank_inv,amount_paid, cheque ,
bk_date , bk_amt FROM vw_banking GROUP BY bank_inv,date_paid,
amount_paid,cheque,bk_date , bk_amt);
$row1-execute();
print start_multipart_form (POST,'bankchg.pl');
while (($date_paid,$bank_inv,$amount_paid,$cheque,$bk_date,$bk_amt1)=
$row1-fetchrow_array()){

print $date_paid,$bank_inv,$amount_paid, $cheque , $bk_date ,
$bk_amt,, br /;

print  Inv Id ,textfield('id'.$bank_inv,$bank_inv,10), amount ,
textfield('amount'.$bank_inv,$amount_paid,10),Bank date, textfield
('bk_date'.$bank_inv,$bk_date,10),Cheque ,textfield
('cheque'.$bank_inv,$cheque,20), 
print Banked,textfield(-name='bk amt'.$bank_inv,-value=$bk_amt1);
}
print submit();
print end_form;
print end_html;

this is the table structure

View public.vw_banking
   Column| Type  | Modifiers
-+---+---
 date_paid   | date  |
 bank_inv| integer   |
 amount_paid | numeric(10,2) |
 code| character varying(15) |
 sum | numeric   |
 cheque  | character varying(20) |
 bk_date | date  |
 bk_amt  | numeric(15,2) |


 --Dks
 

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




Passing httpd auth details to cgi-script

2004-06-24 Thread mike
Is it possible to pass user/password from apache auth to cgi-scripts.

To explain

I have apache set to authenticate using htpasswd, checking a file
in /etc/httpd

When users access the site they get a user/password prompt

This then leads to a bunch of cgi-scripts which access DBI::DBDpg

Is it possible to get the authentication details and pass them to the
scripts so they can be passed to postgres so PG can then authenticate
without further user input (pg is using md5 auth)

thanks fo any tips

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




Re: Using MIME::Lite to send mail/or attachments

2004-06-24 Thread mike
On Wed, 2004-06-23 at 10:22 -0700, jason corbett wrote:
 Can anyone tell me where I can find MIME::Lite or any other perl method to send 
 attachments/documents in mail format? If you have tips or scripts on using it to 
 send mail (documents attached), please let me know.
  
 Thanks,
 JC
 
try MIME::Entity - I find it nice

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




Testing for empty value

2004-08-05 Thread mike
I have the following code

print date times,@date,br;
if ($ti1){
print time 1 is not empty;
}
else {
print time 1 is empty;
}

If there is a value it works but not if there isn't ie:
if there is a value it prints time 1 is not empty, but if there is not
nothing comes out

anyone any ideas?

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




HELP! Reg-ex question

2003-06-27 Thread Mike
Given the following code snippet:
-

print $text\n;

my $text=sour red apples;
my $pattern=(sour);
my $replacement=very \$1;

$text=~s/$pattern/$replacement/;

print $text\n;
-

I was expecting very sour red apples to be printed, but instead I got 
very $1 red apples. I tried changing:

$text=~s/$pattern/$replacement/;

to

$text=~s/$pattern/$replacement/ee;

but that did not work either. How can I make it work, so that it was as if 
I had written:

$test=~s/$pattern/very $1/; # With the very $1 being extracted from the 
 #$replacement variable


Thanks



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: rearrange text

2003-08-30 Thread Mike
Well this is the final code I put together with everyones help from this 
group:

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

print Enter the path of the INFILE to be processed:\n;

chomp (my $infile = STDIN);

open(INFILE, $infile)
  or die Can't open INFILE for input: $!;

print Enter in the path of the OUTFILE:\n;

chomp (my $outfile = STDIN);

open(OUTFILE, $outfile)
  or die Can't open OUTFILE for input: $!;

print Enter in the LENGTH you want the sequence to be:\n;

chomp (my $len = STDIN);

my ($name, @seq);
while ( INFILE ) {
chomp;
unless ( /^\s*$/ or s/^\s*(.+)// ) {
$name = $1;   
my @char = ( split( // ), ( '-' ) x ( $len - length ) ); 
push @seq, ' '.@char   $name;
}
}

{
   local $ =\n;
   print OUTFILE R 1 [EMAIL PROTECTED]; # The top of the file is 
supposed
 
}

close INFILE;
close OUTFILE;



Basically it will take this file:

dog
atcgc
cat
atcgctac
mouse
agctata


and turn it into this:
R 1 10
 a t c g c - - - - -   dog
 a t c g c t a c - -   cat
 a g c t a t a - - -   mouse

However, I forgot that sometime the imput data is like this:

dog
agatgtagt
agtggttga
agggagc
cat
gcatcgatg
agcatatgc
mouse
actagcatc
acgtacgat

That is the sequence of letters can span multiple lines. I would like 
the above script to handle input data that can possibly span several 
lines as well as those that do not. and output as mentioned above.

You all have been much help! I have really learned a lot with the help 
you've given so far!

-Thanks!
-Mike



In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (David Wall) wrote:

 --On Monday, August 25, 2003 6:50 PM -0400 Mike Robeson 
 [EMAIL PROTECTED] wrote:
 
  OK, I feel like an idiot. When I initially asked for help with this I
  just realized that I forgot two little details. I was supposed to add
  the number of sequences as well as the length of the sequences at the
  top of the output file.
 
  That is this file:
 
  dog
  agatagatcgcatcga
  cat
  acgcttcgatacgctagctta
  mouse
  agatatacgggtt
 
  is relly supposed to be:
 
  3 22
  a g a t a g a t c g c a t c g a - - - - - -dog
  a c g c t t c g a t a c g c t a g c t t a -cat
  a g a t a t a c g g g t t - - - - - - - - -mouse
 
  The '3' represents the number of individual sequences in the file (i.e.
  dog, cat, mouse). And the 22 is the number of letters and dashes there
  are. The length is already in the script as $len. I am able to get the
  length listed at the top. However, I cannot find a way to have the
  number of sequences (the 3 in this case) printed to the top.
 
 Here's one way (slightly altering John's solution), but it will use lots of 
 memory if the sequences are long.
 
 
 #!/usr/bin/perl
 use warnings;
 use strict;
 
 my ($name, $num_seq, @seq);
 my $len = 30;
 while ( DATA ) {
 unless ( /^\s*$/ or s/^\s*(\S+)// ) {
 my $name = $1;
 my @char = ( /[acgt]/g, ( '-' ) x $len )[ 0 .. $len - 1 ];
 push @seq, @char$name;
 $num_seq++;
 }
 }
 {
 local $ =\n;
 print [EMAIL PROTECTED];
 }
 
 __DATA__
   dog
 agatagatcgcatcga
   cat
 acgcttcgatacgctagctta
   mouse
 agatatacgggt

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Perl and Jscript Question

2002-06-14 Thread Mike

Im working on an example from a book and incorperating perl script to a
scroll type program this is what I have for perl:


#!/usr/bin/perl

print Content-type: application/x-javascript\n\n;

print var result = new Array(;
use LWP::Simple;

$URL = get 'http://www.perl.org';

print $URL;
print \)\n;


On the web page in put:


SCRIPT LANGUAGE=JavaScript
src=http://www.mydomain.com/cgibin/myscript.pl;
!--
//--
/SCRIPT

SCRIPT LANGUAGE=JavaScript
!--
document.write(result)
//--
/SCRIPT

I get an error result no defined  I believe it is in teh perl code that
my error originates.

Thanks !

Mike


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




very confused - chdir not working

2002-10-10 Thread mike

Hi 
I am building the following script to recurse back and forth down a
directory tree

Unfortunatel chdir does not work

This is the script

#!/usr/bin/perl -ww
open(BLD_LIST,buildlist);
my @pkg=BLD_LIST;
my $ver=$ARGV[2];
my $name=$ARGV[0];
my $release=$ARGV[1];
foreach my $pkg (@pkg){
my $dir1=$pkg;
use Cwd;
my $dir2=getcwd();
my $dir3=$dir2/$dir1/;
chdir $dir3 or die cannot change;
my $dir4=getcwd();
print $dir3\n

the print shows the directory that I am trying to change to but chdir
just does not work
-- 
Linux, Gnome what more do you need
http://www.redtux.demon.co.uk

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: very confused - chdir not working

2002-10-10 Thread mike

On Fri, 2002-10-11 at 05:36, Michael Fowler wrote:
 On Fri, Oct 11, 2002 at 04:16:41AM +0100, mike wrote:
  Unfortunatel chdir does not work
 
 In what way doesn't it work?  Are you getting an error?  How are you
 verifying it doesn't work?

no errors but directory does not change
with use script and -ww all I get is my output from a die statement

  
  This is the script
  
  #!/usr/bin/perl -ww
  open(BLD_LIST,buildlist);
  my @pkg=BLD_LIST;
  my $ver=$ARGV[2];
  my $name=$ARGV[0];
  my $release=$ARGV[1];
  foreach my $pkg (@pkg){
  my $dir1=$pkg;
  use Cwd;
  my $dir2=getcwd();
  my $dir3=$dir2/$dir1/;
  chdir $dir3 or die cannot change;
  my $dir4=getcwd();
  print $dir3\n
 
 You're missing a close brace.  Is there more code?

yep - missed the copy

  the print shows the directory that I am trying to change to but chdir
  just does not work
 
 What do you see when you print $dir4?

the previous directory ie: not changed
 
 Michael
 --
 Administrator  www.shoebox.net
 Programmer, System Administrator   www.gallanttech.com
 --
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
-- 
Linux, Gnome what more do you need
http://www.redtux.demon.co.uk

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: very confused - chdir not working

2002-10-11 Thread mike

On Fri, 2002-10-11 at 09:14, Michael Fowler wrote:
 On Fri, Oct 11, 2002 at 06:50:00AM +0100, mike wrote:
  On Fri, 2002-10-11 at 05:36, Michael Fowler wrote:
   On Fri, Oct 11, 2002 at 04:16:41AM +0100, mike wrote:
Unfortunatel chdir does not work
   
   In what way doesn't it work?  Are you getting an error?  How are you
   verifying it doesn't work?
  
  no errors but directory does not change
  with use script and -ww all I get is my output from a die statement
 
 You get output from your die statement?  So, the script dies with the error
 cannot change on line ...?  If that's the case, that's an error; include
 $! in your die and that'll tell you why the chdir failed.
 
 Also, that's the second time you've used -ww, so I'm thinking it isn't a
 typo.  Only one -w is necessary.
 
  
   What do you see when you print $dir4?
  
  the previous directory ie: not changed
 
 Ok, this would imply the die is never being called, i.e. chdir never fails.
 
 So, let's clear this up; does your die ever get called?
 
Just to clarify - $dir4 only gets printed if I remove the die

When I add a print $dir3 it shows what it shows is this 

../build.pl
/root/cvs/esound # this the output of $dir3
/

cannot change No such file or directory at ./build.pl line 13,
BLD_LIST line 55.
this is ls in same directory, as you can see esound is there
[root@localhost cvs]# ls
atkesoundgnome-desktop gnome-vfs   
libglade librsvg
bonobo-activation  g2_build  gnome-icon-theme  gtk+
libgnome libwnck
build1.pl  g2buildlist   gnome-mime-data   gtk-doc 
libgnomecanvas   libxml2
buildlist  gail  gnome-panel   gtk-engines 
libgnomeprintlibxslt
buildlist1 glib  gnome-session intltool
libgnomeprintui  libzvt
build.pl   gnome-applets gnome-terminallibart_lgpl 
libgnomeui   linc
build.sh   gnome-common  gnome-themes  libbonobo   
libgtop  ORBit2
eelgnome-control-center  gnome-utils   libbonoboui 
libIDL   pango

 
 Michael
 --
 Administrator  www.shoebox.net
 Programmer, System Administrator   www.gallanttech.com
 --
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
-- 
Linux, Gnome what more do you need
http://www.redtux.demon.co.uk

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: very confused - chdir not working

2002-10-12 Thread mike

On Fri, 2002-10-11 at 23:08, Michael Fowler wrote:
 On Fri, Oct 11, 2002 at 04:40:30PM +0100, mike wrote:
  ../build.pl
  /root/cvs/esound # this the output of $dir3
  /
  
  cannot change No such file or directory at ./build.pl line 13,
  BLD_LIST line 55.
  this is ls in same directory, as you can see esound is there
 
 I don't have any context for what the three lines you output are.  The
 reason you can't chdir, though, is clear; now all you have to figure out is
 why you're getting an error.  I can assure you it's not because either Perl
 or the chdir function is broken, so it must be something else.
 
 Perhaps your current directory isn't what you think it is.  I'd suggest you
 make it more clear in your print; i.e. something along the lines of:
 
 print cwd: , getcwd(), , chdir to: $dir\n;
 chdir($dir) || die(Unable to chdir to directory \$dir\: \l$!.\n);
 
 That way you know where you are in the filesystem, and what you're trying to
 chdir to.

I have fixed the problem now, it turns out it was not a problem but one
of context with shell commands, by using system instead of backticks it
works 

thanks for help

for info - revised script (I wrote in bash in the end but just wanted to
work out why it wasn't working)

#!/usr/bin/perl -ww
open(BLD_LIST,buildlist);
my @pkg=BLD_LIST;
my $ver=$ARGV[2];
my $name=$ARGV[0];
my $release=$ARGV[1];
foreach my $pkg (@pkg){
my $dir1=$pkg;
$dir1=~chomp $dir1;
use Cwd;
$dir0=getcwd();
print $dir0\n;
chdir $dir1;
$dir2=getcwd();
print $dir2\n;
system './autogen.sh';
chdir $dir0;
$dir3=getcwd();
print $dir3\n;

}



 
 Michael
 --
 Administrator  www.shoebox.net
 Programmer, System Administrator   www.gallanttech.com
 --
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
-- 
Linux, Gnome what more do you need
http://www.redtux.demon.co.uk

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: DBI prepare syntax

2007-11-08 Thread Mike
That was a rookie mistake :). Double quotes works, thanks Beginner!

Beginner [EMAIL PROTECTED] wrote: On 8 Nov 2007 at 8:59, Mike wrote:

 Hi,

 
 #Update override_exclude set th_flag=N to indicate that thesaurus entries
 #have been added to sierra2_thesaurus.xml
 
 use DBI;
 my $dbh = DBI-connect(dbi:mysql:endeca_tracking,$user,$password);
 my $sth = $dbh-prepare('update override_exclude set th_flag=N 
 where pid=$pid') or die Couldn't prepare statement .$dbh-errstr;
 $sth-execute;

I'm no guru but shouldn't you be double quoting the prepare 
statement:

my $sth = $dbh-prepare(update override_exclude set th_flag='N' 
where pid=$pid)

or better still

my $sth = $dbh-prepare('update override_exclude set th_flag=N 
where pid=?)
$sth-execute($pid);

HTH,
Dp.


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




 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: DBI prepare syntax

2007-11-08 Thread Mike
Perl is Awsome!  Thanks for explaining that basic concept to me Douglas!

Douglas Hunter [EMAIL PROTECTED] wrote: Mike wrote:
 Hi,
 
 I have a variable setup as $pid and i've tried to call this in the prepare 
 part of the DBI module but  i'm  get an Unknown  column $pid syntax error. 
 Probably $pid was passed as a string instead of a variable inside the prepare 
 (''). Anyone has an idea of how i can fix this?   Thanks. 
 
 DBD::mysql::st execute failed: Unknown column '$pid' in 'where clause' at 
 createThesaurus.pl line 33,
 
 ---
 
 while (  ) {
 next if $. == 1;  # exclude header
 chomp;
 my ($pid,$thesaurus_from,$thesaurus_to,$thesaurus_type) = split /\|/;
 
 #Update override_exclude set th_flag=N to indicate that thesaurus entries
 #have been added to sierra2_thesaurus.xml
 
 use DBI;
 my $dbh = DBI-connect(dbi:mysql:endeca_tracking,$user,$password);
 my $sth = $dbh-prepare('update override_exclude set th_flag=N 
 where pid=$pid') or die Couldn't prepare statement .$dbh-errstr;

The prepare statement here is inside single quotes, inside of which Perl 
doesn't interpolate variables (it does inside double quotes).  But DBI 
has a mechanism called placeholders that allow you to not worry about 
quoting and interpolation of variables, documented under the section 
Placeholders and Bind Values in the DBI documentation.

You can change your prepare statement to:

$dbh-prepare('update override_exclude set th_flag=? where pid=?')

(the question marks denote the placeholder)


 $sth-execute;
 

And then change your execute to:

$sth-execute( N, $pid );

to pass along the list of values meant to take the place of your 
placeholders.  This is generally safer than passing variables directly 
to your prepare statement.  For instance, if $pid held a nasty string 
that terminated the original statement and then followed up with 
something destructive, such as 5; truncate table_foo;, bad things 
could happen.  With placeholders you don't have to worry about that, as 
the database driver fixes that up by quoting it properly (not to say you 
shouldn't still validate input to a database!)

Hope that helps a bit,

-- Douglas

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




 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

DBI prepare syntax

2007-11-08 Thread Mike
Hi,

I have a variable setup as $pid and i've tried to call this in the prepare part 
of the DBI module but  i'm  get an Unknown  column $pid syntax error. 
Probably $pid was passed as a string instead of a variable inside the prepare 
(''). Anyone has an idea of how i can fix this?   Thanks. 

DBD::mysql::st execute failed: Unknown column '$pid' in 'where clause' at 
createThesaurus.pl line 33,

---

while ( NEW ) {
next if $. == 1;  # exclude header
chomp;
my ($pid,$thesaurus_from,$thesaurus_to,$thesaurus_type) = split /\|/;

#Update override_exclude set th_flag=N to indicate that thesaurus entries
#have been added to sierra2_thesaurus.xml

use DBI;
my $dbh = DBI-connect(dbi:mysql:endeca_tracking,$user,$password);
my $sth = $dbh-prepare('update override_exclude set th_flag=N where 
pid=$pid') or die Couldn't prepare statement .$dbh-errstr;
$sth-execute;


 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Pass a wild card argument in Win32

2008-06-27 Thread Mike
I've searched google and much of this group to find the answer to this
problem with no luck.

I am able to pass regular arguments to perl but is it possible to get
the * operator to work like it does in Linux? Like typing in *.cpp to
pass perl all .cpp files.

I already fixed the issue getting the file type to open C:\perl\bin
\perl 1% %* but this doesnt seem to work with the wild card.

Thank you.


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




RE: extracting links from HTML data (7my own problem usiing grep

2002-01-16 Thread mike

On Wed, 2002-01-16 at 07:15, Gary Hawkins wrote:
  However the script continues
  print @list3;
  my $var1='META';
  @lista= grep{$var1} @list3;## not picked up at all
  print @lista
  
  anyone any clues
 
 Suppose I'm a little confused but perhaps you meant:
 
 print @list3;
 @lista= grep(/META/, @list3);
 print @lista;
 
 /g

thanks a lot

couple of points

this is basically a learning/getting rid of rustiness exercise
why is this syntax not mentioned in programming perl - any ideas?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Greedy 'split' ???

2002-01-16 Thread mike

On Thu, 2002-01-17 at 00:55, Michael Fowler wrote:
 On Wed, Jan 16, 2002 at 03:57:44PM -0800, Scott Lutz wrote:
  
  $DOM_NAME, my $TLD) = split(/\./, $domain);
  creates two variable out of an inputted domain name, 
  
  until this comes along:
  domainname.org.uk
  
  which it interprets as : 
  $DOM_NAME = domainname
  $TLD = org
  
  so is it possible to do a 'greedy split' ??
 
 Specifying a third argument to split would solve this problem how you want. 
 E.g.
 
 my $domain = domainname.org.uk;
 my($DOM_NAME, $TLD) = split(/\./, $domain, 2);
 
 $DOM_NAME eq 'domainname'
 $TLD  eq 'org.uk'
 
 However, unless you're guaranteed that the first portion of the name will be
 the domain, and the last portion will be the toplevel, this won't work in
 all situations.  Given the above, www.foo.org.uk would parse as 'www' and
 'foo.org.uk'.  The only solution to this problem would be to know what
 toplevels you can have and parse it based on that.

as an idea would using reverse on the string before split be an idea,
then reversing the spit strinngs + a join on $array[1],array[2] etc


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




question re mtiong email tags

2002-01-17 Thread mike

Hi I have been trying to set oup a script for munging html files

My problem is trying to match  tags in html which of course have
specific meanings in perl.

Does anyone hve any advice on this or know of a good resource (this is
something of a building up expertise in perl fundamentals so not
interseted in module references)

Bsically I just want to get some idea about escaping the sodding things



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Perl Help

2002-01-22 Thread Mike

I dont thing my ISP's News Server is working properly so I will thry it
from here.

I am trying to log the users IP via the web and nothing happens the date
nore the ip get there. Also if I put the append to the open statement I
get an error via the web also.  This is the code. I got it to show up
via the web but it never gets to the file.  Is there something I am
missing?

#!/usr/bin/perl

$logfile = '/usr/local/apache/logs/ipaccess.log';
$date = scalar localtime;

open(IPLOG, $logfile) || die Cannot open $logfile;
$ip = $ENV{'REMOTE_ADDR'};
print IPLOG $date;
print IPLOG $ip;
close IPLOG;


If I do it this way it errors out via the web:

#!/usr/bin/perl

$logfile = '/usr/local/apache/logs/ipaccess.log';
$date = scalar localtime;

open(IPLOG, $logfile) || die Cannot open $logfile;
$ip = $ENV{'REMOTE_ADDR'};
print IPLOG $date;
print IPLOG $ip;
close IPLOG;


Mike


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




LISTBOX Problem

2002-02-06 Thread Mike

I am trying to populate a list box in a form with using the following
script and it works fine doing it this way:

#!/usr/bin/perl

print Content-type: text/html\n\n;
print HTMLHEAD\n;
print TITLE Current Weather Products/TITLE\n;
print /HEAD\n;
print BODY\n;
#print select name=\select\\n;
print form name=\form\\n;
print select name=\radar\
onChange=\window.location=document.form.radar.options[document.form.radar.selectedIndex].value\\n;

print option value=\\Zone Forecasts/option\n;
chdir(/var/www/html/members/wx/zfp/) || die Cannot chdir to
/var/www/html/members/wx/zfp/ ($!);
while (*) {
print option
value=\http://www.myserver.com/members/wx/zfp/$_\;$_/option \n;
}
/select\n
/BODY\n
/HTML\n
END


Here is the problem. If I change it to this:


#!/usr/bin/perl
print Content-type: text/html\n\n;

printEND
HTMLHEAD
TITLE Current Weather Products/TITLE
/HEAD
BODY
form name=\form\
select name=\radar\
onChange=\window.location=document.form.radar.options[document.form.radar.selectedIndex].value\

option value=\\Zone Forecasts/option
END

chdir(/var/www/html/members/wx/zfp/) || die Cannot chdir to
/var/www/html/members/wx/zfp/ ($!);
while (*) {
print option
value=\http://www.myserver.com/members/wx/zfp/$_\;$_/option \n;
}

printEND
/select\n
/BODY\n
/HTML\n
END

It errors out Can someone help me with this?

syntax error at ./listfiles.pl line 13, near chdir
  (Might be a runaway multi-line  string starting on line 4)
BEGIN not safe after errors--compilation aborted at ./listfiles.pl line
14.


Thanks Mike



Execute perl Script

2002-02-06 Thread Mike

How do you execute a perlscript within a perl script via the web?

Mike


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Dates Perl SQL7

2002-02-20 Thread mike

On Wed, 2002-02-20 at 11:26, Mason, Andrew wrote:
 This is a concept question rather than a code question.
 
 I have a script which produces a simple report on some simple disk space
 stats for servers I work with.
 I thought it would be useful to put this information into a database on
 a daily basis.  This would allow me to then look at historic data.
 
 Currently I am inserting the date a character string.  I have learned
 that while I can do this I greatly limit my capabilities at the SQL end.
 SQL7 uses a number to represent date and time.  I am sure that Perl does
 (or at least) can also treat numbers like this.
 
 Can anyone suggest what commands (or even modules) I should look up,
 relating to dates and times and conversion between different formats (Ie
 useful ones for manipulation vs human recognisable ones).

From experience with SQL7 I would convert your character strings to iso
dates first ie:10/12/2001 to 20011210 then SQL7 will be able to handle
them

assuming date is dd/mm/

split /'/'/;
print $2$1$0

etc

then should be an easy import

(yes very quick and dirty)
 TAI
 
 rw
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Passing Arguments into a Program

2002-04-12 Thread Mike

If a program calls a perl script as follows:  /tmp/perltest.pl abc def ghi
jkl mno

Is there a variable which would contain the arguments?





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




input with the symbol

2002-04-12 Thread Mike

What happens if I call a perl script as follows:

test.pl  abc

What picks up the abc inside the script?  In shell scripting I would just
use a read statement (read a).  Is there a like function in perl?




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




split delimiters query

2005-02-02 Thread mike
Am I right in thinking that if you double quote the seperator in split
the seperator is added to the array ie:

@array3=split(/\t/,$value4); would add \t to the end of @array3 while

@array3=split(/\t/,$value4); would not

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




Re: split delimiters query

2005-02-02 Thread mike
On Wed, 2005-02-02 at 12:54 -0500, Jay wrote:
 On Wed, 02 Feb 2005 12:39:17 +, mike [EMAIL PROTECTED] wrote:
  Am I right in thinking that if you double quote the seperator in split
  the seperator is added to the array ie:
  
  @array3=split(/\t/,$value4); would add \t to the end of @array3 while
  
  @array3=split(/\t/,$value4); would not
  
 
 I think we need a little more information here, maybe a sample value
 for $value4.  Split, though, doesn't add anything; it removes the
 delimiter.  If you have:
 
  $value4 = one\ttwo\tthree\tfour\tfive ;
 
  @array3=split(/\t/, $value4) ;
 
 returns @array3 = [one, two, three, four, five]
 
 The delimiter is never included in the returned data.  If you
 questions is really what happens when there is a trailing delimiter,
 or an empty field in the data?, the answer is, trailing delimiters
 are ignored, otherwise empty strings are returned.  So if
 
  $value4 = \tone\t\ttwo\tthree\t\tfour\tfive\t ;
 
 then
 
  @array3 = [, one, , two, three, , four, five]
 
 If you need some other behavior, you need to constuct a more complex
 regex for split, but simple adding quotes doesn't change the behavior.
 
 HTH,
 

afraid it did in my case (screwed up a dba query, which is how I
noticed)

the code without quoting the delimiter works with no further changes,
this is on a fc3 box
 --jay
 

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




Re: split delimiters query

2005-02-02 Thread mike
On Wed, 2005-02-02 at 09:23 -0500, Wiggins d'Anconia wrote:
 mike wrote:
  Am I right in thinking that if you double quote the seperator in split
  the seperator is added to the array ie:
  
  @array3=split(/\t/,$value4); would add \t to the end of @array3 while
 
 As you have written it above I get a syntax error:
 
 String found where operator expected at ./test.pl line 12, at end of line
  (Missing semicolon on previous line?)
 Can't find string terminator '' anywhere before EOF at ./test.pl line 12.
 
 If you meant, C/\t/ then I still don't think you will get what you 
 want. Csplit just isn't that smart.
 

No the problem was that this ( with the quote in the right place) was
giving me what I didnt want.

this is the code
@value=param();
shift (@value);
shift (@value);
pop (@value);
print @value;
foreach $value (@value){
$value1=substr($value,0,9);
if ($value1 eq work_emai){
push (@value2,param($value));
push (@value2,\t);
#print $value2;
}
else {
push (@value2,param($value));
push (@value2,'##');
#print param($value)
}
}
$value4=join('',@value2);
print br,value4,$value4,br;
@array3=split(/\t/,$value4);
@[EMAIL PROTECTED];

with \t the \t was being inserted into a db field, without it
everything was hunky dory


  
  @array3=split(/\t/,$value4); would not
  
 
 What are you really trying to do?
 
 http://danconia.org
 

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




DBI problem

2005-02-09 Thread mike
I have the following query which works in psql

SELECT to_char('05 Feb 2005'::date,'-MM-DD')

However when I run it in DBI I get

$row6=$dbh-prepare(SELECT to_char('2005-02-05'::date,'-MM-DD'));
#$row6-bind_param(1,'2005-02-05');
$row6-execute();


Can't call method prepare on an undefined value at /home/www/cgi-
bin/times_upd_multi.pl line 46., referer: http://localhost/cgi-
bin/times_input_mult.pl

(I have tried various variations)

anyone any idea of a workaround?

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




CGI/DBI - Can anyone work out why this fails

2005-02-11 Thread mike
I have the following code

$cat1;
if ($cat1){
my $cat1=%$category%;
}
else {
$cat1=$category;
}

$row=$dbh-prepare(SELECT contact_id,first_name,last_name,organisation
FROM tb_contacts  WHERE (organisation ILIKE ? OR last_name ILIKE ?) OR
contact_id = ?);
$cat1;

print $cat1;
$row-bind_param(1,$cat1);
$row-bind_param(2,$cat1);
$row-bind_param(3,$cat1);
$row-execute();

this fails with 
 DBD::Pg::st execute failed: ERROR:  invalid input syntax for integer:
ford at /home/www/cgi-bin/con_role_add_sel2_org.pl line 33., referer:
http://localhost/cgi-bin/con_role_add_sel1.pl

It only fails if I have both the name and int WHERE Criteria - in psql
it works fine



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




RE: CGI/DBI - Can anyone work out why this fails

2005-02-14 Thread mike
On Fri, 2005-02-11 at 08:02 -0500, Bob Showalter wrote:
 mike wrote:
  I have the following code
  
  $cat1;
  if ($cat1){
  my $cat1=%$category%;
 
 The my here is scoped to this if { } block, so you aren't changing the
 outer $cat1
 
  }
  else {
  $cat1=$category;
  }
  
  $row=$dbh-prepare(SELECT
  contact_id,first_name,last_name,organisation FROM tb_contacts  WHERE
  (organisation ILIKE ? OR last_name ILIKE ?) OR contact_id = ?);
  $cat1;
  
  print $cat1;
  $row-bind_param(1,$cat1);
  $row-bind_param(2,$cat1);
  $row-bind_param(3,$cat1);
 
 Why are you binding $cat1 to param 3 (contact_id)?
 
  $row-execute();
  
  this fails with
   DBD::Pg::st execute failed: ERROR:  invalid input syntax for integer:
  ford at /home/www/cgi-bin/con_role_add_sel2_org.pl line 33.,
  referer: http://localhost/cgi-bin/con_role_add_sel1.pl
 
 I'm guessing that contact_id is a numeric column?
 
 Set DBI-trace(2) before the call to execute and you can see exactly what's
 being passed to the backend.
 
  

apologies this is the current state (which still fails the same way

$cat1=%$category%;

$catid1=$category;





$row=$dbh-prepare(SELECT contact_id,first_name,last_name,organisation
FROM tb_contacts  WHERE organisation ILIKE ? OR last_name ILIKE ? OR
contact_id IN (SELECT contact_id FROM tb_contacts WHERE
contact_id= ?));
#$cat1;

print $cat1;
$row-bind_param(1,$cat1);
$row-bind_param(2,$cat1);
$row-bind_param(3,$catid1);
$row-execute();

output is
SELECT contact_id,first_name,last_name,organisation FROM tb_contacts
WHERE organisation ILIKE  '%ford%' OR last_name ILIKE  '%ford%' OR
contact_id IN (SELECT contact_id FROM tb_contacts WHERE contact_id=
'ford')
ERROR:  invalid input syntax for integer: ford



  It only fails if I have both the name and int WHERE Criteria - in psql
  it works fine
 
 

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




CGI and sub question

2005-02-16 Thread mike
I have cgi script which works fine if I call another cgiscript.

However if I transfer it to runas a sub within the original script some
unwanted things happen

some variables dissapear
The script tries to run the run the sub on open, rather than after
submit.

After submitting, it is impossible to reload the original form (auth
errors)

anyone any ideas.

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




CGI and sub question

2005-02-16 Thread mike
I have cgi script which works fine if I call another cgiscript.

However if I transfer it to runas a sub within the original script some
unwanted things happen

some variables dissapear
The script tries to run the run the sub on open, rather than after
submit.

After submitting, it is impossible to reload the original form (auth
errors)

anyone any ideas.

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




Re: CGI and sub question

2005-02-16 Thread mike
On Wed, 2005-02-16 at 14:36 -0500, Chris Devers wrote:
 On Wed, 16 Feb 2005, mike wrote:
 
  [Does] anyone [have] any ideas[question-mark]
 
 Post the code.
 
 We cannot help you without being able to see the code in question.
  
 
 -- 
 Chris Devers
 


Here it is


#!/usr/bin/perl -ww
use CGI qw/:standard/;
use DBI;

print header;
print start_html(-title=Timesheet,-BGCOLOR='#FCD08C',);
print h1(Type in details of times worked and adjustments);

print br,br,br;

my $user=param('user');
my $pw=param('pass');

my $year=param('year1');
my $month1=param('mon1');
my $date1=param('date1');

if($month1  '10'){
$month2=substr($month1,1,1)}
else{
$month2=$month1
};
$monthsel=$year$month2;
$dbh=DBI-connect(dbi:Pg:dbname=data_cc,$user,$pw);
$sth=$dbh-prepare(q{INSERT INTO tb_times
(date,user1,adj,ti1,ti2,to1,to2,ei,eo,adj_am2,adj_am) SELECT DISTINCT
date1,?,'W','00:00'::time,'00:00'::time,'00:00'::time,'00:00'::time,'00:00'::time,'00:00'::time,
 '00:00'::time, '00:00'::time FROM tb_cal WHERE (?||date1||'W') NOT IN (SELECT 
(user1||date||'W') FROM tb_times)  AND 
date_part('year',date1)||date_part('month',date1)=?});
$sth-bind_param(1,$user);
$sth-bind_param(2,$user);

$sth-bind_param(3,$monthsel);
$sth-execute();
#$row3=$dbh-prepare(SELECT typeabsence FROM lk_absence ORDER BY
typeabsence);

print start_multipart_form (POST,update);

$dbh=DBI-connect(dbi:Pg:dbname=data_cc,$user,$pw);
$row1=$dbh-prepare(SELECT date1,ti1 ,to1,ti2,to2,adj,ei,eo,CASE WHEN
date1 = left(now(),'10') THEN flex_ours ELSE' 00:00:00' END,CASE WHEN
date1 = left(now(),'10') THEN flex_bal ELSE' 00:00:00'
END ,lieu,to_char(date1::date,'Dy'), to_char(date1::date,'DD Mon
'),date1||adj,adj,adj_am,adj_am2 FROM vw_times_list1 WHERE (user1||
date_part('year',date1)||date_part('mon',date1)) = ? ORDER BY date1);
$row1-bind_param(1,$date3);
$row1-execute();

print table border = 1,th,day,td,Date,td,Time In,td,Break
Start,td,Break End,td,Time Out,td,Evening In,td,Evening
Out,td,flex hours,td,flex bal,td,lieu,td,adjustment,td,lieu
adjustment,td,type;

while (($days,$ti1,$to1,$ti2,$to2,$adj,$ei,$eo,$flex,$flex_bal,$lieu,
$dayname,$date_pretty,$key1,$adj,$adj_am1,$adj_am2)= $row1-
fetchrow_array()) {

$row3=$dbh-prepare(SELECT typeabsence FROM lk_absence ORDER BY
typeabsence);
$row3-execute();
@absence;
while (($abtype)= $row3-fetchrow_array()) {
push (@absence,$abtype)
}
@times= ($ti1,$to1,$ti2,$to2,$adj,$days,$ei,$eo,$flex,$flex_bal,$lieu,
$date_pretty,$key1,$adj,$adj_am1,$adj_am2);

$days1=$days;

print Tr;
print td,$dayname;

print hidden(-name='day'.$key1,-default=$days1);
print td,textfield(-name='dayp'.$key1,-size='9',-maxlength='12',-
default=$date_pretty);

default=$days);
default=$month2);

print td,textfield(-name='ti1'.$key1,-size='6',-maxlength='12',-
default=$times[0]);
print td,textfield(-name='to1'.$key1,-size='6',-maxlength='12',-
default=$times[1]);
print td,textfield(-name='ti2'.$key1,-size='6',-maxlength='12',-
default=$times[2]),br;
print td,textfield(-name='to2'.$key1,-size='6',-maxlength='12',-
default=$times[3]);
print td,textfield(-name='e1'.$key1,-size='6',-maxlength='12',-
default=$times[6]);

print td,textfield(-name='e2'.$key1,-size='6',-maxlength='10',-
default=$times[7]);
print td,textfield(-name='flex'.$key1,-size='6',-maxlength='12',-
default=$times[8],-style='Color:White;background: red');
print td,textfield(-name='bal'.$key1,-size='6',-maxlength='12',-
default=$times[9],-style='Color:white;background: red');

print td,textfield(-name='lieu'.$key1,-size='6',-maxlength='10',-
default=$times[10],-style='Color:white;background: red');
print td,textfield(-name='adjam1'.$key1,-size='6',-maxlength='10',-
default=$adj_am1);
print td,textfield(-name='adjam2'.$key1,-size='6',-maxlength='10',-
default=$adj_am2);
print td,popup_menu(-name='adjt'.$key1,-values=[EMAIL PROTECTED],-
default=$adj);

($wkday,$month,$day,$time,$year)=split(/\s+/,localtime);

}
print /table;

print hidden ('user',$user);
print hidden ('pass',$pw);
print p,submit(-name='Save Changes',-style='background:red;
Color:white;border-style:radius;border-size:5');
print end_form,p,p,p,p;
print end_html;



sub update {
$user=param('user');
$pw=param('pw');

@value=param();

$dbh=DBI-connect(dbi:Pg:dbname=data_cc,$user,$pw);

print $monthsel;


pop @value;
pop @value;

pop @value;

#print @value,br;
@value2;
foreach $value (@value){
$value1=substr($value,0,5);
if ($value1 eq adjt2){

push (@value2,param($value));
push (@value2,'~');

}
else {
push (@value2,param($value));
push (@value2,'#');

}
}
$value4=join('',@value2);

@array3=split(/~/,$value4);
$adj_date=param('adj_date');
foreach $array3(@array3){


@times1=split(/#/,$array3);
$row7=$dbh-prepare(SELECT DISTINCT to_char(date::date,'-MM-DD')
FROM tb_times WHERE to_char(date::date,'DD Mon ') = ?);
$row7-bind_param(1,$adj_date);
$row7-execute();
while (($adj_date1)=$row7-fetchrow_array()) {
$adj_date2=$adj_date1;
}

$date;
$date=$times1[0];
$ti1=$times1[2];
$to2=$times1[5];
$to1=$times1[3];
$ti2=$times1[4

DBI query

2005-03-15 Thread mike
Anyone got any any idea what is happening here

$dbh=DBI-connect(dbi:Pg:dbname=data_cc,$user,$pw);
$dump_dir='/home/data_cc/dump';
@names=$dbh-tables();
#$dbh-execute;
#print @names;
foreach $names(@names){
if (substr($names,0,9) eq public.tb)
{
$file1= $dump_dir\/$names;
$dbh-prepare(COPY $names TO ? WITH DELIMITER AS #);
$dbh-bind_param(1,$file1);
$dbh-execute();
}
}

results in output


[Mon Mar 14 17:30:10 2005] [error] [client 127.0.0.1] Can't locate
object method bind_param via package DBI::db at /home/www/cgi-
bin/dump_all.pl line 25.

confused - it seems to be losing the connection to the db


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




DBI query

2005-03-15 Thread mike
Anyone got any any idea what is happening here

$dbh=DBI-connect(dbi:Pg:dbname=data_cc,$user,$pw);
$dump_dir='/home/data_cc/dump';
@names=$dbh-tables();
#$dbh-execute;
#print @names;
foreach $names(@names){
if (substr($names,0,9) eq public.tb)
{
$file1= $dump_dir\/$names;
$dbh-prepare(COPY $names TO ? WITH DELIMITER AS #);
$dbh-bind_param(1,$file1);
$dbh-execute();
}
}

results in output


[Mon Mar 14 17:30:10 2005] [error] [client 127.0.0.1] Can't locate
object method bind_param via package DBI::db at /home/www/cgi-
bin/dump_all.pl line 25.

confused - it seems to be losing the connection to the db


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




Problem with DBD-Pg

2005-05-17 Thread mike
Since upgrading to FC4-test3 which has version 1.4.1 of DBD-Pg
installed, placeholders no longer work for example the following code

 $cat='1';
#$cat=param('Category');
print $cat;
print start_multipart_form (POST,'con_upd.pl');
$row=$dbh-prepare(SELECT type_code FROM lk_sort_of_contact WHERE description 
= ?);
$row-bind_param(1,$cat);
$row-execute();

results in
DBD::Pg::st execute failed: ERROR:  syntax error at or near $1 at character 1
DBD::Pg::st fetchrow_array failed: no statement executing
Use of uninitialized value in print at /home/www/cgi-bin/con_by_role_sel2.pl 
line 22.

anyone any ideas what is happening here?


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




Help with a perl script to parse and email

2007-06-13 Thread Mike
I'm a perl newbie and need help with writing a script to do the
following:

1)  Open a file that is delimited.  The file is in this format:
   name;email address1;user1;user2;userX;
The delimiters can be changed.  This is a manually created file.
Email and user may be more than one item.

2)  Send an email  to email address using the file from #1.  The
email should be like

To name

Please verify that the following users are still under your
supervision by date:
user1
user2
userX

Thank you.

3) For calculating the date, I've used the below and added 14 days
(1209600 seconds):

@Weekdays = ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
'Friday', 'Saturday');
@Months = ('January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December');
@Now = localtime(time + 1209600);  # adding the number of seconds in a
day (86400) and multiplying for 14 days
$Month = $Months[$Now[4]];
$Weekday = $Weekdays[$Now[6]];
$Hour = $Now[2];
if ($Hour  12) {
   $Hour = $Hour - 12;
   $AMPM = PM;
} else {
   $Hour = 12 if $Hour == 0;
   $AMPM =AM;
}
$Minute = $Now[1];
$Minute = 0$Minute if $Minute  10;
$Year = $Now[5]+1900;
$Expire = $Weekday, $Month $Now[3], $Year;


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




Re: [NEWBIE-Question] Processing Menus

2001-11-01 Thread Mike

I am using cgi-lib.pl this is the script that I am using.

#!/usr/bin/perl

#location to your log file.
$logfile = /usr/local/apache/cgi-bin/log/logfile.log;


#location of our sendmail program.
$mailprog = /usr/sbin/sendmail;

#path to cgi-lib.pl.
$library = /usr/local/apache/cgi-bin;

require $library/cgi-lib.pl;

ReadParse;

# Print the http header
print Content-type: text/html\n\n;

# Send the user a thank you
print html\n;
print head\n;
print titleThank you!/title\n;
print /head\n;
print body\n;
print pThanks $in{'email'}br\n;
print Category $in{'category'}\n;
print URL: $in{'url'}\n;
print Description: $in{'description'}\n;
print I'll inform you when your link has been added\n;
print /p/body/html\n;

# Open the log file and write the data
open(FILE, $logfile) || die I can't open $logfile\n;
print FILE Someone requested a link addition\n;
print FILE Category $in{'category'}\n;
print FILE E-mail $in{'email'}\n;
print FILE URL $in{'url'}\n;
print FILE Description $in{'description'}\n;
print FILE \n;
close(FILE);

# Open the sendmail program and pipe the data
open(MAIL, | $mailprog -t) || die I can't open $mailprog\n;
print MAIL To: webmster webmaster\@yourname.com\n;
print MAIL From: $in{'email'}\n;
print MAIL Subject: Link Request\n;
print MAIL Someone requests a link addition\n;
print MAIL Category: $in{'category'}\n;
print MAIL URL: $in{'url'}\n;
print MAIL Description: $in{'description'}\n;
close(MAIL);


Thanks again

Mike

Etienne Marcotte wrote:

 The CGI (or other parsing sub) reads the data selected from the drop
 down, which is in the value part of each option tag.

 select name=dropdown
 option value=1option 1/option
 option value=2option 2/option
 option value=3option 3/option
 /select

 then in your param{'dropdown'}you should have 1, 2 or 3 depending on the
 option that he choose.

 What are you using to parse the data? CGI.pm ? That is probably causing
 the problem because your html seems right

 Etienne

 Bogus email wrote:

  Sorry bout that... I do mean select drop-downs from HTML. What I
  want to
  do is have it email me all the info, which it does email me.
  Everything but
  the dropdown menu information.  see attached.
 
  Thanks again...
 
  Mike
 
 
 
  Curtis Poe [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   --- [EMAIL PROTECTED] wrote:
Hello all,
   
I am trying to process a menu option but for some reason perl
  causes the
value to come up blank can anyone help? This is only hapening on
  the
  menu
items.
   
Is there a trick to sending drop down menus?
   
TNX,
   
Mike
  
   Mike,
  
   What do you mean by menu?  Are you referring to Perl::Tk menus?
  Win32::Gui?  Perhaps you mean
   select drop-downs from HTML?  Can you post some sample code?  We
  need a
  lot more information
   before we can help you.
  
   Show us what you have.  Tell us what you expect.  Tell us what you
  are
  actually getting.  That's
   usually a good start.
  
   Cheers,
   Curtis Ovid Poe
  
   =
   Senior Programmer
   Onsite! Technology (http://www.onsitetech.com/)
   Ovid on http://www.perlmonks.org/
  
   __
   Do You Yahoo!?
   Make a great connection at Yahoo! Personals.
   http://personals.yahoo.com
 
 
 
 
  [Add your link]
  [ Home ] [ Up ]
 
   --

   Category:  URL:

   Email:

   (Note: Your email will only be used to notify you when your link
   has been added.)

 
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: [NEWBIE-Question] Processing Menus

2001-11-01 Thread Mike

I am using cgi-lib.pl this is the script that I am using.

#!/usr/bin/perl

#location to your log file.
$logfile = /usr/local/apache/cgi-bin/log/logfile.log;


#location of our sendmail program.
$mailprog = /usr/sbin/sendmail;

#path to cgi-lib.pl.
$library = /usr/local/apache/cgi-bin;

require $library/cgi-lib.pl;

ReadParse;

# Print the http header
print Content-type: text/html\n\n;

# Send the user a thank you
print html\n;
print head\n;
print titleThank you!/title\n;
print /head\n;
print body\n;
print pThanks $in{'email'}br\n;
print Category $in{'category'}\n;
print URL: $in{'url'}\n;
print Description: $in{'description'}\n;
print I'll inform you when your link has been added\n;
print /p/body/html\n;

# Open the log file and write the data
open(FILE, $logfile) || die I can't open $logfile\n;
print FILE Someone requested a link addition\n;
print FILE Category $in{'category'}\n;
print FILE E-mail $in{'email'}\n;
print FILE URL $in{'url'}\n;
print FILE Description $in{'description'}\n;
print FILE \n;
close(FILE);

# Open the sendmail program and pipe the data
open(MAIL, | $mailprog -t) || die I can't open $mailprog\n;
print MAIL To: webmster webmaster\@yourname.com\n;
print MAIL From: $in{'email'}\n;
print MAIL Subject: Link Request\n;
print MAIL Someone requests a link addition\n;
print MAIL Category: $in{'category'}\n;
print MAIL URL: $in{'url'}\n;
print MAIL Description: $in{'description'}\n;
close(MAIL);


Thanks again

Mike

Etienne Marcotte wrote:

 The CGI (or other parsing sub) reads the data selected from the drop
 down, which is in the value part of each option tag.

 select name=dropdown
 option value=1option 1/option
 option value=2option 2/option
 option value=3option 3/option
 /select

 then in your param{'dropdown'}you should have 1, 2 or 3 depending on the
 option that he choose.

 What are you using to parse the data? CGI.pm ? That is probably causing
 the problem because your html seems right

 Etienne

 Bogus email wrote:

  Sorry bout that... I do mean select drop-downs from HTML. What I
  want to
  do is have it email me all the info, which it does email me.
  Everything but
  the dropdown menu information.  see attached.
 
  Thanks again...
 
  Mike
 
 
 
  Curtis Poe [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   --- [EMAIL PROTECTED] wrote:
Hello all,
   
I am trying to process a menu option but for some reason perl
  causes the
value to come up blank can anyone help? This is only hapening on
  the
  menu
items.
   
Is there a trick to sending drop down menus?
   
TNX,
   
Mike
  
   Mike,
  
   What do you mean by menu?  Are you referring to Perl::Tk menus?
  Win32::Gui?  Perhaps you mean
   select drop-downs from HTML?  Can you post some sample code?  We
  need a
  lot more information
   before we can help you.
  
   Show us what you have.  Tell us what you expect.  Tell us what you
  are
  actually getting.  That's
   usually a good start.
  
   Cheers,
   Curtis Ovid Poe
  
   =
   Senior Programmer
   Onsite! Technology (http://www.onsitetech.com/)
   Ovid on http://www.perlmonks.org/
  
   __
   Do You Yahoo!?
   Make a great connection at Yahoo! Personals.
   http://personals.yahoo.com
 
 
 
 
  [Add your link]
  [ Home ] [ Up ]
 
   --

   Category:  URL:

   Email:

   (Note: Your email will only be used to notify you when your link
   has been added.)

 
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: [NEWBIE-Question] Processing Menus

2001-11-01 Thread Mike

I am using cgi-lib.pl this is the script that I am using.

#!/usr/bin/perl

#location to your log file.
$logfile = /usr/local/apache/cgi-bin/log/logfile.log;


#location of our sendmail program.
$mailprog = /usr/sbin/sendmail;

#path to cgi-lib.pl.
$library = /usr/local/apache/cgi-bin;

require $library/cgi-lib.pl;

ReadParse;

# Print the http header
print Content-type: text/html\n\n;

# Send the user a thank you
print html\n;
print head\n;
print titleThank you!/title\n;
print /head\n;
print body\n;
print pThanks $in{'email'}br\n;
print Category $in{'category'}\n;
print URL: $in{'url'}\n;
print Description: $in{'description'}\n;
print I'll inform you when your link has been added\n;
print /p/body/html\n;

# Open the log file and write the data
open(FILE, $logfile) || die I can't open $logfile\n;
print FILE Someone requested a link addition\n;
print FILE Category $in{'category'}\n;
print FILE E-mail $in{'email'}\n;
print FILE URL $in{'url'}\n;
print FILE Description $in{'description'}\n;
print FILE \n;
close(FILE);

# Open the sendmail program and pipe the data
open(MAIL, | $mailprog -t) || die I can't open $mailprog\n;
print MAIL To: webmster webmaster\@yourname.com\n;
print MAIL From: $in{'email'}\n;
print MAIL Subject: Link Request\n;
print MAIL Someone requests a link addition\n;
print MAIL Category: $in{'category'}\n;
print MAIL URL: $in{'url'}\n;
print MAIL Description: $in{'description'}\n;
close(MAIL);


Thanks again

Mike

Etienne Marcotte wrote:

 The CGI (or other parsing sub) reads the data selected from the drop
 down, which is in the value part of each option tag.

 select name=dropdown
 option value=1option 1/option
 option value=2option 2/option
 option value=3option 3/option
 /select

 then in your param{'dropdown'}you should have 1, 2 or 3 depending on the
 option that he choose.

 What are you using to parse the data? CGI.pm ? That is probably causing
 the problem because your html seems right

 Etienne

 Bogus email wrote:

  Sorry bout that... I do mean select drop-downs from HTML. What I
  want to
  do is have it email me all the info, which it does email me.
  Everything but
  the dropdown menu information.  see attached.
 
  Thanks again...
 
  Mike
 
 
 
  Curtis Poe [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   --- [EMAIL PROTECTED] wrote:
Hello all,
   
I am trying to process a menu option but for some reason perl
  causes the
value to come up blank can anyone help? This is only hapening on
  the
  menu
items.
   
Is there a trick to sending drop down menus?
   
TNX,
   
Mike
  
   Mike,
  
   What do you mean by menu?  Are you referring to Perl::Tk menus?
  Win32::Gui?  Perhaps you mean
   select drop-downs from HTML?  Can you post some sample code?  We
  need a
  lot more information
   before we can help you.
  
   Show us what you have.  Tell us what you expect.  Tell us what you
  are
  actually getting.  That's
   usually a good start.
  
   Cheers,
   Curtis Ovid Poe
  
   =
   Senior Programmer
   Onsite! Technology (http://www.onsitetech.com/)
   Ovid on http://www.perlmonks.org/
  
   __
   Do You Yahoo!?
   Make a great connection at Yahoo! Personals.
   http://personals.yahoo.com
 
 
 
 
  [Add your link]
  [ Home ] [ Up ]
 
   --

   Category:  URL:

   Email:

   (Note: Your email will only be used to notify you when your link
   has been added.)

 
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: me@me.com mail error

2001-11-01 Thread Mike

How is that?
Etienne Marcotte [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 From:
 Mail Delivery Subsystem [EMAIL PROTECTED]
  Subject:
 Returned mail: Host unknown (Name server: me.com: no data known)

  To:
 [EMAIL PROTECTED]

 The original message was received at Thu, 1 Nov 2001 13:06:15 -0500
 (EST)
 from uucp@localhost

- The following addresses had permanent fatal errors -
 [EMAIL PROTECTED]

- Transcript of session follows -
 550 [EMAIL PROTECTED]... Host unknown (Name server: me.com: no data known)

 Reporting-MTA: dns; itlf10.itl.ca
 Arrival-Date: Thu, 1 Nov 2001 13:06:15 -0500 (EST)

 Final-Recipient: rfc822; [EMAIL PROTECTED]
 Action: failed
 Status: 5.1.2
 Remote-MTA: dns; me.com
 Last-Attempt-Date: Thu, 1 Nov 2001 13:06:15 -0500 (EST)

 

 Can you correct this?

 Etienne




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




NET::FTP

2001-12-17 Thread Mike

Is there a way to use NET::FTP to only download files if they are
current day? If not can it be done another way?

Thanks!
Mike


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: :FTP

2001-12-17 Thread Mike


THANKS!
John Edwards wrote:

 Take a look at the Net::FTP docs. There's a function in the module called
 mdtm which returns the modified timestamp of the remote file. Query that,
 then download if it matches your criteria.

 HTH

 John

 -Original Message-
 From: Mike [mailto:[EMAIL PROTECTED]]
 Sent: 17 December 2001 13:39
 To: [EMAIL PROTECTED]
 Subject: NET::FTP

 Is there a way to use NET::FTP to only download files if they are
 current day? If not can it be done another way?

 Thanks!
 Mike

 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

 --Confidentiality--.
 This E-mail is confidential.  It should not be read, copied, disclosed or
 used by any person other than the intended recipient.  Unauthorised use,
 disclosure or copying by whatever medium is strictly prohibited and may be
 unlawful.  If you have received this E-mail in error please contact the
 sender immediately and delete the E-mail from your system.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Get the first 10 characters.

2001-12-17 Thread Mike

How do I get the first 10 characters of a string?

Mike


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




problem with Multipart module

2004-02-10 Thread mike
I am trying to use the Net::SMTP::Multipart to send attachments (word
doc) and the encoding is getting mangled on non-linux machines

If I send it to myself everything is fine (either external or via my
mail server)

this appears to the relevant part of the modules

sub FileAttach {
my $self = shift;
foreach my $file (@_) {
  unless (-f $file) {
carp 'Net::SMTP::Multipart:FileAttach: unable to find file
$file';
next;
  }
  my($bytesread,$buffer,$data,$total);
  open(FH,$file) || carp Net::SMTP::Multipart:FileAttach: failed
to open $file\n;
  binmode(FH);
  while ( ($bytesread=sysread(FH,$buffer, 1024))==1024 ){
$total += $bytesread;
# 500K Limit on Upload Images to prevent buffer overflow
#if (($total/1024)  500){
#  printf TooBig %s\n,$total/1024;
#  $toobig = 1;
#  last;
#}
$data .= $buffer;
  }
  if ($bytesread) {
$data .= $buffer;
$total += $bytesread ;
  }
  #print File Size: $total bytes\n;
  close FH;

  if ($data){
$self-datasend(--$b\n);
$self-datasend(Content-Type: ; name=\$file\\n);
$self-datasend(Content-Transfer-Encoding: base64\n);
$self-datasend(Content-Disposition: attachment; =filename=
\$file\\n\n);
$self-datasend(encode_base64($data));
$self-datasend(--$b\n);
  }
}
}
and this my script

$smtp-Header(
To = $mailing1[2],
Subj = Management Meeting,
From = [EMAIL PROTECTED],
From = [EMAIL PROTECTED]);

$smtp-Text(text);
$smtp-FileAttach (doc_file.doc);
$smtp-End();

any help appreciated

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




Dufus question about form-fields and colour

2004-03-22 Thread mike
Does anyone know if it is possible to give a color attribute to form
field?

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




nested while loops using DBI

2004-03-22 Thread mike
I am trying to get the detail records to appear on a form underneath the
header records with a db lookup

Code

$row=$dbh-prepare(SELECT contact_id,first_name,last_name,organisation
FROM tb_contacts  WHERE organisation ILIKE ?);
my $cat1=%$category%;
$row-bind_param(1,$cat1);
$row-execute();
print start_multipart_form (POST);
while(($id,$first_name,$last_name,$organisation) = $row-fetchrow_array
()) {


print Id,textfield('id'.$id,$id);
print firstname, textfield('first_name'.$id,$first_name);
print last_name,textfield('last_name'.$id,$last_name);
print organisation,textfield('organisation'.$id,$organisation);
print br /;
print br /;
[EMAIL PROTECTED]();
#print @par1;
#foreach $par1(@par1){
#print $par1;
#}

print start_multipart_form (POST);
$row=$dbh-prepare(SELECT id,contact_id,type_of_contact,priority FROM
tb_contact_role  WHERE contact_id ILIKE ?);
my $idsel=$id;
#print $id;
$row-bind_param(1,$idsel);
$row-execute();
while(($id1,$contact_id1,$type,$priority) = $row-fetchrow_array()) {
#print $id1,$contact_id1,$type,$priority;
print Id,textfield('id1'.$id1,$id1);
print firstname, textfield('contact_id'.$id1,$contact_id1);
print last_name,textfield('type'.$id1,$type);
print organisation,textfield('priority'.$id1,$priority);}




}
print Choose Id,textfield('id2','0');
print br /;
print BR /;
print submit;
print end_form;

This only produces on record at the top-level, if I dont have the select
inside the loop, then all matching records appear

Anyone any idea where I am going wrong

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




RE: nested while loops using DBI

2004-03-23 Thread mike
On Mon, 2004-03-22 at 18:04, Guay Jean-Sbastien wrote:
 Hello Mike,
 
  $row=$dbh-prepare(SELECT contact_id,first_name,last_name,organisation
  FROM tb_contacts  WHERE organisation ILIKE ?);
 
 [...]
 
  while(($id,$first_name,$last_name,$organisation) = $row-fetchrow_array())
 {
 
 [...]
 
  $row=$dbh-prepare(SELECT id,contact_id,type_of_contact,priority FROM
  tb_contact_role  WHERE contact_id ILIKE ?);
 
 [...]
 
 }
 
 [...]
 
  This only produces on record at the top-level, if I dont have the select
  inside the loop, then all matching records appear
  
  Anyone any idea where I am going wrong
 
 You are using the same variable as the statement handle for both queries
 ($row). In effect, since your second SELECT probably returns only one row
 (probably the detail of the contact you got in the first SELECT), the
 enclosing while ends afterwards because there are no more rows to get from
 that statement handle (the second SELECT).
 

Yeah I worked this out just after I posted.

 I would suggest you declare a new variable inside your while, say $contact.
 Something like this:
 
 my $contact = $dbh-prepare(qq[SELECT id, contact_id, type_of_contact,
 priority 
  FROM tb_contact_role 
 WHERE contact_id ILIKE ?]);
 
 I also suggest better indentation and whitespace usage in your code. That
 will get very hard to read very fast...
 
 Hope that helps,
 
 J-S

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




Confused

2004-03-24 Thread mike
I am trying to get rid of a blank line at the start of a text file, and
I dont understand why this does not work

open(UPD1,tem);# this file exists
my @update1=UPD1;
foreach $update1(@update1){

$update1=~s/^(\n)//;
$update1=~chomp;
my @update2=split /#/,$update1;# this bit works

But I still get a blank line at the start
ie
print $contact_id,br;# name give to first field
gives

blank line
233
234
235
236
237
238

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




Question about cgi forms (slightly OT)

2004-03-25 Thread mike
I am developing a cgi/DBI app which is nearly finished

I have this one question

The scenario

I have a cgi generated form on a web-page, it consists of several
records defined by a DB lookup.

When I do Search in the web-browser, is there any way to get it to
search the values in the fileds of the form?

Currently all the values show up, but they dont seem to appear to be in
scope for searching

thanks for any tips (and apologies for vaguely OT)

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




Re: Confused

2004-03-25 Thread mike
On Wed, 2004-03-24 at 14:19, James Edward Gray II wrote:
 On Mar 24, 2004, at 7:59 AM, WC -Sx- Jones wrote:
 
  while(UPD1) {
  chomp; s/^\s+//; s/\s+$//; next unless length;
 
 There's probably not much reason to chomp() and s/\s+$//, since the 
 later handles both.
 
 James
 

Thanks for all assistance

This worked 
s/\s+$/;

One question will this only take out blank lines?
eg: if I have this line
anytext tabe space newline
will the non-printing characters be removed and the text be added to the
beginning of the next line?

thanks

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




Re: Question about cgi forms (slightly OT)

2004-03-25 Thread mike
On Thu, 2004-03-25 at 13:18, WC -Sx- Jones wrote:
 mike wrote:
 
  When I do Search in the web-browser, is there any way to get it to
  search the values in the fileds of the form?
  
  Currently all the values show up, but they dont seem to appear to be in
  scope for searching
 
 
 Show some code -- likely your logic is wrong -- if using CGI module
 then capture all params in a single arrary, or hash, then walk
 thru the data.
 
 If you normalize the CGI input to a sane value (IE, make string zero 
 numeric 0 and undefined input as empty strings) you can control
 the order they are placed into the array then you can use array
 index to make sure you are looking at the right array to CGI
 input values.
 
 HTH
 

dont think I was clear enough

this creates the form

print start_multipart_form (POST,'con_role_upd.pl');
print Choose Id,textfield('id2','0');
print br /;
print BR /;
[EMAIL PROTECTED]();
#print @value;
$row1=$dbh-prepare(SELECT
tb_contact_role.id,contact_id,type_of_contact,description,priority FROM
tb_contact_role LEFT JOIN lk_sort_of_contact ON
type_of_contact=type_code WHERE contact_id ILIKE ?);
my $idsel=$id;
$row1-bind_param(1,$idsel);
$row1-execute();
while(($id1,$contact_id1,$type_id,$type,$priority) =
$row1-fetchrow_array()) {
#print $id1,$contact_id1,$type,$priority;
print font {-style='background-color: #F8FC8C;color: blue'};
print Roles for Contact;
print end_font;
print p;
print font {-style='background-color: white;color: blue'};
print Role
ID,textfield(-name='id1'.$id1,-value=$id1,-style='background-color:
#C59E65;color: white');
print Role
ID,textfield(-name='type_id1'.$id1,-value=$type_id,-style='background-color: 
#C59E65;color: white');
print Type of
Contact,textfield(-name='type'.$id1,-value=$type,-style='background-color: 
#C59E65;color: white');
print
priority,textfield(-name='priority'.$id1,-value=$priority,-style='background-color:
 #C59E65;color: white')};
print br;
print br;
print br;
}
print submit;
print end_form;

This results in a html page of forms which is populated, I can tab
through the fields, edit etc, but if I do a control F for instance, the
values in the fields are not found.

What I would like is for users to be able to search for a value and then
go tothat record



 -- 
 _Sx_ http://youve-reached-the.endoftheinternet.org/ _
 perldoc -qa.a | perl -lpe '($_)=m((.*))' | grep Martian

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




passing a hash via cookie and dereferencing it

2010-01-19 Thread mike
Hello everyone:
I am trying to pass a hash of hashes from one script to another via a
cookie.  I can get the cookie to pass, but when I try to get the inner
hash keys and values using what I think is the correct method, I
cannot get them.  Here are two scripts which should do it, but don't:

#1: pretest.cgi

#!/usr/bin/perl -wT
use CGI ':standard';
my $xx = new CGI;
%KK = (a=A,b=B);
open (SCRATCH,/tmp/scratch) or die Couldn't open scratch for
writing: $!\n;
chmod 0755,tmp/scratch;
print SCRATCH  In pretest.cgi.\n;
for (keys %{KK}) {
print SCRATCH  Key: ,$_,\t,
Value from reference: ,${KK}{$_},\n;
}
print SCRATCH \n\n;
my $kk=\%KK;
print $xx-redirect(-COOKIE=$kk,-URL=test.cgi);

#2 test.cgi:

#!/usr/bin/perl -wT
use CGI::Carp qw(fatalsToBrowser);
use CGI ':standard';
use diagnostics;
$xx = new CGI;
%cookhash=cookie('bigcook');
$KK=$cookhash{'KK'};
open (SCRATCH,/tmp/scratch) or die Couldn't open scratch for
appending: $!\n;
chmod 0775,tmp/scratch;
print $xx-header;
print $xx-start_html(-title=test,-bgcolor=silver,-
vlink=blue),
$xx-hr, $xx-p,$xx-br;

print $xx-center( $xx-h2(In test.cgi!\n) );
print $xx-center( $xx-h2(\$KK is $KK\n) );
print SCRATCH In test.cgi!\n;
print SCRATCH \$KK is $KK\n;

for (keys %{$KK}) {
print SCRATCH  Key: ,$_,\t;
print SCRATCH  Value from reference: ,${$KK}{$_},\n;
}

for (keys %{$KK}) {
print   $xx-center($xx-h2(Key: ,$_,\n),
$xx-h2(value from reference: ,${$KK}{$_},\n));
}
print $xx-end_html;


As you can see if you run these two scripts, the dereferencing step
didn't give me back my hash %KK.  I used the same synax to dereference
$KK in both programs, but it didn't work for the passed one.  Can
anybody help?  Thanks in advance.

Mike



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




Introduction and Perl 5 References

2012-02-27 Thread Mike
Hello everyone. I just wanted to introduce myself to the list. Been 
following for a little while, first time posting. My name is Mike 
Dunaway and I am 25 years old. I was curious if there were any other 
members in the 804 area? I'm looking to meet some other programmers in 
my area as I only know of one other. While I'm posting, I may as well 
ask a question related to Perl. Would anyone mind explaining references 
to me like I was five years old? I read about them in Beginning Perl, 
but I can't quite grasp them very well. Thanks!


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




Re: jsFiddle

2013-01-15 Thread Mike

On 1/15/2013 2:35 PM, Bill Stephenson wrote:

Check out this web app:

http://jsfiddle.net/

(Google jsfiddle.net example for examples of use)

It would be nice to have something like that for fiddling with perl.

I haven't really thought it through, but it might not take much to create 
something simple for personal use.

--

Bill Stephenson






Check out IDEOne: http://ideone.com/ and CodePad (mentioned earlier) 
http://codepad.org - CodePad, in my experience, suffers from a lot of 
downtime, however.


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




Re: parsing website

2013-02-26 Thread Mike

On 2/26/2013 1:46 PM, Noah wrote:

Hi there,

I want to parse text from a website.  what are some good methods and 
modules to do this?  Any tutorial links?


Cheers



WWW::Mechanize

http://search.cpan.org/dist/WWW-Mechanize/lib/WWW/Mechanize.pm

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




Re: CPAN unavailable

2014-05-21 Thread Mike

I would recommend using http://metacpan.org

And for installing modules, you could try cpanminus:

curl -L http://cpanmin.us | perl - --sudo App::cpanminu

On 5/20/14, 8:22 PM, Yonghua Peng wrote:

Hello,

Do you know why these days cpan.org has been unavailable?
I always got:


  503 Service Unavailable

No server is available to handle this request.

Thanks.


 




Re: converting ip regex to iprange

2014-05-28 Thread Mike

Maybe this module here?

http://search.cpan.org/~mrsam/Net-CIDR-0.11/CIDR.pm

On 5/28/14, 3:08 AM, Agnello George wrote:


Hi I have about 300 + ip regex in my apache file like this


11\.45\.3[2-9]\..*$

 ^11\.45\.4[0-9]\..*$

 ^11\.45\.5[0-9]\..*$


I have to convert like this into CIDR .


·11.45.32.0/21 http://11.45.32.0/21

·11.45.40.0/21 http://11.45.40.0/21

·11.45.48.0/23 http://11.45.48.0/23

·11.45.50.0/21 http://11.45.50.0/21

11.45.58.0/23 http://11.45.58.0/23

is there a  module that can help me convert ip regex to ip range .


thanks

Agnello








Grabbing HTML fields, return them as hash

2014-06-09 Thread Mike
Hello everyone. Can anyone point me in the direction of a module that 
will allow me to grab HTML fields and return them as a hash?


Thanks.

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




Re: script to match a valid email id

2014-07-10 Thread Mike

That's a lot of regex.

On 7/10/14, 2:25 PM, Ron Bergin wrote:

Sunita Pradhan wrote:

I do not want to use Cpan modules .

-Sunita


What do you have against using a cpan module?

If you don't want to use the module, then why not simply copy/use the
regex that it uses to do the validation?

$RFC822PAT = 'EOF';
[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\
xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xf
f\n\015()]*)*\)[\040\t]*)*(?:(?:[^(\040)@,;:.\\\[\]\000-\037\x80-\x
ff]+(?![^(\040)@,;:.\\\[\]\000-\037\x80-\xff])|[^\\\x80-\xff\n\015
]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015]*)*)[\040\t]*(?:\([^\\\x80-\
xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80
-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*
)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\
\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\
x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\x8
0-\xff]+(?![^(\040)@,;:.\\\[\]\000-\037\x80-\xff])|[^\\\x80-\xff\n
\015]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015]*)*)[\040\t]*(?:\([^\\\x
80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^
\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040
\t]*)*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([
^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\
\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\
x80-\xff]+(?![^(\040)@,;:.\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-
\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()
]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\
x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\04
0\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\
n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\
015()]*)*\)[\040\t]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\x80-\xff]+(?!
[^(\040)@,;:.\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\
]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\
x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\01
5()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*|(?:[^(\040)@,;:.
\\\[\]\000-\037\x80-\xff]+(?![^(\040)@,;:.\\\[\]\000-\037\x80-\xff]
)|[^\\\x80-\xff\n\015]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015]*)*)[^
()@,;:.\\\[\]\x80-\xff\000-\010\012-\037]*(?:(?:\([^\\\x80-\xff\n\0
15()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][
^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)|[^\\\x80-\xff\
n\015]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015]*)*)[^()@,;:.\\\[\]\
x80-\xff\000-\010\012-\037]*)*[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?
:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-
\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:@[\040\t]*
(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015
()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()
]*)*\)[\040\t]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\x80-\xff]+(?![^(\0
40)@,;:.\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\
[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\
xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*
)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80
-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x
80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t
]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\x80-\xff]+(?![^(\040)@,;:.\\
\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])
*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x
80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80
-\xff\n\015()]*)*\)[\040\t]*)*)*(?:,[\040\t]*(?:\([^\\\x80-\xff\n\015(
)]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\
\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*@[\040\t
]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\0
15()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015
()]*)*\)[\040\t]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\x80-\xff]+(?![^(
\040)@,;:.\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|
\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80
-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()
]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x
80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^
\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040
\t]*)*(?:[^(\040)@,;:.\\\[\]\000-\037\x80-\xff]+(?![^(\040)@,;:.
\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff
])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\
\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x
80-\xff\n\015()]*)*\)[\040\t]*)*)*)*:[\040\t]*(?:\([^\\\x80-\xff\n\015

Re: Best way to install perl modules

2014-10-04 Thread Mike

Use cpanminus.

To install:

sudo curl -L http://cpanmin.us | perl - --sudo App::cpanminus

To use: sudo cpanm module to install

Here's the official documentation: 
http://search.cpan.org/~miyagawa/App-cpanminus-1.7012/lib/App/cpanminus.pm


On 10/4/14, 8:32 PM, Benjamin Fernandis wrote:

Hi,

Many times I face problem with module installation and then have to go 
to google and apply trial and error to resolve this permanently, could 
u please suggest me best and correct method to get resolved it?


i mean if i installed centos 7 freshly then what are pre-requisites 
from OS side to get perl module installation successfully. What steps 
require to follow?


Previously i tried cpanm and cpan console but some times faced 
installation faild error.


Is there any specific guideline to resolve this problem? I am using 
centos based distro.


Regards
Ben




Re: Best way to install perl modules

2014-10-06 Thread Mike
Please provide us with any errors from the installation log you've 
received when using cpanm.


On 10/06/2014 08:58 PM, Benjamin Fernandis wrote:

Hi,

Today I face same previous problem to install package with cpanm.

This time i have already installed Development Tools as suggested by Sam.


For testing it more, i was trying to install dancer by cpanm. First 
trial, i got failed and then looked into build log and found some 
dependent modules are not there so then i tried to first install them 
and those also have some more dependencies and then i have to resolve 
first from those and then step by step do install manually and lastly 
dancer installation works for me.


Below is my manually package installation.

Please suggest me to resolve this installation problem. Also suggest 
me if I am missing anything at OS level.


OS : cenots 7

Regards
Ben

 cpanm Dancer
  334
  335  vim /root/.cpanm/work/1412646550.26687/build.log
  336
  337  cpanm HTTP::Server::Simple
  338  vim /root/.cpanm/work/1412646612.26849/build.log
  339  cpanm Test::Pod
  340  cpanm HTTP::Server::Simple
  341  vim /root/.cpanm/work/1412646658.27040/build.log
  342  cpanm Test::Pod::Coverage
  343  cpanm HTTP::Server::Simple
  344  vim /root/.cpanm/work/1412646703.27571/build.log
  345  cpanm HTTP::Server
  346  cpanm Env
  347  cpanm HTTP::Server::Simple
  348  cpanm Dancer
  349  instmodsh
  350  history

On Sun, Oct 5, 2014 at 6:17 PM, Benjamin Fernandis 
benjo11...@gmail.com mailto:benjo11...@gmail.com wrote:


Hi, Sam,

Thanks, After installing development tools group, it works.

Regards
Ben

On Sun, Oct 5, 2014 at 6:02 PM, Sam p...@net153.net
mailto:p...@net153.net wrote:

You probably need to give us more info as both cpan and cpanm
will auto resolve and install needed dependencies.

The dependency installs could be failing because a compiler or
something similar is missing.

If you are on a redhat based system, trying running:
yum groupinstall Development Tools

If you are on a debian based system try running:
aptitude install build-essential


--Sam


On 10/04/2014 11:39 PM, Benjamin Fernandis wrote:

Hi Mike,

Thanks for your kind response. I tried cpanm instead of
cpan, but many
times, it does not install require dependencies for module.

For example, when i was trying to install
cpanm XML::SAX  - it failed and said no Fatal.pm module ,
then i
manually first installed that module and then i tried to
install
XML::SAX and it works.

It happens many times while installing different modules.
I mean cpanm
does not automatically fetch require dependencies for
module. like yum
in centos to install packages.

Is there any tool or something like yum for perl module
installations.
Or Is there , I am missing anything ?

Regards
Ben

On Sun, Oct 5, 2014 at 2:51 PM, Mike
ekimduna...@gmail.com mailto:ekimduna...@gmail.com
mailto:ekimduna...@gmail.com
mailto:ekimduna...@gmail.com wrote:

Use cpanminus.

To install:

sudo curl -L http://cpanmin.us | perl - --sudo
App::cpanminus

To use: sudo cpanm module to install

Here's the official documentation:

http://search.cpan.org/~miyagawa/App-cpanminus-1.7012/lib/App/cpanminus.pm

http://search.cpan.org/%7Emiyagawa/App-cpanminus-1.7012/lib/App/cpanminus.pm


On 10/4/14, 8:32 PM, Benjamin Fernandis wrote:

Hi,

Many times I face problem with module installation
and then have
to go to google and apply trial and error to
resolve this
permanently, could u please suggest me best and
correct method to
get resolved it?

i mean if i installed centos 7 freshly then what are
pre-requisites from OS side to get perl module
installation
successfully. What steps require to follow?

Previously i tried cpanm and cpan console but some
times faced
installation faild error.

Is there any specific guideline to resolve this
problem? I am
using centos based distro.

Regards
Ben





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

IO::Socket

2014-12-29 Thread Mike
Can anyone point me in the direction of more thorough documentation for 
the IO::Socket module? Seems like the documentation on perl.org is 
pretty limited. At least, it doesn't feel very thorough to me.


http://perldoc.perl.org/IO/Socket.html

For example, what exactly does timeout affect?

This documentation also doesn't explain what values the methods accept 
or how to use them.


Thanks.

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




Re: Script for auto conf

2014-12-29 Thread Mike

I have a feeling this could easier be accomplished with bash.

On 12/29/14 9:47 PM, Alan Glait wrote:


Hi !
I have the Idea to make a perl script (better than in bash) to make 
some configuration on linux.

I think to have some files like param.txt with some lines like:
param_one = ZZZ XX  VV
param_two = Z
param_three = X

so need to check if param_one is in some_file.conf and if it is there 
test the value .. if it is not .. add to some_file.conf ... I think it 
should be easy ... right ??


Thanks for any help ..

;)




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




Re: Parsing multi column files

2015-01-18 Thread Mike
Thanks for quick lesson and pro-tips. I'll be sure to implement some of 
these.


In case you were wondering, I am indeed using strict and warnings. 
diagnostics, too.


Thanks again.

On 1/18/15 9:05 PM, Brandon McCaig wrote:

Mike:

On Sun, Jan 18, 2015 at 07:00:05PM -0500, Mike wrote:

So I've got a text file in a multi column format (three
columns), each column is separated by a single space. Here is a
snippet for reference:

artless base-court apple-john
bawdy bat-fowling baggage
beslubbering beef-witted barnacle

I want to be able to randomly select a word from the first
column, then from the second column, then from the third
column, and concatenate them to together into a single string.
Here's the code I currently have, but I'm stuck:

First a little code review.

Be sure to always use strict and warnings to help identify bugs.
Add this to the top of your programs.

use strict;
use warnings;

Perhaps you're already using it. At the very least, your snippet
is strict and warnings approved. :) That said, it is best to
include a full example of what you'e trying, including pragmas.
It saves us the trouble of emphasizing best practices that you're
already following and omitting them might also alter the behavior
of code and confuse us and you. So hopefully you're already using
strict and warnings, but next time include them in your post too!
:)


sub gen_ins {
 open(FH, '', 'insults2.txt') or die [-] ERROR: Can't find
insult list.;

It is better to use lexical file handles.

open(my $fh, '', 'insults2.txt') or
 die [-] ERROR: Can't find insult list.;

Good job using 3-arg open and handling failure. Often you should
include the output of $! in your error message because it will
contain information about what exactly went wrong. For example,
perhaps insults2.txt exists, but the user doesn't have the
necessary permissions to read it. Take that into account also
when you're writing your error messages to avoid confusing the
user (which may be yourself).

open(my $fh, '', 'insults2.txt') or
 die [-] ERROR opening insults list: $!;


 my @cols = split ( , FH);
 print $cols[0];
 close FH;
}

gen_ins();

When currently run, gen_ins() will print out the first word of
the given column: $cols[0], $cols[1], or $cols[2]. How can I
access the rest of the words below the first?

Others have demonstrated good solutions to this problem already.
Here's an alternative take emphasizing modularity and reuse.

use strict;
use warnings;

use Readonly;

exit(main(@ARGV));

sub main {
 Readonly::Scalar my $Filename = 'insults2.txt';

 my ($max) = (@_, 1);

 my $insults = load_insults($Filename);

 for (1..$max) {
 my @chain = random_insult_chain($insults);

 local $, = ' ';

 print @chain, \n;
 }

 return 0;
}

sub get_random_index($) {
 my ($length) = @_;

 # Note: rand() is not meant to be particular good at picking
 # randomly. Look to CPAN for alternative options if you need
 # something *good*.

 return int rand $length;
}

sub load_insults {
 my ($filename) = @_;

 open my $fh, '', $filename or die open $filename: $!;

 my @insults;

 # Load the insults into an array of arrays.
 while ($fh) {
 my ($first, $second, $third) = split;

 push @{$insults[0]}, $first;
 push @{$insults[1]}, $second;
 push @{$insults[2]}, $third;
 }

 close $fh or warn close $filename: $!;

 return \@insults;
}

sub random_insult_chain {
 my ($insults) = @_;

 my @words = map random_insult_word($_), @$insults;

 return @words;
}

sub random_insult_word {
 my ($insult_column) = @_;

 my $i = get_random_index @$insult_column;

 my $word = $insult_column-[$i];

 return $word;
}

__END__

Regards,





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




Re: Parsing multi column files

2015-01-18 Thread Mike

Thanks. I'll give this a shot.


On 1/18/15 7:44 PM, Brandon McCaig wrote:

On Sun, Jan 18, 2015 at 07:24:21PM -0500, Shawn H Corey wrote:

You would need an array for each column:

my $MAX = 10;

my @first = ();
my @second = ();
my @third = ();

sub get_columns {
 my $file = shift @_;

 open my $fh, '', $file or die could not open $file: $!\n;
 while( $fh ){
 my @items = split;
 push @first, $items[0];
 push @second, $items[0];
 push @third, $items[0];

Minor typo there. I believe that Shawn meant:

 push @first, $items[0];
 push @second, $items[1];
 push @third, $items[2];

Alternatively, eliminate the @items array entirely and assign to
a list of 3 lexical variables. For example:

my ($first, $second, $third) = split;

push @first, $first;
push @second, $second;
push @third, $third;


 }
 close $fh or die could not close $file: $!\n;
}

get_columns( 'insults2.txt' );

for ( 1 .. $MAX ){
 my @line = (
  @first[rand(@first)],
  @second[rand(@second)],
  @third[rand(@third)],
);
 print @line\n;
}

Regards,





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




Re: Using regular expressions to populate a variable?

2015-01-18 Thread Mike

I was able to find match extraction in the perldoc.

Here is a snippet of what I have.

my $insult = ( $mech-text =~ m/Insulter\ (.*)\ Taken/ );
print $insult\n;

But $insult is being populated with: 1

It should be populated with text. Can anyone tell me what I'm doing 
wrong here?


Thanks.

On 1/18/15 11:49 AM, Mike wrote:
Hey everyone, I'm trying to find information on how I can use regular 
expressions to populate a variable.


I want to pull text between one set of characters and another set of 
characters and use that to populate my variable. Can anyone point me 
in the right direction?


Thanks.



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




Using regular expressions to populate a variable?

2015-01-18 Thread Mike
Hey everyone, I'm trying to find information on how I can use regular 
expressions to populate a variable.


I want to pull text between one set of characters and another set of 
characters and use that to populate my variable. Can anyone point me in 
the right direction?


Thanks.

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




Re: Using regular expressions to populate a variable?

2015-01-18 Thread Mike

Thanks. This worked.

On 1/18/15 12:28 PM, Jim Gibson wrote:

On Jan 18, 2015, at 9:03 AM, Mike ekimduna...@gmail.com wrote:

I was able to find match extraction in the perldoc.

Here is a snippet of what I have.

my $insult = ( $mech-text =~ m/Insulter\ (.*)\ Taken/ );
print $insult\n;

But $insult is being populated with: 1

It should be populated with text. Can anyone tell me what I'm doing wrong here?

Your error is assigning the return value of the regular expression in a scalar 
context. In scalar context, a regular expression returns true or false 
indicating a match (or not). In array context, however, it returns the captured 
subexpressions as a list.

Try forcing the assignment into array context:

  my( $insult ) = ( $mech-text =~ m/Insulter\ (.*)\ Taken/ );

You can also use the capture variables $1, $2, $3, etc., which will contain the 
captured subexpressions:

  my $insult;
  if( $mech-text =~ m/Insulter\ (.*)\ Taken/ ) ) {
$insult = $1;
  }





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




Parsing multi column files

2015-01-18 Thread Mike
So I've got a text file in a multi column format (three columns), each 
column is separated by a single space. Here is a snippet for reference:


artless base-court apple-john
bawdy bat-fowling baggage
beslubbering beef-witted barnacle

I want to be able to randomly select a word from the first column, then 
from the second column, then from the third column, and concatenate them 
to together into a single string. Here's the code I currently have, but 
I'm stuck:


sub gen_ins {
open(FH, '', 'insults2.txt') or die [-] ERROR: Can't find insult 
list.;

my @cols = split ( , FH);
print $cols[0];
close FH;
}

gen_ins();

When currently run, gen_ins() will print out the first word of the given 
column: $cols[0], $cols[1], or $cols[2]. How can I access the rest of 
the words below the first?


Thanks.

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




Submitting a form with Mechanize -- Can't find form

2015-01-31 Thread Mike
Hey everyone, I'm trying to submit a form with WWW::Mechanize to post a 
new thread on a forum from the command line. The forum also requires an 
image to be uploaded with it. Anyway...here is my snippet:


$mech-submit_form(
form_name = 'post',
fields  = { body = $text, file = $file_location },
button  = 'post'
);

When I run the code, I'm getting this error:

Uncaught exception from user code:
There is no form named post at 
/usr/share/perl5/site_perl/WWW/Mechanize.pm line 1938.


But the HTML source code on the site shows that the form name IS indeed 
post:


form name=post onsubmit=return dopost(this); 
enctype=multipart/form-data action=/post.php method=post


Can anyone tell me why I'm receiving this error?

Thanks.

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




Best practice for executing system commands?

2015-01-24 Thread Mike
Which is generally considered the best practice way of executing system 
commands from within a Perl program?


Should I use backticks or qx//, system(), or exec()?

Or is there no best way and it's just a matter of what you want to return?

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




Re: sftp code to use

2018-10-28 Thread Mike


One way to unzip with Perl is this method:


use warnings;
use strict;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );

my $zipfile = 'zipped.zip';

my $zip = Archive::Zip->new();
die "Error reading $zipfile:$!" unless $zip->read($zipfile) == AZ_OK;
$zip->extractMember($zipfile) for $zip->members;


__END__




On Oct 21, 2018, at 10:56 AM, Asad  wrote:

Hi All ,

   I need to accomplish the following task . i was trying in 
python using subprocess and adive how to proceed will be helpful



sftp u...@xyx.com 1212
pasword:xxx
cd /patch1
get patch1.zip
unzip patch1.zip
sqlplus / as sysdba ===> connect to oracle database
sql>startup


Thanks,

--
Asad Hasan
+91 9582111698

Jim Gibson





PAUSE

2019-06-30 Thread Mike



I understand that to upload a module to CPAN is need
to obtain a PAUSE account.  I have tried twice to get
that, but I don't receive an e-mail with a password.

http://www.mflan.com/temp/pause.jpg

If anybody can notify the PAUSE people that the PAUSE
program appears to be broke, please do.



Mike

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




Re: PAUSE

2019-07-01 Thread Mike



I never did receive the e-mails to my AT e-mail,
but a person in Demmark, or someplace like that,
gave me some personal attention and I believe all
is good now.

Thanks so much to Shlomi, Andreas and everybody else.

I first applied to PAUSE on 6/9/2019.


Mike


On 6/30/2019 7:07 PM, pengyong...@virgilio.it wrote:

He will be waiting for more days to get a response from PAUSE.
I once tried to apply for that, after a few days I got the verification mail.


On June 30, 2019 at 2:23 PM Shlomi Fish  wrote:


Hi all,

can someone try to help Mike here?

On Sun, 30 Jun 2019 05:10:19 -0500
Mike  wrote:


I understand that to upload a module to CPAN is need
to obtain a PAUSE account.  I have tried twice to get
that, but I don't receive an e-mail with a password.

http://www.mflan.com/temp/pause.jpg

If anybody can notify the PAUSE people that the PAUSE
program appears to be broke, please do.



Mike




--
-
Shlomi Fish   http://www.shlomifish.org/
Understand what Open Source is - http://shlom.in/oss-fs

“Did you sleep well?”
“No, I made a couple of mistakes.”
 — https://en.wikiquote.org/wiki/Steven_Wright via Nadav Har’El

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

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




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




Re: Google Sheets API Data Structure

2019-08-16 Thread Mike


Please state the exact module name.
Is it this one:
https://metacpan.org/pod/Net::Google::Spreadsheets::V4

My guess is no.


Mike


On 8/15/2019 10:18 AM, James Kerwin wrote:

Hi All,

I managed to get the Google Sheets API Perl module working.

I'm currently investigating a data structure that it gives me to see 
what values I can get from it. Through random experimentation I've 
managed to find that it had "title" and "id".


I wrote this to get the data structure containing the worksheets:

my @ws = $spreadsheet->worksheets;


Now if I do:

print $ws[1]->id;

print $ws[1]->title;


I get the value in the id and the title for the specific item in the 
array. I want to know what other information is in there.


If I do this:

for my $href (@ws) {

    print "{ ";

    for my $role (keys %{ $href }) {

        print "$role=$href->{$role} ";

    }

    print "}\n";

}

I get:

{ atom=XML::Atom::Entry=HASH(0x1b81928)

container=Net::Google::Spreadsheets::Spreadsheet=HASH(0x1bbdb80)
}

{ atom=XML::Atom::Entry=HASH(0x1bbbe98)

container=Net::Google::Spreadsheets::Spreadsheet=HASH(0x1bbdb80)
}

{

container=Net::Google::Spreadsheets::Spreadsheet=HASH(0x1bbdb80)
atom=XML::Atom::Entry=HASH(0x1b86ca0) }

{

container=Net::Google::Spreadsheets::Spreadsheet=HASH(0x1bbdb80)
atom=XML::Atom::Entry=HASH(0x1b86988) }

{

container=Net::Google::Spreadsheets::Spreadsheet=HASH(0x1bbdb80)
atom=XML::Atom::Entry=HASH(0x1b8c958) }

If I use Dumper it just seems to output SO MUCH information that I 
can't see the wood for the trees. Maybe I'm just tired after a 
dramatic day in Perl land.


Can anyone help me untangle this? My spreadsheet has five worksheets 
and there are five lines in my output so my assumption is that each 
line represents a sheet.


Any advice/help/guidance would be greatly appreciated.

Thanks,
James




Re: Problem executing command via ssh

2019-08-24 Thread Mike


Wow, a complicated question that I know very little
about.  But since nobody else has jumped in, I will
show my ignorance by suggesting this:

Perhaps change $command to @command.
or
use something like
local $/;

These beginners questions are getting
pretty complicated :-)


Mike


On 8/23/2019 11:16 AM, Mario Galindez wrote:

Folks,

I need to execute a program in a remote machine, that takes its input 
from STDIN.


I created a user in such remote machine, and set my program as the 
shell for that account (so I don't need to provide shell access).


On my local node, I have this program:

#!/usr/bin/perl

    use IPC::Open3;
    use POSIX;


    $inputfile= $ARGV[0];
    open(FILE, '<', "$ARGV[0]") or die $!;
    $command= "ssh user\@remotehost.com <http://remotehost.com>";
    $pid = open3('<', '>', '>', $command);

    waitpid( $pid, 0 );


What I expect is that I pass the name of the file as arguments of this 
program ($ARGV[0]), and the contents of this file is fed as STDIN of 
the child I've spawn with open3. This should be received as STDIN of 
my remote program, and the results of the remote program would be 
printed on STDOUT.


This works well. However, my program only reads the first line, and 
then terminates.


If I do a manual test, and do ssh u...@remotehost.com 
<mailto:u...@remotehost.com>, and type multiple lines of input, then 
things work as expected.


Any clues?

Thanks!
-m






Geo::WebService::Elevation::USGS

2019-08-26 Thread Mike



If there is anybody on Strawberry Perl, would
you please go to CPAN and install Geo::WebService::Elevation::USGS

Then run this program:

#!/usr/bin/perl

use strict;
use warnings;
use Geo::WebService::Elevation::USGS;

my $latd = '38.72360';
my $longd = '-90.76983';

my $getelev = Geo::WebService::Elevation::USGS->new();

my $elev = $getelev->elevation($latd, $longd)->{Elevation};

print "All done.   Elevation = $elev ft.\n\n";

__END__


I expect you will get this error:
500 Can't connect to ned.usgs.gov:443 (Bad address) at .pl line 12.


If instead you get the elevation, please let me know.


Then go to USGS.pm, take it off Read Only, and change line 133 from
use constant USGS_URL => 'https://ned.usgs.gov/epqs/pqs.php';
to
use constant USGS_URL => 'https://nationalmap.gov/epqs/pqs.php';

Then run the program and I expect you will get this error:
500 Can't connect to nationalmap.gov:443 (Bad address) at .pl line 12.

If you get either to run correctly, see if you have
Geo::WebService in your environment variables.


Thank you.


Mike

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




Re: Geo::WebService::Elevation::USGS

2019-08-27 Thread Mike



Thank you all for the responses.

I now think this has nothing to do with
Geo::WebService::Elevation::USGS.  See
the script below for other web links that
LWP::Simple cannot reach and parse.  I have
not figured out why, but the problem is not
with USGS.pm,.


#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;

chdir 'C:/Copy';

# Works

#my $test = get('http://osgeo-org.1560.x6.nabble.com/') or die 'Unable 
to get page'; # Works
#my $test = get('https://www.chron.com/neighborhood/bayarea/') or die 
'Unable to get page'; # Works
#my $test = get('http://history.house.gov/Map/Mapping-Congress/') or die 
'Unable to get page'; # Works

#my $test = get('http://hint.fm/wind/') or die 'Unable to get page'; # Works
#my $test = get('http://antwrp.gsfc.nasa.gov/apod/astropix.html') or die 
'Unable to get page'; # Works



# Does not work

my $test = get('https://nationalmap.gov/epqs/') or die 'Unable to get 
page'; # Does not work
#my $test = get('http://www.wrh.noaa.gov/zoa/mwmap3.php?map=usa') or die 
'Unable to get page'; # Does not work
#my $test = get('http://www.glorecords.blm.gov/') or die 'Unable to get 
page'; # Does not work
#my $test = get('https://glorecords.blm.gov/default.aspx') or die 
'Unable to get page'; # Does not work



print "\nAll done.\n\n\$test = $test\n\n";


__END__


There is stuff posted about this problem.  I have
been through using UserAgent, declaring the browser,
environment variables, and other things and it
still doesn't work.  Good thing I don't need this
or it would be driving me crazy.  I will probably
move on to other things now.



use strict;
use warnings;
use LWP::UserAgent;

$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;


my $url = "https://nationalmap.gov/epqs/pqs.php;;

my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0, } );


$ua->env_proxy;
$ua->agent("Mozilla/5.0 (Windows)");
my $response = $ua->get($url);

if ($response->is_success) {
 print $response->content;
} else {
   die $response->status_line;
}

print "All done.\n\n";

__END__


Mike


On 8/26/2019 10:26 PM, Uri Guttman wrote:

On 8/26/19 8:00 PM, Mike wrote:




use constant USGS_URL => 'https://ned.usgs.gov/epqs/pqs.php';
to
use constant USGS_URL => 'https://nationalmap.gov/epqs/pqs.php';



have you tried to just telnet to those hosts?

 telnet nationalmap.gov:443
telnet: could not resolve nationalmap.gov:443/telnet: Name or service 
not known

telnet ned.usgs.gov:443
telnet: could not resolve ned.usgs.gov:443/telnet: Name or service not 
known



so there is something wrong with the urls and not the code (or the 
code has bad urls).


and just getting the web pages is also failing

GET https://ned.usgs.gov/epqs/pqs.php
General failure: Invalid Coordinates

GET https://nationalmap.gov/epqs/pqs.php
General failure: Invalid Coordinates

i dunno the module but it seems that you may not be passing in any 
coordinates or something else is needed.


uri



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




Re: Geo::WebService::Elevation::USGS

2019-08-30 Thread Mike



Yes.  Both of these work fine:

my $test = get('http://google.com/') or die 'Unable to get page'; # Works
my $test = get('https://google.com/') or die 'Unable to get page'; # Works


On 8/29/2019 9:33 PM, Olivier wrote:

Mike  writes:

Sorry Mike, but I have hard time to get a clear picture of what you are
saying.

Did you manage to use LWP::Simple to load google.com?


Yes.  Both of these work:

my $test = get('http://google.com/') or die 'Unable to get page'; # Works
my $test = get('https://google.com/') or die 'Unable to get page'; # Works


This is really the first question, the first step to build the
diagnostic.

So far, I cannot even decide whether the version of LWP::Simple
installed on your machine is properly working or not. So I cannot decide
whether it is a network problem or a software problem.

Best regards,

Olivier



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




Re: Geo::WebService::Elevation::USGS

2019-09-03 Thread Mike



This one gives:
Unable to get page at httpfetch.pl line 35.

I wonder if all of these are redirects:


# Does not work

my $test = get('https://nationalmap.gov/epqs/') or die 'Unable to get 
page'; # Does not work
#my $test = get('https://nationalmap.gov/epqs/pqs.php') or die 'Unable 
to get page'; # Does not work
#my $test = get('http://www.wrh.noaa.gov/zoa/mwmap3.php?map=usa') or die 
'Unable to get page'; # Does not work
#my $test = get('http://www.glorecords.blm.gov/') or die 'Unable to get 
page'; # Does not work
#my $test = get('https://glorecords.blm.gov/default.aspx') or die 
'Unable to get page'; # Does not work



Mike


On 9/2/2019 12:31 AM, Olivier wrote:

Mike  writes:


Yes.  Both of these work fine:

my $test = get('http://google.com/') or die 'Unable to get page'; # Works
my $test = get('https://google.com/') or die 'Unable to get page'; # Works

Good, do we know two things:
- your LWP::Simple is correctly installed
- you have no proxy

Next step is to see what is the result of https://nationalmap.gov/epqs/

So you should try with (note the / at the end):

my $test = get('https://nationalmap.gov/epqs/') or die...

Problem is that it is going through redirections and beacuase it is
encrypted, it is almost impossible to debug by hand.

Olivier



On 8/29/2019 9:33 PM, Olivier wrote:

Mike  writes:

Sorry Mike, but I have hard time to get a clear picture of what you are
saying.

Did you manage to use LWP::Simple to load google.com?

Yes.  Both of these work:

my $test = get('http://google.com/') or die 'Unable to get page'; # Works
my $test = get('https://google.com/') or die 'Unable to get page'; # Works


This is really the first question, the first step to build the
diagnostic.

So far, I cannot even decide whether the version of LWP::Simple
installed on your machine is properly working or not. So I cannot decide
whether it is a network problem or a software problem.

Best regards,

Olivier






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




Re: Geo::WebService::Elevation::USGS

2019-08-29 Thread Mike



Thanks for the response.

I agree with everything you say.
I just want my LWP::Simple to access every
web link that my browser can access.


I now know that some of you can run the
code below and get all 4 of the websites
I have listed to return the website info.
All 4 of those web links gives:
"Unable to get page at httpfetch.pl line 21."

I can see I am not alone in having this problem.
Others have had the same problem with only a few
web links.


#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;


# Does not work

my $test = get('https://nationalmap.gov/epqs/pqs.php') or die 'Unable to 
get page'; # Does not work
#my $test = get('http://www.wrh.noaa.gov/zoa/mwmap3.php?map=usa') or die 
'Unable to get page'; # Does not work
#my $test = get('http://www.glorecords.blm.gov/') or die 'Unable to get 
page'; # Does not work
#my $test = get('https://glorecords.blm.gov/default.aspx') or die 
'Unable to get page'; # Does not work



print "\nAll done.\n\n\$test = $test\n\n";


__END__



On 8/28/2019 10:00 PM, Olivier wrote:

Mike  writes:


Thanks for the response.

Yeah, I don't understand why
https://nationalmap.gov/epqs/pqs.php
won't open in a browser, but

In fact, it does open in a browser and the result is "General failure:
Invalid Coordinates".

This URL runs the PHP script pqs.php, this script needs input
coordinates, if there is no coordinates supplied, this script returns
the message about invalid coordinates.

This message is not a message from your browser, it is not a message
from the web server, it is a message from pqs.php. Your browser and the
web server are just fine.

And frankly speaking, what result are you expecting? pqs.php is a script
that returns some data depending on the input data you give. You give no
input, you get no output.


https://nationalmap.gov/epqs/
will.  I imagine this may have something
to do with redirects, but who knows.

This URL is missing the filename part (after the last /), in that case,
the web server uses a default file (depending on the configuration of
the web server) and the default file is presenting a page that asks for
coordinates.

So you are asking 2 differents URL, that corresponds to two different
pages, each page giving the correct result.


When I put
https://nationalmap.gov/epqs/pqs.php
into a web browser it says:
General failure: Invalid Coordinates


When I put
http://ned.usgs.gov/epqs/pqs.php
into a web browser it says the same exact thing.

And it is expected that the URL with http and with https give the same
correct result.


When I go to
https://nationalmap.gov/epqs/
and put -90.76983 for X
and put 38.72360 for Y
and hit "Get Elevation"
it gives:


    
      3DEP 1/3 arc-second
      583.54
      Feet
    




When I go to:
https://nationalmap.gov/epqs/pqs.php?x=-90.76983=38.72360=feet=xml
it gives:


    
      3DEP 1/3 arc-second
      583.54
      Feet
    


So that works.

It works because you are providing correct input.

Best regards,

Olivier


Mike



On 8/26/2019 10:26 PM, Uri Guttman wrote:

have you tried to just telnet to those hosts?

  telnet nationalmap.gov:443
telnet: could not resolve nationalmap.gov:443/telnet: Name or service
not known
telnet ned.usgs.gov:443
telnet: could not resolve ned.usgs.gov:443/telnet: Name or service not
known


so there is something wrong with the urls and not the code (or the
code has bad urls).

and just getting the web pages is also failing

GET https://ned.usgs.gov/epqs/pqs.php
General failure: Invalid Coordinates

GET https://nationalmap.gov/epqs/pqs.php
General failure: Invalid Coordinates

i dunno the module but it seems that you may not be passing in any
coordinates or something else is needed.

uri



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




Re: Geo::WebService::Elevation::USGS

2019-08-28 Thread Mike



Thanks for the response.

Yeah, I don't understand why
https://nationalmap.gov/epqs/pqs.php
won't open in a browser, but
https://nationalmap.gov/epqs/
will.  I imagine this may have something
to do with redirects, but who knows.


When I put
https://nationalmap.gov/epqs/pqs.php
into a web browser it says:
General failure: Invalid Coordinates


When I put
http://ned.usgs.gov/epqs/pqs.php
into a web browser it says the same exact thing.


When I go to
https://nationalmap.gov/epqs/
and put -90.76983 for X
and put 38.72360 for Y
and hit "Get Elevation"
it gives:


  
    3DEP 1/3 arc-second
    583.54
    Feet
  




When I go to:
https://nationalmap.gov/epqs/pqs.php?x=-90.76983=38.72360=feet=xml
it gives:


  
    3DEP 1/3 arc-second
    583.54
    Feet
  


So that works.



Mike



On 8/26/2019 10:26 PM, Uri Guttman wrote:


have you tried to just telnet to those hosts?

 telnet nationalmap.gov:443
telnet: could not resolve nationalmap.gov:443/telnet: Name or service 
not known

telnet ned.usgs.gov:443
telnet: could not resolve ned.usgs.gov:443/telnet: Name or service not 
known



so there is something wrong with the urls and not the code (or the 
code has bad urls).


and just getting the web pages is also failing

GET https://ned.usgs.gov/epqs/pqs.php
General failure: Invalid Coordinates

GET https://nationalmap.gov/epqs/pqs.php
General failure: Invalid Coordinates

i dunno the module but it seems that you may not be passing in any 
coordinates or something else is needed.


uri



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




Re: Geo::WebService::Elevation::USGS

2019-08-29 Thread Mike


In my Firefox it is set at:
"Use system proxy settings"
I turned it off briefly, but didn't really see
any changes.

I do not implement a proxy in LWP::Simple.

I don't think I use a system Proxy:
http://www.mflan.com/temp/proxy.jpg


Mike


On 8/29/2019 5:52 AM, Olivier wrote:

And another question... Are you using any proxy in your broswer? If you 
do, how did you implemented that proxy in LWP::Simple? Olivier Olivier 
 writes:



Mike  writes:


Thanks for the response.

I agree with everything you say.
I just want my LWP::Simple to access every
web link that my browser can access.


I now know that some of you can run the
code below and get all 4 of the websites
I have listed to return the website info.
All 4 of those web links gives:
"Unable to get page at httpfetch.pl line 21."

I can see I am not alone in having this problem.
Others have had the same problem with only a few
web links.

I don't see why you have a 'die at line 21' while your script has way
less than 21 lines. Also, the script comes all mangled by the mail, so
one cannot say if the error is yours or the mailer.

Make your script simple first, so you can confirm your environment is
working:

#!/usr/bin/perl
use LWP::Simple;
$test=get('https://google.com');
print $test;

When that is working, start changing things one at a time and check at
each stage that it is still working.

You may also explore the documentation of LWP::Simple to get an error
message that makes sense, because what you get so far is only 'it does
not work', one cannot make a diagnostic with that only.

Good luck,

Olivier





Re: Geo::WebService::Elevation::USGS

2019-08-29 Thread Mike



I sure appreciate your help.

I have done quite a few things listed on the internet
with both Simple and UserAgent.

We see that many of the failing sites are govt
sites.  One guy can access all my Not Working sites,
but he says that glorecords and nationalmap.gov react
very slow, even when UserAgent uses the FireFox
identity.

I know I can use Mechanize and really dive into this.
And I might do that someday.  But for the moment I'm
thinking this is unlikely to get fixed in the next week.
Good thing I don't need this.


Mike



On 8/29/2019 5:35 AM, Olivier wrote:

I don't see why you have a 'die at line 21' while your script has way
less than 21 lines. Also, the script comes all mangled by the mail, so
one cannot say if the error is yours or the mailer.

Make your script simple first, so you can confirm your environment is
working:

#!/usr/bin/perl
use LWP::Simple;
$test=get('https://google.com');
print $test;

When that is working, start changing things one at a time and check at
each stage that it is still working.

You may also explore the documentation of LWP::Simple to get an error
message that makes sense, because what you get so far is only 'it does
not work', one cannot make a diagnostic with that only.

Good luck,

Olivier



#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;


# Does not work

my $test = get('https://nationalmap.gov/epqs/pqs.php') or die 'Unable to get 
page'; # Does not work
#my $test = get('http://www.wrh.noaa.gov/zoa/mwmap3.php?map=usa') or die 
'Unable to get page'; # Does not work
#my $test = get('http://www.glorecords.blm.gov/') or die 'Unable to get page'; 
# Does not work
#my $test = get('https://glorecords.blm.gov/default.aspx') or die 'Unable to 
get page'; # Does not work


print "\nAll done.\n\n\$test = $test\n\n";


__END__





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




Re: Geo::WebService::Elevation::USGS

2019-08-29 Thread Mike



I was thinking it might give the fill in form
that you get when you go here:
https://nationalmap.gov/epqs/

I think you are right.  It is acting as intended
when visited with a browser.


Mike


On 8/28/2019 10:00 PM, Olivier wrote:

Mike  writes:


Thanks for the response.

Yeah, I don't understand why
https://nationalmap.gov/epqs/pqs.php
won't open in a browser, but

In fact, it does open in a browser and the result is "General failure:
Invalid Coordinates".

This URL runs the PHP script pqs.php, this script needs input
coordinates, if there is no coordinates supplied, this script returns
the message about invalid coordinates.

This message is not a message from your browser, it is not a message
from the web server, it is a message from pqs.php. Your browser and the
web server are just fine.

And frankly speaking, what result are you expecting? pqs.php is a script
that returns some data depending on the input data you give. You give no
input, you get no output.


https://nationalmap.gov/epqs/
will.  I imagine this may have something
to do with redirects, but who knows.

This URL is missing the filename part (after the last /), in that case,
the web server uses a default file (depending on the configuration of
the web server) and the default file is presenting a page that asks for
coordinates.

So you are asking 2 differents URL, that corresponds to two different
pages, each page giving the correct result.


When I put
https://nationalmap.gov/epqs/pqs.php
into a web browser it says:
General failure: Invalid Coordinates


When I put
http://ned.usgs.gov/epqs/pqs.php
into a web browser it says the same exact thing.

And it is expected that the URL with http and with https give the same
correct result.


When I go to
https://nationalmap.gov/epqs/
and put -90.76983 for X
and put 38.72360 for Y
and hit "Get Elevation"
it gives:


    
      3DEP 1/3 arc-second
      583.54
      Feet
    




When I go to:
https://nationalmap.gov/epqs/pqs.php?x=-90.76983=38.72360=feet=xml
it gives:


    
      3DEP 1/3 arc-second
      583.54
      Feet
    


So that works.

It works because you are providing correct input.

Best regards,

Olivier


Mike



On 8/26/2019 10:26 PM, Uri Guttman wrote:

have you tried to just telnet to those hosts?

  telnet nationalmap.gov:443
telnet: could not resolve nationalmap.gov:443/telnet: Name or service
not known
telnet ned.usgs.gov:443
telnet: could not resolve ned.usgs.gov:443/telnet: Name or service not
known


so there is something wrong with the urls and not the code (or the
code has bad urls).

and just getting the web pages is also failing

GET https://ned.usgs.gov/epqs/pqs.php
General failure: Invalid Coordinates

GET https://nationalmap.gov/epqs/pqs.php
General failure: Invalid Coordinates

i dunno the module but it seems that you may not be passing in any
coordinates or something else is needed.

uri



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




Re: Geo::WebService::Elevation::USGS

2019-08-28 Thread Mike



Thank you.  That helps me a lot to know that it works for you.

Your code, exactly as you sent it, still does not work for me.
It gives:
500 Can't connect to nationalmap.gov:443 (Bad address) at trash.pl line 19.

I'm going to try to assign an environment variable to my
system.  I doubt that will fix it, but I am trying just
about everything.

I still can't figure out why it works on some URL's,
and not others.  It's probably going to take me a
long time to figure this out.


Mike



On 8/28/2019 6:26 PM, $Bill wrote:

This seems fine on my Win10:

use strict;
use warnings;
use LWP::UserAgent;

my $url;
if (0) {    # set to 1 or 0 to flop urls
$url = 'https://nationalmap.gov/epqs';
} else {
$url = 
'https://nationalmap.gov/epqs/pqs.php?y=34.0=-118.0=Feet=xml';

}
my $ua = LWP::UserAgent->new(); #  ssl_opts => { verify_hostname => 0, 
} );

$ua->agent("Mozilla/5.0 (Windows)");
my $response = $ua->get($url);
if ($response->is_success) {
print $response->content;
} else {
die $response->status_line;
}
print "All done.\n\n";

__END__

Dumps the page or elevation depending on url:

perl test.pl
?>y="34.0">3DEP 1/3 
arc-second916.71FeetAll 
done.






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




Re: Hi Folks : I'm trying to create a regular expression for finding a # wishing a dataset for only a number that is a multiple of 5

2019-09-08 Thread Mike



It's probably best if you write a short script
that reads a __DATA__ section of data.
Then tell us what it does and what you expected
it to do.

Off hand I don't see anything wrong with your regex,
but I don't know what you expect it to do.


Mike


On 9/8/2019 4:34 PM, Jim Gibson wrote:

On Sep 8, 2019, at 1:30 PM, Gautam Desai  wrote:

Do you guys have any pointers ?

$t =~ m{
(   # capture matched number in $1
  \d*   # match zero or more decimal digits
  [05]  # followed by a '0' or '5'
)   # end of capture
(?: # followed by either:
  \D# a non-digit
|   # or
  $ # the end of the string
)
}x



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




regular expression

2019-09-08 Thread Mike



You are not doing anything with $t to test whether
it works.  Also you are not telling us what data you
might test it with.


Mike


On 9/8/2019 6:41 PM, Jim Gibson wrote:

On Sep 8, 2019, at 3:39 PM, Mike  wrote:

I expect it to return a positive value if $t contains a number anywhere within 
it and put that number in the $1 capture variable.



On 9/8/2019 4:34 PM, Jim Gibson wrote:

On Sep 8, 2019, at 1:30 PM, Gautam Desai  wrote:

Do you guys have any pointers ?

$t =~ m{
(   # capture matched number in $1
  \d*   # match zero or more decimal digits
  [05]  # followed by a '0' or '5'
)   # end of capture
(?: # followed by either:
  \D# a non-digit
|   # or
  $ # the end of the string
)
}x


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



Jim Gibson
j...@gibson.org



--
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-07 Thread Mike



Maybe you should simplify to:

#!/usr/bin/perl
use strict;
use warnings;
symlink('ab', "foo") || die $!;

If that doesn't work try it after changing
'symlink'
to
'link'

Printing your $target gives a space and this symbol:
https://www.fileformat.info/info/unicode/char/2640/index.htm


I am on Strawberry Perl, so I can't really
help debug this.


Mike


On 9/7/2019 3:25 PM, 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?)

TIA

Jorge Almeida



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