perlcc boot_File__Glob error (solution)

2002-09-06 Thread Tony

I couldn't find a better place to post this information than
beginners section so here it is:

--

If you are compiling your perl prog with perlcc and receive this error,

/tmp/ccaooDv1.o: In function `dl_init':
/tmp/ccaooDv1.o(.text+0x4d687): undefined reference to `boot_File__Glob'
collect2: ld returned 1 exit status

Or one similar to a File__Glob type error, you may want to
check your code to see if your using

while()
{
# statement
}

I was using that statement without using any glob module.

So when I finally narrowed what the error was in reference to down to that code I 
figured what it wanted was a module to define the glob code I was using.

The Fix:

I added this line above all usage instances of that code:

use File::DosGlob 'glob';

I suppose use File::Glob 'glob'
would work too but all I had is DosGlob.pm installed at the moment.

Seems that glob needs to be defined manually with perlcc but with the perl interpreter 
glob is already defined.

If anyone has additional information to educate me a little more on this 'glob' issue 
I'd appreciate it.

Hope this helps someone.

Tony



Re: perlcc boot_File__Glob error (solution)

2002-09-07 Thread Tony

Well, in my case I work for a security company, and I need to close the
source to make sure that our software is "secure".

- Original Message -
From: "Bob Showalter" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, September 07, 2002 8:07 AM
Subject: Re: perlcc boot_File__Glob error (solution)


> I wonder why there's so much traffic on this list about perlcc? Why do so
> many feel the compulsion to "compile" their programs?
>


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




file exists statement

2002-09-08 Thread Tony

I keeps writing this out

if (-e "/dir/path/file"){}else{
#execute
}

To execute a statement when a file doesn't exist.

Someone want to shorten this so I don't have to use an else statement.

Thanks,
Tony



Re: file exists statement

2002-09-08 Thread Tony

Great Jeff, thanks,

Just what I was looking for,

if (not -e '/path') is new to me, that's a great way of handling it!

Thanks,
Tony

- Original Message - 
From: "Jeff" <[EMAIL PROTECTED]>
To: "'Tony'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Sunday, September 08, 2002 2:29 AM
Subject: RE: file exists statement


>  unless -e '/dir/path/file';
> 
> -or-
> 
> if ( not -e '/dir/path/file' ) {
>   
> }
> 


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




Re: perlcc boot_File__Glob error (solution)

2002-09-11 Thread Tony

Paul,

Do you know of a way to reverse the output of perlcc back to the source
code?

Because I've searched for a way and I'm under the impression it is not
reversable.

Also, I figure why not try my best to hide all evidence of what language I'm
using. I try to make it as difficult as possible to determine the language.
Not to mention the group of competitors i'm hidding the code from are
windows c programmers with limited FreeBSD expirience. So I feel this is a
good tactic. Disguising the code as compiled c.

I don't believe the compiled code runs any faster but it must at least save
some cpu usage. Not having to run through the perl interpreter must save
some memory. I seems logical that it would be more efficient for the
computer to run compiled code, than to make it interpret source code.

And I do believe that compiling the code makes it more secure than any other
method. I have been able to unwind encrypted perl scripts which use
filter::decrypt very easily so I choose perlcc as my way of hiding the
source.

If you know something about perlcc that makes it vulnerable to hackers
please share with us,

Thanks Paul,
Tony


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




Re: perlcc boot_File__Glob error (solution)

2002-09-11 Thread Tony

PS.

I don't believe compiling perl source code is a good Idea if you are
distributing to consumers though!

Since it's compiled and it fancies the machine it was compiled on, moving it
means having to ensure that the staticly linked libaries are all in the same
places on the users machice as they were on the machine the code was
compiled.

I just happen to be in the unique position of distributing a product that
I'm able to choose any operating system I want, any software I want, and
configure it in any way I want. So I decided to secure it with perlcc was
the best way only because the code would never be moved onto a server other
than the one's we are distributing. And even if someone slaved the hard
drive and retrieved the perl compiled programs, it would be impossible to
run on another machine with how proprietary I made it to the servers we
build.

Tony


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




Linux Answering Machine

2002-09-16 Thread Tony

I'm trying to create an answering machine for linux,

How can I have perl do something when the modem is getting a ring??

I need to start tinkering with the modem to figure it out.

The modem is on /dev/ttyS4 Whatever that means, I never got that???

Ok, so the basics please, how do I play a message when the ring comes in?

I'm not using mgetty right now because I want to customize the system, and
I can't write c. But I figure I should use something like mgetty to do the hard stuff
and just write customizations around it, but I need a little direction please .. ..

My objective is to have it pickup on the first ring and play a recording
asking for a 4 digit pin number, then if they put in the right one,
it'll ring 4 more times and then go to the answering machine.

So what do you think? Do-able?

I hate telemarketers, and they are driving me nuts!

So guys, for the sake of hating telemarketers help!

Tony



Re: Linux Answering Machine

2002-09-16 Thread Tony

Actually, I think I can do it with

http://search.cpan.org/author/YENYA/Modem-Vgetty-0.03/Vgetty.pm

Vgetty, what do you think?

Looks like it can read the pound key so it should be able to do the 4 digit
#!

Looks promising,
TOny


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




Re: Linux Answering Machine

2002-09-16 Thread Tony

Ok, so this Vgetty module should do most of the work,

but does anyone know of a way to connect two modems together,

if I use modem 1 to check for a pin number followed by a #, then in order
to ring the phones I'll have to use a second modem, no problem, I've got
tons
of modems, but how do I connect the caller on modem one, when I ring the
phones
from modem 2, and that's after I figure out how to ring the phones without
another phone# (If possible)

I'm trying to save money also by not paying sprint for call redirection,
like an ext# system.
Where I dial 1234# and get connected to one phone number, so I'd be writing
an aswering machine
to take my messages, a system to handle exstentions, and a pin number thing
to kill the telemarketers!

Talk about killing 2 birds with one stone.

Well, can't wait to hear some ideas!

Tony

- Original Message -
From: "Tony" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, September 16, 2002 11:42 PM
Subject: Re: Linux Answering Machine


> Actually, I think I can do it with
>
> http://search.cpan.org/author/YENYA/Modem-Vgetty-0.03/Vgetty.pm
>
> Vgetty, what do you think?
>
> Looks like it can read the pound key so it should be able to do the 4
digit
> #!
>
> Looks promising,
> TOny
>
>
> --
> 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: Linux Answering Machine

2002-09-17 Thread Tony

Thanks To Sukumar & Zentara,

I understand about the ringing now, I think I can find something like a usb
device that will ring for me, thanks a lot zentara, that really helps,

Thanks for not letting me go off and kill 20 modems first, hehe

Tony

- Original Message -
From: "zentara" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, September 17, 2002 5:45 AM
Subject: Re: Linux Answering Machine


> On Mon, 16 Sep 2002 23:52:38 -0700, [EMAIL PROTECTED] (Tony)
> wrote:
>
> >Ok, so this Vgetty module should do most of the work,
> >
> >but does anyone know of a way to connect two modems together,
> >
> >if I use modem 1 to check for a pin number followed by a #, then in order
> >to ring the phones I'll have to use a second modem, no problem, I've got
> >tons
> >of modems, but how do I connect the caller on modem one, when I ring the
> >phones
> >from modem 2, and that's after I figure out how to ring the phones
without
> >another phone# (If possible)
> Some thoughts:
> You are not going to be able to ring a modem without some "phoneline
> test equipment". A ring is around a 90 volt sinewave(maybe square), and
> your modem won't produce it.  Various electronic supply companies sell
> phone test equipment to do this, or there are some circuit examples in
> the hobbyist magazines.
> Don't try to make a ringer yourself by reducing the line voltage and
> injecting it, it will burn out your modems input protection
> circuits.  With modem-2-modem connections with a null modem cable, you
> need to use the "GO OFFHOOK" command, I think it was ATOH to get
> a modem to start it's negotiation with another modem.
>
>
>
> --
> 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: Formmail to fax

2002-09-18 Thread Tony

You'll need to use a program like ImageMagick to conver the initial
message into the TIFF format, the universal FAX transmision format.

Then you have to use something like "sendfax" another linux program to send
the fax out, once you have the TIFF file sending the fax is easy,

I'm short on time right now, but read up on "sendfax" and ImageMagick,
Make sure you can run the command on your Linux server "convert", type "man
convert"
and read a little on it, if it can not be found when you type that,
ImageMagick isn't installed and you'll
need to get it. Go to google.com and search ImageMagick to get to their
site.

As for sendmail, also type "man sendmail" in your console to get info, once
again, if it can't be found
install it, go to google.com and search for "Mgetty", sendfax come's with
it, like convert come's with
ImageMagick.

Once you have the proper software, and if you do already all the better,
it's easy.
You'd run the system command through perl like this,

`convert file.html file.tiff`;

I think you can do html to tiff with convert, I'll test for you later, I
really must go but do what I said
and write back if you found the right info ok,

Tony

- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, September 17, 2002 2:59 AM
Subject: Formmail to fax


> How do I get the message collected from a formmail, to be sent to a
> telefax numner. Will it work if I replace the email address with a fax
> number?
>
> Thanks
>
> --
> 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]




substitution from line in context to matched line

2008-08-14 Thread tony
Hello,

gnu grep -C allows for output in context to the matched line
is there an updated way to do this in perl using $. == $linenumber +
context?
I looked into the other thread that mentioned it, but none of the
scripts worked.

I tried the -00 switch and regex backreferences with $1, etc but
thought there must be an easier way.
more importantly,
Is there a way to use such a match as the replacement pattern for a
different line?

Ideally the substitution would be like:
$. == $matchedLineNumber +/- $contextNumber and s/$patternInMatched/
$newPattern/ and print $_;

Here's an example:

I want to edit specific lines in a file using an array of the specific
line numbers.
But I don't know how to reference an element of the array when I use
an implicit loop of the lines in the file from the -p or -n switch.

print line numbers and lines of the file, test.txt

$ perl -wnl -e 'print "$. $_";' test.txt
1 animal cat
2 tag this line
3 animal dog
4 tag this line
5 animal cat
6 tag this line
7

I want to substitute a string in the lines with 'tag' with the
replacement string from the previous line something like:

long way

# get the line numbers of the lines you want the substitution to occur
$ perl -wnl -e '/tag/ and print "$. $_";' test.txt
2 tag this line
4 tag this line
6 tag this line

#then code a substitution line for each line; manually looking at
previous line

#!/usr/bin/env perl -i.old -wpl
$. == 2 and s/this line/cat animal/;
$. == 4 and s/this line/dog animal/;
$. == 6 and s/this line/cat animal/;

instead I want to use an array and loop over the lines in the file
rather than line by line, but
if  is in the implicit array from the -p switch, how do I
reference it?


#!/usr/bin/env perl -i.old -wpl
@array = (2,4,6)
$. = $array[what goes here?] and s/this line/cat animal/

I also tried

#!/usr/bin/env perl -i.old -wpl
@array = (2,4,6)
while (<>){
$. = $array[what goes here?] and s/this line/cat animal/
}

it will work if I specify one line at a time as an argument and I know
beforehand that the line in context is +1 from the matched line:

#!/usr/bin/env perl -s -i.old -wpl
# beforehand find all line numbers that have the pattern
BEGIN {
$ln or warn "Enter line: $0 -ln\n" and exit 255
}
# sample nearby -1 lines that need substitution @lines =
(7303,7309,7315,7321,7327,7333,7339,7345,7351,7357,7363,7369,7375,7381,7387,7393,7399,7405,7411,7417,7423,7429,7435,7441,7447,7453,7459,7465,7471,7477,7483,7489,7495,7501,7507,7513,7519,7525,7531);
$. == $ln + 1 and s/this line/$pattern/g;

Any thoughts or suggestions appreciated!

Best,
tony


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




Re: substitution from line in context to matched line

2008-08-14 Thread tony
On Aug 14, 5:48 am, [EMAIL PROTECTED] (Rob Dixon) wrote:
> -  isn't an implicit array. Where did you read that? It's a read
> operattion on the STDIN file handle.

> Does this program help?
>
> Rob

I was unclear, sorry about that.
You're correct I meant there is an implicit 'loop' (not array!) with
$ perl -pe ';' test.txt or $ perl -e 'while(<>){print;}' test.txt

Thank you very much Rob , this is a great script and help me
understand many things.
I learned lots from reworking it and found a better solution than
manual labor!

I'm sure to learn more from Xavier and John's input too.

I modified it to just get the part of the previous line, but is there
a way get any line besides the previous when one doesn't know the
context range ie -C[0-9]{1,}  when the context is variable (see
revised script)

