Re: help with defined and !not defined

2005-07-22 Thread lorid

Chris Wagner wrote:


You want to check if it's null, not if it's defined.  Defined means that the
variable exists.  You want something like if ($photo_year) {...}.

At 01:48 PM 7/21/05 -0700, lorid wrote:
 

my $ARGV[0]  will sometimes be passed a string like this:nvIGRA with no 
date at end and sometimes with date nvIGRA200511
if it does not have date I need to set it another way but cant get 
syntax of !defined
   



 



you are right about I should test for null or length of value instead but 
I found the place where I got information that says that to be defined a 
var must have a value:

Beginnng Perl by Simon Cozens pg 123:

We can test if a variable is defined by...
#!/usr/bin/perl

use strict;
#use warnings;



my $a;
my $b;

$b = 10;

if (defined $a){
 print a has a value.\n;
}
if (defined $b){
 print b has a value.\n;
}

#only prints b has a value


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: help with getting file stats

2005-07-22 Thread lorid

Eric Amick wrote:


On Thu, 21 Jul 2005 12:05:08 -0700, you wrote:

 


loris reply:
yes I did try stat ($dir/$file)  it would not work , and I tried many 
variation

here is what I finally got to work:

print Opening $dir \n;

opendir DH, $dir  or die Can't open the current dir $!\n;
while(my $file = readdir(DH)){

  if(-d $dir/$file){ 
print \n Dir: $file \n;

my $pic_year = substr($file,0,4);
my $pic_month = substr($file,4,2);
print Year: $pic_year,Month: $pic_month\n;
   
$dir_ctr++;

  }
  elsif(-e $dir/$file){ 
print \n File: $dir/$file ;

#this wont work for me
#my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,$atime, 
$mtime, $ctime, $blksize, $blocks) = stat($dir/$file); 
#print Ctime:$ctime ,Mtime: $mtime\n;

my $now = ctime();
print \n Nowtime: $now\n;
#this works
my $file_moddate = ctime(stat($dir/$file)-mtime);
my $file_create_date = ctime(stat($dir/$file)-ctime);
   



Clearly you directly or indirectly use'd the File::stat module, which
overrides the built-in stat() with an object-oriented version. If you
really want to call the built-in version, try

 my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,$atime, 
$mtime, $ctime, $blksize, $blocks) = CORE::stat($dir/$file); 



 



Thanks Eric

CORE::stat($dir/$file);  
you are correct if I dont use the File::stat module it will work
so using 
CORE::stat($dir/$file); 


also works
lori
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: help with getting file stats

2005-07-21 Thread lorid



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
lorid
Sent: Wednesday, July 20, 2005 3:34 PM
To: perl-win32-users
Subject: help with getting file stats


snip of loris code:
( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, 
$mtime, $ctime, $blksize, $blocks ) = stat($file);
 print \n $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, 
$atime,Mtime: $mtime,\n Ctime:$ctime,\n $blksize, $blocks\n;

 $file_ctr++;
   }

 }

Darrell Gammill wrote:

 Have you tried stat ($dir/$file)?  If you just stat ($file), $file
would have to be the full path or a file in the current directory.  Do
you have a sample output you could share?

-Dgg
 



---
loris reply:
yes I did try stat ($dir/$file)  it would not work , and I tried many 
variation

here is what I finally got to work:

print Opening $dir \n;

 opendir DH, $dir  or die Can't open the current dir $!\n;
 while(my $file = readdir(DH)){

   if(-d $dir/$file){ 
 print \n Dir: $file \n;

 my $pic_year = substr($file,0,4);
 my $pic_month = substr($file,4,2);
 print Year: $pic_year,Month: $pic_month\n;

 $dir_ctr++;

   }
   elsif(-e $dir/$file){ 
 print \n File: $dir/$file ;

 #this wont work for me
 #my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,$atime, 
$mtime, $ctime, $blksize, $blocks) = stat($dir/$file); 
 #print Ctime:$ctime ,Mtime: $mtime\n;

 my $now = ctime();
 print \n Nowtime: $now\n;
 #this works
 my $file_moddate = ctime(stat($dir/$file)-mtime);
 my $file_create_date = ctime(stat($dir/$file)-ctime);

print \nfile create date: $file_create_date, file mod date: 
$file_moddate;

 $file_ctr++;
   }

 }
