Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: split line from one point

by moritz (Cardinal)
on Oct 19, 2011 at 12:17 UTC ( #932377=note: print w/ replies, xml ) Need Help??


in reply to split line from one point

Please be more specific than "doesn't work". What happens? Do blue flames come out of your computer?

Anyway, the problem is likely that you call split in scalar context. Depending on your Perl version, that either puts the number of chunks into $a (newer perls), or does something very weird (in older perl, it writes the chunks to @_).

The solution is to call split in list context:

my ($a) = split /T/; print RE $a;


Comment on Re: split line from one point
Download Code
Replies are listed 'Best First'.
Re^2: split line from one point
by Anonymous Monk on Oct 19, 2011 at 12:29 UTC

    thanks, i have this: read line <> on closed file handle IN at split.pl line 4.

      That means that the first open() call failed. Either use autodie; in the beginning, or write your calls as
      open my $IN, '<', 'transaction' or die "Cannot open 'transaction' for +reading: $!"; ... while (<$IN>) { ... }

      (And adapt the code for the second file accordingly).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2015-08-30 14:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (349 votes), past polls