That is why I tried to get the exact line numbers of nearby matched
lines then collect them in an array and then loop over the linenumber
elements with substitution lines which are in variable context to the
matched line. I finally found out that there is no index using a
foreach loop. :-(

Here's your revised program:
#!/usr/bin/env perl
use strict;
use warnings;
my $prev = ''; #the matched line that is one line previous to the
context line.
my $prevpattern = ''; #a substring of the previous line
my $linepattern = "tag"; #lines that need substitution have 'tag' or
some pattern aka the context line needing substitution

while () {
  chomp;
  if (/$linepattern/) {
$prevpattern = substr($prev,index($prev," ")+1,10); #don't want the
whole previous line just the last word(s), either cat or dog or better
yet any substring within the matched line
s/this/$prevpattern/;
  }
  else {
$prev= $_;
  }
  print "$_\n";
}

__END__
animal cat
tag this line
animal dog
tag this line
blue ideas snore peacefully #this line won't interfere with
substitution because it is not between the matched previous line and
its context line
green thoughts wade holy#this line won't interfere with substitution
because it is not between the matched previous line and its context
line
animal cat
ugh thee line that breaks the script # the next 'tag' line should be
'tag cat line' not 'tag now line'
more
now
tag this line
tool hammer
tag this line

I get a good result, except where the context range is variable as at
lines 7 to 11 where line 7, the match line with my pattern 'cat' is
not previous to line 11, the line where the substitution suppose to
occur:

Result of above program:
 1  animal cat
 2  tag cat line
 3  animal dog
 4  tag dog line
 5  blue ideas snore peacefully #this line won't interfere with
substitution because it is not between the matched previous line and
its context line
 6  green thoughts wade holy#this line won't interfere with
substitution because it is not between the matched previous line and
its context line
 7  animal cat
 8  ugh thee line that breaks the script # the next 'tag' line
should be 'tag cat line' not 'tag now line'
 9  more
10  now
11  tag now line
12  tool hammer
13  tag hammer line


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




can you see the the p-code

2009-05-05 Thread Tony Esposito
Just curious ... does Perl create an (intermediate) file that contains the 
p-code that is created by the compiler just prior to passing control to the 
Perl interpreter?  If so, where would this file be and what would the file be 
named?  Is there a Perl command-line switch that can be used to 'keep' the file 
for viewing afterward?

thx.


  

deleting subdirectories only in Win32

2009-05-13 Thread Tony Esposito
Hello,
  When trying to delete subdirectories and their files on WinXP SP3, the 
following code also removes the root directory of the subdirectories.  Can I 
get some assistance?  I want to keep C:\my\data intact but I am losing the 
\data folder

#
# Code to remove all files and subdirectories under C:\my\data
#
perl -e "use File::Path; rmtree('C:/my/data',{keep_root => 1, safe => 1});"


  

Fw: deleting subdirectories only in Win32

2009-05-14 Thread Tony Esposito
It appears that, after doing more research, the keep_root variable does not 
keep the \data folder intact but removes it.  Unless I am mistaken, is there 
another method to cleaning a directory of files and subdirectories without 
removing the directory itself?
(I know I can do it programmatically but I was wondering if there was a 
'1-liner' like the one previously listed).


- Forwarded Message ----
From: Tony Esposito 
To: Beginners Perl 
Sent: Wednesday, 13 May, 2009 12:56:45
Subject: deleting subdirectories only in Win32

Hello,
  When trying to delete subdirectories and their files on WinXP SP3, the 
following code also removes the root directory of the subdirectories.  Can I 
get some assistance?  I want to keep C:\my\data intact but I am losing the 
\data folder

#
# Code to remove all files and subdirectories under C:\my\data
#
perl -e "use File::Path; rmtree('C:/my/data',{keep_root => 1, safe => 1});"


  

Getting STDIN filename from command line

2009-05-21 Thread Tony Esposito
Hello,

Given the command line:

perl myperl.plx < myfile.txt

is there anyway from within the Perl script to capture the redirected STDIN 
filename (i.e., myfile.txt)?

OS:      WinXP SPSP3
Perl:     5.8.8 for Win32 from ActiveState

Thx.


  

split() does not work with all characters

2009-06-02 Thread Tony Esposito
When trying to use split() where the delimiter is passed from the command-line 
( as seen in stub code that follows ), 
the code fails to parse/split input file via some characters (e.g. | ) but it 
runs ok for others (e.g. , ).

Any idea what could be causing this?


Code:


  use vars qw/ %opt /;    
  use Getopt::Std;
  my $optString = 'd:';

  getopts( "$optString", \%opt );

  while() {
    @cfgData = split(/$opt{d}/); 
    ...
  }



  

Fw: Having problems getting data back to STDOUT once I assign it to a file

2009-07-21 Thread Tony Esposito
Back to the question at hand - have you tried using 'tee'


use File::Tee qw(tee);

# simple usage:
tee(STDOUT, '>', 'stdout.txt');

Tony




From: John W. Krahn 
To: 
Sent: Tuesday, 21 July, 2009 8:41:25
Subject: Re: Having problems getting data back to STDOUT once I assign it to a 
file

Shawn H. Corey wrote:
> John W. Krahn wrote:
>> Shawn H. Corey wrote:
>>> Wagner, David --- Senior Programmer Analyst --- CFS wrote:
>>>>    I am done processing and I want to place the final output line also on 
>>>>the screen. Here is what I have:
>>>> 
>>>>    if ( $GlblInfo{audit} ) {
>>>>        printf "\n\n*Should be last line in the audittrail 
>>>>file...*\n\n";
>>>>        close(STDOUT);
>>>>        close(STDERR);
>>>>        open(STDOUT , '>') || die "Unable to open STDOUT: $!";
>>> 
>>> You're not opening STDOUT to anything.  And you closed STDERR so the die 
>>> message can't go anywhere.  In fact, it goes into an infinite loop.
>> 
>> No it doesn't, there is no loop there.
> 
> It goes into an infinite loop on my machine.  I suggest you try it before you 
> make such blanket statements.

I did and it doesn't on my machine.  Perhaps your OS or C library is doing 
something stupid?  It makes no sense for IO on an unopened filehandle to loop.



John
-- Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov

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


  

Perl and HTML

2009-07-31 Thread Tony Esposito
I am using Perl 5.8.x, Windows XP SP2 and Novell GroupWise email client.  
I have written a program to send an email which contains HTML.  Issue is that 
in the email body the 'body' shows up as HTML text and GroupWise has the choice 
to read it in HTML grayed-out (for this email only).  In other words, I get no 
processed HTML just the HTML text and I can not choose to read it in HTML (btw 
- have no such issue with other emails from other sources containg HTML.  I can 
choose to read it in HTML via GroupWise w/o issues).

Question:  How do I send a email containing HTML that can be read/processed by 
GroupWise as HTML?

Test code snippet: 

#!/usr/bin/perl

my $mailBody;

sub do_html() {
  $mailBody = <
  
   
   
    Hello 
  
   
  
 Hi
 "hello world" HTML document.
  
  
ENDHTML
}

sub do_email() {
  use Net::SMTP;
  my $Smtp;
  
  $Smtp = Net::SMTP->new("smtp.server.net") or die "Unable to connect to email 
server: $!"; 
  $Smtp->mail("b...@yahoo.com"); 
  $Smtp->to("bi...@yahoo.com");
  $Smtp->data();   
  .
  $Smtp->datasend("From: ("b...@yahoo.com"\n");
  $Smtp->datasend("To:("bi...@yahoo.com"");
  $Smtp->datasend("Subject: test HTML message\n");
  $Smtp->datasend("\n");

  $Smtp->datasend($mailBody);
  $Smtp->dataend();   
  $Smtp->quit;    
}

  do_html();
  do_email();
  exit;



  

Re: Perl and HTML

2009-07-31 Thread Tony Esposito
Thanks ... I'll give that a shot ... any other suggestions are welcomed ... 
thank again, Dermot.





From: Dermot 
To: Tony Esposito 
Cc: Beginners Perl 
Sent: Friday, 31 July, 2009 17:00:45
Subject: Re: Perl and HTML

2009/7/31 Tony Esposito :
> I am using Perl 5.8.x, Windows XP SP2 and Novell GroupWise email client.
> I have written a program to send an email which contains HTML.  Issue is that 
> in the email body the 'body' shows up as HTML text and GroupWise has the 
> choice to read it in HTML grayed-out (for this email only).  In other words, 
> I get no processed HTML just the HTML text and I can not choose to read it in 
> HTML (btw - have no such issue with other emails from other sources containg 
> HTML.  I can choose to read it in HTML via GroupWise w/o issues).
>
> Question:  How do I send a email containing HTML that can be read/processed 
> by GroupWise as HTML?
>
> Test code snippet:
>
> #!/usr/bin/perl
>
> my $mailBody;
>
> sub do_html() {
>   $mailBody = <   
>   
>    
>   
>     Hello
>   
>    
>   
>  Hi
>  "hello world" HTML document.
>   
>   
> ENDHTML
> }
>
> sub do_email() {
>   use Net::SMTP;


Take a look at MIME::Lite[1]. HTML emails are multi-part and as far I
know, that not Net::SMTP's game.
HTH,
Dp.


1) http://search.cpan.org/~rjbs/MIME-Lite-3.024/lib/MIME/Lite.pm

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


  

Code for making the 'clock'

2009-08-19 Thread Tony Esposito
Anyone have the code that make the 'clock' show when a Perl program is running?
What I mean by the 'clock' is the command-line movement that sequentially does 
the following (in place):

- \ | / - \ | / 

when running it looks like a 'clock' to show the user that something is 
processing ...
Thx.


  

one liner in Windows to replace string

2009-08-24 Thread Tony Esposito
perl -p -i.bak -e 's/CONSTANT/VARIABLE/' C:\test.txt

Trying to replace a string with this one line perl ... in Windows it does not 
seem to work ...

File test.txt contents is ...

CONSTANT 100
CONSTANT 200

nothing changes ... acts as if it does not 'see' the CONSTANT string.

Help because it looks like it should work !!!


  

Re: one liner in Windows to replace string

2009-08-24 Thread Tony Esposito
I am happy that it works with double quotes BUT now, when I try to get all 
files in a directory with a certain extension, the following does not work ...

perl -p -i.bak -e "'s/CONSTANT/VARIABLE/'" C:\*.txt

does not like th leading * in the file name when I try to pull all .txt files 
...

Help again.





From: Shawn H. Corey 
To: "Wagner, David --- Senior Programmer Analyst --- CFS" 

Cc: Tony Esposito ; Beginners Perl 

Sent: Monday, 24 August, 2009 12:57:27
Subject: Re: one liner in Windows to replace string

Wagner, David --- Senior Programmer Analyst --- CFS wrote:
>     I ran under windows with what Tony sent, both the cmd and a korn
> shell and both worked and updated as expected..
> 
>          If you have any questions and/or problems, please let me know.
>          Thanks.

What version of Windows?  The last time I used Windows was XP and it would see 
single quotes as:

perl -p -i.bak -e "'s/CONSTANT/VARIABLE/'" C:\test.txt

which, of course, don't work.


-- Just my 0.0002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

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


  

Re: one liner in Windows to replace string

2009-08-24 Thread Tony Esposito
Ok, I can glob() ...

perl -e "use File::DosGlob qw(glob);print glob('test.*')"   # works ok!!

but I can not replace (my syntax is incorrect but where) ...

perl -e "use File::DosGlob qw(glob);'s/CONSTANT/VARIABLE/' glob('test.*')"  # 
does not work -- compilation error ...

??



From: Bob McConnell 
To: Tony Esposito ; Shawn H. Corey 
; "Wagner, David --- Senior Programmer Analyst --- CFS" 

Cc: Beginners Perl 
Sent: Monday, 24 August, 2009 14:39:57
Subject: RE: one liner in Windows to replace string

Windows does not expand the wildcard in your filename like the Unix/Linux 
shells do. There is a glob hack that you can use to do that expansion.

Bob McConnell

-Original Message-
From: Tony Esposito [mailto:tony1234567...@yahoo.co.uk] 
Sent: Monday, August 24, 2009 3:20 PM
To: Shawn H. Corey; Wagner, David --- Senior Programmer Analyst --- CFS
Cc: Beginners Perl
Subject: Re: one liner in Windows to replace string

I am happy that it works with double quotes BUT now, when I try to get all 
files in a directory with a certain extension, the following does not work ...

perl -p -i.bak -e "'s/CONSTANT/VARIABLE/'" C:\*.txt

does not like th leading * in the file name when I try to pull all .txt files 
...

Help again.





From: Shawn H. Corey 
To: "Wagner, David --- Senior Programmer Analyst --- CFS" 

Cc: Tony Esposito ; Beginners Perl 

Sent: Monday, 24 August, 2009 12:57:27
Subject: Re: one liner in Windows to replace string

Wagner, David --- Senior Programmer Analyst --- CFS wrote:
>     I ran under windows with what Tony sent, both the cmd and a korn
> shell and both worked and updated as expected..
> 
>          If you have any questions and/or problems, please let me know.
>          Thanks.

What version of Windows?  The last time I used Windows was XP and it would see 
single quotes as:

perl -p -i.bak -e "'s/CONSTANT/VARIABLE/'" C:\test.txt

which, of course, don't work.


-- Just my 0.0002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

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


  

Re: one liner in Windows to replace string

2009-08-24 Thread Tony Esposito
Looks good but it bombs ... the Perl interpreter crashes from the DOS prompt 
... using version 5.10.0 build 1005 from ActiveState.

But it was better than what I had, that's for sure

This makes for a bit of a mind teaser thanks to it being on Windoze ... :-)





From: Shawn H. Corey 
To: Tony Esposito 
Cc: "Wagner, David --- Senior Programmer Analyst --- CFS" 
; Beginners Perl 
Sent: Monday, 24 August, 2009 14:49:47
Subject: Re: one liner in Windows to replace string

Tony Esposito wrote:
> I am happy that it works with double quotes BUT now, when I try to get all 
> files in a directory with a certain extension, the following does not work ...
>  perl -p -i.bak -e "'s/CONSTANT/VARIABLE/'" C:\***.txt
>  does not like th leading * in the file name when I try to pull all .txt 
>files ...
>  Help again.

perl -p -i.bak -e "beg...@argv=map{glob}@ARGV}s/CONSTANT/VARIABLE/" C:\*.txt


-- Just my 0.0002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.



  

removing a 'tee'd file handles going forward

2009-08-26 Thread Tony Esposito
I want to output to both STDOUT and STDERR at one point in my program, then 
want to separate the two handles going forward in the program so that output is 
sent to STDOUT and STDERR separately.  Given the code snip below, would the 
"undef tee" do the trick?
 
use IO::Tee;

my $tee = new IO::Tee(\*STDOUT,\*STDERR);
$tee->print("Hi\n"); 
$tee->flush;

# some code here ... blah, blah, blah ...
# now want to change to set and 'untee' STDOUT and STDERR ...

undef tee;   # is this going to do it?

Thanks.


  

Re: removing a 'tee'd file handles going forward

2009-08-26 Thread Tony Esposito
Agreed.  But the program flow would be such (pseudo-code):

(1) print STDOUT 
    print STDERR
(2) now print to both in one print statement

(3) now go back to 
    print STDOUT
    print STDERR

I want to switch back-and-forth between being able to print to STDOUT, STDERR 
with one 'print' statement and then back ...

HTH






From: Jenda Krynicky 
To: Beginners Perl 
Sent: Wednesday, 26 August, 2009 10:44:15
Subject: Re: removing a 'tee'd file handles going forward

Date sent:    Wed, 26 Aug 2009 15:36:26 + (GMT)
From:    Tony Esposito 
Subject:    removing a 'tee'd file handles going forward
To:    Beginners Perl 

> I want to output to both STDOUT and STDERR at one point in my program, then 
> want to separate the two handles going forward in the program so that output 
> is sent to STDOUT and STDERR separately.  Given the code snip below, would 
> the "undef tee" do the trick?
>  
> use IO::Tee;
>
> my $tee = new IO::Tee(\*STDOUT,\*STDERR);
> $tee->print("Hi\n"); 
> $tee->flush;
>
> # some code here ... blah, blah, blah ...
> # now want to change to set and 'untee' STDOUT and STDERR ...
>
> undef tee;   # is this going to do it?

Well it will, but there is no need to do that. You can print to
STDOUT and STDERR even while the tee exists.

print $tee "Foo\n";

will go to both

print STDOUT "Foo\n";

will go to STDOUT and

print STDERR "Foo\n";

to STDERR.

And

print "Foo\n";

to the select()ed filehandle.

Jenda


= je...@krynicky.cz === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
    -- Terry Pratchett in Sourcery


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


  

Re: removing a 'tee'd file handles going forward

2009-08-26 Thread Tony Esposito
Ok.  I misunderstood.  Thought - incorrectly - that STDOUT and STDERR were 
somehow 'joined' by the 'tee' operation.  Once again, my mistake.  Thx.





From: Jenda Krynicky 
To: Tony Esposito 
Cc: Beginners Perl 
Sent: Wednesday, 26 August, 2009 13:51:03
Subject: Re: removing a 'tee'd file handles going forward

From: Tony Esposito 
> Agreed.  But the program flow would be such (pseudo-code):
>
> (1) print STDOUT
>     print STDERR
> (2) now print to both in one print statement
>
> (3) now go back to
>     print STDOUT
>     print STDERR
>
> I want to switch back-and-forth between being able to print to STDOUT,
> STDERR with one 'print' statement and then back ...
>
> HTH

I said you can! And you do not have to destroy the tee and then
create it again. Once you create the tee you can print to STDOUT,
STDERR or the teen any time you want, as many times you want and in
any order you want.

Jenda
= je...@krynicky.cz === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
    -- Terry Pratchett in Sourcery


  

Re: removing a 'tee'd file handles going forward

2009-08-26 Thread Tony Esposito
Thank you all for the input ... I have it working now.

:-)