closedir DH;

--
note : my verion of perl is v5.005_02

I will try the other code on another machine with newer perl v. and see 
if that helps...

Thanks for all replies

Lori



 



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


help with defined and !not defined

2005-07-21 Thread lorid


Im  want to set the $photo_year and $photo_month to another value if it 
is not already set.


my $ARGV[0]  will sometimes be passed a string like this:nvIGRA with no 
date at end and sometimes with date nvIGRA200511
if it does not have date I need to set it another way but cant get 
syntax of !defined




my $filename = $ARGV[0];
my $photo_year;
$photo_year= substr($filename,6,4);
my $photo_month ;
$photo_month= substr($filename,10,2);
#This just blows my web page
if(!defined $photo_year){
 $photo_year =2005;
}


#I have also tried
if(defined $qphoto_year){
  #test
  $test1 =Im defined;
}
else{
   $test2 =Im Not defined;
   print $test2;
  }

How come It always returns Im defined ,even when no date is passed
should I do some kind of checking on my $ARGV[0] before doing the 
asignment $photo_year= substr($filename,6,4);



help appreciated

thanks
lori
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


help with getting file stats

2005-07-20 Thread lorid

I am trying to get the file stats
I found this code in ch8 of perl cookbook
( $dev, $ino, $mode, $nlink,
 $uid, $gid, $rdev, $size,
 $atime, $mtime, $ctime,
 $blksize, $blocks )   = stat($filename)

and read the man page for stat  and  perlfunc but cant  seem to get a 
simple program to get the file stats
after reading the man page for stat I thought my problem might be that I 
need to use fstat since the file may be open

but that doesnt seem to work either

any suggestions would be appreciated.
my simple test program:


#!/usr/local/bin/perl


use File::stat;



my $dir_ctr = 0;
my $file_ctr = 0;


my $dir = /home/lorid/wrccpics;

 print Opening $dir \n;

 opendir DH, $dir  or die Can't open the current dir $!\n;
 while($file = readdir(DH)){

   if(-d $dir/$file){  
 print \n Dir: $file \n;

 $dir_ctr++;
   }
   elsif(-e $dir/$file){  
 print \nFile: $file \n;  
( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, 
$mtime, $ctime, $blksize, $blocks ) = stat($file);
 print \n $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, 
$atime,Mtime: $mtime,\n Ctime:$ctime,\n $blksize, $blocks\n;

 $file_ctr++;
   }

 }

print \n;
print number of directories: $dir_ctr;
print \n;
print number of files: $file_ctr;

print \n;
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


image map question

2005-07-14 Thread lorid
Can anyone tell me if I should be able to  do both a onclick and a 
mouseover imagemap?

I am only able to do one or the other.

thanks

Lori
my attempt:

map id=Compusmap name=Compusmap
 area shape=rect coords=67,14,113,51 alt=Northern View 
onclick=alert('north1'); onmouseover=doButtons1('north1');
 area shape=rect coords=117,71,161,107 alt=Eastern View 
onmouseover=doButtons1('east1'); 
 area shape=rect coords=66,121,110,160  alt=Southern View 
onmouseover=doButtons1('south1'); 
 area shape=rect coords=17,67,58,108 
onmouseover=doButtons1('west1'); 

/map
label id=label1 for=Compusmap1
Station View #1

/label
img src=\/wraws/images/compus2.gif\  alt=Compus Image 
name=Compus1 width=167 height=163 border=0 usemap=#Compusmap 
id=Compusmap1 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


security question on someones code

2005-07-11 Thread lorid

Just curious
I found thisline in a sample perl program (which created a simple web page)
line:
delete @ENV{'BASH_ENV', 'CDPATH', 'ENV', 'IFS', 'PATH', 'SHELL'}; # For 
security.


