[ale] String -> Number

James P. Kinney III jkinney at localnetsolutions.com
Mon Mar 17 14:33:56 EST 2003


@word_array=split(//, $word);
pop(@word_array);
$word2 = '';
for ($i=0,$i<=$#word_array,$i++){
	$word2.=#word_array[i]
	}



--or--

$word =~ s/<asci code for CR here>//;

On Mon, 2003-03-17 at 14:31, Christopher Fowler wrote:
> Darn!
> 
> chomp() strips NL, Not CR's.  I've got a lingering CR on the end.  How
> can I remove that one?
> 
> 
> On Mon, 2003-03-17 at 14:14, John Wells wrote:
> > So what does SPORT look like when you set $VERBOSE?
> > 
> > Christopher Fowler said:
> > > Is there a formal method of converting a string to a number?  I'm
> > > reading a line from a socket that is really a number.  I'm passing that
> > > var as an argument to IO::Socket::INET but it fails connection.  By
> > >
> > > This works
> > >
> > >
> > > #strip line terminateor off
> > >     chomp($line);
> > >     $SPORT = $line;
> > >
> > >     close($sock);
> > >
> > >     if($VERBOSE == 1) {
> > >         print (STDOUT "Connecting to secondary server on port ", $SPORT,
> > > "\n");
> > >     }
> > >
> > >     my $sock = new IO::Socket::INET (
> > >                                      PeerAddr => $SERVER,
> > >                                      PeerPort => 783,
> > >                                      Proto => 'tcp',
> > >                                      );
> > >     die "Could not create socket: $!\n" unless $sock;
> > >
> > > This does not
> > >     my $sock = new IO::Socket::INET (
> > >                                      PeerAddr => $SERVER,
> > >                                      PeerPort => $SPORT,
> > >                                      Proto => 'tcp',
> > >                                      );
> > >     die "Could not create socket: $!\n" unless $sock;
> > >
> > > I'm trying to write a portable logging program that will log output
> > > received to a file.
> > >
> > > Thanks,
> > > Chris
> > >
> > >
> > >
> > > _______________________________________________
> > > Ale mailing list
> > > Ale at ale.org
> > > http://www.ale.org/mailman/listinfo/ale
> > 
> > 
> > 
> > _______________________________________________
> > Ale mailing list
> > Ale at ale.org
> > http://www.ale.org/mailman/listinfo/ale
> 
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
-- 
James P. Kinney III          \Changing the mobile computing world/
CEO & Director of Engineering \          one Linux user         /
Local Net Solutions,LLC        \           at a time.          /
770-493-8244                    \.___________________________./
http://www.localnetsolutions.com

GPG ID: 829C6CA7 James P. Kinney III (M.S. Physics) <jkinney at localnetsolutions.com>
Fingerprint = 3C9E 6366 54FC A3FE BA4D 0659 6190 ADC3 829C 6CA7 

 This is a digitally signed message part




More information about the Ale mailing list