On Tue, Sep 16, 2008 at 8:28 AM, cancer <[EMAIL PROTECTED]> wrote: > Hi, > I am using Perl on Linux server. I m writing a code which will tell > us the Linux distro with version. For this the command is > > cat /etc/issue > > which is common for all the distributions of linux.
Slackware :-) [EMAIL PROTECTED]:~$ cat /etc/slackware-version Slackware 12.0.0 [EMAIL PROTECTED]:~$ cat /etc/issue Welcome to \s \r (\l) [EMAIL PROTECTED]:~$ ls -la /etc/issue -rw-r--r-- 1 root root 24 2000-09-24 11:39 /etc/issue [EMAIL PROTECTED]:~$ > > > Welcome to openSUSE 11.0 (X86-64) - Kernel \r (\l). > > REDHAT > > Red Hat Enterprise Linux Server release 5 (Tikanga) > > I am able to save the output in a string. Now I want a code or > function which will give me only the number from the string. What Perl code have you already tried so far? If this is a class, your teacher encouraged students to come here (as in we here do not want to short circuit the student/teacher relation ie teacher sometimes needs feedback too) (improvement of lessons, and/or the sources provided for students to study and get their own answers) Where's your answer so far or otherwise what you've tried if this is not a class. See where we are put (or where that puts us) by what your approach has been so far? I'm not too high in Perl skills myself. But the next does some basic things. #!/usr/bin/perl use warnings; use strict; my @fields; while (<DATA>) { @fields = split; foreach (@fields) { next if /\d\)/; # no (X86-64) print "$_\n" if /\d+/; } } __DATA__ Slackware 12.0.0 Welcome to openSUSE 11.0 (X86-64) - Kernel \r (\l). # end of file marker -- Alan.