Re: Probably silly question about loop

2007-09-06 Thread Rob Dixon

Mike Martin wrote:


Its actually a word wrap function, because I couldn't get Text::Wrap
or Gtk wrap to work right.


Like this:


use strict;
use warnings;

use Text::Wrap;

my $string=ffmpeg  -v 2 -i \/home/mike/vcr58uc.avi\ -itsoffset -0.1 -i 
\/home/mike/vcr58uc.avi\  -target dvd -y -s 352x288 -qscale 5 -bf 2 -g 15 -acodec mp2 -ac 2 -ab 64kk 
-me_range 63 -aspect 4:3 -map 1:0 -map 0:1 \/home/mike/vcr58ucen.vob\;

$Text::Wrap::columns = 50;
print wrap('', '', $string);





Rob

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




Probably silly question about loop

2007-09-05 Thread Mike Martin
I am having a problem with looping a string.

This is my code

my $string=ffmpeg  -v 2 -i \/home/mike/vcr58uc.avi\ -itsoffset -0.1
-i \/home/mike/vcr58uc.avi\  -target dvd -y -s 352x288 -qscale 5 -bf
2 -g 15 -acodec mp2 -ac 2 -ab 64kk -me_range 63 -aspect 4:3 -map 1:0
-map 0:1 \/home/mike/vcr58ucen.vob\;
my $wrap='50';

my $count=0;
my $string1=$string;
my @string1=$string1;
my $str_length=length($string1);
print $str_length;
while ($count lt $str_length){
{my $line1=substr($string1,$count,$wrap);
my $len2;
if (rindex($line1,' ') ne -1){
$len2=rindex($line1,' ');
}

my $strin2=substr($string1,$count,$len2);
push (@wwl,$strin2);
$count=$len2;
}
print $count,\n;
}
print $count,\n;

$string=join(\n,@wwl);
print $string,\n;


This code only runs once not any more

Any help appreciated

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




Re: Probably silly question about loop

2007-09-05 Thread Gunnar Hjalmarsson

Mike Martin wrote:

I am having a problem with looping a string.

This is my code


snip


my $count=0;


snip


my $str_length=length($string1);


snip