From: Tim Bowden 
To: Perl Beginners 
Sent: Wednesday, 26 August, 2009 15:20:13
Subject: Re: removing a 'tee'd file handles going forward

On Wed, 2009-08-26 at 18:22 +, Tony Esposito wrote:
> Agreed.  But the program flow would be such (pseudo-code):
> 
> (1) print STDOUT 
>    print STDERR
> (2) now print to both in one print statement
> 
> (3) now go back to 
>    print STDOUT
>    print STDERR
> 
> I want to switch back-and-forth between being able to print to STDOUT, STDERR 
> with one 'print' statement and then back ...
> 
> HTH
> 
> 
> 
> 
> 
> 
> From: Jenda Krynicky 
> To: Beginners Perl 
> Sent: Wednesday, 26 August, 2009 10:44:15
> Subject: Re: removing a 'tee'd file handles going forward
> 
> Date sent:    Wed, 26 Aug 2009 15:36:26 + (GMT)
> From:    Tony Esposito 
> Subject:    removing a 'tee'd file handles going forward
> To:    Beginners Perl 
> 
> > I want to output to both STDOUT and STDERR at one point in my
>  program, then want to separate the two handles going forward in the
>  program so that output is sent to STDOUT and STDERR separately.  Given
>  the code snip below, would the "undef tee" do the trick? >  > use
>  IO::Tee; > > my $tee = new IO::Tee(\*STDOUT,\*STDERR); >
>  $tee->print("Hi\n"); > $tee->flush; > > # some code here ... blah,
>  blah, blah ... > # now want to change to set and 'untee' STDOUT and
>  STDERR ... > > undef tee;  # is this going to do it?
> 
> Well it will, but there is no need to do that. You can print to
> STDOUT and STDERR even while the tee exists.
> 
> print $tee "Foo\n";
> 
> will go to both
> 
> print STDOUT "Foo\n";
> 
> will go to STDOUT and
> 
> print STDERR "Foo\n";
> 
> to STDERR.
> 
> And
> 
> print "Foo\n";
> 
> to the select()ed filehandle.
> 
> Jenda
> 
> 

*WARNING: Newbie alert!*  ;-)
but the code is tested...

If you set it up right, you can also select the filehandle at runtime if
that helps.  If you set autoflush on the fh's, or don't need to use
flush at all then it's even simpler that what I've done here; no need
for references to the fh's, just select the relevant FH directly as
needed.

#!/usr/bin/perl -wT
use strict;

use IO::Tee;
my $tee;
my $somecondition = 1;
my $tee_all = new IO::Tee(\*STDOUT, \*STDERR);
$tee = \*STDOUT;
select $$tee;

print "going to stdout only\n";
$$tee->flush;

# select output fh at runtime
if ($somecondition == 1){
  $tee = \$tee_all;
  select $$tee;
}

print "this goes to all\n";
$$tee->flush;

$tee = \*STDERR;
select $$tee;
print "this goes to stderr only\n";
$$tee->flush;


Regards,
Tim Bowden


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


  

Limit on number of columns pulled using DBI::ODBC

2009-09-30 Thread Tony Esposito
Is there a limit on the number of columns pulled from a table using DBI::ODBC?
 
Database: Oracle 10gR2
O/S:  WIndowsXP
Perl: 5.8.9
 
I am getting an 'out of memory' error if I try to retrieve 40 columns or more 
when using the following ...
 
my $dbh = DBI->connect( dbi:ODBC:orcl, "login", "password",
 { RaiseError => 1 }
  ) || die "Database connection not made: $DBI::errstr";

while (my $tableRef = $sth->fetchrow_arrayref) {
...
}

Send instant messages to your online friends http://uk.messenger.yahoo.com 

Re: Limit on number of columns pulled using DBI::ODBC

2009-09-30 Thread Tony Esposito
I notice the behaviour changes as I adjust the following parameter ...

 $dbh->{LongReadLen} = 2;

This is an Oracle database I am going against - version 10gR2

--- On Wed, 30/9/09, Tony Esposito  wrote:

From: Tony Esposito 
Subject: Limit on number of columns pulled using DBI::ODBC
To: "Beginners Perl" 
Date: Wednesday, 30 September, 2009, 11:06 AM

Is there a limit on the number of columns pulled from a table using DBI::ODBC?
 
Database: Oracle 10gR2
O/S:  WIndowsXP
Perl: 5.8.9
 
I am getting an 'out of memory' error if I try to retrieve 40 columns or more 
when using the following ...
 
my $dbh = DBI->connect( dbi:ODBC:orcl, "login", "password",
 { RaiseError => 1 }
  ) || die "Database connection not made: $DBI::errstr";

while (my $tableRef = $sth->fetchrow_arrayref) {
...
}

Send instant messages to your online friends http://uk.messenger.yahoo.com 


  

Re: Limit on number of columns pulled using DBI::ODBC

2009-09-30 Thread Tony Esposito
After doing some research, it looks like I am having problems either retrieving 
CLOBs or just that the source database (Oracle 10gr2) is set to UTF-8 character 
set.

I am trying to retrieve all columns and some (not all) rows from an Oracle 
table which contain - among other things - 2 CLOB columns and print this to a 
flat file (ASCII file).  

As I "tune" $dbh->{LongReadLen} = 2 I can varying results from 'Out of 
Memory!" errors to not all data retrieved to a Perl Interpreter Error Window, 
which asks me if I want to send the error contents to Microsoft.  

I am running on WindowsXP SP2 and using the DBI::ODBC driver with the Oracle 
Client ODBC driver.

The SQL statement is just SELECT * FROM table, nothing fancy here.  I just 
believe that the data is 'too big/wide' for the variables I am using to hold 
them and that is why I am leaning to this being an character set encoding 
issue.  But I was hoping that adjusting  $dbh->{LongReadLen} = 2 would work.

Alsot tried  $dbh->{LongTruncOk} = 1; just to truncate the any data that 
overflows memory but still get same errors.

HTH

--- On Wed, 30/9/09, Steve Bertrand  wrote:

From: Steve Bertrand 
Subject: Re: Limit on number of columns pulled using DBI::ODBC
To: "Tony Esposito" 
Cc: "Beginners Perl" 
Date: Wednesday, 30 September, 2009, 8:39 PM

Tony Esposito wrote:
> Is there a limit on the number of columns pulled from a table using DBI::ODBC?

Although I just received your own reply to this message, I'll respond to
this one as I have some questions.

> I am getting an 'out of memory' error if I try to retrieve 40 columns or more 
> when using the following ...

Are you referring really to "columns", or do you mean 'rows'?

> my $dbh = DBI->connect( dbi:ODBC:orcl, "login", "password",
>                          { RaiseError => 1 }
>                       ) || die "Database connection not made: $DBI::errstr";
> 

It would be prudent for you to explain what you have in '...' here. ie.
what does your select statement say?

> while (my $tableRef = $sth->fetchrow_arrayref) {
> ...
> }

...again, I can't tell if you are really configuring a statement to
acquire just the table column headings (because you haven't shown us
your SQL statement), or if you are using the terminology 'columns' when
you really mean 'rows'.

Without knowing either Oracle or your statement, I'd have to assume that
it may help if you throw a 'limit N' at the end of your statement.

Grab what you can from the db using 'limit', write a function that
checks the next id in the table and then grabs the next N number of rows.

fwiw, $dbh->{LongReadLen} = 2; is something I've never seen before...

What is it you are trying to do exactly?

Steve



  

Re: Limit on number of columns pulled using DBI::ODBC

2009-10-05 Thread Tony Esposito
Oracle does not have a LIMIT clause ... the best that can be done is to use 
row_num but that can get 'funky'.  Basically you are saying that I get a subset 
(a block) of data at a time and then repeat the process until all rows are 
retrieved.  Is that correct?  Do have an Oracle example of using row_num 
instead of LIMIT (which I believe is MySQL)?
 
thanks

--- On Wed, 30/9/09, Steve Bertrand  wrote:


From: Steve Bertrand 
Subject: Re: Limit on number of columns pulled using DBI::ODBC
To: "Tony Esposito" 
Cc: "Beginners Perl" 
Date: Wednesday, 30 September, 2009, 10:14 PM


Tony Esposito wrote:

Please try to fix your email application (Yahoo) to wrap lines at ~76
chars per line ;)

> I am trying to retrieve all columns and some (not all) rows from an Oracle 
> table which contain - among other things - 2 CLOB columns and print this to a 
> flat file (ASCII file).  
> 
> As I "tune" $dbh->{LongReadLen} = 2 I can varying results from 'Out of 
> Memory!" errors to not all data retrieved to a Perl Interpreter Error Window, 
> which asks me if I want to send the error contents to Microsoft.  

It seems you are setting a global variable for something that you should
limit within a smaller scope.

Again, without knowing what your statement is, it's hard to say, but if
I were running into memory issues, I'd rebuild my SQL query as such:

my $sth = ("
        SELECT *
        FROM table_name
        LIMIT 5000
    ") or die $dbh->errstr;

imho, global catchalls should be used as a *very last* resort to trap
problems that will cause fatal OS errors.

By using the 'LIMIT' statement, you can get what you want, write it to a
file, de-allocate the memory, get the row id that you left off at, and
then start over again by grabbing another 'limit' number of rows and
appending that chunk to the file.

If you need further help with doing this, at least reply with what your
auto-increment is called, and what your full statement is.

I'll help you write a function to 'chunk' things up.

There are two possible outcomes to that:

- I respond with code for you and it works or it doesn't

- someone else responds with code for you that works

and

- the code that you are responded with is reviewed and criticized
heavily, and what falls out the bottom of the thread is much better and
more intriguing than you could have imagined ;)

Steve


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




Send instant messages to your online friends http://uk.messenger.yahoo.com 

Email does not send attachment ...

2009-12-08 Thread Tony Esposito
Hello,