could someone tell me if I should include this on all web pages I create 
and if so why?


thanks

Lori
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


sample dbi \html for program

2005-06-10 Thread lorid

Does anyone have a very short sample program that
presents a html form and gets the input and updates a database ?
I usually do this in C, but would like to start doing in perl.

thanks

Lori
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: function named reset()

2005-04-07 Thread lorid




Chris Cappelletti wrote:

  
There's no way that I'm going to take the name of every function I 
ever write and search the Perl docs to see if it's a reserved name.

  
  

But don't you just get that feeling that maybe reset might be a fxn of
note?  You could always preface your functions w/ something...may be
something that indicates desired scope, or type of fxn, or something
like that.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  

I have the habit of starting all functions with f_
it lets other programmers who have to read my code easily identify
functions,
which is especially important in perl it also prevents the problem
of a reserved names.

cheers
lori


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


simple reg ex

2005-03-10 Thread lorid
I know this is perl not javascript, I thought I was good at deciphering reg ex
but the 2nd line in this function has got me puzzled.
Can anyone decipher:
 X = (!X ? 2 : X);

function round(number,X) {
 // rounds number to X decimal places, defaults to 2
 X = (!X ? 2 : X);
 return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
 }
thanks
lori
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: simple reg ex

2005-03-10 Thread lorid
sorry , I sent question too soon, long day.
forgot about the conditional reg ex
(test_value ? if_true : if_false)
lori
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


question about Bills site

2004-09-09 Thread lorid
Hi Bill
I just checked out you site and wonder what the cmd.exe is used for ?
Lori
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


reg exp help please

2003-12-07 Thread lorid
Here is the string Im trying to split (its a cookie str)
MadHatter Data:
a:7:{i:0;s:19:\MadhatterSize=Adult\;i:1;s:20:\MadHatterColors=blue\;i:2;s:15:\MadHatter_Qty=1\;i:3;s:26:\product_name=Madhatter_Hat\;i:4;s:8:\cd_num=2\;i:5;s:4:\x=39\;i:6;s:4:\y=12\;}

the data I want is

MadhatterSize=Adult,MadHatterColors=blue,MadHatter_Qty=1,product_name=Madhatter_Hat

I have tried :  syntax is spliti(regexp patter,str,max split)
  spliti(:,$my_Propellar_Data,15);

the above is the only regexp that works so far , but doesnt come close
to matching what I want.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: proxy error and using LWP getstore

2003-11-16 Thread lorid
Thanks for the tip on WWW::Mechanize, Im going to play with it later,
meanwhile I grabbed this code from the lwpcook manpage (large documents section)
interesting thing is when I print out the chunk to my outfile... it prints the entire
document,
I was thinking it might not print the last line or so but it does so I guess the page 
does not
send a EOF.
Not sure what pearl considers the EOF to be when getting a html file ?? do you know if 
its
/html ?
Because the printed out chunk does have a /html

Code from the lwpcook manpage (large documents section):
my $expected_length;
  my $bytes_received = 0;
  my $res =
 $ua-request(HTTP::Request-new(GET = $url),
   sub {
   my($chunk, $res) = @_;
   $bytes_received += length($chunk);
   unless (defined $expected_length) {
  $expected_length = $res-content_length || 0;
   }
   if ($expected_length) {
printf OUT %d%% - ,
  100 * $bytes_received / $expected_length;
   }
   print OUT $bytes_received bytes received\n;
   # XXX Should really do something with the chunk itself
   print OUT2 $chunk;
   });
print $res-status_line, \n;
   print OUT $res-status_line, \n;
***
Just in case anyone cares the whole test program:

#!/usr/bin/perl -w


use strict;
use URI::URL;
use LWP;
use LWP::Debug qw(+ -conns);
use HTTP::Cookies;

my $errors_page = proxy_errors.txt;
my $url = url ('http://earthquake.usgs.gov/recenteqsUS/Quakes/quakes_all.html');
#my $url = url 
('http://www.nanpa.com/number_resource_info/co_code_assignments1.html/');

