How to figure out Size of Var.

2005-03-11 Thread Bastian Angerstein

How can I figure out how many chars are stored in a variable?
Or how can I determit the length of a string in a variable?

this methode is a little poor: 
@array = split //, $var;
$size = scalar (@array);

Thanks

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




How to remove everything after the last . dot?

2005-03-08 Thread Bastian Angerstein

I have a line:
  i.like.donuts.but.only.with.tea

now I want to remove everything that follows the last .
including the last ..

in this case .tea

I hav absulte no idea. I tried something like:

@parts = splite /\./, $line; 

$parts[-1] = undef;

foreach $parts (@parts) {
  $newline .= $parts.;
}

but then I got a dot at the end of the line.

Thanks,

Bastian

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




AW: How to remove everything after the last . dot?

2005-03-08 Thread Bastian Angerstein
Hmmm...

use strict; use warnings;
my $a=i.like.donuts.but.only.with.tea;
$a=~s/\.\w+$//; #  maybe w+ not d+???
print $a, \n;


Deutsche Telekom AG
T-Com, Technische Infrastruktur Niederlassung Überregional
Bastian Angerstein
Network Support Center -
Network Management Support
Maybachstr.57; D-70469 Stuttgart
+49 711 8939 1889 (Tel.)
+49 711 8939 6604 (Fax)
mailto:[EMAIL PROTECTED]
http://www.t-com.de

-Ursprüngliche Nachricht-
Von: John Doe [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 8. März 2005 11:46
An: beginners@perl.org
Betreff: Re: How to remove everything after the last . dot?


Hi

 I have a line:
   i.like.donuts.but.only.with.tea

 now I want to remove everything that follows the last .
 including the last ..

[...]

you can use a regex for that.

=== Documentation (from command line:)


perldoc perlre

=== Code:

use strict; use warnings;
my $a=i.like.donuts.but.only.with.tea;
$a=~s/\.\d+$//; #  this does the trick
print $a, \n;

# this prints:
i.like.donuts.but.only.with.tea

=== explanation:
see documentation ;-)


greetings joe

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




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




Moving Directories containing files (something more tricky)

2005-02-24 Thread Bastian Angerstein

Hello there,

I have a tricky problem, I have some (alot) directories containing
alot of files. I want to move the directory  /xyz/123/ with all containing
files to /xyz/abc/123.

The source directory does not (or should not) contain subdirectories.

Does anybody have something for me ?

Thanks,
Bastian


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




how to handle multiline feedback from backticksoperator?

2005-02-22 Thread Bastian Angerstein


Hello there,

I have a cmd-PRogramm which produce multiline output.

/usr/testdrive.

I call this proggi from perl:

`/usr/testdrive -e -k | grep /home`;

This programm produce multiline Output, 
how do I get this into a variable or array ? 

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




Example of hash and array movement correct?

2005-02-18 Thread Bastian Angerstein

  Hello, 
  I am looking for ways to move data 
  between array and hashes.

  Does anybody has a better way or idea to do some of this:
  
  Example 1:
  @indatas = $datas [0 .. 4];
  Example 2:
  $nkey = $dataln[3] . $dataln[4];
  Example 3:
  $base{$bv[0]} = [ $bv[1], $bv[2], $bv[3], $bv[4] ];

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




How to add leading zeros?

2005-02-16 Thread Bastian Angerstein

Hello,

I have some Numbers  1 2 3 40 51 and I want them to be in the format 
001 002 003 ... 040 ... 051 ...

What is the fastest way to do this??

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




AW: email reading script

2004-11-25 Thread Bastian Angerstein
try http://www.koders.com they have a lot of code to evaluate.