while ($count lt $str_length){


snip


This code only runs once not any more


You are using the wrong operator to compare numbers. See perldoc perlop.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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




Re: Probably silly question about loop

2007-09-05 Thread Tom Phoenix
On 9/5/07, Mike Martin [EMAIL PROTECTED] wrote:

 I am having a problem with looping a string.

Have you tried stepping through your code in the debugger?

 while ($count lt $str_length){

That looks like a place where you used a string comparison ('lt') but
maybe meant a numeric comparison ('').

Your code structure will be easier to understand if you indent
consistently. Using 'use strict' and 'use warnings' will also help to
improve your code.

Does that get you closer to making your algorithm work? Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

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




Re: Probably silly question about loop

2007-09-05 Thread Mike Martin
On 05/09/07, Tom Phoenix [EMAIL PROTECTED] wrote:
 On 9/5/07, Mike Martin [EMAIL PROTECTED] wrote:

  I am having a problem with looping a string.

 Have you tried stepping through your code in the debugger?

  while ($count lt $str_length){

 That looks like a place where you used a string comparison ('lt') but
 maybe meant a numeric comparison ('').

 Your code structure will be easier to understand if you indent
 consistently. Using 'use strict' and 'use warnings' will also help to
 improve your code.

 Does that get you closer to making your algorithm work? Good luck with it!

 --Tom Phoenix
 Stonehenge Perl Training


thanks this is the solution (BTW I had use strict, diagnostics and warnings on)


#!/usr/bin/perl -w
use diagnostics;
use strict;
my $string=ffmpeg  -v 2 -i \/home/mike/vcr58uc.avi\ -itsoffset -0.1
-i \/home/mike/vcr58uc.avi\  -target dvd -y -s 352x288 -qscale 5 -bf
2 -g 15 -acodec mp2 -ac 2 -ab 64kk -me_range 63 -aspect 4:3 -map 1:0
-map 0:1 \/home/mike/vcr58ucen.vob\;
my $wrap='50';
my @wwl;
my $count=0;
my $string1=$string;
my @string1=$string1;
my $str_length=length($string1);
print $str_length,\n;

while ($count  $str_length){  # correct operator


{
my $len2;
my $line1=substr($string1,$count,$wrap);
if ((length($line1)+$count)$str_length){ # extra condition to make
sure it increments
 if (rindex($line1,' ') ne -1){# when check for
white space results in 0 value
  $len2=rindex($line1,' ');
 }
 else {$len2=$wrap}
 }
else {$len2=$wrap}

my $strin2=substr($string1,$count,$len2);
push (@wwl,$strin2);
$count=$count+$len2; # I wasn't incrementing count properly

}


}
$string=join(\n,@wwl);
print $string,\n;


Its actually a word wrap function, because I couldn't get Text::Wrap
or Gtk wrap to work right.

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




RE: Silly question

2003-09-27 Thread Gupta, Sharad
Thank you.

-Sharad

-Original Message-
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]
Sent: Monday, September 22, 2003 10:20 PM
To: Gupta, Sharad
Cc: [EMAIL PROTECTED]
Subject: Re: Silly question


On Sep 22, Gupta, Sharad said:

   package Foo;
   use overload q() = sub {return shift-{bar}};
   $s = bless{bar=hello}, Foo;
   print $s\n

prints hello.

Because you have overloaded  for objects of class Foo.

   package Foo;
   use overload q() = sub {return shift-{bar}};
   $s = bless{bar=hello},Foo;
   $wilma = how r u;
   print $wilma\n

prints how r u.

Because you have overloaded  for objects of class Foo, but there is no
object of class Foo in double quotes.

If you want to intercept ALL quoted strings, you'll need to use
overload::constant, but that becomes tricky business.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]



Silly question

2003-09-22 Thread Gupta, Sharad

Hi ALL,

I know i am missing something somewhere:


perl -e '  
package Foo;   
use overload q() = sub {return shift-{bar}};   
$s = bless{bar=hello}, Foo;   
print $s\n 
 '

prints hello.


Whereas:

perl -e ' 
package Foo;   
use overload q() = sub {return shift-{bar}};   
$s = bless{bar=hello},Foo;   
$wilma = how r u;   
print $wilma\n  
 '

prints how r u.


Why is'nt it overloading   in the second case??. I was expecting it to again print 
hello.


Thanx for showing me light,
-Sharad


RE: Short silly question

2003-07-21 Thread Bob Showalter
Gabor Urban wrote:
 Hi,
 
 
 could someone give me a quick info whar __END__ and __DATA__ lines
 are good for? 

They are used to tell Perl to stop compiling the script at that point,
because whatever follows is either:

a) data to be read in to the script using the special DATA filehandle (see
perldoc perldata)

b) code that should be compiled only on demand (see perldoc SelfLoader)

I would guess the latter is probably rarely used in this day of speedy
processors and systems.

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



Short silly question

2003-07-18 Thread Gabor Urban
Hi,


could someone give me a quick info whar __END__ and __DATA__ lines are
good for?

Gabaux

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



Re: Short silly question

2003-07-18 Thread Rob Dixon
Gabor Urban wrote:
 Hi,


 could someone give me a quick info whar __END__ and __DATA__ lines
 are good for?


Short silly answer:

__END__ing the program and starting the __DATA__ that you can
read from the implicit DATA filehandle.

Rob





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



Re: silly question

2003-07-10 Thread zentara
On 09 Jul 2003 09:09:34 -0700, [EMAIL PROTECTED] (John Tarn) wrote:

i am still a novice in perl so forgive me for this simple question.
what is socket programming? what do sockets do? is there a site 
that can explain them to me? thanks

From a really simple viewpoint, I compare sockets to the concept
of extensions on the old phone system. When you used to call
a pbx system, they would ask, what extension do you want to connect to?

A tcp networked computer is similar, it has an IP address (the number),
then it has 64000+ extensions(called ports). You can assign programs
to listen to their assigned ports and do stuff when packets (calls)
come in.  A whole standard has emerged as to what programs are
supposeded to listen to what port numbers.  http is 80  . https is
443 ..smtp is 25..pop3 is 110..ftp is 21

If you are using linux, look at the file /etc/services. You will see all
the ports and what is defined for them.  Also check out /etc/inetd.conf
or /etc/xinetd.conf.  Ports are so important, that some general purpose
port daemons have been written, to make port programming easier.
They are called inetd and xinetd.  They handle alot of the socket
details, and you can write socket programs to use them, or be
independent.