my $outdir = C:\\a_perl\\proxy_tests\\ ;
my $src = $outdir .'quakes_all.html';

open OUT, $errors_page or die Create $errors_page: $!;
open (OUT2,  $src) or die Cant write on file '$src'\n;


my $PROXY_URL = 'http://proxy-web.dri.edu/'; ### Proxy URL or Address + Port
my $PROXY_FTP = 'http://proxy-ftp.dri.edu/';


my $ua = LWP::UserAgent-new(env_proxy = 1,
  timeout = 120,
 );

$ua-proxy(http = $PROXY_URL);
$ua-proxy(ftp = $PROXY_FTP);

$ua-cookie_jar();

$ua-cookie_jar(HTTP::Cookies-new(file = 'lwpcookies.txt',
  autosave = 1));

#my $req = new HTTP::Request 'GET', $url;


my $expected_length;
  my $bytes_received = 0;
  my $res =
 $ua-request(HTTP::Request-new(GET = $url),
   sub {
   my($chunk, $res) = @_;
   $bytes_received += length($chunk);
   unless (defined $expected_length) {
  $expected_length = $res-content_length || 0;
   }
   if ($expected_length) {
printf OUT %d%% - ,
  100 * $bytes_received / $expected_length;
   }
   print OUT $bytes_received bytes received\n;
   # XXX Should really do something with the chunk itself
   print OUT2 $chunk;
   });
print $res-status_line, \n;
   print OUT $res-status_line, \n;
**
$Bill Luebkert wrote:

 lorid wrote:
  Thanks Bill!
  Your code worked great, I tested it on a different url and it worked ! yeah, but
  it timed out on the page Im trying to get (Im working from home on a 56k modem) 
  but it
  seems to get
  other pages just fine. With the debug code I can see that on  the ... quakes.all 
  page it
  zips along and then
  it hangs. I played with increasing the timeout and it still timesout... must be
  something in the source code..
  but the main thing is now I can use LWP to get files.
  The purpose in reading this file was to learn how to get a file thru LWP (even 
  through a
  proxy) to parse it
  and create new files.
  Ive got the rest working fine but was stuck on the proxy part... thanks again

 Some sites may need to send cookies.

 Try using one of these (the third one will allow you to save them
 between session):

 $ua-cookie_jar();
 $ua-cookie_jar(HTTP::Cookies::Netscape-new);
 $ua-cookie_jar(HTTP::Cookies-new(file = 'lwpcookies.txt',
   autosave = 1));

 You can also check out WWW::Mechanize for this sort of thing.

 --
   ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
  (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
   / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
 -/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: proxy error and using LWP getstore

2003-11-15 Thread lorid
Thanks Bill!
Your code worked great, I tested it on a different url and it worked ! yeah, but
it timed out on the page Im trying to get (Im working from home on a 56k modem) but it
seems to get
other pages just fine. With the debug code I can see that on  the ... quakes.all page 
it
zips along and then
it hangs. I played with increasing the timeout and it still timesout... must be
something in the source code..
but the main thing is now I can use LWP to get files.
The purpose in reading this file was to learn how to get a file thru LWP (even through 
a
proxy) to parse it
and create new files.
Ive got the rest working fine but was stuck on the proxy part... thanks again
Lori

$Bill Luebkert wrote:

 lorid wrote:

  I am still having trouble using the proxy, I thought I'd send my new code in which
  I hopefully used your code suggestions correctly. I can ping proxy-web.dri.edu  ,
  and I have added this debug line (use LWP::Debug qw(+ -conns);)
  so I can see that it is really proxied to proxy-web.dri.edu
  any clues ??
  
  New error:
  500 (Internal Server Error) Can't connect to proxy-web.dri.edu:80 (Bad hostname
  'proxy-web.dri.edu')
  Client-Date: Fri, 14 Nov 2003 19:44:18 GMT
  
  heres my new code:

 This works (commented out the $ua-proxy lines to test):

 use strict;
 use URI::URL;
 use LWP;
 use LWP::Debug qw(+ -conns);

 my $errors_page = proxy_errors.txt;
 my $url = url ('http://earthquake.usgs.gov/recenteqsUS/Quakes/quakes_all.html');

 my $PROXY_URL = 'http://proxy-web.dri.edu/'; ### Proxy URL or Address + Port
 my $PROXY_FTP = 'http://proxy-ftp.dri.edu/';

 my $ua = new LWP::UserAgent;
 $ua-proxy(http = $PROXY_URL);
 $ua-proxy(ftp = $PROXY_FTP);

 my $req = new HTTP::Request 'GET', $url;
 my $res = $ua-request($req);

 open OUT, $errors_page or die Create $errors_page: $!;
 if ($res-is_success) {
 print OUT $res-as_string;
 print Got URL OK\n;
 } else {
 print OUT Error getting $url, , $res-status_line, \n;
 print STDERR Error getting $url, , $res-status_line, \n;
 die;
 }
 close OUT;

 # what's the purpose in reading this file ?

 #my $outdir = 'C:/a_perl/hw10/sols' ;
 #my $src = $outdir/quakes_all.html;
 # open IN, $src or die Can't read file $src: $!\n;
 print Hi Lori\n;
 # close IN;

 __END__

 --
   ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
  (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
   / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
 -/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: proxy error and using LWP getstore

2003-11-14 Thread lorid

I am still having trouble using the proxy, I thought I'd send my new code in which
I hopefully used your code suggestions correctly. I can ping proxy-web.dri.edu  ,
and I have added this debug line (use LWP::Debug qw(+ -conns);)
so I can see that it is really proxied to proxy-web.dri.edu
any clues ??

New error:
500 (Internal Server Error) Can't connect to proxy-web.dri.edu:80 (Bad hostname
'proxy-web.dri.edu')
Client-Date: Fri, 14 Nov 2003 19:44:18 GMT