I am using Perl 5.8 on WindowsXP and Windows Server 2003.  I can not get the 
following attachment to arrive/attach even though I get the email with no 
issues.  Any ideas?

  use MIME::Lite;
 use Net::SMTP;
 
 unless (-e 'C:/my_file.log' && -s 'C:/my_file.log' ) { print "file not 
found\n"; }
 
  my $msg = MIME::Lite->new (
    From => 'my_em...@yahoo.com',
    To => 'your_em...@yahoo.com',
    Subject => 'Testing error email',
    Type =>'multipart/mixed'
  ) or die "Error creating multipart container: $!\n";
  
 $msg->attach (
    Type => 'TEXT',
    Data => 'Error in the module that caused this email',
  ) or die "Error adding the body text to email message: $!\n";
 
   $msg->attach (
 Type => 'TEXT',
 Path => 'C:/my_file.log',
 Filename => 'my_file.log',
 Disposition => 'attachment'
 ) or die "Error adding file attachment: $!\n";

  MIME::Lite->send('smtp', 'smtp.server.net', Timeout=>60);
  $msg->send; 
 
__END__

Thank you!


  

Re: Email does not send attachment ...

2009-12-09 Thread Tony Esposito
Thanks to all.  I abandoned MIME::Lite in favor Mail::Sender and got it to work 
fine.




From: Philip Potter 
To: "beginners@perl.org" 
Sent: Wed, 9 December, 2009 6:06:01
Subject: Re: Email does not send attachment ...

2009/12/9 Sneed, Sean P :
> Try the paths like this C:\\my_file.log

Is there a reason that you suggested this? Perl under Windows, just
like C and C++ under Windows, accepts / as a directory separator just
fine. And if you stick to using / as your directory separator, porting
to unix-based systems becomes that much easier.

Perlmonks has a far more full discussion of the implications of using
"/" or "\\" as your directory separator under Windows:
http://www.perlmonks.org/?node_id=110030

and indeed there are some good reasons given for using "\\" in
filenames under windows, such as when you are passing a filename to a
system() call. But there are also good reasons for avoiding "\\", such
as consistency and portability. I doubt that MIME::Lite will be
affected by being passed a "/" delimited filename but I guess it's
worth a go. Without much more information to go on, though, it's hard
to diagose the original problem.

Phil

> -Original Message-
> From: Robert H [mailto:sigz...@gmail.com]
> Sent: Tuesday, December 08, 2009 6:58 PM
> To: beginners@perl.org
> Subject: Re: Email does not send attachment ...
>
> On 12/8/09 3:56 PM, Tony Esposito wrote:
>> Hello,
>>
>> I am using Perl 5.8 on WindowsXP and Windows Server 2003.  I can not get the 
>> following attachment to arrive/attach even though I get the email with no 
>> issues.  Any ideas?
>>
>>    use MIME::Lite;
>>   use Net::SMTP;
>>
>>   unless (-e 'C:/my_file.log'&&  -s 'C:/my_file.log' ) { print "file
>> not found\n"; }
>>
>>    my $msg = MIME::Lite->new (
>>      From =>  'my_em...@yahoo.com',
>>      To =>  'your_em...@yahoo.com',
>>      Subject =>  'Testing error email',
>>      Type =>'multipart/mixed'
>>    ) or die "Error creating multipart container: $!\n";
>>
>>   $msg->attach (
>>      Type =>  'TEXT',
>>      Data =>  'Error in the module that caused this email',
>>    ) or die "Error adding the body text to email message: $!\n";
>>
>>     $msg->attach (
>>       Type =>  'TEXT',
>>       Path =>  'C:/my_file.log',
>>       Filename =>  'my_file.log',
>>       Disposition =>  'attachment'
>>       ) or die "Error adding file attachment: $!\n";
>>
>>    MIME::Lite->send('smtp', 'smtp.server.net', Timeout=>60);
>>    $msg->send;
>
> I see why you do that now. Sorry.
>
> Bob
>
> --
> 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/
>
>
>

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


  

Getting USER env variable in Windows -- How to?

2009-12-09 Thread Tony Esposito
I need to get the current USER env var in a Windows Perl program.  Does anyone 
know how this is done?  I have done it on UNIX/Linux.

Thx.


  

passing command-line arg containing '@'

2009-12-09 Thread Tony Esposito
I need to pass an command-line arg that is a string which contains the '@'.  Is 
there any way to do this and also 'tell' Perl not to interpret this as other 
than a '@' character?
 
Thx.



  

Oracle DBI::ODBC and SELECT FOR UPDATE

2009-12-26 Thread Tony Esposito
Has anyone successfully used, in Oracle, a 'SELECT ... FOR UPDATE' using the 
Perl DBI:: ODBC?


  

prepare(SELECT ... FROM TABLE) error

2010-02-01 Thread Tony Esposito
when the table does not exist the prepare fails.  How do ignore the error 
thrown by the prepare() and catch it later in the program?
 
 
my $dbh = DBI->connect("dbi:ODBC:mysql"  
 ,$login 
 ,$passwd
 ,{ RaiseError => 0 }
    );
...
$sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   # don't catch
 $retCode = $sth->execute();
if ($dbh->err) {
  print "Table $table -- DOES NOT EXIST\n";
}

 


  

Re: prepare(SELECT ... FROM TABLE) error

2010-02-01 Thread Tony Esposito
Is this the idea? I do not ever want to catch the error from the prepare 
statement itself -- I want my code to catch and throw the error.  And I am 
using Perl 5.8 so I do not need the use 5.010; pragma   thx 

use strict;
use warnings;
use 5.010;  

eval {
my $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   
};

if ($dbh->err) {
  print "Table $table -- DOES NOT EXIST\n";
}
$retCode = $sth->execute();
 
--- On Mon, 1/2/10, 7 <7stud.7s...@gmail.com> wrote:


From: 7 <7stud.7s...@gmail.com>
Subject: Re: prepare(SELECT ... FROM TABLE) error
To: "Beginners Perl" 
Date: Monday, 1 February, 2010, 14:05


On Mon, Feb 1, 2010 at 12:11 PM, Tony Esposito
wrote:

> when the table does not exist the prepare fails.  How do ignore the error
> thrown by the prepare() and catch it later in the program?
>
>
> my $dbh = DBI->connect("dbi:ODBC:mysql"
>                          ,$login
>                          ,$passwd
>                          ,{ RaiseError => 0 }
>                         );
> ...
> $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   # don't catch
>  $retCode = $sth->execute();
> if ($dbh->err) {
>   print "Table $table -- DOES NOT EXIST\n";
> }
> 
>



See if this helps:


use strict;
use warnings;
use 5.010;


eval {
    die "***prepare error***";
};

say 'executing other code here';

if ($@) {
    say "There was an error inside that eval block above: $@";
}



 
 
 
 
 
 
 
> my $dbh = DBI->connect("dbi:ODBC:mysql"
>                          ,$login
>                          ,$passwd
>                          ,{ RaiseError => 0 }
>                         );
> ...
> $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   # don't catch
>  $retCode = $sth->execute();
> if ($dbh->err) {
>   print "Table $table -- DOES NOT EXIST\n";
> }
> 
>



See if this helps:


use strict;
use warnings;
use 5.010;


eval {
    die "***prepare error***";
};

say 'executing other code here';

if ($@) {
    say "There was an error inside that eval block above: $@";
}


--- On Mon, 1/2/10, 7 <7stud.7s...@gmail.com> wrote:


From: 7 <7stud.7s...@gmail.com>
Subject: Re: prepare(SELECT ... FROM TABLE) error
To: "Beginners Perl" 
Date: Monday, 1 February, 2010, 14:05


On Mon, Feb 1, 2010 at 12:11 PM, Tony Esposito
wrote:

> when the table does not exist the prepare fails.  How do ignore the error
> thrown by the prepare() and catch it later in the program?
>
>
> my $dbh = DBI->connect("dbi:ODBC:mysql"
>                          ,$login
>                          ,$passwd
>                          ,{ RaiseError => 0 }
>                         );
> ...
> $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   # don't catch
>  $retCode = $sth->execute();
> if ($dbh->err) {
>   print "Table $table -- DOES NOT EXIST\n";
> }
> 
>



See if this helps:


use strict;
use warnings;
use 5.010;


eval {
    die "***prepare error***";
};

say 'executing other code here';

if ($@) {
    say "There was an error inside that eval block above: $@";
}


--output:--
executing other code here
There was an error inside that eval block above: ***prepare error*** at
2perl.pl line 7.



  

Re: prepare(SELECT ... FROM TABLE) error

2010-02-01 Thread Tony Esposito
Also, if prepare fails, I want to continue processing -- hence the need to 
capture the error in my code and not have DBI::DBD throw and exception then 
stop all processing ...

--- On Mon, 1/2/10, Tony Esposito  wrote:


From: Tony Esposito 
Subject: Re: prepare(SELECT ... FROM TABLE) error
To: "Beginners Perl" , "7" <7stud.7s...@gmail.com>
Date: Monday, 1 February, 2010, 14:40


Is this the idea? I do not ever want to catch the error from the prepare 
statement itself -- I want my code to catch and throw the error.  And I am 
using Perl 5.8 so I do not need the use 5.010; pragma   thx 

use strict;
use warnings;
use 5.010;  

eval {
my $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   
};

if ($dbh->err) {
  print "Table $table -- DOES NOT EXIST\n";
}
$retCode = $sth->execute();
 
--- On Mon, 1/2/10, 7 <7stud.7s...@gmail.com> wrote:


From: 7 <7stud.7s...@gmail.com>
Subject: Re: prepare(SELECT ... FROM TABLE) error
To: "Beginners Perl" 
Date: Monday, 1 February, 2010, 14:05


On Mon, Feb 1, 2010 at 12:11 PM, Tony Esposito
wrote:

> when the table does not exist the prepare fails.  How do ignore the error
> thrown by the prepare() and catch it later in the program?
>
>
> my $dbh = DBI->connect("dbi:ODBC:mysql"
>                          ,$login
>                          ,$passwd
>                          ,{ RaiseError => 0 }
>                         );
> ...
> $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   # don't catch
>  $retCode = $sth->execute();
> if ($dbh->err) {
>   print "Table $table -- DOES NOT EXIST\n";
> }
> 
>



See if this helps:


use strict;
use warnings;
use 5.010;


eval {
    die "***prepare error***";
};

say 'executing other code here';

if ($@) {
    say "There was an error inside that eval block above: $@";
}



 
 
 
 
 
 
 
> my $dbh = DBI->connect("dbi:ODBC:mysql"
>                          ,$login
>                          ,$passwd
>                          ,{ RaiseError => 0 }
>                         );
> ...
> $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   # don't catch
>  $retCode = $sth->execute();
> if ($dbh->err) {
>   print "Table $table -- DOES NOT EXIST\n";
> }
> 
>



See if this helps:


use strict;
use warnings;
use 5.010;


eval {
    die "***prepare error***";
};

say 'executing other code here';

if ($@) {
    say "There was an error inside that eval block above: $@";
}


--- On Mon, 1/2/10, 7 <7stud.7s...@gmail.com> wrote:


From: 7 <7stud.7s...@gmail.com>
Subject: Re: prepare(SELECT ... FROM TABLE) error
To: "Beginners Perl" 
Date: Monday, 1 February, 2010, 14:05


On Mon, Feb 1, 2010 at 12:11 PM, Tony Esposito
wrote:

> when the table does not exist the prepare fails.  How do ignore the error
> thrown by the prepare() and catch it later in the program?
>
>
> my $dbh = DBI->connect("dbi:ODBC:mysql"
>                          ,$login
>                          ,$passwd
>                          ,{ RaiseError => 0 }
>                         );
> ...
> $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   # don't catch
>  $retCode = $sth->execute();
> if ($dbh->err) {
>   print "Table $table -- DOES NOT EXIST\n";
> }
> 
>



See if this helps:


use strict;
use warnings;
use 5.010;


eval {
    die "***prepare error***";
};

say 'executing other code here';

if ($@) {
    say "There was an error inside that eval block above: $@";
}


--output:--
executing other code here
There was an error inside that eval block above: ***prepare error*** at
2perl.pl line 7.



      


  

Re: prepare(SELECT ... FROM TABLE) error

2010-02-03 Thread Tony Esposito
This question has never been answered.  To out it another way, given the code 
...

 foreach my $mytable (@mytables) {
 my $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   
 # report error but move on to next table
}

how do I ignore the situation/error that DBI throws when $mytable does not 
exist and just move on to the next table?



--- On Mon, 1/2/10, Tony Esposito  wrote:

From: Tony Esposito 
Subject: Re: prepare(SELECT ... FROM TABLE) error
To: "Beginners Perl" , "7" <7stud.7s...@gmail.com>
Date: Monday, 1 February, 2010, 17:02

Also, if prepare fails, I want to continue processing -- hence the need to 
capture the error in my code and not have DBI::DBD throw and exception then 
stop all processing ...

--- On Mon, 1/2/10, Tony Esposito  wrote:


From: Tony Esposito 
Subject: Re: prepare(SELECT ... FROM TABLE) error
To: "Beginners Perl" , "7" <7stud.7s...@gmail.com>
Date: Monday, 1 February, 2010, 14:40


Is this the idea? I do not ever want to catch the error from the prepare 
statement itself -- I want my code to catch and throw the error.  And I am 
using Perl 5.8 so I do not need the use 5.010; pragma   thx 

use strict;
use warnings;
use 5.010;  

eval {
my $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   
};

if ($dbh->err) {
  print "Table $table -- DOES NOT EXIST\n";
}
$retCode = $sth->execute();
 
--- On Mon, 1/2/10, 7 <7stud.7s...@gmail.com> wrote:


From: 7 <7stud.7s...@gmail.com>
Subject: Re: prepare(SELECT ... FROM TABLE) error
To: "Beginners Perl" 
Date: Monday, 1 February, 2010, 14:05


On Mon, Feb 1, 2010 at 12:11 PM, Tony Esposito
wrote:

> when the table does not exist the prepare fails.  How do ignore the error
> thrown by the prepare() and catch it later in the program?
>
>
> my $dbh = DBI->connect("dbi:ODBC:mysql"
>                          ,$login
>                          ,$passwd
>                          ,{ RaiseError => 0 }
>                         );
> ...
> $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   # don't catch
>  $retCode = $sth->execute();
> if ($dbh->err) {
>   print "Table $table -- DOES NOT EXIST\n";
> }
> 
>



See if this helps:


use strict;
use warnings;
use 5.010;


eval {
    die "***prepare error***";
};

say 'executing other code here';

if ($@) {
    say "There was an error inside that eval block above: $@";
}



 
 
 
 
 
 
 
> my $dbh = DBI->connect("dbi:ODBC:mysql"
>                          ,$login
>                          ,$passwd
>                          ,{ RaiseError => 0 }
>                         );
> ...
> $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   # don't catch
>  $retCode = $sth->execute();
> if ($dbh->err) {
>   print "Table $table -- DOES NOT EXIST\n";
> }
> 
>



See if this helps:


use strict;
use warnings;
use 5.010;


eval {
    die "***prepare error***";
};

say 'executing other code here';

if ($@) {
    say "There was an error inside that eval block above: $@";
}


--- On Mon, 1/2/10, 7 <7stud.7s...@gmail.com> wrote:


From: 7 <7stud.7s...@gmail.com>
Subject: Re: prepare(SELECT ... FROM TABLE) error
To: "Beginners Perl" 
Date: Monday, 1 February, 2010, 14:05


On Mon, Feb 1, 2010 at 12:11 PM, Tony Esposito
wrote:

> when the table does not exist the prepare fails.  How do ignore the error
> thrown by the prepare() and catch it later in the program?
>
>
> my $dbh = DBI->connect("dbi:ODBC:mysql"
>                          ,$login
>                          ,$passwd
>                          ,{ RaiseError => 0 }
>                         );
> ...
> $sth = $dbh->prepare("SELECT COUNT(*) FROM mytable");   # don't catch
>  $retCode = $sth->execute();
> if ($dbh->err) {
>   print "Table $table -- DOES NOT EXIST\n";
> }
> 
>



See if this helps:


use strict;
use warnings;
use 5.010;


eval {
    die "***prepare error***";
};

say 'executing other code here';

if ($@) {
    say "There was an error inside that eval block above: $@";
}


--output:--
executing other code here
There was an error inside that eval block above: ***prepare error*** at
2perl.pl line 7.



      


      


  

Need email list for Perl/Tk questions

2010-02-04 Thread Tony Esposito
Besides this forum, does anyone know of a good Perl/Tk email list/forum in 
which to ask questions about Perl/Tk?



  

tr// versus s///g

2010-03-08 Thread Tony Esposito
Does tr/'\n'/' '/ do the same as tr/'\n'/' '/g?  ( replace newline with space )
If so, is one preferred over the other?
 


  

Re: tr// versus s///g

2010-03-08 Thread Tony Esposito
You miss my point but thanks for the syntax check.  I am concerned with 
comparing the functionality, one versus the other.
 
Thanks.

--- On Mon, 8/3/10, Shawn H Corey  wrote:


From: Shawn H Corey 
Subject: Re: tr// versus s///g
To: "Tony Esposito" 
Cc: "Beginners Perl" 
Date: Monday, 8 March, 2010, 9:38


Tony Esposito wrote:
> Does tr/'\n'/' '/ do the same as tr/'\n'/' '/g?  ( replace newline with space 
> )
> If so, is one preferred over the other?

Neither of the above is correct.  The correct forms are:

tr/\n/ /;
s/\n/ /g;


-- 
Just my 0.0002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

Eliminate software piracy:  use only FLOSS.

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





  

Re: tr// versus s///g

2010-03-08 Thread Tony Esposito
Sorry about the syntax errors ... Yes, just want to replace all newline 
characters with a space and since tr does not have g (global) 'option' I was 
thinking that s/\n/ /g is actually better. Or does tr do a global translate by 
default?
 
Thanks
--- On Mon, 8/3/10, John W. Krahn  wrote:


From: John W. Krahn 
Subject: Re: tr// versus s///g
To: "Perl Beginners" 
Date: Monday, 8 March, 2010, 9:50


Tony Esposito wrote:
> Does tr/'\n'/' '/

Replace every ' with ' and every "\n" with " " and every ' with '. Should 
probably just be tr/\n/ /.


> do the same as tr/'\n'/' '/g?

I assume you mean s/'\n'/' '/g because /g is not a valid option for tr///.  
That will replace the string "'\n'" with the string "' '" globally but I assume 
you meant s/\n/ /g.


>  ( replace newline with space )
> If so, is one preferred over the other?

tr/// is usually more efficient (faster) than s///g.  Unless you really meant 
to use the string "'\n'" because tr/// cannot do strings, just characters.




John
-- The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

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





  

Date_GetPrev "error"

2010-04-15 Thread Tony Esposito
Hello,

Date_GetPrev only getting 3 previous days, not 5 previous days.  Using Perl 
5.8.x.

Code


use strict;
use Date::Manip;
my @days = ( 'Fri', 'Mon', 'Tue', 'Wed', 'Thu' );
Date_Init("TZ=CST6CDT");
foreach (@days) {
  print $_ . "\n";
}
my @dates = ();
my $today = ParseDate('today');
foreach (@days) {
  push(@dates, substr(Date_GetPrev($today, $_, 0/1/2),0,8));
}
foreach (@dates) {
  pop(@dates);
  print $_ . "\n";
}
exit;

Output
--
Fri
Mon
Tue
Wed
Thu
20100409
20100412
20100413


  

Re: Date_GetPrev "error"

2010-04-15 Thread Tony Esposito
Thx.  I see that I do not need to do both!  Got it fixed.





From: Uri Guttman 
To: Tony Esposito 
Cc: Beginners Perl 
Sent: Thu, 15 April, 2010 13:04:09
Subject: Re: Date_GetPrev "error"

>>>>> "TE" == Tony Esposito  writes:

  TE> foreach (@dates) {
  TE>   pop(@dates);

why are you popping @dates there? you are looping over it from left to
right but also losing elements from the right.

  TE>   print $_ . "\n";
  TE> }

      

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -



  

Perl LWP::Simple

2010-05-04 Thread Tony Esposito
Cheers!

New to LWP and downloading file/copying file from Web to local box.  Had a go 
at it and failed horribly...  On Solaris 10 with Perl 5.10.
#!/usr/bin/perl -w
use strict;
use LWP::Simple qw($ua get);
my $webpage ="https://www.mywebpage.com/Documents.zip";;
$ua->timeout(20);
my $content = get $webpage or die "Page timed out...$!\n"; 
if (defined $content) {
  open FILE,"> Documents.zip" or die "Can't create file";
  binmode FILE; 
  print FILE $content; 
  close FILE;
} else {
  print "LWP get() failed\n";
}
exit;

Don't see where I authenticate -- login and password, that is.  Get system 
timed out as an error.  Any help would be grateful.


  

Re: Perl LWP::Simple

2010-05-04 Thread Tony Esposito
Bravo!  I am in ... but I need to traverse many links over multiple pages to 
get to the one that points to the file I want to download.  Would follow_link() 
be the answer?

Cheers!!





From: Shawn H Corey 
To: Tony Esposito 
Cc: Beginners Perl 
Sent: Tue, 4 May, 2010 11:59:53
Subject: Re: Perl LWP::Simple

Tony Esposito wrote:
> Cheers!
> 
> New to LWP and downloading file/copying file from Web to local box.  Had a go 
> at it and failed horribly...  On Solaris 10 with Perl 5.10.
> #!/usr/bin/perl -w
> use strict;
> use LWP::Simple qw($ua get);
> my $webpage ="https://www.mywebpage.com/Documents.zip";;
> $ua->timeout(20);
> my $content = get $webpage or die "Page timed out...$!\n"; if (defined 
> $content) {
>  open FILE,"> Documents.zip" or die "Can't create file";
>  binmode FILE;  print FILE $content;  close FILE;
> } else {
>  print "LWP get() failed\n";
> }
> exit;
> 
> Don't see where I authenticate -- login and password, that is.  Get system 
> timed out as an error.  Any help would be grateful.
> 
> 
>      

I suggest you use WWW::Mechanize instead. 
http://search.cpan.org/~petdance/WWW-Mechanize-1.62/lib/WWW/Mechanize.pm

It is design for stateful websites, that is, those with logins.


-- Just my 0.0002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

Eliminate software piracy:  use only FLOSS.

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


  

Re: help on perlform

2010-10-06 Thread Tony Frasketi


H K.V..
Might want to try again... I googled and got "About 15,600 results (0.23 
seconds) "


  try. perldoc.perl.org/*perlform*.html

Tony

pawan kumar wrote:

Hi folks,
 Can anyone please explain what is "perlform" and its
usage.I used google but i was not able to crack.
Thanks for the time.
   



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




while(@data) works but why

2011-08-12 Thread Tony Esposito
.
.
.
while(@dat = $sth->fetchrow) {
print "@dat\n";
.
.
.

This code works yet there is no 'my @dat' defined anywhere in the code.
Using Perl 5.8.x - 5.14.x

Q: Why does the variable @dat not need a 'my' in front?

Cheers!

Re: while(@data) works but why

2011-08-12 Thread Tony Esposito
got it ... thank you.  cheers!





From: Brandon McCaig 
To: Tony Esposito 
Cc: beginners@perl.org
Sent: Fri, 12 August, 2011 14:08:52
Subject: Re: while(@data) works but why

On Fri, Aug 12, 2011 at 3:02 PM, Tony Esposito
 wrote:
> .
> .
> .
> while(@dat = $sth->fetchrow) {
>print "@dat\n";
> .
> .
> .
>
> This code works yet there is no 'my @dat' defined anywhere in the code.
> Using Perl 5.8.x - 5.14.x
>
> Q: Why does the variable @dat not need a 'my' in front?

See `perldoc strict'. In particular, the "strict vars" section.


-- 
Brandon McCaig <http://www.bamccaig.com/> 
V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl.
Castopulence Software <http://www.castopulence.org/> 


Re: while(@data) works but why

2011-08-12 Thread Tony Esposito
It was the absence of the 'use strict;' that permitted the execution.
Now fails if 'use strict;' is added to code and 'my' is missing.
Added 'use strict;' and 'my'.

Cheers!





From: Jim Gibson 
To: beginners@perl.org
Sent: Fri, 12 August, 2011 14:13:26
Subject: Re: while(@data) works but why

On 8/12/11 Fri  Aug 12, 2011  12:02 PM, "Tony Esposito"
 scribbled:

> .
> .
> .
> while(@dat = $sth->fetchrow) {
> print "@dat\n";
> .
> .
> .
> 
> This code works yet there is no 'my @dat' defined anywhere in the code.
> Using Perl 5.8.x - 5.14.x
> 
> Q: Why does the variable @dat not need a 'my' in front?

It does on my system:

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

use DBI;

my $sth = DBI->connect();

while( my @dat = $sth->fecthrow) {
  print "dat: ", join(",",@dat), "\n";
}

% perl -c esposito.pl
Global symbol "@dat" requires explicit package name at esposito.pl line 9.
Global symbol "@dat" requires explicit package name at esposito.pl line 10.
esposito.pl had compilation errors.

perl v5.10.1



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

Re: Need a Perl Book for Beginner

2012-12-05 Thread Tony Esposito
I agree with David ... good list.

Tony





 From: David Christensen 
To: beginners@perl.org 
Sent: Tuesday, 4 December 2012, 20:36
Subject: Re: Need a Perl Book for Beginner
 
On 12/04/12 14:56, Asad wrote:
>            Would you guidance to start  develop logic for perl programming .
> Also I am looking for a book to start with .
>              Which explains the basic of perl programming with examples also
> how to develop logic for programing.

IMHO the canonical trilogy for aspiring Perl programmers is:

1. Learning Perl -- this book gets you up the initial learning curve. Read it 
cover to cover, enter and play with the example code, and do the exercises:

  http://shop.oreilly.com/product/0636920018452.do

2.  Perl Cookbook -- this is a source book of example Perl code,
organized by topic/ task.  The code is idiomatic, and the explanations
are excellent.  This book will give you the understanding and confidence
you need to start writing useful Perl scripts:

    http://shop.oreilly.com/product/9780596003135.do

3.  Programming Perl -- this is the language reference manual.  Use it
to look things up when you need the hard-core explanation:

    http://shop.oreilly.com/product/9780596004927.do


HTH,

David

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

Re: Tutorial for a menu driven perl script

2012-12-21 Thread Tony Esposito
Look for tutorials on Perl/Tk
Google Perl/Tk
Here's an old one that is still good -> http://www.perl.com/pub/1999/10/perltk/

HTH






 From: newbie01 perl 
To: beginners  
Sent: Thursday, 20 December 2012, 18:42
Subject: Tutorial for a menu driven perl script
 
Hi,

Does anyone know of any great source/link for tutorials on menu driven Perl?

Thanks in advance.

Very simple question.

2005-05-16 Thread Tony Marquis
I'm creating a script that open a directory.
create a file call lock
Work in the directory.
delete the lock file and quit.

my ($rep_em) = "/test";

opendir (DIR, $rep_em) || die ("Error open directory $rep_em.");
chdir($rep_em) || die ("Error change directory to $rep_em");
my @fic = readdir(DIR);
open(LOCK , '>lock') || die ("Unable to create the lock file.");
foreach (@fic) {
if (!(($_ eq ".") || ($_ eq "..") || ($_ eq "lock"))) {
printf ("%s \n", $_);
}
}
close(DIR);
unlink(LOCK) || die ("Unable to delete the lock file.");

I'm able to delete the file manually but when i run the script under the
same user i get an error Unable to delete the lock file at line xx.

Thank for your help.


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




Simple question

2005-05-30 Thread Tony Marquis

Very simple question.

I'm reading a file and i want to remove all the  in each lines.

while(FIC) {

   $test = $_; #remove crlf.
   ... some code

}

How can i do that.


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




'Use Lib' problem...

2005-07-26 Thread Tony Frasketi

Hello listers

I'm trying to use the following 'use lib' statement as described at
http://www.unix.org.ua/orelly/perl/prog3/ch31_13.htm

use lib "$ENV{HOME}/libperl"; # add ~/libperl

In a *test* program, I've written....

$ENV{HOME} = 'home/tony/cgi-bin'; # My cgi-bin directory
use lib "$ENV{HOME}/pm";  # Add my personal perl module 
directory (pm)


However this method doesn't seem to work for me... printing out @INC 
gives me...
0 /pm   <---Incorrect/incomplete  
location of my personal perl module directory

1 /usr/lib/perl5/5.6.1/i386-linux
2 /usr/lib/perl5/5.6.1
3 /usr/lib/perl5/site_perl/5.6.1/i386-linux
4 /usr/lib/perl5/site_perl/5.6.1
5 /usr/lib/perl5/site_perl/5.6.0
6 /usr/lib/perl5/site_perl
7 /usr/lib/perl5/vendor_perl/5.6.1/i386-linux
8 /usr/lib/perl5/vendor_perl/5.6.1
9 /usr/lib/perl5/vendor_perl
10 .


However if I use the following...

use lib "home/tony/cgi-bin/pm";

This works! printing out @INC give me
0 /home/tonysf/cgi-bin/pm   <--- Correct 
Location of my personal perl module directory (pm)

1 /usr/lib/perl5/5.6.1/i386-linux
2 /usr/lib/perl5/5.6.1
3 /usr/lib/perl5/site_perl/5.6.1/i386-linux
4 /usr/lib/perl5/site_perl/5.6.1
5 /usr/lib/perl5/site_perl/5.6.0
6 /usr/lib/perl5/site_perl
7 /usr/lib/perl5/vendor_perl/5.6.1/i386-linux
8 /usr/lib/perl5/vendor_perl/5.6.1
9 /usr/lib/perl5/vendor_perl
10 .


What I'm trying to avoid is having all my scripts platform dependent by 
hard coding my personal perl module directory in the 'use lib' 
statement. I'd like to set the actual $ENV{HOME}environment variable in 
my home script to the location of my cgi-bin directory and have it 
applied automatically to all my scripts simply by referencing $ENV{HOME}..


Hoping I've explained this properlu
Thanks in advance.
tony


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




Re: 'Use Lib' problem...

2005-07-30 Thread Tony Frasketi

Hello Tom
I've been successful in getting my use lib statment to work by inserting 
the following statments in my .bash_profile file as follows


  CGIDIR=$HOME/cgi-bin
  PMDIR=$CGIDIR/pm
  export CGIDIR PMDIR

Then in my CGI script I have...
  -
  use lib "$PMDIR";
  use WSP qw(%WSP); # My web site parameter definitions

  print "Content-type: text/html\n\n";
  foreach $name (sort keys(%WSP)) {
  print "$name = $WSP{$name}\n";
   }
  -
Where WSP is where I've define my web site parameters. I then print out 
those parameters and it all works.


However there is something that I don't understand Since I've 
defined CGIDIR and PMDIR shell variables in .bash_profile and exported 
them, they are available to be used in my CGI applications according to 
what I've read. And this is certainly true because my 'use lib "$PMDIR" 
' statement has successfully utilized the PMDIR definition.  What I 
don't understand then is why  when I use the following print statements, 
I don't get the expected values. I get nothing


  print  "CGIDIR [$CGIDIR]";
  print  "PMDIR [$PMDIR]";

Can you shed some light on this for me?
Thanks
Tony

Tony Frasketi wrote:


Hey Tom
Thanks for the response.
That's what I was afraid of and wanted to avoid - Having this in all 
my scripts. I think I'll look into the '~/.bashrc, ~/bash_profile, 
/etc/profile' route. If I can get that to work, then I'll have what I 
want.

Thanks for the help!
Tony Frasketi

Tom Allison wrote:


Tony Frasketi wrote:

Thanks Tom for the quick response... But could you please elaborate 
a bit on what these two lines do?


  export PERL5LIB=$PERL5LIB:$HOME/lib
  myperlscript.pl

and where would I use them, in a single script? in all my scripts?
Thanks
Tony



Unfortunately it would be in all your scripts.
Unless...

you can either add something like this to you ~/.bashrc, 
~/bash_profile, /etc/profile (depending on how you want to use it).


I have a similar issue with a Solaris box at work and can't get the 
right permissions to configure the files I need.  So I have to wrap 
everything in a script and include that "export PERL5LIB" string in 
every single file that I run from crontab.


It's not as bad as it sounds.  It's really better to run crontab jobs 
from wrapper scripts but sometimes I'm just lazy about it.








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




Re: 'Use Lib' problem...

2005-07-31 Thread Tony Frasketi
Sorry... I've since discovered that my approach in fact DID NOT solve my 
problem I inadvertently place my perl module in the SAME directory 
as my CGI file and of course that would always work. So it looks like 
I'm back to square one. Still looking for a zimple solution to avoid 
explicitly naming the path to the directory where my perl modules reside


I still DO NOT understand why the shell variable definition method 
(.bash_profile and .bashrc) DID NOT work Anyone?


Perhaps I'd also better investigate the 'export PERL5LIB' method that 
Tom suggested.

Thanks
Tony Frasketi


Hello Tom
I've been successful in getting my use lib statment to work by inserting 
the following statments in my .bash_profile file as follows


 CGIDIR=$HOME/cgi-bin
 PMDIR=$CGIDIR/pm
 export CGIDIR PMDIR

Then in my CGI script I have...
 -
 use lib "$PMDIR";
 use WSP qw(%WSP); # My web site parameter definitions

 print "Content-type: text/html\n\n";
 foreach $name (sort keys(%WSP)) {
 print "$name = $WSP{$name}\n";
  }
 -
Where WSP is where I've define my web site parameters. I then print out 
those parameters and it all works.


However there is something that I don't understand Since I've 
defined CGIDIR and PMDIR shell variables in .bash_profile and exported 
them, they are available to be used in my CGI applications according to 
what I've read. And this is certainly true because my 'use lib "$PMDIR" 
' statement has successfully utilized the PMDIR definition.  What I 
don't understand then is why  when I use the following print statements, 
I don't get the expected values. I get nothing....


 print  "CGIDIR [$CGIDIR]";
 print  "PMDIR [$PMDIR]";

Can you shed some light on this for me?
Thanks
Tony

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




Re: 'Use Lib' problem...

2005-08-01 Thread Tony Frasketi

Sorry... Didn't notice that's what it was
Tony

Dave Gray wrote:


On 7/26/05, Tony Frasketi <[EMAIL PROTECTED]> wrote:
 


I'm trying to use the following 'use lib' statement as described at
http://www.unix.org.ua/orelly/perl/prog3/ch31_13.htm
   



It's not nice to link to pirated copies of books. BAD.

 



Re: perl and java and html

2005-08-03 Thread Tony Frasketi




Hello
I would appreciate it if you would steer me to one or more of those 
groups you mentioned that offer pre-packaged version of Apache with 
Perl, MySQL and PHP for windows  Can these packages run on the same 
machine that I have windows running? Do I access these packages from 
Windows or do i have to dedicate a windows machine just for Apache 
functionality? 
Thanks

Tony



You can run CGI scripts on your local computer IF you have a web server, 
but that's not necessarily a problem. Most versions of Unix will already 
include some version of the Apache web server, and there are many groups 
offering pre-packaged versions of Apache along with Perl, MySQL, and PHP 
for Windows. Once you have Apache installed, there's not much overhead 
to running things this way -- you just interact with things through a 
web browser on your computer using <http://localhost/myscript.pl> etc. 
 



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




Re: perl and java and html

2005-08-03 Thread Tony Frasketi
Thanks very much Chris for the clear explanation. Sounds like just what 
I need - A way to completely build and check out a web site on my own 
compter and then be able to migrate it to a hosting service when I'm 
ready. Sure beats the local editing and back and forth trips from my 
computer to the hosting service via FTP and SSH shell.


Tony


These kits are useful for developers to set up things on their Windows 
workstations (or laptops) and do all the work there, developing and 
testing sites all from one computer that isn't even necessarily attached 
to a network -- think of commuting on a train, etc. Once you're happy 
with how it works here, you can upload your work to whatever the server 
may be (or serverS, for that matter, if things are broken up that way), 
and everything should work the same way there that it did originally. 

These kits make things very easy, too. I've seen them set up on laptops 
for non-technical managers and salespeople so that they could do onsite 
demos of complex Apache / Perl / PHP / MySQL / Flash / Actionscript web
sites. Even if there wouldn't be a network connection available for the 
demo, no problem, just click the "Apache Start" icon in the Start menu, 
then open up http://localhost/demo/ in the web browser, and it seems as 
if the salesperson was connected back to the "real" site. Everything is 
going to work exactly the same way as the real site, even when it's all 
just running from a modest little Windows laptop.



 



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




Emptying a log file....

2005-08-11 Thread Tony Frasketi

Hello Listers

Is there any way in perl to effectively clear the contents of an 
***existing*** file  (making the file empty) ?  I have a log file that 
I'd like to empty out after it reaches a certain maximum file size.


thanks in advance
Tony

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




Re: Emptying a log file....

2005-08-12 Thread Tony Frasketi

Hello Listers
Thanks very much for all the suggestions for solving my problem with 
clearing out my log file I've followed the suggestion by 
[EMAIL PROTECTED] and it does the job for me...


 ---
 open FD, ">filename";  
 ---


What a great group!
Thanks
Tony Frasketi

Tony Frasketi wrote:


Hello Listers

Is there any way in perl to effectively clear the contents of an 
***existing*** file  (making the file empty) ?  I have a log file that 
I'd like to empty out after it reaches a certain maximum file size.


thanks in advance
Tony



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




Unitialized value in hash element problem...

2005-08-16 Thread Tony Frasketi

Hello Listers
I'm getting the following error when executing the function listed below...

  cimagedisp_new.cgi: Use of uninitialized value in hash
  element at /.../cimagedisp_new.cgi line 238,  line 69.

223 #-
224 # Build a hash of pricelist names/ids from an inc file
225 #  my(%plhash) = &build_pricelist_hash($plnameid_file);
226 #-
227 sub build_pricelist_hash {
228   my($file) = @_;
229
230   my(%plhash) = ();
231   if(!open(FILE,$file)) {
232  &abort_program("FILE ERROR:Can't open file 
$file\n[$!]");

233   }
234   my($i) = 0;
235   while () {
236  chop $_;
237  my($name,$id) = split(/\|/,$_);
238  $plhash{$id} = $_;
239  $i++;
240   }
241   close(FILE);
242   return %plhash;
243 }

The plnameid file contains lines formatted as follows...
  -
  Classic Chimpanzee/Monkey Space Flight Covers|chimps
  Experimental Test Covers, Various Flights, Various Cachets|exfl01
  GEMINI Program Prime Recovery Ships|primesc2
  etc
  -
where the first item in each line is a pricelist description and the 
second item is the name of the pricelist.


I've tried initializing %plhash and $name and $id to no avail...
Please ignore $i as it was previously use for another purpose but I 
forgot to remove it.


Any help would be greatly appreciated...
Tony frasketi

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




Unitialized value in hash element problem...

2005-08-16 Thread Tony Frasketi

Hello Listers
I'm getting the following error when executing the function listed below...

 cimagedisp_new.cgi: Use of uninitialized value in hash
 element at /.../cimagedisp_new.cgi line 238,  line 69.

223 #-
224 # Build a hash of pricelist names/ids from an inc file
225 #  my(%plhash) = &build_pricelist_hash($plnameid_file);
226 #-
227 sub build_pricelist_hash {
228   my($file) = @_;
229
230   my(%plhash) = ();
231   if(!open(FILE,$file)) {
232  &abort_program("FILE ERROR:Can't open file 
$file\n[$!]");

233   }
234   my($i) = 0;
235   while () {
236  chop $_;
237  my($name,$id) = split(/\|/,$_);
238  $plhash{$id} = $_;
239  $i++;
240   }
241   close(FILE);
242   return %plhash;
243 }

The plnameid file contains lines formatted as follows...
 -
 Classic Chimpanzee/Monkey Space Flight Covers|chimps
 Experimental Test Covers, Various Flights, Various Cachets|exfl01
 GEMINI Program Prime Recovery Ships|primesc2
 etc
 -
where the first item in each line is a pricelist description and the 
second item is the name of the pricelist.


I've tried initializing %plhash and $name and $id to no avail...
Please ignore $i as it was previously use for another purpose but I 
forgot to remove it.


Any help would be greatly appreciated...
Tony frasketi

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




test

2005-08-19 Thread Tony Frasketi

test

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




UID question

2005-08-25 Thread Tony Frasketi
Is there an ASCII equivalent to the numeric value UID returned by 
stat($filename)[4] and if so is there a function to aquire the ASCII 
value... Also is the UID  related to the owner of the file as shown in 
the directory display ls -al in Unix?


If UID and file ownership is not, however related, is there a function 
to obtain the file's owner name in ASCII format?


TIA
Tony Frasketi

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




Re: UID question

2005-08-25 Thread Tony Frasketi

Thanks very much John.

John W. Krahn wrote:


Tony Frasketi wrote:
 


Is there an ASCII equivalent to the numeric value UID returned by
stat($filename)[4] and if so is there a function to aquire the ASCII
value... Also is the UID  related to the owner of the file as shown in
the directory display ls -al in Unix?

If UID and file ownership is not, however related, is there a function
to obtain the file's owner name in ASCII format?
   




my $user = getpwuid( (stat $filename)[4] );


perldoc -f getpwuid


John
 



Dot and Dubble Dot directory names

2005-08-26 Thread Tony Frasketi


In a program such as the following
-
#!/usr/local/bin/perl -w

$windir = "/home/users/tony";
opendir(NT, $windir) || die "no $windir?: $!";
while ($name = readdir(NT)) { # scalar context, one per loop
   print "$name\n"; # prints ., .., system.ini, and so on
}
closedir(NT);
exit;
---
$name returns each of the files in the given directory. To form the 
absolute path of the files given by $name, you would simply combine the 
$windir and the $name variables like so: "$windir/$name". For example 
"/home/users/tony/x.txt".


My question relates to the two files '.' and '..'. Is there any function 
that will give the absolute path of these directories when fed $name 
values of '.' and '..' ?  Without having to chdir to these directories, 
that is.


I hope I've posed my question so as to be understandable...
I've looked online and in the O'reilly books but can't find the answer.

TIA
Tony Frasketi


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




test

2005-09-03 Thread Tony Frasketi

test

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




Re: %ENV

2005-09-08 Thread Tony Frasketi
I've had problems with this in this the past and found your solution to 
work as long as I run my script from the bash command line.


However if the script is run from a web page, I still do not get the 
value of the environment variable that I had set from the bash prompt or 
even in the .profile file. Can you  shed some light on why the variables 
do not show up on the web page?

TIA
tony

Nahalingam Kanakavel wrote:


hi,

I think that it shows only the exported varaibles.
I tried some thing like this

---try this--
1) add one more variable with your own as

prompt$ MY_OWN='name'

2) then run your program your variable MY_OWN will not be in the list
but use suffix export infornt of the above line, then it will show this 
thing also.


prompt$ export MY_OWN='name'
now you try, see the changes.

On 9/8/05, Gergely Buday <[EMAIL PROTECTED]> wrote:
 


Hi there,

why is the script

#!/usr/bin/perl
foreach $key (sort keys %ENV) {
print "$key=$ENV{$key}\n";
}

returns much less variable than

$ set

using bash?

- Gergely

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



   




No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.19/92 - Release Date: 9/7/2005
   



--
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 backtick command to compile a perl program

2005-09-13 Thread Tony Frasketi
I can't seem to get any results back from compiling a perl progam from 
another perl program via the backtick method. My understanding that the 
output of the backtick command returns the results of the command 
executed into an array. And in the past I've used the backtick method 
successfully for getting output of the ls command.


Following is an extract from my program 
 ===

 my($filename) = "/home/blahblah/cgi-bin/ifgen/ifgen.cgi
 my($command) = "/usr/bin/perl -c $filename";
 print "command[$command]";
 my(@results) = `$command`;
 my $len = @results;
 print "len[$len]";
 print "results of compile: [EMAIL PROTECTED]";
 ===

And this is the output I get ...

command[/usr/bin/perl -c /home/blahblah/cgi-bin/ifgen/ifgen.cgi]
len[0]
results of compileresults[]
-
Any help would be greatly appreciated
TIA
Tony Frasketi
P.S. And I will try to break my habit of TOP POSTING  :-)


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




Re: Problem with backtick command to compile a perl program

2005-09-13 Thread Tony Frasketi



Jeff 'japhy' Pinyan wrote:


On Sep 13, Tony Frasketi said:


my($filename) = "/home/blahblah/cgi-bin/ifgen/ifgen.cgi
my($command) = "/usr/bin/perl -c $filename";
print "command[$command]";
my(@results) = `$command`;



'perl -c' sends its output to STDERR, not STDOUT.  To catch that, I 
would suggest using the IPC::Open3 module, which comes with Perl.



Thanks for quick response, Jeff. I'll investigate IPC::Open3 module.
In the meantime, I've found the following also works to redirect STDERR 
to STDOUT..


my($command) = "/usr/bin/perl -c $filename 2>&1";

Thanks again!
Tony Frasketi


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




Deprecated perl hash reference statement problem

2005-10-04 Thread Tony Frasketi

Hello Listers
I've used the following statement in several instances before and never 
had any errors reported and the programs all seem to work ok.


  %{$hashRef}->{$key} = $value;

But since I've began using

  use strict;
  use warnings;
  use diagnostics;

in my programs, I'm now starting to get the following error message...

Using a hash as a reference is deprecated at
/wpgen/wpgen.cgi line 399 (#1)
(D deprecated) You tried to use a hash as a reference, as in
< %foo-{"bar"} >> or < %$ref-{"hello"} >>. Versions of perl <= 5.6.1
used to allow this syntax, but shouldn't have. It is now deprecated, and 
will

be removed in a future version.
wpgen.cgi: Using a hash as a reference is deprecated at /wpgen/wpgen.cgi 
line 399.


I've tried Googling but have never found any thing that approaches what 
could be

used instead of the deprecated statement
Any help would be appreciated.
Thanks
Tony Frasketi



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




Re: Deprecated perl hash reference statement problem

2005-10-04 Thread Tony Frasketi

Timothy Johnson wrote:


It depends on what you're trying to do.  if $hashRef is a hash
reference, then the correct syntax would be:

  $hashRef->{$key} = $value;

or

  %{$hashRef}{$key} = $value;

What you're saying below is something like:

-- Take $hashRef and dereference it to %HASH1 (I'm giving it a name
  for clarity)
-- Then use %HASH as a reference to another hash, let's say %HASH2.
-- Finally, use the -> operator to get the $key key of the hash %HASH2.


If this doesn't answer your question, then you will need to give us some
examples.

 



Thanks for the quick response, Timothy. Here is the function in question 
and a representative calling sequence


Calling sequence...
# Form buffer
my(%FIELDS,$query,$code,$checks);

# Get data from form (get_form_data_1 is local to this program) 
&get_form_data_1(\%FIELDS);

Function
sub get_form_data_1 {
  my($hashRef) = @_;
  my($buffer) = "";
  my($key,$value,$pair,@pairs);

  if ($ENV{'REQUEST_METHOD'} eq "GET") {
 $buffer = $ENV{'QUERY_STRING'};
  }else {
 read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  }
  @pairs = split(/&/, $buffer);
  foreach $pair (@pairs) {
 my($key, $value) = split(/=/, $pair);
 $key   = decodeURL($key);   # Decode the key
 $value = decodeURL($value); # Decode the value
 %{$hashRef}->{$key} = $value;!# Enter the value in the hash 
<- Deprecated stmt

 print "get_form_data_1: Setting $key to [$value]"; #Debug
  }
}

Thanks
Tony



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




Re: Deprecated perl hash reference statement problem

2005-10-04 Thread Tony Frasketi

Jeff 'japhy' Pinyan wrote:



%hash->{$key} and @array->[$idx] are syntaces that you should not use. 
The fact that they work is due to intricacies of the Perl parser. 
Similarly, %{$hashref}->{$key} and @{$arrayref}->[$idx] are equally bad.


Use $hash{$key} and $array[$idx] for normal hash and array access.  
When using hash and array references, you have two choices: 
$hash->{$key} and $array->[$idx], or $$hash{$key} and $$array[$idx].


Thanks Japhy
Both $hash->{$key} and $$hash{$key} work fine and this also works 
Although I'm not sure why ${$hash}{$key}.


I seem to have a lot of problems with the perl language in that there 
are so many ways to accomplish (express) the same thing A wonderful 
feature but sometimes confusing as hell (to me at least).


Anyway thanks again - Problem solved! No more error messages.
Best regards
Tony Frasketi



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




Re: Deprecated perl hash reference statement problem

2005-10-04 Thread Tony Frasketi

Thanks to all who answered - I really appreciate the help!
Now busy reading perldoc perlreftut !
Tony

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




sdf

2006-01-13 Thread Tony Frasketi

asdfdsf

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




asdf 2

2006-01-13 Thread Tony Frasketi

asdf

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




sending email problem....

2006-03-31 Thread Tony Marquis

Hi everyone,
   The problem is really simple. When i try to send a message with this 
function with a wrong sender email address, my script just stops...


as an exemple : sender address [EMAIL PROTECTED] the error message 
is  - user not found on this server and the script stops.


-
use Mail::Sendmail;
use MIME::Lite;
use Email::Valid;

sub send_mail {

   my ($mailto, $mailfrom, $sujet, $body_file, $file_send, $cc) = @_;
   my $body_msg = "";
   my $mail_err;

   if ((Email::Valid->address( -address => $mailto, -mxcheck => 1 ) ? 
'1' : '0') eq '0' ) {
   ($mailto, $mailerr, $mailrom) = ($mailfrom, $mailto, 
"[EMAIL PROTECTED]");
   $sujet = "Destination invalide / Invalid destination $mailerr" . 
$sujet;
   if ((Email::Valid->address( -address => $mailto, -mxcheck => 1 ) 
? '1' : '0') eq '0' ) {

   $sujet = "ERROR: $mailto $mailfrom " . $sujet;
   $mailto = "[EMAIL PROTECTED]";
   }
   }

   if ( $cc eq "1" ) {
   ### Create a new multipart message:
   $msg = MIME::Lite->new(
   From =>$mailfrom,
   To =>$mailto,
   Cc =>$mailfrom,
   Subject =>$sujet,
   Type =>'multipart/mixed'
   );
   }
   else {
   ### Create a new multipart message:
   $msg = MIME::Lite->new(
   From =>$mailfrom,
   To =>$mailto,
   Subject =>$sujet,
   Type =>'multipart/mixed'
   );
   }

   open (FIC, $body_file) or die("Le fichier body $body n'existe pas\n");
   while () {
   $body_msg .= $_;
   }
   ### Add parts (each "attach" has same arguments as "new"):
   $msg->attach(Type =>'TEXT',
   Data =>$body_msg
   );

   $msg->attach(Type =>'application/pdf',
   Path =>$file_send,
   Filename =>$file_name,
   Disposition => 'attachment'
   );
   ### Send in the "best" way (the default is to use "sendmail"):
   MIME::Lite->send('smtp', "mail..com", Timeout=>60);
   $msg->send;
   }



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




PACK statement compile error

2006-09-21 Thread Tony Frasketi

Hello list.
I'm getting the following error message when compiling the program 
listed below ...


  Bad name after c' at /test/test1.cgi line 22.

line 22 is  '   s/%(..)/pack('c', hex($1))/eg;'

Need help in eliminating this error!
thnx
tony

=
#!/usr/local/bin/perl -w

use strict;

# Enable HTTP output
print("Content-type: text/html\n\n");

my $url = "nice.cgi?a=b+c+d&x=a+m";
my $x = &decodeURL($url);
print 'x[$x]";

exit;


#-
# Decode the URL
# &decoded_url = &decodeURL($url);
#-
sub decodeURL {
  $_ = shift;
  tr/+/ /;
  s/%(..)/pack('c', hex($1))/eg;
  return($_);
}

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




Re: PACK statement compile error

2006-09-21 Thread Tony Frasketi

Hi list
I found the problem. It was at line 10
 print 'x[$x]";

should have been...
 print "x[$x]";

Thanks
tony


Tony Frasketi wrote:


Hello list.
I'm getting the following error message when compiling the program 
listed below ...


  Bad name after c' at /test/test1.cgi line 22.

line 22 is  '   s/%(..)/pack('c', hex($1))/eg;'

Need help in eliminating this error!
thnx
tony

=
#!/usr/local/bin/perl -w

use strict;

# Enable HTTP output
print("Content-type: text/html\n\n");

my $url = "nice.cgi?a=b+c+d&x=a+m";
my $x = &decodeURL($url);
print 'x[$x]";

exit;


#-
# Decode the URL
# &decoded_url = &decodeURL($url);
#-
sub decodeURL {
  $_ = shift;
  tr/+/ /;
  s/%(..)/pack('c', hex($1))/eg;
  return($_);
}



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




default C compiler

2002-12-06 Thread Tony Yi
sun solaris  have come with perl, But it is use cc as default c
compiler. I don't have license Sun C compiler, Can I change to C
compiler to gcc.

Thanks in advance


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


Length of String

2003-01-17 Thread Ho, Tony
Hi guys
Do you know whether there is a function in perl to find the size of a string
?
For example, "06" would be size 2.

Cheers
Tony



Tk with Perl

2003-01-23 Thread Tony Esposito
Help
I have installed Perl 5.6.1 ( which works ) and Tcl/Tk 8.3 ( which
works ) on Windows 2000 but when I try to perl -e "use Tk" I get the
following error:

Can't locate Tk.pm in @INC ( @INC contains: D:/Perl 5.6.1/lib
D:/Perl 5.6.1/site/lib . ) at -e line 1.

And I can not find any file name Tk.pm on my system.  How is this
file created?  Where should it be?
Thanks!

Anthony (Tony) Esposito
Database Administrator
Inovis(tm), formerly Harbinger and Extricity
2425 North Central Expressway
Suite 900
Richardson, Texas 75080, USA
Direct (972)643-3115
Fax (972)479-9779



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




RE: Tk with Perl

2003-01-23 Thread Tony Esposito
I did get my Perl and Tcl/Tk from ActiveState.com.  So what you are saying
is I just have to download this Tk.pm file from ActiveState.com and install
it in D:\Perl\site\lib\Tk.pm and I'll be ok, correct?
Thanks!

Anthony (Tony) Esposito
Database Administrator
Inovis(tm), formerly Harbinger and Extricity
2425 North Central Expressway
Suite 900
Richardson, Texas 75080, USA
Direct (972)643-3115
Fax (972)479-9779



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 23, 2003 3:41 PM
To: Tony Esposito
Cc: [EMAIL PROTECTED]
Subject: Re: Tk with Perl



>I have installed Perl 5.6.1 ( which works ) and Tcl/Tk 8.3 (
which
>works ) on Windows 2000 but when I try to perl -e "use Tk" I get the
>following error:
>
>Can't locate Tk.pm in @INC ( @INC contains: D:/Perl 5.6.1/lib
>D:/Perl 5.6.1/site/lib . ) at -e line 1.

Have you downloaded and installed the Tk.pm from ActiveState.com?  It is
not installed with Perl or Tcl by default.

The actual module is "D:\Perl\site\lib\Tk.pm" on my box.  YMMV (?).



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




RE: Tk with Perl

2003-01-23 Thread Tony Esposito
I am using ActiveState Perl 5.6.1.  That does not seem too old to me.  Is
there an ftp site where I can download Tk.pm?
Then I will install Tk using the Perl Package Mgr.
Thanks!

Anthony (Tony) Esposito
Database Administrator
Inovis(tm), formerly Harbinger and Extricity
2425 North Central Expressway
Suite 900
Richardson, Texas 75080, USA
Direct (972)643-3115
Fax (972)479-9779



-Original Message-
From: Bob Showalter [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 23, 2003 4:06 PM
To: Tony Esposito
Cc: [EMAIL PROTECTED]
Subject: RE: Tk with Perl


Tony Esposito wrote:
> I did get my Perl and Tcl/Tk from ActiveState.com.  So what you are
> saying is I just have to download this Tk.pm file from
> ActiveState.com and install
> it in D:\Perl\site\lib\Tk.pm and I'll be ok, correct? Thanks!

No, you don't just copy the .pm file. You need to use ppm to install the
module, which installs a ton of files.

  C:\> ppm install Tk

But are you using an ancient verison of ActiveState Perl? Because Tk comes
standard with recent versions, AFAIK.

Note that Perl's Tk module is separate from Tcl/Tk and doesn't use or
require Tcl/Tk to be installed.

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




RE: Tk with Perl

2003-01-23 Thread Tony Esposito
Trying it now from the Command Prompt.seems to be just 'sitting'
there.

Anthony (Tony) Esposito
Database Administrator
Inovis(tm), formerly Harbinger and Extricity
2425 North Central Expressway
Suite 900
Richardson, Texas 75080, USA
Direct (972)643-3115
Fax (972)479-9779



-Original Message-
From: Perry, Alan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 23, 2003 4:32 PM
To: [EMAIL PROTECTED]
Cc: Tony Esposito
Subject: RE: Tk with Perl


Tony Esposito wrote:
> I am using ActiveState Perl 5.6.1.  That does not seem too old to me.
> Is there an ftp site where I can download Tk.pm?
> Then I will install Tk using the Perl Package Mgr.

There is actually no need for that, as long as you have Internet access.  If
you type (note the "ppm3" instead of "ppm")...

ppm3 install Tk

...PPM will download it for you.

When I tried it though, it said that it was already installed.  I am running
5.6.1 (build 633), and have never installed Tk separately, but it was there
already.

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




DBI and getting values from the DB

2003-03-05 Thread Tony Bandy
Hello everyone,

Please forgive in advance if this has already been posted...fairly new
to the list as have only been on it a week. At this point I only get the
digest, but just sent an email to subscribe to the full list.


I'm running apache 2.0x with mod_perl on a windows 2000 server.

I have a form page on the website where folks can enter a name and then
search a DB looking for that name and then give back the results on
another htm page.  I'm hoping this is a common thing to do.


Ok...the upshot is that using DBI:ODBC to access the access db works.
Also, I can use CGI.pm and know that the value from the form is getting
to the script.  

The problem lies in comparing the values from the form and the values
from the DB.  I keep getting no results.


Here's a snippet of the code:

#The CGI.pm module will take input from the form.
use CGI qw(:standard );
my $name=param("name");



#Connecting to DB
my $dbh = DBI->connect('DBI:ODBC:opal') or die "Oops! Couldn't
Connect".  DBI->errstr;
my $sth = $dbh->prepare ('SELECT ContactName FROM Contacts WHERE
ContactName=?')
or die "Couldn't prepare the statement:" . $dbh->errstr;
my @row;
#DB now connected.  Run statements to find information.
$sth->execute(my $name);
while (@row = $sth->fetchrow_array){
print "@row\n";
}
if ($sth->rows == 0) {
print "No names matched `$wholename'.\n\n";
}

$sth->finish;
print "\n";


-->Would anybody have any ideas?  I've got the Programming the DBI book
as well as some others, but since I'm new to this, I may be leaving
something totally out.


Thanks in advance for your help and if this is a wrong post or offtopic,
please let me know.

thanks!



-- 


Tony Bandy, MLS
[EMAIL PROTECTED]
Sys. Admin. OPAL
OHIONET
1500 West Lane Ave.
Columbus, OH  43221-3975
1-800-686-8975
(614) 486-2966 X19
(Emergency-->614-352-9409)
http://www.ohionet.org
http://cat.opal-libraries.org

IMPORTANT NOTICE:

This electronic message, including all attachments,
is intended only for the individual/company/representative
addressed above, and may contain CONFIDENTIAL, PRIVILEGED,
and/or TRADE SECRET INFORMATION.  If you are not the intended
recipient, this notification is to let you know that any use,
distribution, or copying of this electronic message, including
any attachments, is strictly prohibited.

If you feel you have received this email in error, please contact 
[EMAIL PROTECTED]




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



CONSTANTS in Perl

2003-03-14 Thread Tony Esposito
In C, you can define a constants - "variables" whose contents can not be
changed.
Is there any way to do this in Perl?  There are some variables I use that I
would love to set as a constant.

Thanks.


> Anthony (Tony) Esposito
> Senior Technical Consultant 
> Inovis(tm), formerly Harbinger and Extricity
> 2425 N. Central Expressway, Suite 900 
> Richardson, TX  75080 
> (972) 643-3115 
> [EMAIL PROTECTED] 
> 
> 
> 
> 

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



RE: CONSTANTS in Perl

2003-03-17 Thread Tony Esposito
ThanksI got this issue resolved.
One could also "resolve" the constant in a print statement like so:

use constant MAX_THRESHOLD => 99;
use constant MIN_THRESHOLD => 1;

print STDERR "ERROR 4: Command line arg  is out of range.\n";
print STDERR "ERROR 4:  where  is between @{[
MIN_THRESHOLD ]} and @{[ MAX_THRESHOLD ]}.\n";

> Anthony (Tony) Esposito
> Senior Technical Consultant 
> Inovis(tm), formerly Harbinger and Extricity
> 2425 N. Central Expressway, Suite 900 
> Richardson, TX  75080 
> (972) 643-3115 
> [EMAIL PROTECTED] 
> 

-Original Message-
From: Jenda Krynicky [mailto:[EMAIL PROTECTED]
Sent: Monday, March 17, 2003 11:01 AM
To: [EMAIL PROTECTED]
Subject: Re: CONSTANTS in Perl


From: Tony Esposito <[EMAIL PROTECTED]>
> In C, you can define a constants - "variables" whose contents can not
> be changed. Is there any way to do this in Perl?  There are some
> variables I use that I would love to set as a constant.

In case you really wanted them to be variables you may do this:

*Pi = \3.1415927;
print "The area is:", $Pi * $r**2, "\n";
$Pi = 3;
# -> Modification of a read-only value attempted ...

But the more common (and more efficient) way is

use constant Pi => 3.1415927;
print "The area is:", Pi * $r**2, "\n";

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
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: Punishing Your Server With Perl

2003-03-17 Thread Tony Esposito
See CPAN www.cpan.org for a Win32 Perl port.

-Original Message-
From: AK [mailto:[EMAIL PROTECTED]
Sent: Monday, March 17, 2003 11:04 AM
To: [EMAIL PROTECTED]
Subject: Re: Punishing Your Server With Perl


On Thu, 13 Mar 2003 14:10:36 +0800 (GMT-8), [EMAIL PROTECTED] wrote:
>> A couple of years ago there was a great article by the title of
"Punishing 
>> Your Server With Perl". (I believe that either Randal Schwartz or Ruben 
>The article can be found at:
>  http://stein.cshl.org/~lstein/torture/torture.html


Is there a Win32 implementation of this available?

- Aamir


-- 
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: help with whois code

2003-03-17 Thread Tony Esposito
BTW - Anyone know where to get the Carp module for Perl 5.6.1 on Win32 (
WindowsNT ) and how to install it?  I am using the OpenPerl IDE and it
complains about not being able to locate Carp.  I checked and it is not on
my Win32 system.
Thanks!

-Original Message-
From: Brett W. McCoy [mailto:[EMAIL PROTECTED]
Sent: Monday, March 17, 2003 2:21 PM
To: Thomas Browner
Cc: [EMAIL PROTECTED]
Subject: Re: help with whois code


On Mon, 17 Mar 2003, Thomas Browner wrote:

> Could some one help me with this code. Every time that I this code:
>
> use Net::Whois;
>
> use Carp;
>
> $dom ="digidyne.com";
>
> my $w = new Net::Whois::Domain $dom or die "Can't connect to Whois
> server\n;
^^^

Need a closing " here

-- Brett
  http://www.chapelperilous.net/

"Danger, you haven't seen the last of me!"
   "No, but the first of you turns my stomach!"
-- The Firesign Theatre's Nick Danger


-- 
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: help with whois code

2003-03-17 Thread Tony Esposito
Addendum:  I tried CPAN and my search(es) do not show the module itself.
Thanks!

> Anthony (Tony) Esposito
> Senior Technical Consultant 
> Inovis(tm), formerly Harbinger and Extricity
> 2425 N. Central Expressway, Suite 900 
> Richardson, TX  75080 
> (972) 643-3115 
> [EMAIL PROTECTED] 
> 


-Original Message-
From: Tony Esposito 
Sent: Monday, March 17, 2003 1:59 PM
To: 'Brett W. McCoy'; Thomas Browner
Cc: [EMAIL PROTECTED]
Subject: RE: help with whois code


BTW - Anyone know where to get the Carp module for Perl 5.6.1 on Win32 (
WindowsNT ) and how to install it?  I am using the OpenPerl IDE and it
complains about not being able to locate Carp.  I checked and it is not on
my Win32 system.
Thanks!

-Original Message-
From: Brett W. McCoy [mailto:[EMAIL PROTECTED]
Sent: Monday, March 17, 2003 2:21 PM
To: Thomas Browner
Cc: [EMAIL PROTECTED]
Subject: Re: help with whois code


On Mon, 17 Mar 2003, Thomas Browner wrote:

> Could some one help me with this code. Every time that I this code:
>
> use Net::Whois;
>
> use Carp;
>
> $dom ="digidyne.com";
>
> my $w = new Net::Whois::Domain $dom or die "Can't connect to Whois
> server\n;
^^^

Need a closing " here

-- Brett
  http://www.chapelperilous.net/

"Danger, you haven't seen the last of me!"
   "No, but the first of you turns my stomach!"
-- The Firesign Theatre's Nick Danger


-- 
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: help with whois code

2003-03-17 Thread Tony Esposito
I am using SiePerl.  I had trouble installing ActiveState on WindowsNT for
some reason ( probably OE but I did not want to mess with it ) even though
it installed fine on Windows2000.  The OpenPerl IDE fails to even open up
with the WindowsNT version of ActiveState so I used SiePerl.  With SiePerl,
the OpenPerl IDE comes up but when I run the demo Perl program it complains
about "no Carp" module.

Oh, bother!

-Original Message-
From: Brett W. McCoy [mailto:[EMAIL PROTECTED]
Sent: Monday, March 17, 2003 2:54 PM
To: Tony Esposito
Cc: Thomas Browner; [EMAIL PROTECTED]
Subject: RE: help with whois code


On Mon, 17 Mar 2003, Tony Esposito wrote:

> BTW - Anyone know where to get the Carp module for Perl 5.6.1 on Win32 (
> WindowsNT ) and how to install it?  I am using the OpenPerl IDE and it
> complains about not being able to locate Carp.  I checked and it is not on
> my Win32 system.

Did you try CPAN?  If youa re using ActiveState Perl, you can get
pre-packaged modules from their repository (PPM).

Carp (and CGI::Carp) is usually bundled by default with all distributions
of Perl, to the best of my knowledge.  What distro of Perl are you using?

-- Brett
  http://www.chapelperilous.net/

I remember Ulysses well...  Left one day for the post office to mail a
letter,
met a blonde named Circe on the streetcar, and didn't come back for 20
years.

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



RE: help with whois code

2003-03-17 Thread Tony Esposito
I checked my whole system for Carp.pm and it was nowhere to be found.
Perl seems to work fine from the command line.  It is the OpenPerl IDE that
seems to need it ( for stack tracing I am guessing ).  In fact, the OpenPerl
IDE in debug mode stops right at the line in the demo script that says "use
Carp;".

:-)

-Original Message-
From: Brett W. McCoy [mailto:[EMAIL PROTECTED]
Sent: Monday, March 17, 2003 4:56 PM
To: Tony Esposito
Cc: Thomas Browner; [EMAIL PROTECTED]
Subject: RE: help with whois code


On Mon, 17 Mar 2003, Tony Esposito wrote:

> I am using SiePerl.  I had trouble installing ActiveState on WindowsNT for
> some reason ( probably OE but I did not want to mess with it ) even though
> it installed fine on Windows2000.  The OpenPerl IDE fails to even open up
> with the WindowsNT version of ActiveState so I used SiePerl.  With
SiePerl,
> the OpenPerl IDE comes up but when I run the demo Perl program it
complains
> about "no Carp" module.

Can you run SiePerl from a command-line (sorry, I am not at all familair
with it)?  Can you run the program that way?

It seems to me that an include path for modules needs to be set
somewhere, that for some reason isn't built in.

-- Brett
  http://www.chapelperilous.net/

"Being against torture ought to be sort of a multipartisan thing."
-- Karl Lehenbauer, as amended by Jeff Daiell, a Libertarian

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



  1   2   3   >