Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: cmd o/p- each line should be stored as each element in an Array?

by G Nagasri Varma (Novice)
on Dec 03, 2015 at 10:26 UTC ( [id://1149284]=note: print w/replies, xml ) Need Help??


in reply to Re: cmd o/p- each line should be stored as each element in an Array?
in thread cmd o/p- each line should be stored as each element in an Array?

chomp ( my @x = <> );
The above one worked, but array is getting all the entire list of values. But in the index zero, why isnt first value being stored.
o/p:
1431037440 1431038327
$files[0]=
$files1=1431037440
  • Comment on Re^2: cmd o/p- each line should be stored as each element in an Array?

Replies are listed 'Best First'.
Re^3: cmd o/p- each line should be stored as each element in an Array?
by soonix (Canon) on Dec 03, 2015 at 12:48 UTC

    Is there an empty line at the beginning of your input file?

    If that's not the case, you should try to create an →SSCCE
Re^3: cmd o/p- each line should be stored as each element in an Array?
by NetWallah (Canon) on Dec 03, 2015 at 21:55 UTC
    To filter out empty lines (or lines not containing digits), try:
    chomp ( my @x = grep{/\d/} <> );

            Our business is run on trust. We trust you will pay in advance.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1149284]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-23 23:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found