heres my new code:


#!/usr/bin/perl -w

use strict;
use URI::URL;
use LWP;   # LWP = Library for World Wide Web access in Perl
use LWP::Debug qw(+ -conns);

require LWP::UserAgent;
#proxy-web.dri.edu
my $PROXY_URL = 'http://proxy-web.dri.edu/'; ### Proxy URL or Address + Port
my $PROXY_FTP = 'http://proxy-ftp.dri.edu/';

my $ua = ;
$ua = new LWP::UserAgent;
$ua-proxy(['http', 'ftp'], $PROXY_URL,$PROXY_FTP);


my $n = ;
my $data = ;
my $response = ;

my $errors_page = proxy_errors.txt;
open (OUT2,  $errors_page) or die Can't write to file $errors_page: $!\n;

my $outdir = 'C:a_perl\\hw10\\sols\\' ;
my $url = url('http://earthquake.usgs.gov/recenteqsUS/Quakes/quakes_all.html/');

my $src = $outdir .'quakes_all.html';


my $req = new HTTP::Request 'GET', $url;
my $res = $ua-request($req);
print OUT2 $res-as_string;

$response = $ua-get($url);

die Error while getting , $response-request-uri,
-- , $response-status_line, \nAborting
  unless $response-is_success;

open (OUT,  $src) or die Can't read file $src: $!\n;
  print Hi Lori\n;
close OUT;


close OUT2;