Now computer ports are much more complicated than what I described
above. There are tcp and udp protocols for each port, and  the simplest
way to describe sockets is a filehandle to a port.

Just like you open a filehandle to read and write to a file, you open a
socket to read and write to a port.  Socket programming allows programs
to open ports to talk to one another, sometimes the programs can be on
the same machine, where sockets are a convenient way to do inter-process
communication.  Sometimes the programs are on different machines, where
it is networking, over the internet for example.




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



silly question

2003-07-09 Thread john tarn
i am still a novice in perl so forgive me for this simple question.
what is socket programming? what do sockets do? is there a site 
that can explain them to me? thanks

john


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



RE: silly question

2003-07-09 Thread Tim Johnson

Short answer:  

A socket is a machine address and a TCP port, identifying a particular
application running at a particular address.  This allows two-way
communication between machines running a particular application.

Long answer:

http://www.faqs.org/rfcs/rfc147.html

-Original Message-
From: john tarn [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 9:10 AM
To: [EMAIL PROTECTED]
Subject: silly question


i am still a novice in perl so forgive me for this simple question.
what is socket programming? what do sockets do? is there a site 
that can explain them to me? thanks

john


-- 
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: silly question

2003-07-09 Thread LI NGOK LAM
I would say the other name of socket programming is network programming.
The socket modules will act as a interface to deal with other machines, such
as
FTP, telnet, smtp, pop, etc.
I would recommand Network Programming with Perl, by Addison Weskey,
but that's a book, not a site =)


- Original Message - 
From: john tarn [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, July 10, 2003 12:09 AM
Subject: silly question


 i am still a novice in perl so forgive me for this simple question.
 what is socket programming? what do sockets do? is there a site
 that can explain them to me? thanks

 john


 -- 
 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: silly question

2003-07-09 Thread NYIMI Jose (BMB)
The fact that you are still a novice in Perl
has nothing to do with socket's notions :)
As you will see from defintions sent in previous post
sockets are not specifics to Perl
you can do Socket Programming with
any decent programming language (C,Java,PHP,Python etc ..).
With Perl, the module IO::Socket is certainly a good place to start.
See:
http://search.cpan.org/author/JHI/perl-5.8.0/ext/IO/lib/IO/Socket.pm

José.

-Original Message-
From: Tim Johnson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 09, 2003 6:25 PM
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: silly question



Short answer:  

A socket is a machine address and a TCP port, identifying a particular application 
running at a particular address.  This allows two-way communication between machines 
running a particular application.

Long answer:

http://www.faqs.org/rfcs/rfc147.html

-Original Message-
From: john tarn [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 9:10 AM
To: [EMAIL PROTECTED]
Subject: silly question


i am still a novice in perl so forgive me for this simple question. what is socket 
programming? what do sockets do? is there a site 
that can explain them to me? thanks

john


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



 DISCLAIMER 

This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer.

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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



RE: silly question

2003-07-09 Thread jdavis
On Wed, 2003-07-09 at 10:25, Tim Johnson wrote:
 Short answer:  
 
 A socket is a machine address and a TCP port, identifying a particular
 application running at a particular address.  This allows two-way
 communication between machines running a particular application.
 
 Long answer:
 
 http://www.faqs.org/rfcs/rfc147.html
 


at least with unix and its varients..you also have file sockets. Does
not need a inetrnet addr just a file name. If you have ever worked 
with files using perl...you pretty much already know how to do some
basic stuff with internet or unix sockets.

HTH,
jd




 -Original Message-
 From: john tarn [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, July 09, 2003 9:10 AM
 To: [EMAIL PROTECTED]
 Subject: silly question
 
 
 i am still a novice in perl so forgive me for this simple question.
 what is socket programming? what do sockets do? is there a site 
 that can explain them to me? thanks
 
 john
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
-- 
jdavis [EMAIL PROTECTED]


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



Silly question

2002-10-31 Thread Gajo Csaba
While I'm at silly questions, I guess I could ask this one 
too: what is the difference between a   and a ' '. I have 
a book that explains it to me in one sentence, and I don't 
understand one word that the author's using (I suck at 
English), so could someone explain it to me? An example 
would be nice too :)

Thanx, Csaba



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




RE: Silly question

2002-10-31 Thread Nikola Janceski
let's suppose

$variable = some text;

print $variable\n; # prints: some text

print '$varibale\n'; # prints: $variable\n

get it?

double quotes interpolate - expands variables and special characters.
single quotes do not interpolate - it's all just plain text don't think of
them as variables or special characters.

 -Original Message-
 From: Gajo Csaba [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, October 31, 2002 2:20 PM
 To: perl-beginners
 Subject: Silly question
 
 
 While I'm at silly questions, I guess I could ask this one 
 too: what is the difference between a   and a ' '. I have 
 a book that explains it to me in one sentence, and I don't 
 understand one word that the author's using (I suck at 
 English), so could someone explain it to me? An example 
 would be nice too :)
 
 Thanx, Csaba
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




Re: Silly question

2002-10-31 Thread Frank Wiles
 .--[ Gajo Csaba wrote (2002/10/31 at 20:19:43) ]--
 | 
 |  While I'm at silly questions, I guess I could ask this one 
 |  too: what is the difference between a   and a ' '. I have 
 |  a book that explains it to me in one sentence, and I don't 
 |  understand one word that the author's using (I suck at 
 |  English), so could someone explain it to me? An example 
 |  would be nice too :)
 |  
 `-

Basically it is to parse, or not to parse. :) 

If we have a scalar variable called $foo which is defined as: 

my $foo = 'is really cool.'; 

And we want to print it out using both methods as such: 

print 1 -- This $foo\n; 
print '2 -- This $foo\n'; 

Will produce the following: 

1 -- This is really cool.
2 -- This $foo\n

If you have variables or special characters ( i.e. \n, \t, etc )
in a string enclosed by s then they will be replaced with their
values.  If you have them enclosed in ''s they will be used
literally. 

Hope that helps. 

 -
   Frank Wiles [EMAIL PROTECTED]
   http://frank.wiles.org
 -


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




RE: Silly question

2002-10-31 Thread royce . wells



actually it gives you an error :)
You misspelled variable!

You made a  boo...boo
I know bad Halloween humor


If you set the examples...
  you don't have to set the rules


Royce Wells
Unix Systems Engineer






let's suppose

$variable = some text;

print $variable\n; # prints: some text

 print '$varibale\n'; # prints: $variable\n

get it?

double quotes interpolate - expands variables and special characters.
single quotes do not interpolate - it's all just plain text don't think of
them as variables or special characters.






The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.



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




Re: silly question

2002-03-08 Thread William.Ampeh


A good forum is the linux forum.
Go to www.redhat.com, and join a group in your geographical region.

A good forum is

[EMAIL PROTECTED]

__

William Ampeh (x3939)
Federal Reserve Board


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




silly question

2002-03-07 Thread M z

does anyone know if there is a similar question form
for unix?  my roomate is studying to become a sys
admin
and I'm trying to direct him to a similar email?

i.e. [EMAIL PROTECTED]???

__
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

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




ok silly question

2001-06-26 Thread royce . wells

I am working on a program that prints out script varibles to an html. When
I run it from the command line I see the variable. When the web page
(cgi-script runs) it eats them and just prints blank lines.  An example
follows.

# this works
$ID=`id`
print $ID

#this doesnt
$STORE=`store_output.x output 34`
print $STORE

yes my path is right ... yes the permissions are right... yes apache is
running as the user to execute script yes i have 2 \n on the content
line. I even tried escaping the $ just prints out the address of the
variable as opposed to the value inside.


The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.




RE: ok silly question

2001-06-26 Thread John Edwards

What does the output look like on the command line? It doesn't have  tags
round it by any chance??

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 26 June 2001 16:49
To: [EMAIL PROTECTED]
Subject: ok silly question


I am working on a program that prints out script varibles to an html. When
I run it from the command line I see the variable. When the web page
(cgi-script runs) it eats them and just prints blank lines.  An example
follows.

# this works
$ID=`id`
print $ID

#this doesnt
$STORE=`store_output.x output 34`
print $STORE

yes my path is right ... yes the permissions are right... yes apache is
running as the user to execute script yes i have 2 \n on the content
line. I even tried escaping the $ just prints out the address of the
variable as opposed to the value inside.


The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.


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