Re: Database insertion, escape issue

2007-06-12 Thread Tom Allison
$sth->execute() and read up on DBI a little more. the first page of the perldoc shows a synapsis of all the commands. I frequently have to re-visit these pages to recall what the different functions are. On Jun 12, 2007, at 1:32 PM, Northstardomus wrote: On Jun 12, 4:59 am, [EMAIL PROTECTE

Re: Help creating a random string in Perl

2007-06-12 Thread Randal L. Schwartz
> "p46921x" == p46921x <[EMAIL PROTECTED]> writes: p46921x> 1. Only characters in the source string are in the random string p46921x> meaning if Z is not in my source string, it will not be in my random p46921x> string. If A and B are in the source string, then at least one of them p46921x> w

Re: Prompt in Net::Telnet

2007-06-12 Thread Chas Owens
On 6/12/07, Chas Owens <[EMAIL PROTECTED]> wrote: snip If you are trying to connect to the "telnet" server that comes with Microsoft OSes then you are SOL. If you are trying to connect to a different telnet server, then please provide the name of the server and operating system it is running und

Re: Prompt in Net::Telnet

2007-06-12 Thread Chas Owens
On 6/12/07, Lakshmi Sailaja <[EMAIL PROTECTED]> wrote: Hello, I am supposed to write a program that will telnet to a remote server and execute some commands. I get the following error: "timed-out waiting for command prompt at line " This is because the prompt is not set correctly. Can you plea

Re: Database insertion, escape issue

2007-06-12 Thread Chas Owens
On 6/12/07, Northstardomus <[EMAIL PROTECTED]> wrote: snip $dbh->prepare('INSERT INTO area_status (areaID, survey_date, update_time, status ) VALUES (?,?,?,?)'); $dbh->execute('$values[0]', '$values[1]', '$values[2]', '$values[3]'); snip You are getting an error because $dbh->pr

Re: Help creating a random string in Perl

2007-06-12 Thread Chas Owens
On 6/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: snip I can see how to generate a random number between 0 and 6 (meaning I can pick one of the 7 characters in my source string) by using "print int(rand(6))", but I don't know where to being on the second and third and fourth characters to

RE: Help creating a random string in Perl

2007-06-12 Thread Brown, Rodrick
Look at crypt(); $ perldoc -f crypt is a good -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 12, 2007 3:39 PM To: beginners@perl.org Subject: Help creating a random string in Perl Hello, this is perl.beginners and I am really a beginner. This

Need help for writing attachment saver

2007-06-12 Thread ash
Hi! I'm trying to write a code to read mail from POP3 server and then save the attachment in specified folder. I checked the Email::MIME::Attachment::Stripper which needs to be initialized with Email::MIME object. I checked the Email::MIME module but I couldn't understand how to read mail and crea

Help creating a random string in Perl

2007-06-12 Thread p46921x
Hello, this is perl.beginners and I am really a beginner. This is also my first Google group post so if I am in the wrong group, I am sorry. I need to create a random combination of n-1 characters in a source string. For example if the string is ABcDeFG (7 characters) * I want to execute my perl

Re: Net::Telnet - Variable in Prompt

2007-06-12 Thread Chas Owens
On 6/12/07, Lakshmi Sailaja <[EMAIL PROTECTED]> wrote: snip $sub = "xyz"; $prompt = "L:\\$sub"; my $t = Net::Telnet->new( Timeout => 10, Prompt => "/$prompt/" ); snip from perldoc Net::Telnet What To Know Before Using ยท When constructing the match operator argume

Prompt in Net::Telnet

2007-06-12 Thread Lakshmi Sailaja
Hello, I am supposed to write a program that will telnet to a remote server and execute some commands. I get the following error: "timed-out waiting for command prompt at line " This is because the prompt is not set correctly. Can you please tell me what the prompt value should be set to? how c

Re: Perl directory listing program

2007-06-12 Thread [EMAIL PROTECTED]
On Jun 12, 5:26 pm, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote: > Looking for some help here you perl geniuses you : ) > > I need a program Sorry, I think you are in the wrong place. Here we help people who want to learn Perl. (People who want bespoke ad-hoc programs written for free are general

Re: Database insertion, escape issue

2007-06-12 Thread Northstardomus
On Jun 12, 8:48 am, [EMAIL PROTECTED] (Jenda Krynicky) wrote: > From: "Mumia W." <[EMAIL PROTECTED]> > > > On 06/11/2007 06:52 PM, Northstardomus wrote: > > > [...] > > > print "Inserting into Database , @values."; > > > Use the "quotemeta" function to escape special characters > > that may

Re: Database insertion, escape issue

2007-06-12 Thread Northstardomus
On Jun 12, 4:59 am, [EMAIL PROTECTED] (Tom Allison) wrote: > On Jun 11, 2007, at 7:52 PM, Northstardomus wrote: > > > > > > > > > I have a Perl script where I try to strip some data from a web page > > and insert it > > > into a database. I'm having a problem where, it seems like the method > > of

RE: Net::Telnet - Variable in Prompt

2007-06-12 Thread Lakshmi Sailaja
I am if my question was brief. $prompt is a scalar variable. like this: $sub = "xyz"; $prompt = "L:\\$sub"; my $t = Net::Telnet->new( Timeout => 10, Prompt => "/$prompt/" ); Thanks & Regards, Lakshmi 952-833-1220 -Original Message- From: Chas Owens [mailto:[EMAIL PROTE

Re: Net::Telnet - Variable in Prompt

2007-06-12 Thread Chas Owens
On 6/12/07, Lakshmi Sailaja <[EMAIL PROTECTED]> wrote: But it did not work. I was getting the below error: "timed-out waiting for command prompt at line " snip This code works for me. #!/usr/bin/perl use strict; use warnings; use Net::Telnet; #my propmt is /home/user> my $prompt =

RE: Net::Telnet - Variable in Prompt

2007-06-12 Thread Lakshmi Sailaja
But it did not work. I was getting the below error: "timed-out waiting for command prompt at line " Thanks & Regards, Lakshmi 952-833-1220 -Original Message- From: Martin Barth [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 12, 2007 2:23 PM To: beginners@perl.org Cc: [EMAIL PROTEC

Re: Net::Telnet - Variable in Prompt

2007-06-12 Thread Martin Barth
On Tue, 12 Jun 2007 11:56:12 -0500 "Lakshmi Sailaja" <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a way to use a variable in the Prompt parameter like the below > line? > > my $telnet = Net::Telnet->new([HOST => "$server",] > [PROMPT => /$prompt/,]); > > Thanks & Regards, > La

Re: regex for matching repeated strings

2007-06-12 Thread John W. Krahn
yitzle wrote: Issues with both methods: John's doesn't work for this data: aa aa bbb cc cc I would expect: aa bbb cc I would get: aa bbb cc cc It works for me: $ perl -le' my $data = q[aa aa bbb cc cc ]; print $data; $data =~ s/(.*\n)(?=\1

Re: Perl directory listing program

2007-06-12 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Looking for some help here you perl geniuses you : ) I need a program that will list all of the files in a directory. Without any arguments the program will list only the files (not directories) in the current directory. But I must have some command line options: -d i

Re: regex for matching repeated strings

2007-06-12 Thread Chas Owens
On 6/12/07, yitzle <[EMAIL PROTECTED]> wrote: Issues with both methods: snip If you only want to reduce runs (as opposed to removing dups) then #!/usr/bin/perl use strict; use warnings; my $cur = undef; while () { print unless defined $cur and $_ eq $cur; $cur = $_; } __DATA__

Re: Perl directory listing program

2007-06-12 Thread Chas Owens
On 6/12/07, Beginner <[EMAIL PROTECTED]> wrote: snip perldoc -f format # For an alternative way to format some headers. snip I would suggest using Perl6::Form instead of the built-in format handling. The built-in format pretty much forces you to use bad style. * http://

Re: regex for matching repeated strings

2007-06-12 Thread yitzle
Issues with both methods: John's doesn't work for this data: aa aa bbb cc cc I would expect: aa bbb cc I would get: aa bbb cc cc With the solution by Chas and the data: aa aa bbb aa aa I expect: aa bbb aa I get: aa bbb -- To un

Re: regex for matching repeated strings

2007-06-12 Thread Chas Owens
On 6/12/07, James <[EMAIL PROTECTED]> wrote: Is there a way of writing a regex to find 1 or more occurances of specific text string, and replace with a single occurance. Possibly, but using a hash is a lot easier and probably more efficient: #!/usr/bin/perl use strict; use warnings; my %h;

Re: Perl directory listing program

2007-06-12 Thread Beginner
On 12 Jun 2007 at 16:26, [EMAIL PROTECTED] wrote: > Looking for some help here you perl geniuses you : ) > > I need a program that will list all of the files in a directory. > Without any arguments the program will list only the files (not > directories) in the current directory. But I must have

Perl directory listing program

2007-06-12 Thread [EMAIL PROTECTED]
Looking for some help here you perl geniuses you : ) I need a program that will list all of the files in a directory. Without any arguments the program will list only the files (not directories) in the current directory. But I must have some command line options: -d if no argument is given, the

Re: regex for matching repeated strings

2007-06-12 Thread John W. Krahn
James wrote: Is there a way of writing a regex to find 1 or more occurances of specific text string, and replace with a single occurance. e.g.: AI01 AI01 AI01 AI01 needs to be replaced with AI001 thus (m/(AI\d{6}\n)/) will find one occurance and capture as $1 (assumin

Net::Telnet - Variable in Prompt

2007-06-12 Thread Lakshmi Sailaja
Hi, Is there a way to use a variable in the Prompt parameter like the below line? my $telnet = Net::Telnet->new([HOST => "$server",] [PROMPT => /$prompt/,]); Thanks & Regards, Lakshmi 952-833-1220 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [

regex for matching repeated strings

2007-06-12 Thread James
Is there a way of writing a regex to find 1 or more occurances of specific text string, and replace with a single occurance. e.g.: AI01 AI01 AI01 AI01 needs to be replaced with AI001 thus (m/(AI\d{6}\n)/) will find one occurance and capture as $1 (assuming delimiter se

Re: Database insertion, escape issue

2007-06-12 Thread Northstardomus
On Jun 12, 8:48 am, [EMAIL PROTECTED] (Jenda Krynicky) wrote: > From: "Mumia W." <[EMAIL PROTECTED]> > > > On 06/11/2007 06:52 PM, Northstardomus wrote: > > > [...] > > > print "Inserting into Database , @values."; > > > Use the "quotemeta" function to escape special characters > > that may

Re: Is there an "EXIF" for video files ?

2007-06-12 Thread Jenda Krynicky
Date sent: 11 Jun 2007 21:40:40 - To: beginners@perl.org Subject:Is there an "EXIF" for video files ? From: TDJ <[EMAIL PROTECTED]> Organization: ACME > I use a Perl script to download images from my digital camera, >

Re: Declaring constants in perl

2007-06-12 Thread Paul Lalli
On Jun 12, 9:48 am, [EMAIL PROTECTED] (Jenda Krynicky) wrote: > Everything has it's pros and cons. > > 1) The constant pragma is already installed with any Perl 5.004 or > newer, while you have to install Readonly.pm Agreed, but with the availability of CPAN.pm and the relative ease with which mo

Re: Declaring constants in perl

2007-06-12 Thread Jenda Krynicky
From: Paul Lalli <[EMAIL PROTECTED]> > On Jun 8, 7:33 am, [EMAIL PROTECTED] (Alok Nath) wrote: > > What is the convention used to declare constants in perl ? > > In C we declare constant type in Capital letters , not sure > > how its in perl. > > There is a 'constant' pragm

Re: Database insertion, escape issue

2007-06-12 Thread Jenda Krynicky
From: "Mumia W." <[EMAIL PROTECTED]> > On 06/11/2007 06:52 PM, Northstardomus wrote: > > [...] > > print "Inserting into Database , @values."; > > Use the "quotemeta" function to escape special characters > that may be in the values. Please don't! > my @values_copy = @values; >

Re: Annoying HASH(0x...) in Output

2007-06-12 Thread Jenda Krynicky
From: "Tom Phoenix" <[EMAIL PROTECTED]> > On 6/4/07, GMan <[EMAIL PROTECTED]> wrote: > Things go smoothly for a while, and things seem quiet. Too quiet. Then... > > > sub addfriend { > > my ($self,$f) = @_; > > #dereference the array from the hash > > $fr = $self->{'_friends'}; > >

Re: Leading zeros kept or not kept while increment or decrement

2007-06-12 Thread Adriano Ferreira
On 6/12/07, Angerstein <[EMAIL PROTECTED]> wrote: Perl does $x="0001"; $x++; print $x; Output: 0002 BUT $x="0002"; $x--; print $x; Output: 1 Why and how can I avoid that. (yes, i know about printf) So use it ;-) Read the section "Auto-increment and Auto-decrement" in " perldoc perlop " w

Leading zeros kept or not kept while increment or decrement

2007-06-12 Thread Angerstein
Perl does $x="0001"; $x++; print $x; Output: 0002 BUT $x="0002"; $x--; print $x; Output: 1 Why and how can I avoid that. (yes, i know about printf) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Database insertion, escape issue

2007-06-12 Thread Mumia W.
On 06/11/2007 06:52 PM, Northstardomus wrote: [...] print "Inserting into Database , @values."; Use the "quotemeta" function to escape special characters that may be in the values. my @values_copy = @values; @values = map quotemeta($_), @values; $dbh->do("INS

Re: Database insertion, escape issue

2007-06-12 Thread Tom Allison
On Jun 11, 2007, at 7:52 PM, Northstardomus wrote: I have a Perl script where I try to strip some data from a web page and insert it into a database. I'm having a problem where, it seems like the method of quoting the data for insertion don't seem to be working (as far as escaping the text)

Database insertion, escape issue

2007-06-12 Thread Northstardomus
I have a Perl script where I try to strip some data from a web page and insert it into a database. I'm having a problem where, it seems like the method of quoting the data for insertion don't seem to be working (as far as escaping the text) and some of the text is ending up getting injected int