$Bill Luebkert wrote:

 lorid wrote:

  Any docs or examples on how to use a proxy when using getstore will be
  greatly appreciated.!
 
  I am having trouble getting a html file from the web due to a proxy
  issue:
 
  I found a debugging tool that helps, and I may just need to ask my boss
  for the right proxy name but I think I have it...
  anyway here is my simple test case , but first the error msg's I
  received:
 
  1st error I got that let me know it really is a proxy problem :
  LWP::UserAgent:: _need_proxy: Not proxid .
 
 
  So I am guessing I can use the same proxy I use for FTP and tried
  using this line I got from the UserAgent manpage under LWP
  :$ua-proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');
   replacing the line in bold with my ftp proxy from work (which is how
  I'm connected to the web)
 
  Which didnt quite work cuz the error I get now is:
  Cant call methond proxy on an undefined value at line 30 (the line
  entails: my$ua-proxy(['http','ftp'],'http://proxy-ftp.dri.edu/');
 
  my test program:
  #!/usr/bin/perl -w
 
  use strict;
  use LWP::Simple;   # LWP = Library for World Wide Web access in Perl
  #use LWP::DebugFile;
 
  use LWP::Debug qw(+ -conns);
 
  my $n = ;
  my $data = ;
  my $response = ;
  print LWP::Debug::conns(read $n bytes: $data);
 
  use URI::URL;
 
 
  my $outdir = C:\\a_perl\\test\\getwebfiles\\ ;
  my $url =
  url('http://earthquake.usgs.gov/recenteqsUS/Quakes/quakes_all.html');
  my $src = $outdir .'quakes_all.html';
  open (OUT,  $src) or die Can't read file $src: $!\n;
 
  require LWP::UserAgent;
  #$ua-proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');
 
  my $ua-proxy(['http', 'ftp'],'http://proxy-ftp.dri.edu/');

 Either use Simple or use an agent.  If you are going to use $ua,
 you need to define it:

 use LWP;
 my $ua = new LWP::UserAgent;
 my $ua-proxy(['http', 'ftp'], 'http://proxy-ftp.dri.edu/');
 my $req = new HTTP::Request 'GET', $url;
 my $res = $ua-request($req);
 print $res-as_string;

   $response = $ua-get($url);
   die Error while getting , $response-request-uri,
  -- , $response-status_line, \nAborting
unless $response-is_success;
 
 
  close OUT;

 --
   ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
  (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
   / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
 -/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: passing parms to subroutine

2003-10-29 Thread lorid
Thanks.
I didnt see anything about the $$ for refering to the value in my book , but
then again Im in a hurry.
anyway - I get it, it works now

Lori

Moon, John wrote:

 SUN1-BATCHperl -e 'my $a=abc; Show(\$a);sub Show {my ($value)[EMAIL 
 PROTECTED];print
 value=$$value\n;}'
 value=abc
 SUN1-BATCH

 Hope this helps ...

 jwm

 -Original Message-
 From: lorid [mailto:[EMAIL PROTECTED]
 Sent: October 29, 2003 14:31
 To: perl users
 Subject: passing parms to subroutine

 Im used to subs in C or VB but this has me puzzled...
 I am trying to pass a scalar ref to a subroutine,
 When I try to use the value of the passed parm inside the sub
 Im getting a garbage value (has address instead of  value? ) from my
 process_files sub,and the increment sub,
 but the sub that I dont declare a prototype on or use () in the func.
 definition It works ??

 Can someone spot my error, or tell me the right way to pass a scalar to
 a sub and use it ?

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

 #prototypes
 sub increment(\$);
 sub process_files(\$);

 my $a= 5;
 my $pc_unzipped_file = 'C:\\TMCC\\CIT_153\\hw9\\hw9_files\\CNUTLZD.TXT';

 increment($a);
 print $a;
 process_files($pc_unzipped_file);

 my $a= 5;
 my $pc_unzipped_file = 'C:\\TMCC\\CIT_153\\hw9\\hw9_files\\CNUTLZD.TXT';

 increment($a);
 print $a;

 process_files($pc_unzipped_file);

 #function defs
 sub increment(\$){

   my $reference = shift;

   print \nThe reference:$reference\n;
   print \nThe reference:@_\n;

   $$reference++;

 }

 sub process_files(\$){

   my $file_ref = shift;

   print \nGot the Filename: $file_ref \n;

print \nGot the Filename: @_\n;
 }

 first (1,2,3);
 sub  first   #how come no ()
 here ? , also I notice they dont create a prototype
 {
   print \nIn first the ars are @_\n;  # this allows me to get
 at values inside the sub which is what I need.
 }

 Thanks

 Lori

 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs