Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: it should be simple enough...

by ELISHEVA (Prior)
on Feb 20, 2011 at 10:31 UTC ( #889170=note: print w/replies, xml ) Need Help??

in reply to it should be simple enough...

I suspect you are confused because your final print statement emits something like $VAR1 = 'GLOB(0x817f880)'. As for why:

  • You never set the global separator to "//". You merely defined it to nothing at all. To set the record separator to "//", you do local $/='//'. That will break your input stream into records ending with '//'.
  • You never read in your file. Your split statement is attempting to split the string representation of an input handle, i.e. 'GLOB(...)', not the contents of your inputfile. To read a file into an array you need to use <$in>. To remove the '//' from the end you need to use chomp.

Your code should look something like this if you want to read in everything in one gulp:

local $/='//'; #define record separator my @records = <$in>; # read in all records chomp @records; #get rid of trailing // from each record

Or this, which reads in one record at a time and is much more memory efficient

local $/='//'; while (my $record = <$in>) { chomp $record; #remove // from end of line #... process the record ... }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://889170]
[Corion]: marto: Ow! You got hit by the storm that is bringing warm weather to me ...
[1nickt]: marto Good to hear that was the worst of it for you...
[marto]: 1nickt the worst I'm aware of at the moment :P
LanX .♩..♬ ... Another one bites the Sahara dust ...
marto wonders what fresh hell the firefox update has brought, apart from maxing out CPUs
1nickt was looking into Firefox Extended Support releases yesterday. You don't have to go with the updates!
[erix]: wonderfully red sun here
[LanX]: FF has become a source of instability :(
[1nickt]: erix not so wonderful for the lungs :-(

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2017-10-17 12:27 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (230 votes). Check out past polls.