-Ursprüngliche Nachricht-
Von: vishwas bhakit [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 25. November 2004 10:19
An: [EMAIL PROTECTED]
Betreff: email reading script


hello,

I am working for email reading script in perl,
can anybody plz tell me where can i get
help for this.

thnx.


Yahoo! India Matrimony: Find your life partneronline.


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




Sinus and PI in perl

2004-11-24 Thread Bastian Angerstein
Hello,

in an excel sheet I use:
=SIN((2*PI()/96)*1)
=SIN((2*PI()/96)*2) etc...

my question is how to get this function in perl?

The Results are values (in the example max. 96) on the Y-Axes of the
Sinuswave.

BTW:
I want to replace the 96 (measuringpoints) and the multiplication value with
variables, too.

Thanks,
Bastian


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





AW: Reading from a filehandle in while-loop

2004-10-27 Thread Bastian Angerstein
Yes it should, but not on my system.

Thanks for your comments.

-Ursprüngliche Nachricht-
Von: Bob Showalter [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 26. Oktober 2004 16:00
An: 'David le Blanc'
Cc: [EMAIL PROTECTED]
Betreff: RE: Reading from a filehandle in while-loop


David le Blanc wrote:
...
 You are making the assumption that  'TEST' sets '$_' which is not
 true.  Oddly, perl makes '' set $_, but not FILE... dunno why

Sorry, but that's just not correct.

   while (TEST)

DOES set $_, as documented in perldoc perlop under the secion I/O
Operators

The OP has some other problem.

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




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




Reading from a filehandle in while-loop

2004-10-26 Thread Bastian Angerstein

Why does this don´t work in my Script?

open (TEST, /tmp/test.txt);
while (TEST) {
  print $_;
  # or just
  print;
}


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




AW: Reading from a filehandle in while-loop

2004-10-26 Thread Bastian Angerstein
Joop,
if I use open... or die $! i see that the file is opened correctly but nothing is in 
$_.




-Ursprngliche Nachricht-
Von: Flemming Greve Skovengaard [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 26. Oktober 2004 11:45
An: [EMAIL PROTECTED]
Cc: Bastian Angerstein
Betreff: Re: Reading from a filehandle in while-loop


Bastian Angerstein wrote:
 Why does this dont work in my Script?
 
 open (TEST, /tmp/test.txt);
 while (TEST) {
   print $_;
   # or just
   print;
 }
 
 

Does the file exists and can you read it?

-- 
Flemming Greve SkovengaardThe killer's breed or the Demon's seed,
a.k.a Greven, TuxPowerThe glamour, the fortune, the pain,
[EMAIL PROTECTED]   Go to war again, blood is freedom's stain,
4112.38 BogoMIPS  Don't you pray for my soul anymore.



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




Perl/TK Development Suite/Gui

2004-10-14 Thread Bastian Angerstein
Hi,
I am looking for a free (graphic) development tool for building perl/tk
applications.
It should run under AIX and/or Linux.

If anybody knows a good tool, with something like a tk gui-painter tell me,
please.

Thanks Bastian


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




can´t call method xyz on an undefined value at...

2004-09-03 Thread Bastian Angerstein

Good Morning,

I, once again, have a question.

How can I check if a Method is undefined or not without getting this error?




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




can´t call method xyz on an undefined value at...

2004-09-03 Thread Bastian Angerstein
Now I gate can´t call methode can on an undefined value xyz line xyz.
Any Idea?


-Ursprüngliche Nachricht-
Von: Charles K. Clarkson [mailto:[EMAIL PROTECTED]
Gesendet: Freitag, 3. September 2004 10:37
An: 'Bastian Angerstein'; 'Mailinglist Perl Beginners'
Betreff: RE: can´t call method xyz on an undefined value at...


Bastian Angerstein [EMAIL PROTECTED] wrote:

: How can I check if a Method is undefined or not without
: getting this error?


Assuming you mean the method to an object. Use the
UNIVERSAL method 'can'.


use CGI;
my $q = CGI-new();
print method 'xyz' invalid for '\$q'\n unless $q-can( 'xyz' );
print method 'xyz' valid for '\$q'\n;

__END__

use CGI ('xyz');
my $q = CGI-new();
print method 'xyz' invalid for '\$q'\n unless $q-can( 'xyz' );
print method 'xyz' valid for '\$q'\n;

__END__


HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328



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




Code in Variable ausführen?

2004-07-23 Thread Bastian Angerstein

Hello,

is it possible to execute code that is within a var?

like:

$var = 'print Hallo Welt\n';

I had seen something like that in compination with eval...

but I can´t remeber where and I can´t find that code anymore.


Thanks

Bastian


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




__DATA__ Token Question

2004-07-22 Thread Bastian Angerstein
Hello,

some weeks ago I had a question regarding The DATA-Token.

Now there is anonther one:

Could I change the contens of the datatoken (filehandle)
during the runtime of the skript?

If anyone has an idea I would be grateful.



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




AW: Counting characters in a thread

2004-07-09 Thread Bastian Angerstein

unless ($string =~ /%{0,10}/) {
  $string = undef;
}



-Ursprungliche Nachricht-
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Gesendet: Freitag, 9. Juli 2004 13:21
An: [EMAIL PROTECTED]
Betreff: Counting characters in a thread



$string =
a%3A2%3A%7Bi%3A0%3Bs%3A3%3A%22489%22%3Bi%3A1%3Bs%3A32%3A%22a85a44c188152379
8bc155a5369e1226%22%3B%7D

How would I empty $string if it contained more than ten % characters? In
other words

$string =
a%3A2%3A%7Bi%3A0%3Bs%3A3%3A%22489%22%3Bi%3A1%3Bs%3A32%3A%22a85a44c188152379
8bc155a5369e1226%22%3B%7D

Would be emptied, while

$string = a%3A2%3A%7Bi%3A0%3Bs%3A3%3A%22489%22

would not.


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




RE: __DATA__ Token Problem

2004-07-06 Thread Bastian Angerstein


Thanks for your Tips.

my $data = tell DATA;
print $data\n;
truncate $0, $data;

This looks very promising to me.
Therefor that the host is a Unixsystem, I might be able to solve my problem.

I don´t really understand $0 at the moment.
I thought its the name the script was started with.

Bastian


-Ursprüngliche Nachricht-
Von: John W. Krahn [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 6. Juli 2004 06:37
An: Perl Beginners
Betreff: Re: __DATA__ Token Problem


On Monday 05 July 2004 05:07, Bastian Angerstein wrote:

 Hello,

Hello,

 I have a few questions regarding to the DATA Filehandle:

 1.
 This handle ist opend by default or do I have to open it by myself?

It is opened by default.


 2.
 Is it possible to change to content of what the handle so that the
 __DATA__ Sektion of my skript changes?

It depends on the operating system.  *nix will allow you to modify any
file if you have permission to do so.  Some versions of DOS\Windows
will allow you to modify running programs but most won't.


 3.
 Can I delete anything data from DATA so that the __DATA__ section is
 empty?

Again, it depends on what the operating system will allow.

This works on my Linux OS:

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

my $data = tell DATA;
print $data\n;
truncate $0, $data;

__DATA__
line 1
line 2
line 3
line 4



John
--
use Perl;
program
fulfillment

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




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




__DATA__ Token Problem

2004-07-05 Thread Bastian Angerstein
Hello,

I have a few questions regarding to the DATA Filehandle:

1.
This handle ist opend by default or do I have to open it by myself?

2.
Is it possible to change to content of what the handle so that the
__DATA__ Sektion of my skript changes?


3.
Can I delete anything data from DATA so that the __DATA__ section is
empty?

Deutsche Telekom AG
T-Com, Technische Infrastruktur Niederlassung Überregional
Bastian Angerstein
Network Support Center -
Network Management Support
Maybachstr.57; D-70469 Stuttgart
+49 711 8939 1889 (Tel.)
+49 711 8939 6604 (Fax)
mailto:[EMAIL PROTECTED]
http://www.t-com.de


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




Socket or NetServer::generic???

2004-06-30 Thread Bastian Angerstein

Hello, there

I am progarmming a client server passed solution.

My Question here ist which Modul I should use.

I already noticed that the IO::Socket and the NetServer::Generic
are both easy to use.

My question is does a IO::Socket server handle multiple clients
or not?


Thank you,
Bastian

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




POD anyone with a good example???

2004-06-28 Thread Bastian Angerstein
Hello there,

does anyone have a good example for pod documented sourcecode.

I would like to have some sort of example where I can start with.

Thanks,
Bastian

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




How to get Interface IP using perl?

2004-06-09 Thread Bastian Angerstein
How to get Interface IP (DailUp Interface with nonstatic ip) using perl?



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




How get a special value of an arrayfield stored in an hash?

2004-05-24 Thread Bastian Angerstein

I tought:
$index = 1

$var = ${$myhash{mykey}}[$index];

would do the trick.

But it don´t.


Any suggestions?


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




Perl / Tk Gui Toolkit?

2004-02-25 Thread Bastian Angerstein

Hi

has anybody expirience with GUI Toolkit for Perl/Kit?

Which would you recommend for Solaris or Windows? 

Thanks

Bastian

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




Maybe Stupid RegEx Question

2004-02-12 Thread Bastian Angerstein

Hi 

I have two strings 0x1479ee und 0x1479fe. 

The strings a in $var1 and $var2.

if I do:
  if ( $var2 =~ /\Q$var1\E/) 

 It matches.

  how can I match an the string and not on each sign? 


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




AW: FW: special vars

2004-02-04 Thread Bastian Angerstein
It is important believe me.

Especialy if you are writting to logfiles, databases and unix named pipes.

If in this context buffered io is on it will happen that if you prints
something to
a file or anywhere not the whole line is dumped only the stuff what was in
the buffer
when the buffer was flushed because of its size the last time.

if you give out the line:
Hello, I am here./n

Buffered it could look like this at the destination:
Hello, I a

Unbuffered it will look like this:
Hello, I am here./n

Beware THERE IS A DIFFERENCE OF PRINTING TO A FILE, PIPE, PROGRAM and a TTY
/ COMMANDLINE.


See Fcntl, File::Handle, Io::Handle at cpan for more.


-Ursprungliche Nachricht-
Von: Eternius [mailto:[EMAIL PROTECTED]
Gesendet: Mittwoch, 4. Februar 2004 12:00
An: [EMAIL PROTECTED]
Betreff: Re: FW: special vars


Nilay Puri wrote:


 -Original Message-
From: Nilay   Puri, Noida
Sent: Wednesday, February 04, 2004 11:37 AM
To:   Perl (E-mail)
Subject:  FW: special vars



 -Original Message-
From: Nilay   Puri, Noida
Sent: Wednesday, February 04, 2004 11:32 AM
To:   Perl (E-mail)
Subject:  special vars

Hi all,

Can any one help me understand the usage of special variable $| ?

I know the description of this var. If set to nonzero, forces a flush
after every write or print.

But I am not able to understand its importance.

If I am reading a file and writing the contents in a separat file after
some processing.
What will happen if I set $|=1 ?

Thanks,
NP





if u use an OS like linux (which will not write things imediately to
disc) this forces it to do so.

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




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




How to sort hashkeys by numbersize??

2004-01-20 Thread Bastian Angerstein

I got the following Problem:

My hashkeys looks like number:string .

For example 10530:fileparameter-sa1
10529:fileparameter-mv1
10531:fileparameter-tx4

(without the  signs...)

I would like to sort the hashkeys by the number
before the doublepoint.

Any Idea?

Thx, Bastian.




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




Re: Re: How t o sort haskeys by numbersize??

2004-01-20 Thread Bastian Angerstein
Thank´s a lot people!

Have a nice day,
Bastian


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




How to work with 64 Bit unsinged Intergers or Network formatted numbers.

2003-11-20 Thread Bastian Angerstein
Hello,

I am working with SNMP and 64 Bit unsigned Intergers.

To give you a view on the different possible values and types I come across:
2147483648 =  1000 =  8000 = 2^31
4294967296 = 1 = 1 = 2^32
4294967295 =   =   = 2^32 -1
8589934591 = 1 = 1 = 2^33 -1

9223372036854775808 =
1000 =
8000 = 2^63
9223372036854775807 =
111 =
7FFF = 2^63 -1

18446744073709551616 =
1 =  ?? =
2^64
18446744073709551615 =
 =  ?? =
2^64 - 1
36893488147419103231 =
1 =  ?? =
2^65 - 1

The thing that I do is
$var = unpack(N*, $any64bitvalue);
or
$var = unpack(I*, $any64bitvalue);
to make sure the number is an unsigned Interger.

When I access the number in $var (as a string or a number) it has ben
chopped to a 32 Bit number.

Now I tested Math:BigInt  $var = Math::BigInt-new(unpack(I*,
$any64bitvalue));
But still on the  $var is chopped to 32 Bit in the next subroutine;

This means that the value 36893488147419103231  becomes  8589934591.

I do not have the possibility to use 64 BIT perl.
I am using aix 4.3.3 and I cant tell you it is no fun building a perl there.

BTW: Does anyone knows anything about perl typecasting?

Thx,
Bastian


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